OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 CcTest::InitializeVM(); | 114 CcTest::InitializeVM(); |
115 | 115 |
116 v8::HandleScope sc(CcTest::isolate()); | 116 v8::HandleScope sc(CcTest::isolate()); |
117 | 117 |
118 // Do a mark compact GC to shrink the heap. | 118 // Do a mark compact GC to shrink the heap. |
119 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 119 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
120 | 120 |
121 // Allocate a big Fixed array in the new space. | 121 // Allocate a big Fixed array in the new space. |
122 int length = (Page::kMaxNonCodeHeapObjectSize - | 122 int length = (Page::kMaxNonCodeHeapObjectSize - |
123 FixedArray::kHeaderSize) / (2 * kPointerSize); | 123 FixedArray::kHeaderSize) / (2 * kPointerSize); |
124 Object* obj = i::Isolate::Current()->heap()->AllocateFixedArray(length)-> | 124 Object* obj = CcTest::i_isolate()->heap()->AllocateFixedArray(length)-> |
125 ToObjectChecked(); | 125 ToObjectChecked(); |
126 | 126 |
127 Handle<FixedArray> array(FixedArray::cast(obj)); | 127 Handle<FixedArray> array(FixedArray::cast(obj)); |
128 | 128 |
129 // Array still stays in the new space. | 129 // Array still stays in the new space. |
130 CHECK(HEAP->InSpace(*array, NEW_SPACE)); | 130 CHECK(HEAP->InSpace(*array, NEW_SPACE)); |
131 | 131 |
132 // Allocate objects in the old space until out of memory. | 132 // Allocate objects in the old space until out of memory. |
133 FixedArray* host = *array; | 133 FixedArray* host = *array; |
134 while (true) { | 134 while (true) { |
135 Object* obj; | 135 Object* obj; |
136 { MaybeObject* maybe_obj = HEAP->AllocateFixedArray(100, TENURED); | 136 { MaybeObject* maybe_obj = HEAP->AllocateFixedArray(100, TENURED); |
137 if (!maybe_obj->ToObject(&obj)) break; | 137 if (!maybe_obj->ToObject(&obj)) break; |
138 } | 138 } |
139 | 139 |
140 host->set(0, obj); | 140 host->set(0, obj); |
141 host = FixedArray::cast(obj); | 141 host = FixedArray::cast(obj); |
142 } | 142 } |
143 | 143 |
144 // Call mark compact GC, and it should pass. | 144 // Call mark compact GC, and it should pass. |
145 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 145 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 TEST(MarkCompactCollector) { | 149 TEST(MarkCompactCollector) { |
150 FLAG_incremental_marking = false; | 150 FLAG_incremental_marking = false; |
151 CcTest::InitializeVM(); | 151 CcTest::InitializeVM(); |
152 Isolate* isolate = Isolate::Current(); | 152 Isolate* isolate = CcTest::i_isolate(); |
153 Heap* heap = isolate->heap(); | 153 Heap* heap = isolate->heap(); |
154 | 154 |
155 v8::HandleScope sc(CcTest::isolate()); | 155 v8::HandleScope sc(CcTest::isolate()); |
156 Handle<GlobalObject> global(isolate->context()->global_object()); | 156 Handle<GlobalObject> global(isolate->context()->global_object()); |
157 | 157 |
158 // call mark-compact when heap is empty | 158 // call mark-compact when heap is empty |
159 heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 1"); | 159 heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 1"); |
160 | 160 |
161 // keep allocating garbage in new space until it fails | 161 // keep allocating garbage in new space until it fails |
162 const int ARRAY_SIZE = 100; | 162 const int ARRAY_SIZE = 100; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // TODO(1600): compaction of map space is temporary removed from GC. | 236 // TODO(1600): compaction of map space is temporary removed from GC. |
237 #if 0 | 237 #if 0 |
238 static Handle<Map> CreateMap(Isolate* isolate) { | 238 static Handle<Map> CreateMap(Isolate* isolate) { |
239 return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 239 return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
240 } | 240 } |
241 | 241 |
242 | 242 |
243 TEST(MapCompact) { | 243 TEST(MapCompact) { |
244 FLAG_max_map_space_pages = 16; | 244 FLAG_max_map_space_pages = 16; |
245 CcTest::InitializeVM(); | 245 CcTest::InitializeVM(); |
246 Isolate* isolate = Isolate::Current(); | 246 Isolate* isolate = CcTest::i_isolate(); |
247 Factory* factory = isolate->factory(); | 247 Factory* factory = isolate->factory(); |
248 | 248 |
249 { | 249 { |
250 v8::HandleScope sc; | 250 v8::HandleScope sc; |
251 // keep allocating maps while pointers are still encodable and thus | 251 // keep allocating maps while pointers are still encodable and thus |
252 // mark compact is permitted. | 252 // mark compact is permitted. |
253 Handle<JSObject> root = factory->NewJSObjectFromMap(CreateMap()); | 253 Handle<JSObject> root = factory->NewJSObjectFromMap(CreateMap()); |
254 do { | 254 do { |
255 Handle<Map> map = CreateMap(); | 255 Handle<Map> map = CreateMap(); |
256 map->set_prototype(*root); | 256 map->set_prototype(*root); |
(...skipping 17 matching lines...) Expand all Loading... |
274 void* id) { | 274 void* id) { |
275 ASSERT(id == reinterpret_cast<void*>(1234)); | 275 ASSERT(id == reinterpret_cast<void*>(1234)); |
276 NumberOfWeakCalls++; | 276 NumberOfWeakCalls++; |
277 handle->Dispose(); | 277 handle->Dispose(); |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 TEST(ObjectGroups) { | 281 TEST(ObjectGroups) { |
282 FLAG_incremental_marking = false; | 282 FLAG_incremental_marking = false; |
283 CcTest::InitializeVM(); | 283 CcTest::InitializeVM(); |
284 GlobalHandles* global_handles = Isolate::Current()->global_handles(); | 284 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
285 | 285 |
286 NumberOfWeakCalls = 0; | 286 NumberOfWeakCalls = 0; |
287 v8::HandleScope handle_scope(CcTest::isolate()); | 287 v8::HandleScope handle_scope(CcTest::isolate()); |
288 | 288 |
289 Handle<Object> g1s1 = | 289 Handle<Object> g1s1 = |
290 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 290 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
291 Handle<Object> g1s2 = | 291 Handle<Object> g1s2 = |
292 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 292 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
293 Handle<Object> g1c1 = | 293 Handle<Object> g1c1 = |
294 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 294 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 virtual const char* GetLabel() { return "whatever"; } | 403 virtual const char* GetLabel() { return "whatever"; } |
404 | 404 |
405 private: | 405 private: |
406 bool has_been_disposed_; | 406 bool has_been_disposed_; |
407 }; | 407 }; |
408 | 408 |
409 | 409 |
410 TEST(EmptyObjectGroups) { | 410 TEST(EmptyObjectGroups) { |
411 CcTest::InitializeVM(); | 411 CcTest::InitializeVM(); |
412 GlobalHandles* global_handles = Isolate::Current()->global_handles(); | 412 GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); |
413 | 413 |
414 v8::HandleScope handle_scope(CcTest::isolate()); | 414 v8::HandleScope handle_scope(CcTest::isolate()); |
415 | 415 |
416 Handle<Object> object = | 416 Handle<Object> object = |
417 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); | 417 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); |
418 | 418 |
419 TestRetainedObjectInfo info; | 419 TestRetainedObjectInfo info; |
420 global_handles->AddObjectGroup(NULL, 0, &info); | 420 global_handles->AddObjectGroup(NULL, 0, &info); |
421 ASSERT(info.has_been_disposed()); | 421 ASSERT(info.has_been_disposed()); |
422 | 422 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 549 |
550 | 550 |
551 TEST(RegressJoinThreadsOnIsolateDeinit) { | 551 TEST(RegressJoinThreadsOnIsolateDeinit) { |
552 intptr_t size_limit = ShortLivingIsolate() * 2; | 552 intptr_t size_limit = ShortLivingIsolate() * 2; |
553 for (int i = 0; i < 10; i++) { | 553 for (int i = 0; i < 10; i++) { |
554 CHECK_GT(size_limit, ShortLivingIsolate()); | 554 CHECK_GT(size_limit, ShortLivingIsolate()); |
555 } | 555 } |
556 } | 556 } |
557 | 557 |
558 #endif // __linux__ and !USE_SIMULATOR | 558 #endif // __linux__ and !USE_SIMULATOR |
OLD | NEW |