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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 HandleScope scope(isolate); | 434 HandleScope scope(isolate); |
435 | 435 |
436 Handle<Object> i = factory->NewStringFromStaticChars("fisk"); | 436 Handle<Object> i = factory->NewStringFromStaticChars("fisk"); |
437 Handle<Object> u = factory->NewNumber(1.12344); | 437 Handle<Object> u = factory->NewNumber(1.12344); |
438 | 438 |
439 h1 = global_handles->Create(*i); | 439 h1 = global_handles->Create(*i); |
440 h2 = global_handles->Create(*u); | 440 h2 = global_handles->Create(*u); |
441 } | 441 } |
442 | 442 |
443 // Make sure the objects are promoted. | 443 // Make sure the objects are promoted. |
444 heap->CollectGarbage(OLD_SPACE); | 444 heap->CollectGarbage(OLD_POINTER_SPACE); |
445 heap->CollectGarbage(NEW_SPACE); | 445 heap->CollectGarbage(NEW_SPACE); |
446 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2)); | 446 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2)); |
447 | 447 |
448 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); | 448 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); |
449 GlobalHandles::MakeWeak(h2.location(), | 449 GlobalHandles::MakeWeak(h2.location(), |
450 reinterpret_cast<void*>(&handle_and_id), | 450 reinterpret_cast<void*>(&handle_and_id), |
451 &TestWeakGlobalHandleCallback); | 451 &TestWeakGlobalHandleCallback); |
452 CHECK(!GlobalHandles::IsNearDeath(h1.location())); | 452 CHECK(!GlobalHandles::IsNearDeath(h1.location())); |
453 CHECK(!GlobalHandles::IsNearDeath(h2.location())); | 453 CHECK(!GlobalHandles::IsNearDeath(h2.location())); |
454 | 454 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 GlobalHandles::MakeWeak(h.location(), | 487 GlobalHandles::MakeWeak(h.location(), |
488 reinterpret_cast<void*>(&handle_and_id), | 488 reinterpret_cast<void*>(&handle_and_id), |
489 &TestWeakGlobalHandleCallback); | 489 &TestWeakGlobalHandleCallback); |
490 | 490 |
491 // Scanvenge does not recognize weak reference. | 491 // Scanvenge does not recognize weak reference. |
492 heap->CollectGarbage(NEW_SPACE); | 492 heap->CollectGarbage(NEW_SPACE); |
493 | 493 |
494 CHECK(!WeakPointerCleared); | 494 CHECK(!WeakPointerCleared); |
495 | 495 |
496 // Mark-compact treats weak reference properly. | 496 // Mark-compact treats weak reference properly. |
497 heap->CollectGarbage(OLD_SPACE); | 497 heap->CollectGarbage(OLD_POINTER_SPACE); |
498 | 498 |
499 CHECK(WeakPointerCleared); | 499 CHECK(WeakPointerCleared); |
500 } | 500 } |
501 | 501 |
502 | 502 |
503 static const char* not_so_random_string_table[] = { | 503 static const char* not_so_random_string_table[] = { |
504 "abstract", | 504 "abstract", |
505 "boolean", | 505 "boolean", |
506 "break", | 506 "break", |
507 "byte", | 507 "byte", |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 CcTest::InitializeVM(); | 886 CcTest::InitializeVM(); |
887 Isolate* isolate = CcTest::i_isolate(); | 887 Isolate* isolate = CcTest::i_isolate(); |
888 Factory* factory = isolate->factory(); | 888 Factory* factory = isolate->factory(); |
889 v8::HandleScope scope(CcTest::isolate()); | 889 v8::HandleScope scope(CcTest::isolate()); |
890 | 890 |
891 // Array of objects to scan haep for. | 891 // Array of objects to scan haep for. |
892 const int objs_count = 6; | 892 const int objs_count = 6; |
893 Handle<Object> objs[objs_count]; | 893 Handle<Object> objs[objs_count]; |
894 int next_objs_index = 0; | 894 int next_objs_index = 0; |
895 | 895 |
896 // Allocate a JS array to OLD_SPACE and NEW_SPACE | 896 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE |
897 objs[next_objs_index++] = factory->NewJSArray(10); | 897 objs[next_objs_index++] = factory->NewJSArray(10); |
898 objs[next_objs_index++] = factory->NewJSArray(10, | 898 objs[next_objs_index++] = factory->NewJSArray(10, |
899 FAST_HOLEY_ELEMENTS, | 899 FAST_HOLEY_ELEMENTS, |
900 TENURED); | 900 TENURED); |
901 | 901 |
902 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE | 902 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE |
903 objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij"); | 903 objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij"); |
904 objs[next_objs_index++] = | 904 objs[next_objs_index++] = |
905 factory->NewStringFromStaticChars("abcdefghij", TENURED); | 905 factory->NewStringFromStaticChars("abcdefghij", TENURED); |
906 | 906 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 CHECK_EQ(0, jsobject->properties()->length()); | 995 CHECK_EQ(0, jsobject->properties()->length()); |
996 // Create a reference to object in new space in jsobject. | 996 // Create a reference to object in new space in jsobject. |
997 FieldIndex index = FieldIndex::ForInObjectOffset( | 997 FieldIndex index = FieldIndex::ForInObjectOffset( |
998 JSObject::kHeaderSize - kPointerSize); | 998 JSObject::kHeaderSize - kPointerSize); |
999 jsobject->FastPropertyAtPut(index, array); | 999 jsobject->FastPropertyAtPut(index, array); |
1000 | 1000 |
1001 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); | 1001 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); |
1002 | 1002 |
1003 // Step 4: clone jsobject, but force always allocate first to create a clone | 1003 // Step 4: clone jsobject, but force always allocate first to create a clone |
1004 // in old pointer space. | 1004 // in old pointer space. |
1005 Address old_space_top = heap->old_space()->top(); | 1005 Address old_pointer_space_top = heap->old_pointer_space()->top(); |
1006 AlwaysAllocateScope aa_scope(isolate); | 1006 AlwaysAllocateScope aa_scope(isolate); |
1007 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); | 1007 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); |
1008 JSObject* clone = JSObject::cast(clone_obj); | 1008 JSObject* clone = JSObject::cast(clone_obj); |
1009 if (clone->address() != old_space_top) { | 1009 if (clone->address() != old_pointer_space_top) { |
1010 // Alas, got allocated from free list, we cannot do checks. | 1010 // Alas, got allocated from free list, we cannot do checks. |
1011 return; | 1011 return; |
1012 } | 1012 } |
1013 CHECK(heap->old_space()->Contains(clone->address())); | 1013 CHECK(heap->old_pointer_space()->Contains(clone->address())); |
1014 } | 1014 } |
1015 | 1015 |
1016 | 1016 |
1017 UNINITIALIZED_TEST(TestCodeFlushing) { | 1017 UNINITIALIZED_TEST(TestCodeFlushing) { |
1018 // If we do not flush code this test is invalid. | 1018 // If we do not flush code this test is invalid. |
1019 if (!FLAG_flush_code) return; | 1019 if (!FLAG_flush_code) return; |
1020 i::FLAG_allow_natives_syntax = true; | 1020 i::FLAG_allow_natives_syntax = true; |
1021 i::FLAG_optimize_for_size = false; | 1021 i::FLAG_optimize_for_size = false; |
1022 v8::Isolate* isolate = v8::Isolate::New(); | 1022 v8::Isolate* isolate = v8::Isolate::New(); |
1023 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1023 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 | 2131 |
2132 { | 2132 { |
2133 v8::HandleScope scope(CcTest::isolate()); | 2133 v8::HandleScope scope(CcTest::isolate()); |
2134 v8::Handle<v8::Object> global = CcTest::global(); | 2134 v8::Handle<v8::Object> global = CcTest::global(); |
2135 v8::Handle<v8::Function> g = | 2135 v8::Handle<v8::Function> g = |
2136 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); | 2136 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); |
2137 g->Call(global, 0, NULL); | 2137 g->Call(global, 0, NULL); |
2138 } | 2138 } |
2139 | 2139 |
2140 CcTest::heap()->incremental_marking()->set_should_hurry(true); | 2140 CcTest::heap()->incremental_marking()->set_should_hurry(true); |
2141 CcTest::heap()->CollectGarbage(OLD_SPACE); | 2141 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); |
2142 } | 2142 } |
2143 | 2143 |
2144 | 2144 |
2145 static int NumberOfProtoTransitions(Map* map) { | 2145 static int NumberOfProtoTransitions(Map* map) { |
2146 return TransitionArray::NumberOfPrototypeTransitions( | 2146 return TransitionArray::NumberOfPrototypeTransitions( |
2147 TransitionArray::GetPrototypeTransitions(map)); | 2147 TransitionArray::GetPrototypeTransitions(map)); |
2148 } | 2148 } |
2149 | 2149 |
2150 | 2150 |
2151 TEST(PrototypeTransitionClearing) { | 2151 TEST(PrototypeTransitionClearing) { |
(...skipping 30 matching lines...) Expand all Loading... |
2182 // Verify that prototype transitions array was compacted. | 2182 // Verify that prototype transitions array was compacted. |
2183 FixedArray* trans = | 2183 FixedArray* trans = |
2184 TransitionArray::GetPrototypeTransitions(baseObject->map()); | 2184 TransitionArray::GetPrototypeTransitions(baseObject->map()); |
2185 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { | 2185 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { |
2186 int j = TransitionArray::kProtoTransitionHeaderSize + i; | 2186 int j = TransitionArray::kProtoTransitionHeaderSize + i; |
2187 CHECK(trans->get(j)->IsMap()); | 2187 CHECK(trans->get(j)->IsMap()); |
2188 } | 2188 } |
2189 | 2189 |
2190 // Make sure next prototype is placed on an old-space evacuation candidate. | 2190 // Make sure next prototype is placed on an old-space evacuation candidate. |
2191 Handle<JSObject> prototype; | 2191 Handle<JSObject> prototype; |
2192 PagedSpace* space = CcTest::heap()->old_space(); | 2192 PagedSpace* space = CcTest::heap()->old_pointer_space(); |
2193 { | 2193 { |
2194 AlwaysAllocateScope always_allocate(isolate); | 2194 AlwaysAllocateScope always_allocate(isolate); |
2195 SimulateFullSpace(space); | 2195 SimulateFullSpace(space); |
2196 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 2196 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
2197 } | 2197 } |
2198 | 2198 |
2199 // Add a prototype on an evacuation candidate and verify that transition | 2199 // Add a prototype on an evacuation candidate and verify that transition |
2200 // clearing correctly records slots in prototype transition array. | 2200 // clearing correctly records slots in prototype transition array. |
2201 i::FLAG_always_compact = true; | 2201 i::FLAG_always_compact = true; |
2202 Handle<Map> map(baseObject->map()); | 2202 Handle<Map> map(baseObject->map()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 | 2302 |
2303 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2303 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
2304 CHECK_EQ(0, f->shared()->opt_count()); | 2304 CHECK_EQ(0, f->shared()->opt_count()); |
2305 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); | 2305 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); |
2306 } | 2306 } |
2307 | 2307 |
2308 | 2308 |
2309 TEST(IdleNotificationFinishMarking) { | 2309 TEST(IdleNotificationFinishMarking) { |
2310 i::FLAG_allow_natives_syntax = true; | 2310 i::FLAG_allow_natives_syntax = true; |
2311 CcTest::InitializeVM(); | 2311 CcTest::InitializeVM(); |
2312 SimulateFullSpace(CcTest::heap()->old_space()); | 2312 SimulateFullSpace(CcTest::heap()->old_pointer_space()); |
2313 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 2313 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
2314 marking->Abort(); | 2314 marking->Abort(); |
2315 marking->Start(); | 2315 marking->Start(); |
2316 | 2316 |
2317 CHECK_EQ(CcTest::heap()->gc_count(), 0); | 2317 CHECK_EQ(CcTest::heap()->gc_count(), 0); |
2318 | 2318 |
2319 // TODO(hpayer): We cannot write proper unit test right now for heap. | 2319 // TODO(hpayer): We cannot write proper unit test right now for heap. |
2320 // The ideal test would call kMaxIdleMarkingDelayCounter to test the | 2320 // The ideal test would call kMaxIdleMarkingDelayCounter to test the |
2321 // marking delay counter. | 2321 // marking delay counter. |
2322 | 2322 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 | 2415 |
2416 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2416 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
2417 Handle<JSObject> int_array_handle = | 2417 Handle<JSObject> int_array_handle = |
2418 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2418 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); |
2419 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); | 2419 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
2420 Handle<JSObject> double_array_handle = | 2420 Handle<JSObject> double_array_handle = |
2421 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2421 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
2422 | 2422 |
2423 Handle<JSObject> o = | 2423 Handle<JSObject> o = |
2424 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2424 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2425 CHECK(CcTest::heap()->InOldSpace(*o)); | 2425 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2426 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 2426 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); |
2427 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 2427 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); |
2428 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 2428 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); |
2429 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 2429 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); |
2430 } | 2430 } |
2431 | 2431 |
2432 | 2432 |
2433 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2433 TEST(OptimizedPretenuringObjectArrayLiterals) { |
2434 i::FLAG_allow_natives_syntax = true; | 2434 i::FLAG_allow_natives_syntax = true; |
2435 i::FLAG_expose_gc = true; | 2435 i::FLAG_expose_gc = true; |
2436 CcTest::InitializeVM(); | 2436 CcTest::InitializeVM(); |
2437 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2437 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2438 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2438 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2439 v8::HandleScope scope(CcTest::isolate()); | 2439 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2458 "f(); f();" | 2458 "f(); f();" |
2459 "%%OptimizeFunctionOnNextCall(f);" | 2459 "%%OptimizeFunctionOnNextCall(f);" |
2460 "f();", | 2460 "f();", |
2461 AllocationSite::kPretenureMinimumCreated); | 2461 AllocationSite::kPretenureMinimumCreated); |
2462 | 2462 |
2463 v8::Local<v8::Value> res = CompileRun(source.start()); | 2463 v8::Local<v8::Value> res = CompileRun(source.start()); |
2464 | 2464 |
2465 Handle<JSObject> o = | 2465 Handle<JSObject> o = |
2466 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2466 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2467 | 2467 |
2468 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 2468 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); |
2469 CHECK(CcTest::heap()->InOldSpace(*o)); | 2469 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2470 } | 2470 } |
2471 | 2471 |
2472 | 2472 |
2473 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2473 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2474 i::FLAG_allow_natives_syntax = true; | 2474 i::FLAG_allow_natives_syntax = true; |
2475 i::FLAG_expose_gc = true; | 2475 i::FLAG_expose_gc = true; |
2476 CcTest::InitializeVM(); | 2476 CcTest::InitializeVM(); |
2477 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2477 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2478 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2478 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2479 v8::HandleScope scope(CcTest::isolate()); | 2479 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 19 matching lines...) Expand all Loading... |
2499 "f(); f();" | 2499 "f(); f();" |
2500 "%%OptimizeFunctionOnNextCall(f);" | 2500 "%%OptimizeFunctionOnNextCall(f);" |
2501 "f();", | 2501 "f();", |
2502 AllocationSite::kPretenureMinimumCreated); | 2502 AllocationSite::kPretenureMinimumCreated); |
2503 | 2503 |
2504 v8::Local<v8::Value> res = CompileRun(source.start()); | 2504 v8::Local<v8::Value> res = CompileRun(source.start()); |
2505 | 2505 |
2506 Handle<JSObject> o = | 2506 Handle<JSObject> o = |
2507 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2507 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2508 | 2508 |
2509 CHECK(CcTest::heap()->InOldSpace(*o)); | 2509 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2510 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); | 2510 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); |
2511 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); | 2511 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); |
2512 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx1))); | 2512 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(idx1))); |
2513 if (!o->IsUnboxedDoubleField(idx2)) { | 2513 if (!o->IsUnboxedDoubleField(idx2)) { |
2514 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx2))); | 2514 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(idx2))); |
2515 } else { | 2515 } else { |
2516 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); | 2516 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); |
2517 } | 2517 } |
2518 | 2518 |
2519 JSObject* inner_object = | 2519 JSObject* inner_object = |
2520 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); | 2520 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); |
2521 CHECK(CcTest::heap()->InOldSpace(inner_object)); | 2521 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); |
2522 if (!inner_object->IsUnboxedDoubleField(idx1)) { | 2522 if (!inner_object->IsUnboxedDoubleField(idx1)) { |
2523 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx1))); | 2523 CHECK( |
| 2524 CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(idx1))); |
2524 } else { | 2525 } else { |
2525 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); | 2526 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); |
2526 } | 2527 } |
2527 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx2))); | 2528 CHECK( |
| 2529 CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(idx2))); |
2528 } | 2530 } |
2529 | 2531 |
2530 | 2532 |
2531 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2533 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2532 i::FLAG_allow_natives_syntax = true; | 2534 i::FLAG_allow_natives_syntax = true; |
2533 i::FLAG_expose_gc = true; | 2535 i::FLAG_expose_gc = true; |
2534 CcTest::InitializeVM(); | 2536 CcTest::InitializeVM(); |
2535 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2537 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2536 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2538 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2537 v8::HandleScope scope(CcTest::isolate()); | 2539 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2556 "f(); f();" | 2558 "f(); f();" |
2557 "%%OptimizeFunctionOnNextCall(f);" | 2559 "%%OptimizeFunctionOnNextCall(f);" |
2558 "f();", | 2560 "f();", |
2559 AllocationSite::kPretenureMinimumCreated); | 2561 AllocationSite::kPretenureMinimumCreated); |
2560 | 2562 |
2561 v8::Local<v8::Value> res = CompileRun(source.start()); | 2563 v8::Local<v8::Value> res = CompileRun(source.start()); |
2562 | 2564 |
2563 Handle<JSObject> o = | 2565 Handle<JSObject> o = |
2564 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2566 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2565 | 2567 |
2566 CHECK(CcTest::heap()->InOldSpace(*o)); | 2568 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2567 CHECK(CcTest::heap()->InOldSpace(o->properties())); | 2569 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); |
2568 } | 2570 } |
2569 | 2571 |
2570 | 2572 |
2571 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2573 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2572 i::FLAG_allow_natives_syntax = true; | 2574 i::FLAG_allow_natives_syntax = true; |
2573 i::FLAG_expose_gc = true; | 2575 i::FLAG_expose_gc = true; |
2574 CcTest::InitializeVM(); | 2576 CcTest::InitializeVM(); |
2575 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2577 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2576 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2578 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2577 v8::HandleScope scope(CcTest::isolate()); | 2579 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2596 "f(); f();" | 2598 "f(); f();" |
2597 "%%OptimizeFunctionOnNextCall(f);" | 2599 "%%OptimizeFunctionOnNextCall(f);" |
2598 "f();", | 2600 "f();", |
2599 AllocationSite::kPretenureMinimumCreated); | 2601 AllocationSite::kPretenureMinimumCreated); |
2600 | 2602 |
2601 v8::Local<v8::Value> res = CompileRun(source.start()); | 2603 v8::Local<v8::Value> res = CompileRun(source.start()); |
2602 | 2604 |
2603 Handle<JSObject> o = | 2605 Handle<JSObject> o = |
2604 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2606 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2605 | 2607 |
2606 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 2608 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); |
2607 CHECK(CcTest::heap()->InOldSpace(*o)); | 2609 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2608 } | 2610 } |
2609 | 2611 |
2610 | 2612 |
2611 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2613 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2612 i::FLAG_allow_natives_syntax = true; | 2614 i::FLAG_allow_natives_syntax = true; |
2613 i::FLAG_expose_gc = true; | 2615 i::FLAG_expose_gc = true; |
2614 CcTest::InitializeVM(); | 2616 CcTest::InitializeVM(); |
2615 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2617 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2616 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2618 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2617 v8::HandleScope scope(CcTest::isolate()); | 2619 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 23 matching lines...) Expand all Loading... |
2641 | 2643 |
2642 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2644 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
2643 Handle<JSObject> int_array_handle = | 2645 Handle<JSObject> int_array_handle = |
2644 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2646 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); |
2645 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); | 2647 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
2646 Handle<JSObject> double_array_handle = | 2648 Handle<JSObject> double_array_handle = |
2647 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2649 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
2648 | 2650 |
2649 Handle<JSObject> o = | 2651 Handle<JSObject> o = |
2650 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2652 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2651 CHECK(CcTest::heap()->InOldSpace(*o)); | 2653 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2652 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 2654 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); |
2653 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 2655 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); |
2654 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 2656 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); |
2655 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 2657 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); |
2656 } | 2658 } |
2657 | 2659 |
2658 | 2660 |
2659 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2661 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2660 i::FLAG_allow_natives_syntax = true; | 2662 i::FLAG_allow_natives_syntax = true; |
2661 i::FLAG_expose_gc = true; | 2663 i::FLAG_expose_gc = true; |
2662 CcTest::InitializeVM(); | 2664 CcTest::InitializeVM(); |
2663 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2665 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2664 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2666 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2665 v8::HandleScope scope(CcTest::isolate()); | 2667 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 24 matching lines...) Expand all Loading... |
2690 | 2692 |
2691 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); | 2693 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); |
2692 Handle<JSObject> int_array_handle_1 = | 2694 Handle<JSObject> int_array_handle_1 = |
2693 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); | 2695 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); |
2694 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); | 2696 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); |
2695 Handle<JSObject> int_array_handle_2 = | 2697 Handle<JSObject> int_array_handle_2 = |
2696 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); | 2698 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); |
2697 | 2699 |
2698 Handle<JSObject> o = | 2700 Handle<JSObject> o = |
2699 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2701 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2700 CHECK(CcTest::heap()->InOldSpace(*o)); | 2702 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2701 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); | 2703 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); |
2702 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); | 2704 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); |
2703 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); | 2705 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); |
2704 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); | 2706 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); |
2705 } | 2707 } |
2706 | 2708 |
2707 | 2709 |
2708 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2710 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2709 i::FLAG_allow_natives_syntax = true; | 2711 i::FLAG_allow_natives_syntax = true; |
2710 i::FLAG_expose_gc = true; | 2712 i::FLAG_expose_gc = true; |
2711 CcTest::InitializeVM(); | 2713 CcTest::InitializeVM(); |
2712 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2714 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2713 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2715 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2714 v8::HandleScope scope(CcTest::isolate()); | 2716 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 26 matching lines...) Expand all Loading... |
2741 v8::Object::Cast(*res)->Get(v8_str("0")); | 2743 v8::Object::Cast(*res)->Get(v8_str("0")); |
2742 Handle<JSObject> double_array_handle_1 = | 2744 Handle<JSObject> double_array_handle_1 = |
2743 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); | 2745 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); |
2744 v8::Local<v8::Value> double_array_2 = | 2746 v8::Local<v8::Value> double_array_2 = |
2745 v8::Object::Cast(*res)->Get(v8_str("1")); | 2747 v8::Object::Cast(*res)->Get(v8_str("1")); |
2746 Handle<JSObject> double_array_handle_2 = | 2748 Handle<JSObject> double_array_handle_2 = |
2747 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2)); | 2749 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2)); |
2748 | 2750 |
2749 Handle<JSObject> o = | 2751 Handle<JSObject> o = |
2750 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2752 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2751 CHECK(CcTest::heap()->InOldSpace(*o)); | 2753 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2752 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); | 2754 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1)); |
2753 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); | 2755 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements())); |
2754 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); | 2756 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2)); |
2755 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); | 2757 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements())); |
2756 } | 2758 } |
2757 | 2759 |
2758 | 2760 |
2759 // Make sure pretenuring feedback is gathered for constructed objects as well | 2761 // Make sure pretenuring feedback is gathered for constructed objects as well |
2760 // as for literals. | 2762 // as for literals. |
2761 TEST(OptimizedPretenuringConstructorCalls) { | 2763 TEST(OptimizedPretenuringConstructorCalls) { |
2762 if (!i::FLAG_pretenuring_call_new) { | 2764 if (!i::FLAG_pretenuring_call_new) { |
2763 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2765 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2764 return; | 2766 return; |
2765 } | 2767 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 "%%OptimizeFunctionOnNextCall(f);" | 2800 "%%OptimizeFunctionOnNextCall(f);" |
2799 "f();", | 2801 "f();", |
2800 AllocationSite::kPretenureMinimumCreated + | 2802 AllocationSite::kPretenureMinimumCreated + |
2801 JSFunction::kGenerousAllocationCount); | 2803 JSFunction::kGenerousAllocationCount); |
2802 | 2804 |
2803 v8::Local<v8::Value> res = CompileRun(source.start()); | 2805 v8::Local<v8::Value> res = CompileRun(source.start()); |
2804 | 2806 |
2805 Handle<JSObject> o = | 2807 Handle<JSObject> o = |
2806 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2808 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2807 | 2809 |
2808 CHECK(CcTest::heap()->InOldSpace(*o)); | 2810 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2809 } | 2811 } |
2810 | 2812 |
2811 | 2813 |
2812 TEST(OptimizedPretenuringCallNew) { | 2814 TEST(OptimizedPretenuringCallNew) { |
2813 if (!i::FLAG_pretenuring_call_new) { | 2815 if (!i::FLAG_pretenuring_call_new) { |
2814 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2816 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2815 return; | 2817 return; |
2816 } | 2818 } |
2817 i::FLAG_allow_natives_syntax = true; | 2819 i::FLAG_allow_natives_syntax = true; |
2818 i::FLAG_expose_gc = true; | 2820 i::FLAG_expose_gc = true; |
(...skipping 26 matching lines...) Expand all Loading... |
2845 "f(); f();" | 2847 "f(); f();" |
2846 "%%OptimizeFunctionOnNextCall(f);" | 2848 "%%OptimizeFunctionOnNextCall(f);" |
2847 "f();", | 2849 "f();", |
2848 AllocationSite::kPretenureMinimumCreated + | 2850 AllocationSite::kPretenureMinimumCreated + |
2849 JSFunction::kGenerousAllocationCount); | 2851 JSFunction::kGenerousAllocationCount); |
2850 | 2852 |
2851 v8::Local<v8::Value> res = CompileRun(source.start()); | 2853 v8::Local<v8::Value> res = CompileRun(source.start()); |
2852 | 2854 |
2853 Handle<JSObject> o = | 2855 Handle<JSObject> o = |
2854 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2856 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2855 CHECK(CcTest::heap()->InOldSpace(*o)); | 2857 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2856 } | 2858 } |
2857 | 2859 |
2858 | 2860 |
2859 // Test regular array literals allocation. | 2861 // Test regular array literals allocation. |
2860 TEST(OptimizedAllocationArrayLiterals) { | 2862 TEST(OptimizedAllocationArrayLiterals) { |
2861 i::FLAG_allow_natives_syntax = true; | 2863 i::FLAG_allow_natives_syntax = true; |
2862 CcTest::InitializeVM(); | 2864 CcTest::InitializeVM(); |
2863 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2865 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2864 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2866 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2865 v8::HandleScope scope(CcTest::isolate()); | 2867 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 AddTransitions(transitions_count); | 3032 AddTransitions(transitions_count); |
3031 CompileRun("var root = new F;"); | 3033 CompileRun("var root = new F;"); |
3032 Handle<JSObject> root = GetByName("root"); | 3034 Handle<JSObject> root = GetByName("root"); |
3033 | 3035 |
3034 // Count number of live transitions before marking. | 3036 // Count number of live transitions before marking. |
3035 int transitions_before = CountMapTransitions(root->map()); | 3037 int transitions_before = CountMapTransitions(root->map()); |
3036 CHECK_EQ(transitions_count, transitions_before); | 3038 CHECK_EQ(transitions_count, transitions_before); |
3037 | 3039 |
3038 root = GetByName("root"); | 3040 root = GetByName("root"); |
3039 AddPropertyTo(0, root, "prop9"); | 3041 AddPropertyTo(0, root, "prop9"); |
3040 CcTest::i_isolate()->heap()->CollectGarbage(OLD_SPACE); | 3042 CcTest::i_isolate()->heap()->CollectGarbage(OLD_POINTER_SPACE); |
3041 | 3043 |
3042 // Count number of live transitions after marking. Note that one transition | 3044 // Count number of live transitions after marking. Note that one transition |
3043 // is left, because 'o' still holds an instance of one transition target. | 3045 // is left, because 'o' still holds an instance of one transition target. |
3044 int transitions_after = CountMapTransitions( | 3046 int transitions_after = CountMapTransitions( |
3045 Map::cast(root->map()->GetBackPointer())); | 3047 Map::cast(root->map()->GetBackPointer())); |
3046 CHECK_EQ(1, transitions_after); | 3048 CHECK_EQ(1, transitions_after); |
3047 } | 3049 } |
3048 | 3050 |
3049 | 3051 |
3050 TEST(TransitionArraySimpleToFull) { | 3052 TEST(TransitionArraySimpleToFull) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3168 i::FLAG_crankshaft = false; | 3170 i::FLAG_crankshaft = false; |
3169 i::FLAG_always_opt = false; | 3171 i::FLAG_always_opt = false; |
3170 CcTest::InitializeVM(); | 3172 CcTest::InitializeVM(); |
3171 Isolate* isolate = CcTest::i_isolate(); | 3173 Isolate* isolate = CcTest::i_isolate(); |
3172 Factory* factory = isolate->factory(); | 3174 Factory* factory = isolate->factory(); |
3173 Heap* heap = isolate->heap(); | 3175 Heap* heap = isolate->heap(); |
3174 v8::HandleScope scope(CcTest::isolate()); | 3176 v8::HandleScope scope(CcTest::isolate()); |
3175 static const int number_of_test_pages = 20; | 3177 static const int number_of_test_pages = 20; |
3176 | 3178 |
3177 // Prepare many pages with low live-bytes count. | 3179 // Prepare many pages with low live-bytes count. |
3178 PagedSpace* old_space = heap->old_space(); | 3180 PagedSpace* old_pointer_space = heap->old_pointer_space(); |
3179 CHECK_EQ(1, old_space->CountTotalPages()); | 3181 CHECK_EQ(1, old_pointer_space->CountTotalPages()); |
3180 for (int i = 0; i < number_of_test_pages; i++) { | 3182 for (int i = 0; i < number_of_test_pages; i++) { |
3181 AlwaysAllocateScope always_allocate(isolate); | 3183 AlwaysAllocateScope always_allocate(isolate); |
3182 SimulateFullSpace(old_space); | 3184 SimulateFullSpace(old_pointer_space); |
3183 factory->NewFixedArray(1, TENURED); | 3185 factory->NewFixedArray(1, TENURED); |
3184 } | 3186 } |
3185 CHECK_EQ(number_of_test_pages + 1, old_space->CountTotalPages()); | 3187 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); |
3186 | 3188 |
3187 // Triggering one GC will cause a lot of garbage to be discovered but | 3189 // Triggering one GC will cause a lot of garbage to be discovered but |
3188 // even spread across all allocated pages. | 3190 // even spread across all allocated pages. |
3189 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, | 3191 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, |
3190 "triggered for preparation"); | 3192 "triggered for preparation"); |
3191 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); | 3193 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); |
3192 | 3194 |
3193 // Triggering subsequent GCs should cause at least half of the pages | 3195 // Triggering subsequent GCs should cause at least half of the pages |
3194 // to be released to the OS after at most two cycles. | 3196 // to be released to the OS after at most two cycles. |
3195 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); | 3197 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); |
3196 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); | 3198 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); |
3197 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); | 3199 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); |
3198 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages() * 2); | 3200 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); |
3199 | 3201 |
3200 // Triggering a last-resort GC should cause all pages to be released to the | 3202 // Triggering a last-resort GC should cause all pages to be released to the |
3201 // OS so that other processes can seize the memory. If we get a failure here | 3203 // OS so that other processes can seize the memory. If we get a failure here |
3202 // where there are 2 pages left instead of 1, then we should increase the | 3204 // where there are 2 pages left instead of 1, then we should increase the |
3203 // size of the first page a little in SizeOfFirstPage in spaces.cc. The | 3205 // size of the first page a little in SizeOfFirstPage in spaces.cc. The |
3204 // first page should be small in order to reduce memory used when the VM | 3206 // first page should be small in order to reduce memory used when the VM |
3205 // boots, but if the 20 small arrays don't fit on the first page then that's | 3207 // boots, but if the 20 small arrays don't fit on the first page then that's |
3206 // an indication that it is too small. | 3208 // an indication that it is too small. |
3207 heap->CollectAllAvailableGarbage("triggered really hard"); | 3209 heap->CollectAllAvailableGarbage("triggered really hard"); |
3208 CHECK_EQ(1, old_space->CountTotalPages()); | 3210 CHECK_EQ(1, old_pointer_space->CountTotalPages()); |
3209 } | 3211 } |
3210 | 3212 |
3211 | 3213 |
3212 TEST(Regress2237) { | 3214 TEST(Regress2237) { |
3213 i::FLAG_stress_compaction = false; | 3215 i::FLAG_stress_compaction = false; |
3214 CcTest::InitializeVM(); | 3216 CcTest::InitializeVM(); |
3215 Isolate* isolate = CcTest::i_isolate(); | 3217 Isolate* isolate = CcTest::i_isolate(); |
3216 Factory* factory = isolate->factory(); | 3218 Factory* factory = isolate->factory(); |
3217 v8::HandleScope scope(CcTest::isolate()); | 3219 v8::HandleScope scope(CcTest::isolate()); |
3218 Handle<String> slice(CcTest::heap()->empty_string()); | 3220 Handle<String> slice(CcTest::heap()->empty_string()); |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4838 "var array = new Array(40000);" | 4840 "var array = new Array(40000);" |
4839 "var tmp = new Array(100000);" | 4841 "var tmp = new Array(100000);" |
4840 "array[0] = 10;" | 4842 "array[0] = 10;" |
4841 "gc();" | 4843 "gc();" |
4842 "gc();" | 4844 "gc();" |
4843 "array.shift();" | 4845 "array.shift();" |
4844 "array;"); | 4846 "array;"); |
4845 | 4847 |
4846 Handle<JSObject> o = | 4848 Handle<JSObject> o = |
4847 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4849 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
4848 CHECK(heap->InOldSpace(o->elements())); | 4850 CHECK(heap->InOldPointerSpace(o->elements())); |
4849 CHECK(heap->InOldSpace(*o)); | 4851 CHECK(heap->InOldPointerSpace(*o)); |
4850 Page* page = Page::FromAddress(o->elements()->address()); | 4852 Page* page = Page::FromAddress(o->elements()->address()); |
4851 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE || | 4853 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE || |
4852 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4854 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
4853 } | 4855 } |
4854 | 4856 |
4855 | 4857 |
4856 UNINITIALIZED_TEST(PromotionQueue) { | 4858 UNINITIALIZED_TEST(PromotionQueue) { |
4857 i::FLAG_expose_gc = true; | 4859 i::FLAG_expose_gc = true; |
4858 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB); | 4860 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB); |
4859 v8::Isolate* isolate = v8::Isolate::New(); | 4861 v8::Isolate* isolate = v8::Isolate::New(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4952 Handle<Map> map2 = | 4954 Handle<Map> map2 = |
4953 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), | 4955 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), |
4954 HeapType::Any(isolate), NONE, Representation::Tagged(), | 4956 HeapType::Any(isolate), NONE, Representation::Tagged(), |
4955 OMIT_TRANSITION).ToHandleChecked(); | 4957 OMIT_TRANSITION).ToHandleChecked(); |
4956 | 4958 |
4957 int desired_offset = Page::kPageSize - map1->instance_size(); | 4959 int desired_offset = Page::kPageSize - map1->instance_size(); |
4958 | 4960 |
4959 // Allocate fixed array in old pointer space so, that object allocated | 4961 // Allocate fixed array in old pointer space so, that object allocated |
4960 // afterwards would end at the end of the page. | 4962 // afterwards would end at the end of the page. |
4961 { | 4963 { |
4962 SimulateFullSpace(heap->old_space()); | 4964 SimulateFullSpace(heap->old_pointer_space()); |
4963 int padding_size = desired_offset - Page::kObjectStartOffset; | 4965 int padding_size = desired_offset - Page::kObjectStartOffset; |
4964 int padding_array_length = | 4966 int padding_array_length = |
4965 (padding_size - FixedArray::kHeaderSize) / kPointerSize; | 4967 (padding_size - FixedArray::kHeaderSize) / kPointerSize; |
4966 | 4968 |
4967 Handle<FixedArray> temp2 = | 4969 Handle<FixedArray> temp2 = |
4968 factory->NewFixedArray(padding_array_length, TENURED); | 4970 factory->NewFixedArray(padding_array_length, TENURED); |
4969 Page* page = Page::FromAddress(temp2->address()); | 4971 Page* page = Page::FromAddress(temp2->address()); |
4970 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); | 4972 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); |
4971 } | 4973 } |
4972 | 4974 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5021 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 5023 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
5022 } | 5024 } |
5023 // Stash the backing store in a handle. | 5025 // Stash the backing store in a handle. |
5024 Handle<Object> save(weak_map->table(), isolate); | 5026 Handle<Object> save(weak_map->table(), isolate); |
5025 // The following line will update the backing store. | 5027 // The following line will update the backing store. |
5026 CompileRun( | 5028 CompileRun( |
5027 "for (var i = 0; i < 50; i++) {" | 5029 "for (var i = 0; i < 50; i++) {" |
5028 " weak_map.set(future_keys[i], i);" | 5030 " weak_map.set(future_keys[i], i);" |
5029 "}"); | 5031 "}"); |
5030 heap->incremental_marking()->set_should_hurry(true); | 5032 heap->incremental_marking()->set_should_hurry(true); |
5031 heap->CollectGarbage(OLD_SPACE); | 5033 heap->CollectGarbage(OLD_POINTER_SPACE); |
5032 } | 5034 } |
5033 | 5035 |
5034 | 5036 |
5035 TEST(Regress442710) { | 5037 TEST(Regress442710) { |
5036 CcTest::InitializeVM(); | 5038 CcTest::InitializeVM(); |
5037 Isolate* isolate = CcTest::i_isolate(); | 5039 Isolate* isolate = CcTest::i_isolate(); |
5038 Heap* heap = isolate->heap(); | 5040 Heap* heap = isolate->heap(); |
5039 Factory* factory = isolate->factory(); | 5041 Factory* factory = isolate->factory(); |
5040 | 5042 |
5041 HandleScope sc(isolate); | 5043 HandleScope sc(isolate); |
5042 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); | 5044 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); |
5043 Handle<JSArray> array = factory->NewJSArray(2); | 5045 Handle<JSArray> array = factory->NewJSArray(2); |
5044 | 5046 |
5045 Handle<String> name = factory->InternalizeUtf8String("testArray"); | 5047 Handle<String> name = factory->InternalizeUtf8String("testArray"); |
5046 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); | 5048 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); |
5047 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); | 5049 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); |
5048 heap->CollectGarbage(OLD_SPACE); | 5050 heap->CollectGarbage(OLD_POINTER_SPACE); |
5049 } | 5051 } |
5050 | 5052 |
5051 | 5053 |
5052 TEST(NumberStringCacheSize) { | 5054 TEST(NumberStringCacheSize) { |
5053 // Test that the number-string cache has not been resized in the snapshot. | 5055 // Test that the number-string cache has not been resized in the snapshot. |
5054 CcTest::InitializeVM(); | 5056 CcTest::InitializeVM(); |
5055 Isolate* isolate = CcTest::i_isolate(); | 5057 Isolate* isolate = CcTest::i_isolate(); |
5056 if (!isolate->snapshot_available()) return; | 5058 if (!isolate->snapshot_available()) return; |
5057 Heap* heap = isolate->heap(); | 5059 Heap* heap = isolate->heap(); |
5058 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, | 5060 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, |
(...skipping 12 matching lines...) Expand all Loading... |
5071 v8::Local<v8::Value> result = | 5073 v8::Local<v8::Value> result = |
5072 CompileRun("(function () { return {x : 10}; })();"); | 5074 CompileRun("(function () { return {x : 10}; })();"); |
5073 Handle<JSObject> proto = | 5075 Handle<JSObject> proto = |
5074 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 5076 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
5075 map->set_prototype(*proto); | 5077 map->set_prototype(*proto); |
5076 heap->AddRetainedMap(map); | 5078 heap->AddRetainedMap(map); |
5077 weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); | 5079 weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); |
5078 } | 5080 } |
5079 CHECK(!weak_cell->cleared()); | 5081 CHECK(!weak_cell->cleared()); |
5080 for (int i = 0; i < n; i++) { | 5082 for (int i = 0; i < n; i++) { |
5081 heap->CollectGarbage(OLD_SPACE); | 5083 heap->CollectGarbage(OLD_POINTER_SPACE); |
5082 } | 5084 } |
5083 CHECK(!weak_cell->cleared()); | 5085 CHECK(!weak_cell->cleared()); |
5084 heap->CollectGarbage(OLD_SPACE); | 5086 heap->CollectGarbage(OLD_POINTER_SPACE); |
5085 CHECK(weak_cell->cleared()); | 5087 CHECK(weak_cell->cleared()); |
5086 } | 5088 } |
5087 | 5089 |
5088 | 5090 |
5089 TEST(MapRetaining) { | 5091 TEST(MapRetaining) { |
5090 CcTest::InitializeVM(); | 5092 CcTest::InitializeVM(); |
5091 v8::HandleScope scope(CcTest::isolate()); | 5093 v8::HandleScope scope(CcTest::isolate()); |
5092 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); | 5094 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); |
5093 CheckMapRetainingFor(0); | 5095 CheckMapRetainingFor(0); |
5094 CheckMapRetainingFor(1); | 5096 CheckMapRetainingFor(1); |
(...skipping 15 matching lines...) Expand all Loading... |
5110 | 5112 |
5111 TEST(WritableVsImmortalRoots) { | 5113 TEST(WritableVsImmortalRoots) { |
5112 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { | 5114 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { |
5113 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); | 5115 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); |
5114 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); | 5116 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); |
5115 bool immortal = Heap::RootIsImmortalImmovable(root_index); | 5117 bool immortal = Heap::RootIsImmortalImmovable(root_index); |
5116 // A root value can be writable, immortal, or neither, but not both. | 5118 // A root value can be writable, immortal, or neither, but not both. |
5117 CHECK(!immortal || !writable); | 5119 CHECK(!immortal || !writable); |
5118 } | 5120 } |
5119 } | 5121 } |
OLD | NEW |