| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 Isolate* isolate = GetIsolateFrom(&context); | 175 Isolate* isolate = GetIsolateFrom(&context); |
| 176 Factory* factory = isolate->factory(); | 176 Factory* factory = isolate->factory(); |
| 177 Heap* heap = isolate->heap(); | 177 Heap* heap = isolate->heap(); |
| 178 HandleScope scope(isolate); | 178 HandleScope scope(isolate); |
| 179 Handle<JSFunction> function = factory->NewFunction( | 179 Handle<JSFunction> function = factory->NewFunction( |
| 180 factory->function_string()); | 180 factory->function_string()); |
| 181 Handle<JSObject> key = factory->NewJSObject(function); | 181 Handle<JSObject> key = factory->NewJSObject(function); |
| 182 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); | 182 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); |
| 183 | 183 |
| 184 // Start second old-space page so that values land on evacuation candidate. | 184 // Start second old-space page so that values land on evacuation candidate. |
| 185 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); | 185 Page* first_page = heap->old_space()->anchor()->next_page(); |
| 186 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; | 186 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; |
| 187 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); | 187 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); |
| 188 | 188 |
| 189 // Fill up weak set with values on an evacuation candidate. | 189 // Fill up weak set with values on an evacuation candidate. |
| 190 { | 190 { |
| 191 HandleScope scope(isolate); | 191 HandleScope scope(isolate); |
| 192 for (int i = 0; i < 32; i++) { | 192 for (int i = 0; i < 32; i++) { |
| 193 Handle<JSObject> object = factory->NewJSObject(function, TENURED); | 193 Handle<JSObject> object = factory->NewJSObject(function, TENURED); |
| 194 CHECK(!heap->InNewSpace(object->address())); | 194 CHECK(!heap->InNewSpace(object->address())); |
| 195 CHECK(!first_page->Contains(object->address())); | 195 CHECK(!first_page->Contains(object->address())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 214 | 214 |
| 215 LocalContext context; | 215 LocalContext context; |
| 216 Isolate* isolate = GetIsolateFrom(&context); | 216 Isolate* isolate = GetIsolateFrom(&context); |
| 217 Factory* factory = isolate->factory(); | 217 Factory* factory = isolate->factory(); |
| 218 Heap* heap = isolate->heap(); | 218 Heap* heap = isolate->heap(); |
| 219 HandleScope scope(isolate); | 219 HandleScope scope(isolate); |
| 220 Handle<JSFunction> function = factory->NewFunction( | 220 Handle<JSFunction> function = factory->NewFunction( |
| 221 factory->function_string()); | 221 factory->function_string()); |
| 222 | 222 |
| 223 // Start second old-space page so that keys land on evacuation candidate. | 223 // Start second old-space page so that keys land on evacuation candidate. |
| 224 Page* first_page = heap->old_pointer_space()->anchor()->next_page(); | 224 Page* first_page = heap->old_space()->anchor()->next_page(); |
| 225 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; | 225 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; |
| 226 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); | 226 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); |
| 227 | 227 |
| 228 // Fill up weak set with keys on an evacuation candidate. | 228 // Fill up weak set with keys on an evacuation candidate. |
| 229 Handle<JSObject> keys[32]; | 229 Handle<JSObject> keys[32]; |
| 230 for (int i = 0; i < 32; i++) { | 230 for (int i = 0; i < 32; i++) { |
| 231 keys[i] = factory->NewJSObject(function, TENURED); | 231 keys[i] = factory->NewJSObject(function, TENURED); |
| 232 CHECK(!heap->InNewSpace(keys[i]->address())); | 232 CHECK(!heap->InNewSpace(keys[i]->address())); |
| 233 CHECK(!first_page->Contains(keys[i]->address())); | 233 CHECK(!first_page->Contains(keys[i]->address())); |
| 234 } | 234 } |
| 235 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); | 235 Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); |
| 236 for (int i = 0; i < 32; i++) { | 236 for (int i = 0; i < 32; i++) { |
| 237 Handle<Smi> smi(Smi::FromInt(i), isolate); | 237 Handle<Smi> smi(Smi::FromInt(i), isolate); |
| 238 Runtime::WeakCollectionSet(weakset, keys[i], smi); | 238 Runtime::WeakCollectionSet(weakset, keys[i], smi); |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Force compacting garbage collection. The subsequent collections are used | 241 // Force compacting garbage collection. The subsequent collections are used |
| 242 // to verify that key references were actually updated. | 242 // to verify that key references were actually updated. |
| 243 CHECK(FLAG_always_compact); | 243 CHECK(FLAG_always_compact); |
| 244 heap->CollectAllGarbage(Heap::kNoGCFlags); | 244 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 245 heap->CollectAllGarbage(Heap::kNoGCFlags); | 245 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 246 heap->CollectAllGarbage(Heap::kNoGCFlags); | 246 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 247 } | 247 } |
| OLD | NEW |