| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // Test that weak map values on an evacuation candidate which are not reachable | 180 // Test that weak map values on an evacuation candidate which are not reachable |
| 181 // by other paths are correctly recorded in the slots buffer. | 181 // by other paths are correctly recorded in the slots buffer. |
| 182 TEST(Regress2060a) { | 182 TEST(Regress2060a) { |
| 183 if (i::FLAG_never_compact) return; | 183 if (i::FLAG_never_compact) return; |
| 184 FLAG_always_compact = true; | 184 FLAG_always_compact = true; |
| 185 LocalContext context; | 185 LocalContext context; |
| 186 Isolate* isolate = GetIsolateFrom(&context); | 186 Isolate* isolate = GetIsolateFrom(&context); |
| 187 Factory* factory = isolate->factory(); | 187 Factory* factory = isolate->factory(); |
| 188 Heap* heap = isolate->heap(); | 188 Heap* heap = isolate->heap(); |
| 189 HandleScope scope(isolate); | 189 HandleScope scope(isolate); |
| 190 Handle<JSFunction> function = | 190 Handle<JSFunction> function = factory->NewFunctionWithPrototype( |
| 191 factory->NewFunction(factory->function_string(), factory->null_value()); | 191 factory->function_string(), factory->null_value()); |
| 192 Handle<JSObject> key = factory->NewJSObject(function); | 192 Handle<JSObject> key = factory->NewJSObject(function); |
| 193 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 193 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
| 194 | 194 |
| 195 // Start second old-space page so that values land on evacuation candidate. | 195 // Start second old-space page so that values land on evacuation candidate. |
| 196 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); | 196 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); |
| 197 factory->NewFixedArray(900 * KB / kPointerSize, TENURED); | 197 factory->NewFixedArray(900 * KB / kPointerSize, TENURED); |
| 198 | 198 |
| 199 // Fill up weak map with values on an evacuation candidate. | 199 // Fill up weak map with values on an evacuation candidate. |
| 200 { | 200 { |
| 201 HandleScope scope(isolate); | 201 HandleScope scope(isolate); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 220 FLAG_always_compact = true; | 220 FLAG_always_compact = true; |
| 221 #ifdef VERIFY_HEAP | 221 #ifdef VERIFY_HEAP |
| 222 FLAG_verify_heap = true; | 222 FLAG_verify_heap = true; |
| 223 #endif | 223 #endif |
| 224 | 224 |
| 225 LocalContext context; | 225 LocalContext context; |
| 226 Isolate* isolate = GetIsolateFrom(&context); | 226 Isolate* isolate = GetIsolateFrom(&context); |
| 227 Factory* factory = isolate->factory(); | 227 Factory* factory = isolate->factory(); |
| 228 Heap* heap = isolate->heap(); | 228 Heap* heap = isolate->heap(); |
| 229 HandleScope scope(isolate); | 229 HandleScope scope(isolate); |
| 230 Handle<JSFunction> function = | 230 Handle<JSFunction> function = factory->NewFunctionWithPrototype( |
| 231 factory->NewFunction(factory->function_string(), factory->null_value()); | 231 factory->function_string(), factory->null_value()); |
| 232 | 232 |
| 233 // Start second old-space page so that keys land on evacuation candidate. | 233 // Start second old-space page so that keys land on evacuation candidate. |
| 234 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); | 234 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); |
| 235 factory->NewFixedArray(900 * KB / kPointerSize, TENURED); | 235 factory->NewFixedArray(900 * KB / kPointerSize, TENURED); |
| 236 | 236 |
| 237 // Fill up weak map with keys on an evacuation candidate. | 237 // Fill up weak map with keys on an evacuation candidate. |
| 238 Handle<JSObject> keys[32]; | 238 Handle<JSObject> keys[32]; |
| 239 for (int i = 0; i < 32; i++) { | 239 for (int i = 0; i < 32; i++) { |
| 240 keys[i] = factory->NewJSObject(function, TENURED); | 240 keys[i] = factory->NewJSObject(function, TENURED); |
| 241 CHECK(!heap->InNewSpace(keys[i]->address())); | 241 CHECK(!heap->InNewSpace(keys[i]->address())); |
| 242 CHECK(!first_page->Contains(keys[i]->address())); | 242 CHECK(!first_page->Contains(keys[i]->address())); |
| 243 } | 243 } |
| 244 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 244 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
| 245 for (int i = 0; i < 32; i++) { | 245 for (int i = 0; i < 32; i++) { |
| 246 PutIntoWeakMap(weakmap, | 246 PutIntoWeakMap(weakmap, |
| 247 keys[i], | 247 keys[i], |
| 248 Handle<Smi>(Smi::FromInt(i), isolate)); | 248 Handle<Smi>(Smi::FromInt(i), isolate)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Force compacting garbage collection. The subsequent collections are used | 251 // Force compacting garbage collection. The subsequent collections are used |
| 252 // to verify that key references were actually updated. | 252 // to verify that key references were actually updated. |
| 253 CHECK(FLAG_always_compact); | 253 CHECK(FLAG_always_compact); |
| 254 heap->CollectAllGarbage(Heap::kNoGCFlags); | 254 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 255 heap->CollectAllGarbage(Heap::kNoGCFlags); | 255 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 256 heap->CollectAllGarbage(Heap::kNoGCFlags); | 256 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 257 } | 257 } |
| OLD | NEW |