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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <utility> | 28 #include <utility> |
29 | 29 |
30 #include "src/v8.h" | 30 #include "src/v8.h" |
31 | 31 |
32 #include "src/global-handles.h" | 32 #include "src/global-handles.h" |
33 #include "test/cctest/cctest.h" | 33 #include "test/cctest/cctest.h" |
34 #include "test/cctest/heap/utils-inl.h" | 34 #include "test/cctest/heap/heap-utils.h" |
35 | 35 |
36 using namespace v8::internal; | 36 using namespace v8::internal; |
37 | 37 |
38 static Isolate* GetIsolateFrom(LocalContext* context) { | 38 static Isolate* GetIsolateFrom(LocalContext* context) { |
39 return reinterpret_cast<Isolate*>((*context)->GetIsolate()); | 39 return reinterpret_cast<Isolate*>((*context)->GetIsolate()); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { | 43 static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { |
44 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); | 44 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 Factory* factory = isolate->factory(); | 170 Factory* factory = isolate->factory(); |
171 Heap* heap = isolate->heap(); | 171 Heap* heap = isolate->heap(); |
172 HandleScope scope(isolate); | 172 HandleScope scope(isolate); |
173 Handle<JSFunction> function = factory->NewFunction( | 173 Handle<JSFunction> function = factory->NewFunction( |
174 factory->function_string()); | 174 factory->function_string()); |
175 Handle<JSObject> key = factory->NewJSObject(function); | 175 Handle<JSObject> key = factory->NewJSObject(function); |
176 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 176 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
177 | 177 |
178 // Start second old-space page so that values land on evacuation candidate. | 178 // Start second old-space page so that values land on evacuation candidate. |
179 Page* first_page = heap->old_space()->anchor()->next_page(); | 179 Page* first_page = heap->old_space()->anchor()->next_page(); |
180 SimulateFullSpace(heap->old_space()); | 180 heap::SimulateFullSpace(heap->old_space()); |
181 | 181 |
182 // Fill up weak map with values on an evacuation candidate. | 182 // Fill up weak map with values on an evacuation candidate. |
183 { | 183 { |
184 HandleScope scope(isolate); | 184 HandleScope scope(isolate); |
185 for (int i = 0; i < 32; i++) { | 185 for (int i = 0; i < 32; i++) { |
186 Handle<JSObject> object = factory->NewJSObject(function, TENURED); | 186 Handle<JSObject> object = factory->NewJSObject(function, TENURED); |
187 CHECK(!heap->InNewSpace(*object)); | 187 CHECK(!heap->InNewSpace(*object)); |
188 CHECK(!first_page->Contains(object->address())); | 188 CHECK(!first_page->Contains(object->address())); |
189 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); | 189 int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); |
190 JSWeakCollection::Set(weakmap, key, object, hash); | 190 JSWeakCollection::Set(weakmap, key, object, hash); |
(...skipping 18 matching lines...) Expand all Loading... |
209 LocalContext context; | 209 LocalContext context; |
210 Isolate* isolate = GetIsolateFrom(&context); | 210 Isolate* isolate = GetIsolateFrom(&context); |
211 Factory* factory = isolate->factory(); | 211 Factory* factory = isolate->factory(); |
212 Heap* heap = isolate->heap(); | 212 Heap* heap = isolate->heap(); |
213 HandleScope scope(isolate); | 213 HandleScope scope(isolate); |
214 Handle<JSFunction> function = factory->NewFunction( | 214 Handle<JSFunction> function = factory->NewFunction( |
215 factory->function_string()); | 215 factory->function_string()); |
216 | 216 |
217 // Start second old-space page so that keys land on evacuation candidate. | 217 // Start second old-space page so that keys land on evacuation candidate. |
218 Page* first_page = heap->old_space()->anchor()->next_page(); | 218 Page* first_page = heap->old_space()->anchor()->next_page(); |
219 SimulateFullSpace(heap->old_space()); | 219 heap::SimulateFullSpace(heap->old_space()); |
220 | 220 |
221 // Fill up weak map with keys on an evacuation candidate. | 221 // Fill up weak map with keys on an evacuation candidate. |
222 Handle<JSObject> keys[32]; | 222 Handle<JSObject> keys[32]; |
223 for (int i = 0; i < 32; i++) { | 223 for (int i = 0; i < 32; i++) { |
224 keys[i] = factory->NewJSObject(function, TENURED); | 224 keys[i] = factory->NewJSObject(function, TENURED); |
225 CHECK(!heap->InNewSpace(*keys[i])); | 225 CHECK(!heap->InNewSpace(*keys[i])); |
226 CHECK(!first_page->Contains(keys[i]->address())); | 226 CHECK(!first_page->Contains(keys[i]->address())); |
227 } | 227 } |
228 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); | 228 Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
229 for (int i = 0; i < 32; i++) { | 229 for (int i = 0; i < 32; i++) { |
(...skipping 12 matching lines...) Expand all Loading... |
242 | 242 |
243 | 243 |
244 TEST(Regress399527) { | 244 TEST(Regress399527) { |
245 CcTest::InitializeVM(); | 245 CcTest::InitializeVM(); |
246 v8::HandleScope scope(CcTest::isolate()); | 246 v8::HandleScope scope(CcTest::isolate()); |
247 Isolate* isolate = CcTest::i_isolate(); | 247 Isolate* isolate = CcTest::i_isolate(); |
248 Heap* heap = isolate->heap(); | 248 Heap* heap = isolate->heap(); |
249 { | 249 { |
250 HandleScope scope(isolate); | 250 HandleScope scope(isolate); |
251 AllocateJSWeakMap(isolate); | 251 AllocateJSWeakMap(isolate); |
252 SimulateIncrementalMarking(heap); | 252 heap::SimulateIncrementalMarking(heap); |
253 } | 253 } |
254 // The weak map is marked black here but leaving the handle scope will make | 254 // The weak map is marked black here but leaving the handle scope will make |
255 // the object unreachable. Aborting incremental marking will clear all the | 255 // the object unreachable. Aborting incremental marking will clear all the |
256 // marking bits which makes the weak map garbage. | 256 // marking bits which makes the weak map garbage. |
257 heap->CollectAllGarbage(); | 257 heap->CollectAllGarbage(); |
258 } | 258 } |
OLD | NEW |