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_POINTER_SPACE); | 444 heap->CollectGarbage(OLD_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_POINTER_SPACE); | 497 heap->CollectGarbage(OLD_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_POINTER_SPACE and NEW_SPACE | 896 // Allocate a JS array to OLD_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_pointer_space_top = heap->old_pointer_space()->top(); | 1005 Address old_space_top = heap->old_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_pointer_space_top) { | 1009 if (clone->address() != old_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_pointer_space()->Contains(clone->address())); | 1013 CHECK(heap->old_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_POINTER_SPACE); | 2141 CcTest::heap()->CollectGarbage(OLD_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_pointer_space(); | 2192 PagedSpace* space = CcTest::heap()->old_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_pointer_space()); | 2312 SimulateFullSpace(CcTest::heap()->old_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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 | 2413 |
2414 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2414 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
2415 Handle<JSObject> int_array_handle = | 2415 Handle<JSObject> int_array_handle = |
2416 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2416 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); |
2417 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); | 2417 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
2418 Handle<JSObject> double_array_handle = | 2418 Handle<JSObject> double_array_handle = |
2419 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2419 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
2420 | 2420 |
2421 Handle<JSObject> o = | 2421 Handle<JSObject> o = |
2422 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2422 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2423 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2423 CHECK(CcTest::heap()->InOldSpace(*o)); |
2424 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); | 2424 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
2425 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); | 2425 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
2426 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); | 2426 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
2427 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); | 2427 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
2428 } | 2428 } |
2429 | 2429 |
2430 | 2430 |
2431 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2431 TEST(OptimizedPretenuringObjectArrayLiterals) { |
2432 i::FLAG_allow_natives_syntax = true; | 2432 i::FLAG_allow_natives_syntax = true; |
2433 i::FLAG_expose_gc = true; | 2433 i::FLAG_expose_gc = true; |
2434 CcTest::InitializeVM(); | 2434 CcTest::InitializeVM(); |
2435 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2435 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2436 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2436 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2437 v8::HandleScope scope(CcTest::isolate()); | 2437 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2456 "f(); f();" | 2456 "f(); f();" |
2457 "%%OptimizeFunctionOnNextCall(f);" | 2457 "%%OptimizeFunctionOnNextCall(f);" |
2458 "f();", | 2458 "f();", |
2459 AllocationSite::kPretenureMinimumCreated); | 2459 AllocationSite::kPretenureMinimumCreated); |
2460 | 2460 |
2461 v8::Local<v8::Value> res = CompileRun(source.start()); | 2461 v8::Local<v8::Value> res = CompileRun(source.start()); |
2462 | 2462 |
2463 Handle<JSObject> o = | 2463 Handle<JSObject> o = |
2464 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2464 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2465 | 2465 |
2466 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); | 2466 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
2467 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2467 CHECK(CcTest::heap()->InOldSpace(*o)); |
2468 } | 2468 } |
2469 | 2469 |
2470 | 2470 |
2471 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2471 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2472 i::FLAG_allow_natives_syntax = true; | 2472 i::FLAG_allow_natives_syntax = true; |
2473 i::FLAG_expose_gc = true; | 2473 i::FLAG_expose_gc = true; |
2474 CcTest::InitializeVM(); | 2474 CcTest::InitializeVM(); |
2475 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2475 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2476 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2476 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2477 v8::HandleScope scope(CcTest::isolate()); | 2477 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 19 matching lines...) Expand all Loading... |
2497 "f(); f();" | 2497 "f(); f();" |
2498 "%%OptimizeFunctionOnNextCall(f);" | 2498 "%%OptimizeFunctionOnNextCall(f);" |
2499 "f();", | 2499 "f();", |
2500 AllocationSite::kPretenureMinimumCreated); | 2500 AllocationSite::kPretenureMinimumCreated); |
2501 | 2501 |
2502 v8::Local<v8::Value> res = CompileRun(source.start()); | 2502 v8::Local<v8::Value> res = CompileRun(source.start()); |
2503 | 2503 |
2504 Handle<JSObject> o = | 2504 Handle<JSObject> o = |
2505 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2505 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2506 | 2506 |
2507 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2507 CHECK(CcTest::heap()->InOldSpace(*o)); |
2508 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); | 2508 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); |
2509 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); | 2509 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); |
2510 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(idx1))); | 2510 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx1))); |
2511 if (!o->IsUnboxedDoubleField(idx2)) { | 2511 if (!o->IsUnboxedDoubleField(idx2)) { |
2512 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(idx2))); | 2512 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx2))); |
2513 } else { | 2513 } else { |
2514 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); | 2514 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); |
2515 } | 2515 } |
2516 | 2516 |
2517 JSObject* inner_object = | 2517 JSObject* inner_object = |
2518 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); | 2518 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); |
2519 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); | 2519 CHECK(CcTest::heap()->InOldSpace(inner_object)); |
2520 if (!inner_object->IsUnboxedDoubleField(idx1)) { | 2520 if (!inner_object->IsUnboxedDoubleField(idx1)) { |
2521 CHECK( | 2521 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx1))); |
2522 CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(idx1))); | |
2523 } else { | 2522 } else { |
2524 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); | 2523 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); |
2525 } | 2524 } |
2526 CHECK(CcTest::heap()->InOldPointerSpace( | 2525 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx2))); |
2527 inner_object->RawFastPropertyAt(idx2))); | |
2528 } | 2526 } |
2529 | 2527 |
2530 | 2528 |
2531 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2529 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2532 i::FLAG_allow_natives_syntax = true; | 2530 i::FLAG_allow_natives_syntax = true; |
2533 i::FLAG_expose_gc = true; | 2531 i::FLAG_expose_gc = true; |
2534 CcTest::InitializeVM(); | 2532 CcTest::InitializeVM(); |
2535 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2533 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2536 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2534 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2537 v8::HandleScope scope(CcTest::isolate()); | 2535 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2556 "f(); f();" | 2554 "f(); f();" |
2557 "%%OptimizeFunctionOnNextCall(f);" | 2555 "%%OptimizeFunctionOnNextCall(f);" |
2558 "f();", | 2556 "f();", |
2559 AllocationSite::kPretenureMinimumCreated); | 2557 AllocationSite::kPretenureMinimumCreated); |
2560 | 2558 |
2561 v8::Local<v8::Value> res = CompileRun(source.start()); | 2559 v8::Local<v8::Value> res = CompileRun(source.start()); |
2562 | 2560 |
2563 Handle<JSObject> o = | 2561 Handle<JSObject> o = |
2564 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2562 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2565 | 2563 |
2566 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2564 CHECK(CcTest::heap()->InOldSpace(*o)); |
2567 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); | 2565 CHECK(CcTest::heap()->InOldSpace(o->properties())); |
2568 } | 2566 } |
2569 | 2567 |
2570 | 2568 |
2571 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2569 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2572 i::FLAG_allow_natives_syntax = true; | 2570 i::FLAG_allow_natives_syntax = true; |
2573 i::FLAG_expose_gc = true; | 2571 i::FLAG_expose_gc = true; |
2574 CcTest::InitializeVM(); | 2572 CcTest::InitializeVM(); |
2575 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2573 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2576 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2574 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2577 v8::HandleScope scope(CcTest::isolate()); | 2575 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 18 matching lines...) Expand all Loading... |
2596 "f(); f();" | 2594 "f(); f();" |
2597 "%%OptimizeFunctionOnNextCall(f);" | 2595 "%%OptimizeFunctionOnNextCall(f);" |
2598 "f();", | 2596 "f();", |
2599 AllocationSite::kPretenureMinimumCreated); | 2597 AllocationSite::kPretenureMinimumCreated); |
2600 | 2598 |
2601 v8::Local<v8::Value> res = CompileRun(source.start()); | 2599 v8::Local<v8::Value> res = CompileRun(source.start()); |
2602 | 2600 |
2603 Handle<JSObject> o = | 2601 Handle<JSObject> o = |
2604 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2602 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2605 | 2603 |
2606 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); | 2604 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
2607 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2605 CHECK(CcTest::heap()->InOldSpace(*o)); |
2608 } | 2606 } |
2609 | 2607 |
2610 | 2608 |
2611 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2609 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2612 i::FLAG_allow_natives_syntax = true; | 2610 i::FLAG_allow_natives_syntax = true; |
2613 i::FLAG_expose_gc = true; | 2611 i::FLAG_expose_gc = true; |
2614 CcTest::InitializeVM(); | 2612 CcTest::InitializeVM(); |
2615 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2613 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2616 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2614 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2617 v8::HandleScope scope(CcTest::isolate()); | 2615 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 23 matching lines...) Expand all Loading... |
2641 | 2639 |
2642 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2640 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
2643 Handle<JSObject> int_array_handle = | 2641 Handle<JSObject> int_array_handle = |
2644 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2642 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")); | 2643 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
2646 Handle<JSObject> double_array_handle = | 2644 Handle<JSObject> double_array_handle = |
2647 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2645 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
2648 | 2646 |
2649 Handle<JSObject> o = | 2647 Handle<JSObject> o = |
2650 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2648 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2651 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2649 CHECK(CcTest::heap()->InOldSpace(*o)); |
2652 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); | 2650 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
2653 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); | 2651 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
2654 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); | 2652 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
2655 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); | 2653 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
2656 } | 2654 } |
2657 | 2655 |
2658 | 2656 |
2659 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2657 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2660 i::FLAG_allow_natives_syntax = true; | 2658 i::FLAG_allow_natives_syntax = true; |
2661 i::FLAG_expose_gc = true; | 2659 i::FLAG_expose_gc = true; |
2662 CcTest::InitializeVM(); | 2660 CcTest::InitializeVM(); |
2663 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2661 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2664 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2662 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2665 v8::HandleScope scope(CcTest::isolate()); | 2663 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 24 matching lines...) Expand all Loading... |
2690 | 2688 |
2691 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); | 2689 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); |
2692 Handle<JSObject> int_array_handle_1 = | 2690 Handle<JSObject> int_array_handle_1 = |
2693 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); | 2691 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")); | 2692 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); |
2695 Handle<JSObject> int_array_handle_2 = | 2693 Handle<JSObject> int_array_handle_2 = |
2696 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); | 2694 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); |
2697 | 2695 |
2698 Handle<JSObject> o = | 2696 Handle<JSObject> o = |
2699 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2697 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2700 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2698 CHECK(CcTest::heap()->InOldSpace(*o)); |
2701 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); | 2699 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); |
2702 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); | 2700 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); |
2703 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); | 2701 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); |
2704 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); | 2702 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); |
2705 } | 2703 } |
2706 | 2704 |
2707 | 2705 |
2708 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2706 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2709 i::FLAG_allow_natives_syntax = true; | 2707 i::FLAG_allow_natives_syntax = true; |
2710 i::FLAG_expose_gc = true; | 2708 i::FLAG_expose_gc = true; |
2711 CcTest::InitializeVM(); | 2709 CcTest::InitializeVM(); |
2712 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2710 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2713 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2711 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2714 v8::HandleScope scope(CcTest::isolate()); | 2712 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 26 matching lines...) Expand all Loading... |
2741 v8::Object::Cast(*res)->Get(v8_str("0")); | 2739 v8::Object::Cast(*res)->Get(v8_str("0")); |
2742 Handle<JSObject> double_array_handle_1 = | 2740 Handle<JSObject> double_array_handle_1 = |
2743 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); | 2741 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); |
2744 v8::Local<v8::Value> double_array_2 = | 2742 v8::Local<v8::Value> double_array_2 = |
2745 v8::Object::Cast(*res)->Get(v8_str("1")); | 2743 v8::Object::Cast(*res)->Get(v8_str("1")); |
2746 Handle<JSObject> double_array_handle_2 = | 2744 Handle<JSObject> double_array_handle_2 = |
2747 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2)); | 2745 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2)); |
2748 | 2746 |
2749 Handle<JSObject> o = | 2747 Handle<JSObject> o = |
2750 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2748 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2751 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2749 CHECK(CcTest::heap()->InOldSpace(*o)); |
2752 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1)); | 2750 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); |
2753 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements())); | 2751 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); |
2754 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2)); | 2752 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); |
2755 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements())); | 2753 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); |
2756 } | 2754 } |
2757 | 2755 |
2758 | 2756 |
2759 // Make sure pretenuring feedback is gathered for constructed objects as well | 2757 // Make sure pretenuring feedback is gathered for constructed objects as well |
2760 // as for literals. | 2758 // as for literals. |
2761 TEST(OptimizedPretenuringConstructorCalls) { | 2759 TEST(OptimizedPretenuringConstructorCalls) { |
2762 if (!i::FLAG_pretenuring_call_new) { | 2760 if (!i::FLAG_pretenuring_call_new) { |
2763 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2761 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2764 return; | 2762 return; |
2765 } | 2763 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 "%%OptimizeFunctionOnNextCall(f);" | 2796 "%%OptimizeFunctionOnNextCall(f);" |
2799 "f();", | 2797 "f();", |
2800 AllocationSite::kPretenureMinimumCreated + | 2798 AllocationSite::kPretenureMinimumCreated + |
2801 JSFunction::kGenerousAllocationCount); | 2799 JSFunction::kGenerousAllocationCount); |
2802 | 2800 |
2803 v8::Local<v8::Value> res = CompileRun(source.start()); | 2801 v8::Local<v8::Value> res = CompileRun(source.start()); |
2804 | 2802 |
2805 Handle<JSObject> o = | 2803 Handle<JSObject> o = |
2806 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2804 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2807 | 2805 |
2808 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2806 CHECK(CcTest::heap()->InOldSpace(*o)); |
2809 } | 2807 } |
2810 | 2808 |
2811 | 2809 |
2812 TEST(OptimizedPretenuringCallNew) { | 2810 TEST(OptimizedPretenuringCallNew) { |
2813 if (!i::FLAG_pretenuring_call_new) { | 2811 if (!i::FLAG_pretenuring_call_new) { |
2814 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2812 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2815 return; | 2813 return; |
2816 } | 2814 } |
2817 i::FLAG_allow_natives_syntax = true; | 2815 i::FLAG_allow_natives_syntax = true; |
2818 i::FLAG_expose_gc = true; | 2816 i::FLAG_expose_gc = true; |
(...skipping 26 matching lines...) Expand all Loading... |
2845 "f(); f();" | 2843 "f(); f();" |
2846 "%%OptimizeFunctionOnNextCall(f);" | 2844 "%%OptimizeFunctionOnNextCall(f);" |
2847 "f();", | 2845 "f();", |
2848 AllocationSite::kPretenureMinimumCreated + | 2846 AllocationSite::kPretenureMinimumCreated + |
2849 JSFunction::kGenerousAllocationCount); | 2847 JSFunction::kGenerousAllocationCount); |
2850 | 2848 |
2851 v8::Local<v8::Value> res = CompileRun(source.start()); | 2849 v8::Local<v8::Value> res = CompileRun(source.start()); |
2852 | 2850 |
2853 Handle<JSObject> o = | 2851 Handle<JSObject> o = |
2854 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2852 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2855 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2853 CHECK(CcTest::heap()->InOldSpace(*o)); |
2856 } | 2854 } |
2857 | 2855 |
2858 | 2856 |
2859 // Test regular array literals allocation. | 2857 // Test regular array literals allocation. |
2860 TEST(OptimizedAllocationArrayLiterals) { | 2858 TEST(OptimizedAllocationArrayLiterals) { |
2861 i::FLAG_allow_natives_syntax = true; | 2859 i::FLAG_allow_natives_syntax = true; |
2862 CcTest::InitializeVM(); | 2860 CcTest::InitializeVM(); |
2863 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2861 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2864 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2862 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2865 v8::HandleScope scope(CcTest::isolate()); | 2863 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 AddTransitions(transitions_count); | 3028 AddTransitions(transitions_count); |
3031 CompileRun("var root = new F;"); | 3029 CompileRun("var root = new F;"); |
3032 Handle<JSObject> root = GetByName("root"); | 3030 Handle<JSObject> root = GetByName("root"); |
3033 | 3031 |
3034 // Count number of live transitions before marking. | 3032 // Count number of live transitions before marking. |
3035 int transitions_before = CountMapTransitions(root->map()); | 3033 int transitions_before = CountMapTransitions(root->map()); |
3036 CHECK_EQ(transitions_count, transitions_before); | 3034 CHECK_EQ(transitions_count, transitions_before); |
3037 | 3035 |
3038 root = GetByName("root"); | 3036 root = GetByName("root"); |
3039 AddPropertyTo(0, root, "prop9"); | 3037 AddPropertyTo(0, root, "prop9"); |
3040 CcTest::i_isolate()->heap()->CollectGarbage(OLD_POINTER_SPACE); | 3038 CcTest::i_isolate()->heap()->CollectGarbage(OLD_SPACE); |
3041 | 3039 |
3042 // Count number of live transitions after marking. Note that one transition | 3040 // Count number of live transitions after marking. Note that one transition |
3043 // is left, because 'o' still holds an instance of one transition target. | 3041 // is left, because 'o' still holds an instance of one transition target. |
3044 int transitions_after = CountMapTransitions( | 3042 int transitions_after = CountMapTransitions( |
3045 Map::cast(root->map()->GetBackPointer())); | 3043 Map::cast(root->map()->GetBackPointer())); |
3046 CHECK_EQ(1, transitions_after); | 3044 CHECK_EQ(1, transitions_after); |
3047 } | 3045 } |
3048 | 3046 |
3049 | 3047 |
3050 TEST(TransitionArraySimpleToFull) { | 3048 TEST(TransitionArraySimpleToFull) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3168 i::FLAG_crankshaft = false; | 3166 i::FLAG_crankshaft = false; |
3169 i::FLAG_always_opt = false; | 3167 i::FLAG_always_opt = false; |
3170 CcTest::InitializeVM(); | 3168 CcTest::InitializeVM(); |
3171 Isolate* isolate = CcTest::i_isolate(); | 3169 Isolate* isolate = CcTest::i_isolate(); |
3172 Factory* factory = isolate->factory(); | 3170 Factory* factory = isolate->factory(); |
3173 Heap* heap = isolate->heap(); | 3171 Heap* heap = isolate->heap(); |
3174 v8::HandleScope scope(CcTest::isolate()); | 3172 v8::HandleScope scope(CcTest::isolate()); |
3175 static const int number_of_test_pages = 20; | 3173 static const int number_of_test_pages = 20; |
3176 | 3174 |
3177 // Prepare many pages with low live-bytes count. | 3175 // Prepare many pages with low live-bytes count. |
3178 PagedSpace* old_pointer_space = heap->old_pointer_space(); | 3176 PagedSpace* old_space = heap->old_space(); |
3179 CHECK_EQ(1, old_pointer_space->CountTotalPages()); | 3177 CHECK_EQ(1, old_space->CountTotalPages()); |
3180 for (int i = 0; i < number_of_test_pages; i++) { | 3178 for (int i = 0; i < number_of_test_pages; i++) { |
3181 AlwaysAllocateScope always_allocate(isolate); | 3179 AlwaysAllocateScope always_allocate(isolate); |
3182 SimulateFullSpace(old_pointer_space); | 3180 SimulateFullSpace(old_space); |
3183 factory->NewFixedArray(1, TENURED); | 3181 factory->NewFixedArray(1, TENURED); |
3184 } | 3182 } |
3185 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); | 3183 CHECK_EQ(number_of_test_pages + 1, old_space->CountTotalPages()); |
3186 | 3184 |
3187 // Triggering one GC will cause a lot of garbage to be discovered but | 3185 // Triggering one GC will cause a lot of garbage to be discovered but |
3188 // even spread across all allocated pages. | 3186 // even spread across all allocated pages. |
3189 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, | 3187 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, |
3190 "triggered for preparation"); | 3188 "triggered for preparation"); |
3191 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); | 3189 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); |
3192 | 3190 |
3193 // Triggering subsequent GCs should cause at least half of the pages | 3191 // Triggering subsequent GCs should cause at least half of the pages |
3194 // to be released to the OS after at most two cycles. | 3192 // to be released to the OS after at most two cycles. |
3195 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); | 3193 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); |
3196 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); | 3194 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); |
3197 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); | 3195 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); |
3198 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); | 3196 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages() * 2); |
3199 | 3197 |
3200 // Triggering a last-resort GC should cause all pages to be released to the | 3198 // 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 | 3199 // 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 | 3200 // 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 | 3201 // 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 | 3202 // 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 | 3203 // 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. | 3204 // an indication that it is too small. |
3207 heap->CollectAllAvailableGarbage("triggered really hard"); | 3205 heap->CollectAllAvailableGarbage("triggered really hard"); |
3208 CHECK_EQ(1, old_pointer_space->CountTotalPages()); | 3206 CHECK_EQ(1, old_space->CountTotalPages()); |
3209 } | 3207 } |
3210 | 3208 |
3211 | 3209 |
3212 TEST(Regress2237) { | 3210 TEST(Regress2237) { |
3213 i::FLAG_stress_compaction = false; | 3211 i::FLAG_stress_compaction = false; |
3214 CcTest::InitializeVM(); | 3212 CcTest::InitializeVM(); |
3215 Isolate* isolate = CcTest::i_isolate(); | 3213 Isolate* isolate = CcTest::i_isolate(); |
3216 Factory* factory = isolate->factory(); | 3214 Factory* factory = isolate->factory(); |
3217 v8::HandleScope scope(CcTest::isolate()); | 3215 v8::HandleScope scope(CcTest::isolate()); |
3218 Handle<String> slice(CcTest::heap()->empty_string()); | 3216 Handle<String> slice(CcTest::heap()->empty_string()); |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 "var array = new Array(40000);" | 4835 "var array = new Array(40000);" |
4838 "var tmp = new Array(100000);" | 4836 "var tmp = new Array(100000);" |
4839 "array[0] = 10;" | 4837 "array[0] = 10;" |
4840 "gc();" | 4838 "gc();" |
4841 "gc();" | 4839 "gc();" |
4842 "array.shift();" | 4840 "array.shift();" |
4843 "array;"); | 4841 "array;"); |
4844 | 4842 |
4845 Handle<JSObject> o = | 4843 Handle<JSObject> o = |
4846 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4844 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
4847 CHECK(heap->InOldPointerSpace(o->elements())); | 4845 CHECK(heap->InOldSpace(o->elements())); |
4848 CHECK(heap->InOldPointerSpace(*o)); | 4846 CHECK(heap->InOldSpace(*o)); |
4849 Page* page = Page::FromAddress(o->elements()->address()); | 4847 Page* page = Page::FromAddress(o->elements()->address()); |
4850 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE || | 4848 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE || |
4851 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4849 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
4852 } | 4850 } |
4853 | 4851 |
4854 | 4852 |
4855 UNINITIALIZED_TEST(PromotionQueue) { | 4853 UNINITIALIZED_TEST(PromotionQueue) { |
4856 i::FLAG_expose_gc = true; | 4854 i::FLAG_expose_gc = true; |
4857 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB); | 4855 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB); |
4858 v8::Isolate* isolate = v8::Isolate::New(); | 4856 v8::Isolate* isolate = v8::Isolate::New(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4951 Handle<Map> map2 = | 4949 Handle<Map> map2 = |
4952 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), | 4950 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), |
4953 HeapType::Any(isolate), NONE, Representation::Tagged(), | 4951 HeapType::Any(isolate), NONE, Representation::Tagged(), |
4954 OMIT_TRANSITION).ToHandleChecked(); | 4952 OMIT_TRANSITION).ToHandleChecked(); |
4955 | 4953 |
4956 int desired_offset = Page::kPageSize - map1->instance_size(); | 4954 int desired_offset = Page::kPageSize - map1->instance_size(); |
4957 | 4955 |
4958 // Allocate fixed array in old pointer space so, that object allocated | 4956 // Allocate fixed array in old pointer space so, that object allocated |
4959 // afterwards would end at the end of the page. | 4957 // afterwards would end at the end of the page. |
4960 { | 4958 { |
4961 SimulateFullSpace(heap->old_pointer_space()); | 4959 SimulateFullSpace(heap->old_space()); |
4962 int padding_size = desired_offset - Page::kObjectStartOffset; | 4960 int padding_size = desired_offset - Page::kObjectStartOffset; |
4963 int padding_array_length = | 4961 int padding_array_length = |
4964 (padding_size - FixedArray::kHeaderSize) / kPointerSize; | 4962 (padding_size - FixedArray::kHeaderSize) / kPointerSize; |
4965 | 4963 |
4966 Handle<FixedArray> temp2 = | 4964 Handle<FixedArray> temp2 = |
4967 factory->NewFixedArray(padding_array_length, TENURED); | 4965 factory->NewFixedArray(padding_array_length, TENURED); |
4968 Page* page = Page::FromAddress(temp2->address()); | 4966 Page* page = Page::FromAddress(temp2->address()); |
4969 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); | 4967 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); |
4970 } | 4968 } |
4971 | 4969 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5020 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 5018 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
5021 } | 5019 } |
5022 // Stash the backing store in a handle. | 5020 // Stash the backing store in a handle. |
5023 Handle<Object> save(weak_map->table(), isolate); | 5021 Handle<Object> save(weak_map->table(), isolate); |
5024 // The following line will update the backing store. | 5022 // The following line will update the backing store. |
5025 CompileRun( | 5023 CompileRun( |
5026 "for (var i = 0; i < 50; i++) {" | 5024 "for (var i = 0; i < 50; i++) {" |
5027 " weak_map.set(future_keys[i], i);" | 5025 " weak_map.set(future_keys[i], i);" |
5028 "}"); | 5026 "}"); |
5029 heap->incremental_marking()->set_should_hurry(true); | 5027 heap->incremental_marking()->set_should_hurry(true); |
5030 heap->CollectGarbage(OLD_POINTER_SPACE); | 5028 heap->CollectGarbage(OLD_SPACE); |
5031 } | 5029 } |
5032 | 5030 |
5033 | 5031 |
5034 TEST(Regress442710) { | 5032 TEST(Regress442710) { |
5035 CcTest::InitializeVM(); | 5033 CcTest::InitializeVM(); |
5036 Isolate* isolate = CcTest::i_isolate(); | 5034 Isolate* isolate = CcTest::i_isolate(); |
5037 Heap* heap = isolate->heap(); | 5035 Heap* heap = isolate->heap(); |
5038 Factory* factory = isolate->factory(); | 5036 Factory* factory = isolate->factory(); |
5039 | 5037 |
5040 HandleScope sc(isolate); | 5038 HandleScope sc(isolate); |
5041 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); | 5039 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); |
5042 Handle<JSArray> array = factory->NewJSArray(2); | 5040 Handle<JSArray> array = factory->NewJSArray(2); |
5043 | 5041 |
5044 Handle<String> name = factory->InternalizeUtf8String("testArray"); | 5042 Handle<String> name = factory->InternalizeUtf8String("testArray"); |
5045 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); | 5043 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); |
5046 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); | 5044 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); |
5047 heap->CollectGarbage(OLD_POINTER_SPACE); | 5045 heap->CollectGarbage(OLD_SPACE); |
5048 } | 5046 } |
5049 | 5047 |
5050 | 5048 |
5051 TEST(NumberStringCacheSize) { | 5049 TEST(NumberStringCacheSize) { |
5052 // Test that the number-string cache has not been resized in the snapshot. | 5050 // Test that the number-string cache has not been resized in the snapshot. |
5053 CcTest::InitializeVM(); | 5051 CcTest::InitializeVM(); |
5054 Isolate* isolate = CcTest::i_isolate(); | 5052 Isolate* isolate = CcTest::i_isolate(); |
5055 if (!isolate->snapshot_available()) return; | 5053 if (!isolate->snapshot_available()) return; |
5056 Heap* heap = isolate->heap(); | 5054 Heap* heap = isolate->heap(); |
5057 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, | 5055 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5099 Heap* heap = isolate->heap(); | 5097 Heap* heap = isolate->heap(); |
5100 Handle<WeakCell> weak_cell; | 5098 Handle<WeakCell> weak_cell; |
5101 { | 5099 { |
5102 HandleScope inner_scope(isolate); | 5100 HandleScope inner_scope(isolate); |
5103 Handle<Map> map = Map::Create(isolate, 1); | 5101 Handle<Map> map = Map::Create(isolate, 1); |
5104 heap->AddRetainedMap(map); | 5102 heap->AddRetainedMap(map); |
5105 weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); | 5103 weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); |
5106 } | 5104 } |
5107 CHECK(!weak_cell->cleared()); | 5105 CHECK(!weak_cell->cleared()); |
5108 for (int i = 0; i < n; i++) { | 5106 for (int i = 0; i < n; i++) { |
5109 heap->CollectGarbage(OLD_POINTER_SPACE); | 5107 heap->CollectGarbage(OLD_SPACE); |
5110 } | 5108 } |
5111 CHECK(!weak_cell->cleared()); | 5109 CHECK(!weak_cell->cleared()); |
5112 heap->CollectGarbage(OLD_POINTER_SPACE); | 5110 heap->CollectGarbage(OLD_SPACE); |
5113 CHECK(weak_cell->cleared()); | 5111 CHECK(weak_cell->cleared()); |
5114 } | 5112 } |
5115 | 5113 |
5116 | 5114 |
5117 TEST(MapRetaining) { | 5115 TEST(MapRetaining) { |
5118 CcTest::InitializeVM(); | 5116 CcTest::InitializeVM(); |
5119 v8::HandleScope scope(CcTest::isolate()); | 5117 v8::HandleScope scope(CcTest::isolate()); |
5120 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); | 5118 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); |
5121 CheckMapRetainingFor(0); | 5119 CheckMapRetainingFor(0); |
5122 CheckMapRetainingFor(1); | 5120 CheckMapRetainingFor(1); |
(...skipping 15 matching lines...) Expand all Loading... |
5138 | 5136 |
5139 TEST(WritableVsImmortalRoots) { | 5137 TEST(WritableVsImmortalRoots) { |
5140 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { | 5138 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { |
5141 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); | 5139 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); |
5142 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); | 5140 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); |
5143 bool immortal = Heap::RootIsImmortalImmovable(root_index); | 5141 bool immortal = Heap::RootIsImmortalImmovable(root_index); |
5144 // A root value can be writable, immortal, or neither, but not both. | 5142 // A root value can be writable, immortal, or neither, but not both. |
5145 CHECK(!immortal || !writable); | 5143 CHECK(!immortal || !writable); |
5146 } | 5144 } |
5147 } | 5145 } |
OLD | NEW |