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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 Factory* factory = isolate->factory(); | 181 Factory* factory = isolate->factory(); |
182 Heap* heap = isolate->heap(); | 182 Heap* heap = isolate->heap(); |
183 HandleScope scope(isolate); | 183 HandleScope scope(isolate); |
184 Handle<JSFunction> function = factory->NewFunction( | 184 Handle<JSFunction> function = factory->NewFunction( |
185 factory->function_string()); | 185 factory->function_string()); |
186 Handle<JSObject> key = factory->NewJSObject(function); | 186 Handle<JSObject> key = factory->NewJSObject(function); |
187 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 187 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
188 | 188 |
189 // Start second old-space page so that values land on evacuation candidate. | 189 // Start second old-space page so that values land on evacuation candidate. |
190 Page* first_page = heap->old_space()->anchor()->next_page(); | 190 Page* first_page = heap->old_space()->anchor()->next_page(); |
191 SimulateFullSpace(heap->old_space()); | 191 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; |
| 192 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); |
192 | 193 |
193 // Fill up weak map with values on an evacuation candidate. | 194 // Fill up weak map with values on an evacuation candidate. |
194 { | 195 { |
195 HandleScope scope(isolate); | 196 HandleScope scope(isolate); |
196 for (int i = 0; i < 32; i++) { | 197 for (int i = 0; i < 32; i++) { |
197 Handle<JSObject> object = factory->NewJSObject(function, TENURED); | 198 Handle<JSObject> object = factory->NewJSObject(function, TENURED); |
198 CHECK(!heap->InNewSpace(object->address())); | 199 CHECK(!heap->InNewSpace(object->address())); |
199 CHECK(!first_page->Contains(object->address())); | 200 CHECK(!first_page->Contains(object->address())); |
200 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); | 201 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); |
201 JSWeakCollection::Set(weakmap, key, object, hash); | 202 JSWeakCollection::Set(weakmap, key, object, hash); |
(...skipping 18 matching lines...) Expand all Loading... |
220 LocalContext context; | 221 LocalContext context; |
221 Isolate* isolate = GetIsolateFrom(&context); | 222 Isolate* isolate = GetIsolateFrom(&context); |
222 Factory* factory = isolate->factory(); | 223 Factory* factory = isolate->factory(); |
223 Heap* heap = isolate->heap(); | 224 Heap* heap = isolate->heap(); |
224 HandleScope scope(isolate); | 225 HandleScope scope(isolate); |
225 Handle<JSFunction> function = factory->NewFunction( | 226 Handle<JSFunction> function = factory->NewFunction( |
226 factory->function_string()); | 227 factory->function_string()); |
227 | 228 |
228 // Start second old-space page so that keys land on evacuation candidate. | 229 // Start second old-space page so that keys land on evacuation candidate. |
229 Page* first_page = heap->old_space()->anchor()->next_page(); | 230 Page* first_page = heap->old_space()->anchor()->next_page(); |
230 SimulateFullSpace(heap->old_space()); | 231 int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB; |
| 232 factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED); |
231 | 233 |
232 // Fill up weak map with keys on an evacuation candidate. | 234 // Fill up weak map with keys on an evacuation candidate. |
233 Handle<JSObject> keys[32]; | 235 Handle<JSObject> keys[32]; |
234 for (int i = 0; i < 32; i++) { | 236 for (int i = 0; i < 32; i++) { |
235 keys[i] = factory->NewJSObject(function, TENURED); | 237 keys[i] = factory->NewJSObject(function, TENURED); |
236 CHECK(!heap->InNewSpace(keys[i]->address())); | 238 CHECK(!heap->InNewSpace(keys[i]->address())); |
237 CHECK(!first_page->Contains(keys[i]->address())); | 239 CHECK(!first_page->Contains(keys[i]->address())); |
238 } | 240 } |
239 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 241 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
240 for (int i = 0; i < 32; i++) { | 242 for (int i = 0; i < 32; i++) { |
(...skipping 19 matching lines...) Expand all Loading... |
260 { | 262 { |
261 HandleScope scope(isolate); | 263 HandleScope scope(isolate); |
262 AllocateJSWeakMap(isolate); | 264 AllocateJSWeakMap(isolate); |
263 SimulateIncrementalMarking(heap); | 265 SimulateIncrementalMarking(heap); |
264 } | 266 } |
265 // The weak map is marked black here but leaving the handle scope will make | 267 // The weak map is marked black here but leaving the handle scope will make |
266 // the object unreachable. Aborting incremental marking will clear all the | 268 // the object unreachable. Aborting incremental marking will clear all the |
267 // marking bits which makes the weak map garbage. | 269 // marking bits which makes the weak map garbage. |
268 heap->CollectAllGarbage(); | 270 heap->CollectAllGarbage(); |
269 } | 271 } |
OLD | NEW |