OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Force compacting garbage collection. | 185 // Force compacting garbage collection. |
186 CHECK(FLAG_always_compact); | 186 CHECK(FLAG_always_compact); |
187 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 187 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
188 } | 188 } |
189 | 189 |
190 | 190 |
191 // Test that weak map keys on an evacuation candidate which are reachable by | 191 // Test that weak map keys on an evacuation candidate which are reachable by |
192 // other strong paths are correctly recorded in the slots buffer. | 192 // other strong paths are correctly recorded in the slots buffer. |
193 TEST(Regress2060b) { | 193 TEST(Regress2060b) { |
194 FLAG_always_compact = true; | 194 FLAG_always_compact = true; |
| 195 #ifdef DEBUG |
195 FLAG_verify_heap = true; | 196 FLAG_verify_heap = true; |
| 197 #endif |
196 LocalContext context; | 198 LocalContext context; |
197 v8::HandleScope scope; | 199 v8::HandleScope scope; |
198 Handle<JSFunction> function = | 200 Handle<JSFunction> function = |
199 FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); | 201 FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); |
200 | 202 |
201 // Start second old-space page so that keys land on evacuation candidate. | 203 // Start second old-space page so that keys land on evacuation candidate. |
202 Page* first_page = HEAP->old_pointer_space()->anchor()->next_page(); | 204 Page* first_page = HEAP->old_pointer_space()->anchor()->next_page(); |
203 FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED); | 205 FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED); |
204 | 206 |
205 // Fill up weak map with keys on an evacuation candidate. | 207 // Fill up weak map with keys on an evacuation candidate. |
206 Handle<JSObject> keys[32]; | 208 Handle<JSObject> keys[32]; |
207 for (int i = 0; i < 32; i++) { | 209 for (int i = 0; i < 32; i++) { |
208 keys[i] = FACTORY->NewJSObject(function, TENURED); | 210 keys[i] = FACTORY->NewJSObject(function, TENURED); |
209 CHECK(!HEAP->InNewSpace(keys[i]->address())); | 211 CHECK(!HEAP->InNewSpace(keys[i]->address())); |
210 CHECK(!first_page->Contains(keys[i]->address())); | 212 CHECK(!first_page->Contains(keys[i]->address())); |
211 } | 213 } |
212 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(); | 214 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(); |
213 for (int i = 0; i < 32; i++) { | 215 for (int i = 0; i < 32; i++) { |
214 PutIntoWeakMap(weakmap, keys[i], Handle<Smi>(Smi::FromInt(i))); | 216 PutIntoWeakMap(weakmap, keys[i], Handle<Smi>(Smi::FromInt(i))); |
215 } | 217 } |
216 | 218 |
217 // Force compacting garbage collection. The subsequent collections are used | 219 // Force compacting garbage collection. The subsequent collections are used |
218 // to verify that key references were actually updated. | 220 // to verify that key references were actually updated. |
219 CHECK(FLAG_always_compact); | 221 CHECK(FLAG_always_compact); |
220 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 222 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
221 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 223 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
222 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 224 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
223 } | 225 } |
OLD | NEW |