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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Force compacting garbage collection. | 186 // Force compacting garbage collection. |
187 CHECK(FLAG_always_compact); | 187 CHECK(FLAG_always_compact); |
188 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 188 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 // Test that weak map keys on an evacuation candidate which are reachable by | 192 // Test that weak map keys on an evacuation candidate which are reachable by |
193 // other strong paths are correctly recorded in the slots buffer. | 193 // other strong paths are correctly recorded in the slots buffer. |
194 TEST(Regress2060b) { | 194 TEST(Regress2060b) { |
195 FLAG_always_compact = true; | 195 FLAG_always_compact = true; |
196 #ifdef DEBUG | |
197 FLAG_verify_heap = true; | 196 FLAG_verify_heap = true; |
198 #endif | 197 |
199 LocalContext context; | 198 LocalContext context; |
200 v8::HandleScope scope; | 199 v8::HandleScope scope; |
201 Handle<JSFunction> function = | 200 Handle<JSFunction> function = |
202 FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); | 201 FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); |
203 | 202 |
204 // 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. |
205 Page* first_page = HEAP->old_pointer_space()->anchor()->next_page(); | 204 Page* first_page = HEAP->old_pointer_space()->anchor()->next_page(); |
206 FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED); | 205 FACTORY->NewFixedArray(900 * KB / kPointerSize, TENURED); |
207 | 206 |
208 // Fill up weak map with keys on an evacuation candidate. | 207 // Fill up weak map with keys on an evacuation candidate. |
209 Handle<JSObject> keys[32]; | 208 Handle<JSObject> keys[32]; |
210 for (int i = 0; i < 32; i++) { | 209 for (int i = 0; i < 32; i++) { |
211 keys[i] = FACTORY->NewJSObject(function, TENURED); | 210 keys[i] = FACTORY->NewJSObject(function, TENURED); |
212 CHECK(!HEAP->InNewSpace(keys[i]->address())); | 211 CHECK(!HEAP->InNewSpace(keys[i]->address())); |
213 CHECK(!first_page->Contains(keys[i]->address())); | 212 CHECK(!first_page->Contains(keys[i]->address())); |
214 } | 213 } |
215 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(); | 214 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(); |
216 for (int i = 0; i < 32; i++) { | 215 for (int i = 0; i < 32; i++) { |
217 PutIntoWeakMap(weakmap, keys[i], Handle<Smi>(Smi::FromInt(i))); | 216 PutIntoWeakMap(weakmap, keys[i], Handle<Smi>(Smi::FromInt(i))); |
218 } | 217 } |
219 | 218 |
220 // Force compacting garbage collection. The subsequent collections are used | 219 // Force compacting garbage collection. The subsequent collections are used |
221 // to verify that key references were actually updated. | 220 // to verify that key references were actually updated. |
222 CHECK(FLAG_always_compact); | 221 CHECK(FLAG_always_compact); |
223 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 222 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
224 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 223 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
225 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 224 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
226 } | 225 } |
OLD | NEW |