| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 CcTest::InitializeVM(); | 151 CcTest::InitializeVM(); |
| 152 Isolate* isolate = Isolate::Current(); |
| 153 Heap* heap = isolate->heap(); |
| 151 | 154 |
| 152 v8::HandleScope sc(CcTest::isolate()); | 155 v8::HandleScope sc(CcTest::isolate()); |
| 156 |
| 153 // call mark-compact when heap is empty | 157 // call mark-compact when heap is empty |
| 154 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 158 heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 1"); |
| 155 | 159 |
| 156 // keep allocating garbage in new space until it fails | 160 // keep allocating garbage in new space until it fails |
| 157 const int ARRAY_SIZE = 100; | 161 const int ARRAY_SIZE = 100; |
| 158 Object* array; | 162 Object* array; |
| 159 MaybeObject* maybe_array; | 163 MaybeObject* maybe_array; |
| 160 do { | 164 do { |
| 161 maybe_array = HEAP->AllocateFixedArray(ARRAY_SIZE); | 165 maybe_array = heap->AllocateFixedArray(ARRAY_SIZE); |
| 162 } while (maybe_array->ToObject(&array)); | 166 } while (maybe_array->ToObject(&array)); |
| 163 HEAP->CollectGarbage(NEW_SPACE); | 167 heap->CollectGarbage(NEW_SPACE, "trigger 2"); |
| 164 | 168 |
| 165 array = HEAP->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked(); | 169 array = heap->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked(); |
| 166 | 170 |
| 167 // keep allocating maps until it fails | 171 // keep allocating maps until it fails |
| 168 Object* mapp; | 172 Object* mapp; |
| 169 MaybeObject* maybe_mapp; | 173 MaybeObject* maybe_mapp; |
| 170 do { | 174 do { |
| 171 maybe_mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 175 maybe_mapp = heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 172 } while (maybe_mapp->ToObject(&mapp)); | 176 } while (maybe_mapp->ToObject(&mapp)); |
| 173 HEAP->CollectGarbage(MAP_SPACE); | 177 heap->CollectGarbage(MAP_SPACE, "trigger 3"); |
| 174 mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, | 178 mapp = heap->AllocateMap(JS_OBJECT_TYPE, |
| 175 JSObject::kHeaderSize)->ToObjectChecked(); | 179 JSObject::kHeaderSize)->ToObjectChecked(); |
| 176 | 180 |
| 177 // allocate a garbage | 181 // allocate a garbage |
| 178 String* func_name = String::cast( | 182 String* func_name = String::cast( |
| 179 HEAP->InternalizeUtf8String("theFunction")->ToObjectChecked()); | 183 heap->InternalizeUtf8String("theFunction")->ToObjectChecked()); |
| 180 SharedFunctionInfo* function_share = SharedFunctionInfo::cast( | 184 SharedFunctionInfo* function_share = SharedFunctionInfo::cast( |
| 181 HEAP->AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); | 185 heap->AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); |
| 182 JSFunction* function = JSFunction::cast( | 186 JSFunction* function = JSFunction::cast( |
| 183 HEAP->AllocateFunction(*Isolate::Current()->function_map(), | 187 heap->AllocateFunction(*isolate->function_map(), |
| 184 function_share, | 188 function_share, |
| 185 HEAP->undefined_value())->ToObjectChecked()); | 189 heap->undefined_value())->ToObjectChecked()); |
| 186 Map* initial_map = | 190 Map* initial_map = |
| 187 Map::cast(HEAP->AllocateMap(JS_OBJECT_TYPE, | 191 Map::cast(heap->AllocateMap(JS_OBJECT_TYPE, |
| 188 JSObject::kHeaderSize)->ToObjectChecked()); | 192 JSObject::kHeaderSize)->ToObjectChecked()); |
| 189 function->set_initial_map(initial_map); | 193 function->set_initial_map(initial_map); |
| 190 Isolate::Current()->context()->global_object()->SetProperty( | 194 isolate->context()->global_object()->SetProperty( |
| 191 func_name, function, NONE, kNonStrictMode)->ToObjectChecked(); | 195 func_name, function, NONE, kNonStrictMode)->ToObjectChecked(); |
| 192 | 196 |
| 193 JSObject* obj = JSObject::cast( | 197 JSObject* obj = JSObject::cast( |
| 194 HEAP->AllocateJSObject(function)->ToObjectChecked()); | 198 heap->AllocateJSObject(function)->ToObjectChecked()); |
| 195 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 199 heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 4"); |
| 196 | 200 |
| 197 func_name = String::cast( | 201 func_name = String::cast( |
| 198 HEAP->InternalizeUtf8String("theFunction")->ToObjectChecked()); | 202 heap->InternalizeUtf8String("theFunction")->ToObjectChecked()); |
| 199 CHECK(Isolate::Current()->context()->global_object()-> | 203 CHECK(isolate->context()->global_object()->HasLocalProperty(func_name)); |
| 200 HasLocalProperty(func_name)); | 204 Object* func_value = isolate->context()->global_object()-> |
| 201 Object* func_value = Isolate::Current()->context()->global_object()-> | |
| 202 GetProperty(func_name)->ToObjectChecked(); | 205 GetProperty(func_name)->ToObjectChecked(); |
| 203 CHECK(func_value->IsJSFunction()); | 206 CHECK(func_value->IsJSFunction()); |
| 204 function = JSFunction::cast(func_value); | 207 function = JSFunction::cast(func_value); |
| 205 | 208 |
| 206 obj = JSObject::cast(HEAP->AllocateJSObject(function)->ToObjectChecked()); | 209 obj = JSObject::cast(heap->AllocateJSObject(function)->ToObjectChecked()); |
| 207 String* obj_name = | 210 String* obj_name = |
| 208 String::cast(HEAP->InternalizeUtf8String("theObject")->ToObjectChecked()); | 211 String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked()); |
| 209 Isolate::Current()->context()->global_object()->SetProperty( | 212 isolate->context()->global_object()->SetProperty( |
| 210 obj_name, obj, NONE, kNonStrictMode)->ToObjectChecked(); | 213 obj_name, obj, NONE, kNonStrictMode)->ToObjectChecked(); |
| 211 String* prop_name = | 214 String* prop_name = |
| 212 String::cast(HEAP->InternalizeUtf8String("theSlot")->ToObjectChecked()); | 215 String::cast(heap->InternalizeUtf8String("theSlot")->ToObjectChecked()); |
| 213 obj->SetProperty(prop_name, | 216 obj->SetProperty(prop_name, |
| 214 Smi::FromInt(23), | 217 Smi::FromInt(23), |
| 215 NONE, | 218 NONE, |
| 216 kNonStrictMode)->ToObjectChecked(); | 219 kNonStrictMode)->ToObjectChecked(); |
| 217 | 220 |
| 218 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 221 heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 5"); |
| 219 | 222 |
| 220 obj_name = | 223 obj_name = |
| 221 String::cast(HEAP->InternalizeUtf8String("theObject")->ToObjectChecked()); | 224 String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked()); |
| 222 CHECK(Isolate::Current()->context()->global_object()-> | 225 CHECK(isolate->context()->global_object()->HasLocalProperty(obj_name)); |
| 223 HasLocalProperty(obj_name)); | 226 CHECK(isolate->context()->global_object()-> |
| 224 CHECK(Isolate::Current()->context()->global_object()-> | |
| 225 GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); | 227 GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); |
| 226 obj = JSObject::cast(Isolate::Current()->context()->global_object()-> | 228 obj = JSObject::cast(isolate->context()->global_object()-> |
| 227 GetProperty(obj_name)->ToObjectChecked()); | 229 GetProperty(obj_name)->ToObjectChecked()); |
| 228 prop_name = | 230 prop_name = |
| 229 String::cast(HEAP->InternalizeUtf8String("theSlot")->ToObjectChecked()); | 231 String::cast(heap->InternalizeUtf8String("theSlot")->ToObjectChecked()); |
| 230 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); | 232 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); |
| 231 } | 233 } |
| 232 | 234 |
| 233 | 235 |
| 234 // TODO(1600): compaction of map space is temporary removed from GC. | 236 // TODO(1600): compaction of map space is temporary removed from GC. |
| 235 #if 0 | 237 #if 0 |
| 236 static Handle<Map> CreateMap(Isolate* isolate) { | 238 static Handle<Map> CreateMap(Isolate* isolate) { |
| 237 return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 239 return isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 238 } | 240 } |
| 239 | 241 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 582 |
| 581 | 583 |
| 582 TEST(RegressJoinThreadsOnIsolateDeinit) { | 584 TEST(RegressJoinThreadsOnIsolateDeinit) { |
| 583 intptr_t size_limit = ShortLivingIsolate() * 2; | 585 intptr_t size_limit = ShortLivingIsolate() * 2; |
| 584 for (int i = 0; i < 10; i++) { | 586 for (int i = 0; i < 10; i++) { |
| 585 CHECK_GT(size_limit, ShortLivingIsolate()); | 587 CHECK_GT(size_limit, ShortLivingIsolate()); |
| 586 } | 588 } |
| 587 } | 589 } |
| 588 | 590 |
| 589 #endif // __linux__ and !USE_SIMULATOR | 591 #endif // __linux__ and !USE_SIMULATOR |
| OLD | NEW |