Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: test/cctest/test-heap.cc

Issue 1051233002: Reland "Merge old data and pointer space." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-dictionary.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 HandleScope scope(isolate); 433 HandleScope scope(isolate);
434 434
435 Handle<Object> i = factory->NewStringFromStaticChars("fisk"); 435 Handle<Object> i = factory->NewStringFromStaticChars("fisk");
436 Handle<Object> u = factory->NewNumber(1.12344); 436 Handle<Object> u = factory->NewNumber(1.12344);
437 437
438 h1 = global_handles->Create(*i); 438 h1 = global_handles->Create(*i);
439 h2 = global_handles->Create(*u); 439 h2 = global_handles->Create(*u);
440 } 440 }
441 441
442 // Make sure the objects are promoted. 442 // Make sure the objects are promoted.
443 heap->CollectGarbage(OLD_POINTER_SPACE); 443 heap->CollectGarbage(OLD_SPACE);
444 heap->CollectGarbage(NEW_SPACE); 444 heap->CollectGarbage(NEW_SPACE);
445 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2)); 445 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2));
446 446
447 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); 447 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
448 GlobalHandles::MakeWeak(h2.location(), 448 GlobalHandles::MakeWeak(h2.location(),
449 reinterpret_cast<void*>(&handle_and_id), 449 reinterpret_cast<void*>(&handle_and_id),
450 &TestWeakGlobalHandleCallback); 450 &TestWeakGlobalHandleCallback);
451 CHECK(!GlobalHandles::IsNearDeath(h1.location())); 451 CHECK(!GlobalHandles::IsNearDeath(h1.location()));
452 CHECK(!GlobalHandles::IsNearDeath(h2.location())); 452 CHECK(!GlobalHandles::IsNearDeath(h2.location()));
453 453
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 GlobalHandles::MakeWeak(h.location(), 486 GlobalHandles::MakeWeak(h.location(),
487 reinterpret_cast<void*>(&handle_and_id), 487 reinterpret_cast<void*>(&handle_and_id),
488 &TestWeakGlobalHandleCallback); 488 &TestWeakGlobalHandleCallback);
489 489
490 // Scanvenge does not recognize weak reference. 490 // Scanvenge does not recognize weak reference.
491 heap->CollectGarbage(NEW_SPACE); 491 heap->CollectGarbage(NEW_SPACE);
492 492
493 CHECK(!WeakPointerCleared); 493 CHECK(!WeakPointerCleared);
494 494
495 // Mark-compact treats weak reference properly. 495 // Mark-compact treats weak reference properly.
496 heap->CollectGarbage(OLD_POINTER_SPACE); 496 heap->CollectGarbage(OLD_SPACE);
497 497
498 CHECK(WeakPointerCleared); 498 CHECK(WeakPointerCleared);
499 } 499 }
500 500
501 501
502 static const char* not_so_random_string_table[] = { 502 static const char* not_so_random_string_table[] = {
503 "abstract", 503 "abstract",
504 "boolean", 504 "boolean",
505 "break", 505 "break",
506 "byte", 506 "byte",
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 CcTest::InitializeVM(); 885 CcTest::InitializeVM();
886 Isolate* isolate = CcTest::i_isolate(); 886 Isolate* isolate = CcTest::i_isolate();
887 Factory* factory = isolate->factory(); 887 Factory* factory = isolate->factory();
888 v8::HandleScope scope(CcTest::isolate()); 888 v8::HandleScope scope(CcTest::isolate());
889 889
890 // Array of objects to scan haep for. 890 // Array of objects to scan haep for.
891 const int objs_count = 6; 891 const int objs_count = 6;
892 Handle<Object> objs[objs_count]; 892 Handle<Object> objs[objs_count];
893 int next_objs_index = 0; 893 int next_objs_index = 0;
894 894
895 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE 895 // Allocate a JS array to OLD_SPACE and NEW_SPACE
896 objs[next_objs_index++] = factory->NewJSArray(10); 896 objs[next_objs_index++] = factory->NewJSArray(10);
897 objs[next_objs_index++] = factory->NewJSArray(10, 897 objs[next_objs_index++] = factory->NewJSArray(10,
898 FAST_HOLEY_ELEMENTS, 898 FAST_HOLEY_ELEMENTS,
899 TENURED); 899 TENURED);
900 900
901 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE 901 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
902 objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij"); 902 objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij");
903 objs[next_objs_index++] = 903 objs[next_objs_index++] =
904 factory->NewStringFromStaticChars("abcdefghij", TENURED); 904 factory->NewStringFromStaticChars("abcdefghij", TENURED);
905 905
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 CHECK_EQ(0, jsobject->properties()->length()); 994 CHECK_EQ(0, jsobject->properties()->length());
995 // Create a reference to object in new space in jsobject. 995 // Create a reference to object in new space in jsobject.
996 FieldIndex index = FieldIndex::ForInObjectOffset( 996 FieldIndex index = FieldIndex::ForInObjectOffset(
997 JSObject::kHeaderSize - kPointerSize); 997 JSObject::kHeaderSize - kPointerSize);
998 jsobject->FastPropertyAtPut(index, array); 998 jsobject->FastPropertyAtPut(index, array);
999 999
1000 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); 1000 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr));
1001 1001
1002 // Step 4: clone jsobject, but force always allocate first to create a clone 1002 // Step 4: clone jsobject, but force always allocate first to create a clone
1003 // in old pointer space. 1003 // in old pointer space.
1004 Address old_pointer_space_top = heap->old_pointer_space()->top(); 1004 Address old_space_top = heap->old_space()->top();
1005 AlwaysAllocateScope aa_scope(isolate); 1005 AlwaysAllocateScope aa_scope(isolate);
1006 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); 1006 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked();
1007 JSObject* clone = JSObject::cast(clone_obj); 1007 JSObject* clone = JSObject::cast(clone_obj);
1008 if (clone->address() != old_pointer_space_top) { 1008 if (clone->address() != old_space_top) {
1009 // Alas, got allocated from free list, we cannot do checks. 1009 // Alas, got allocated from free list, we cannot do checks.
1010 return; 1010 return;
1011 } 1011 }
1012 CHECK(heap->old_pointer_space()->Contains(clone->address())); 1012 CHECK(heap->old_space()->Contains(clone->address()));
1013 } 1013 }
1014 1014
1015 1015
1016 UNINITIALIZED_TEST(TestCodeFlushing) { 1016 UNINITIALIZED_TEST(TestCodeFlushing) {
1017 // If we do not flush code this test is invalid. 1017 // If we do not flush code this test is invalid.
1018 if (!FLAG_flush_code) return; 1018 if (!FLAG_flush_code) return;
1019 i::FLAG_allow_natives_syntax = true; 1019 i::FLAG_allow_natives_syntax = true;
1020 i::FLAG_optimize_for_size = false; 1020 i::FLAG_optimize_for_size = false;
1021 v8::Isolate* isolate = v8::Isolate::New(); 1021 v8::Isolate* isolate = v8::Isolate::New();
1022 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1022 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 2130
2131 { 2131 {
2132 v8::HandleScope scope(CcTest::isolate()); 2132 v8::HandleScope scope(CcTest::isolate());
2133 v8::Handle<v8::Object> global = CcTest::global(); 2133 v8::Handle<v8::Object> global = CcTest::global();
2134 v8::Handle<v8::Function> g = 2134 v8::Handle<v8::Function> g =
2135 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 2135 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
2136 g->Call(global, 0, NULL); 2136 g->Call(global, 0, NULL);
2137 } 2137 }
2138 2138
2139 CcTest::heap()->incremental_marking()->set_should_hurry(true); 2139 CcTest::heap()->incremental_marking()->set_should_hurry(true);
2140 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 2140 CcTest::heap()->CollectGarbage(OLD_SPACE);
2141 } 2141 }
2142 2142
2143 2143
2144 static int NumberOfProtoTransitions(Map* map) { 2144 static int NumberOfProtoTransitions(Map* map) {
2145 return TransitionArray::NumberOfPrototypeTransitions( 2145 return TransitionArray::NumberOfPrototypeTransitions(
2146 TransitionArray::GetPrototypeTransitions(map)); 2146 TransitionArray::GetPrototypeTransitions(map));
2147 } 2147 }
2148 2148
2149 2149
2150 TEST(PrototypeTransitionClearing) { 2150 TEST(PrototypeTransitionClearing) {
(...skipping 30 matching lines...) Expand all
2181 // Verify that prototype transitions array was compacted. 2181 // Verify that prototype transitions array was compacted.
2182 FixedArray* trans = 2182 FixedArray* trans =
2183 TransitionArray::GetPrototypeTransitions(baseObject->map()); 2183 TransitionArray::GetPrototypeTransitions(baseObject->map());
2184 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { 2184 for (int i = initialTransitions; i < initialTransitions + transitions; i++) {
2185 int j = TransitionArray::kProtoTransitionHeaderSize + i; 2185 int j = TransitionArray::kProtoTransitionHeaderSize + i;
2186 CHECK(trans->get(j)->IsMap()); 2186 CHECK(trans->get(j)->IsMap());
2187 } 2187 }
2188 2188
2189 // Make sure next prototype is placed on an old-space evacuation candidate. 2189 // Make sure next prototype is placed on an old-space evacuation candidate.
2190 Handle<JSObject> prototype; 2190 Handle<JSObject> prototype;
2191 PagedSpace* space = CcTest::heap()->old_pointer_space(); 2191 PagedSpace* space = CcTest::heap()->old_space();
2192 { 2192 {
2193 AlwaysAllocateScope always_allocate(isolate); 2193 AlwaysAllocateScope always_allocate(isolate);
2194 SimulateFullSpace(space); 2194 SimulateFullSpace(space);
2195 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 2195 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
2196 } 2196 }
2197 2197
2198 // Add a prototype on an evacuation candidate and verify that transition 2198 // Add a prototype on an evacuation candidate and verify that transition
2199 // clearing correctly records slots in prototype transition array. 2199 // clearing correctly records slots in prototype transition array.
2200 i::FLAG_always_compact = true; 2200 i::FLAG_always_compact = true;
2201 Handle<Map> map(baseObject->map()); 2201 Handle<Map> map(baseObject->map());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 2307
2308 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2308 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2309 CHECK_EQ(0, f->shared()->opt_count()); 2309 CHECK_EQ(0, f->shared()->opt_count());
2310 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2310 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2311 } 2311 }
2312 2312
2313 2313
2314 TEST(IdleNotificationFinishMarking) { 2314 TEST(IdleNotificationFinishMarking) {
2315 i::FLAG_allow_natives_syntax = true; 2315 i::FLAG_allow_natives_syntax = true;
2316 CcTest::InitializeVM(); 2316 CcTest::InitializeVM();
2317 SimulateFullSpace(CcTest::heap()->old_pointer_space()); 2317 SimulateFullSpace(CcTest::heap()->old_space());
2318 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2318 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2319 marking->Abort(); 2319 marking->Abort();
2320 marking->Start(); 2320 marking->Start();
2321 2321
2322 CHECK_EQ(CcTest::heap()->gc_count(), 0); 2322 CHECK_EQ(CcTest::heap()->gc_count(), 0);
2323 2323
2324 // TODO(hpayer): We cannot write proper unit test right now for heap. 2324 // TODO(hpayer): We cannot write proper unit test right now for heap.
2325 // The ideal test would call kMaxIdleMarkingDelayCounter to test the 2325 // The ideal test would call kMaxIdleMarkingDelayCounter to test the
2326 // marking delay counter. 2326 // marking delay counter.
2327 2327
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 2423
2424 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); 2424 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
2425 Handle<JSObject> int_array_handle = 2425 Handle<JSObject> int_array_handle =
2426 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); 2426 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
2427 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); 2427 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
2428 Handle<JSObject> double_array_handle = 2428 Handle<JSObject> double_array_handle =
2429 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); 2429 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
2430 2430
2431 Handle<JSObject> o = 2431 Handle<JSObject> o =
2432 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2432 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2433 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2433 CHECK(CcTest::heap()->InOldSpace(*o));
2434 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); 2434 CHECK(CcTest::heap()->InOldSpace(*int_array_handle));
2435 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); 2435 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements()));
2436 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); 2436 CHECK(CcTest::heap()->InOldSpace(*double_array_handle));
2437 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); 2437 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements()));
2438 } 2438 }
2439 2439
2440 2440
2441 TEST(OptimizedPretenuringObjectArrayLiterals) { 2441 TEST(OptimizedPretenuringObjectArrayLiterals) {
2442 i::FLAG_allow_natives_syntax = true; 2442 i::FLAG_allow_natives_syntax = true;
2443 i::FLAG_expose_gc = true; 2443 i::FLAG_expose_gc = true;
2444 CcTest::InitializeVM(); 2444 CcTest::InitializeVM();
2445 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2445 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2446 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2446 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2447 v8::HandleScope scope(CcTest::isolate()); 2447 v8::HandleScope scope(CcTest::isolate());
(...skipping 18 matching lines...) Expand all
2466 "f(); f();" 2466 "f(); f();"
2467 "%%OptimizeFunctionOnNextCall(f);" 2467 "%%OptimizeFunctionOnNextCall(f);"
2468 "f();", 2468 "f();",
2469 AllocationSite::kPretenureMinimumCreated); 2469 AllocationSite::kPretenureMinimumCreated);
2470 2470
2471 v8::Local<v8::Value> res = CompileRun(source.start()); 2471 v8::Local<v8::Value> res = CompileRun(source.start());
2472 2472
2473 Handle<JSObject> o = 2473 Handle<JSObject> o =
2474 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2474 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2475 2475
2476 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); 2476 CHECK(CcTest::heap()->InOldSpace(o->elements()));
2477 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2477 CHECK(CcTest::heap()->InOldSpace(*o));
2478 } 2478 }
2479 2479
2480 2480
2481 TEST(OptimizedPretenuringMixedInObjectProperties) { 2481 TEST(OptimizedPretenuringMixedInObjectProperties) {
2482 i::FLAG_allow_natives_syntax = true; 2482 i::FLAG_allow_natives_syntax = true;
2483 i::FLAG_expose_gc = true; 2483 i::FLAG_expose_gc = true;
2484 CcTest::InitializeVM(); 2484 CcTest::InitializeVM();
2485 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2485 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2486 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2486 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2487 v8::HandleScope scope(CcTest::isolate()); 2487 v8::HandleScope scope(CcTest::isolate());
(...skipping 19 matching lines...) Expand all
2507 "f(); f();" 2507 "f(); f();"
2508 "%%OptimizeFunctionOnNextCall(f);" 2508 "%%OptimizeFunctionOnNextCall(f);"
2509 "f();", 2509 "f();",
2510 AllocationSite::kPretenureMinimumCreated); 2510 AllocationSite::kPretenureMinimumCreated);
2511 2511
2512 v8::Local<v8::Value> res = CompileRun(source.start()); 2512 v8::Local<v8::Value> res = CompileRun(source.start());
2513 2513
2514 Handle<JSObject> o = 2514 Handle<JSObject> o =
2515 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2515 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2516 2516
2517 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2517 CHECK(CcTest::heap()->InOldSpace(*o));
2518 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); 2518 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0);
2519 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); 2519 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1);
2520 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(idx1))); 2520 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx1)));
2521 if (!o->IsUnboxedDoubleField(idx2)) { 2521 if (!o->IsUnboxedDoubleField(idx2)) {
2522 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(idx2))); 2522 CHECK(CcTest::heap()->InOldSpace(o->RawFastPropertyAt(idx2)));
2523 } else { 2523 } else {
2524 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2)); 2524 CHECK_EQ(1.1, o->RawFastDoublePropertyAt(idx2));
2525 } 2525 }
2526 2526
2527 JSObject* inner_object = 2527 JSObject* inner_object =
2528 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); 2528 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1));
2529 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); 2529 CHECK(CcTest::heap()->InOldSpace(inner_object));
2530 if (!inner_object->IsUnboxedDoubleField(idx1)) { 2530 if (!inner_object->IsUnboxedDoubleField(idx1)) {
2531 CHECK( 2531 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx1)));
2532 CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(idx1)));
2533 } else { 2532 } else {
2534 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); 2533 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1));
2535 } 2534 }
2536 CHECK( 2535 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx2)));
2537 CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(idx2)));
2538 } 2536 }
2539 2537
2540 2538
2541 TEST(OptimizedPretenuringDoubleArrayProperties) { 2539 TEST(OptimizedPretenuringDoubleArrayProperties) {
2542 i::FLAG_allow_natives_syntax = true; 2540 i::FLAG_allow_natives_syntax = true;
2543 i::FLAG_expose_gc = true; 2541 i::FLAG_expose_gc = true;
2544 CcTest::InitializeVM(); 2542 CcTest::InitializeVM();
2545 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2543 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2546 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2544 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2547 v8::HandleScope scope(CcTest::isolate()); 2545 v8::HandleScope scope(CcTest::isolate());
(...skipping 18 matching lines...) Expand all
2566 "f(); f();" 2564 "f(); f();"
2567 "%%OptimizeFunctionOnNextCall(f);" 2565 "%%OptimizeFunctionOnNextCall(f);"
2568 "f();", 2566 "f();",
2569 AllocationSite::kPretenureMinimumCreated); 2567 AllocationSite::kPretenureMinimumCreated);
2570 2568
2571 v8::Local<v8::Value> res = CompileRun(source.start()); 2569 v8::Local<v8::Value> res = CompileRun(source.start());
2572 2570
2573 Handle<JSObject> o = 2571 Handle<JSObject> o =
2574 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2572 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2575 2573
2576 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2574 CHECK(CcTest::heap()->InOldSpace(*o));
2577 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); 2575 CHECK(CcTest::heap()->InOldSpace(o->properties()));
2578 } 2576 }
2579 2577
2580 2578
2581 TEST(OptimizedPretenuringdoubleArrayLiterals) { 2579 TEST(OptimizedPretenuringdoubleArrayLiterals) {
2582 i::FLAG_allow_natives_syntax = true; 2580 i::FLAG_allow_natives_syntax = true;
2583 i::FLAG_expose_gc = true; 2581 i::FLAG_expose_gc = true;
2584 CcTest::InitializeVM(); 2582 CcTest::InitializeVM();
2585 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2583 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2586 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2584 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2587 v8::HandleScope scope(CcTest::isolate()); 2585 v8::HandleScope scope(CcTest::isolate());
(...skipping 18 matching lines...) Expand all
2606 "f(); f();" 2604 "f(); f();"
2607 "%%OptimizeFunctionOnNextCall(f);" 2605 "%%OptimizeFunctionOnNextCall(f);"
2608 "f();", 2606 "f();",
2609 AllocationSite::kPretenureMinimumCreated); 2607 AllocationSite::kPretenureMinimumCreated);
2610 2608
2611 v8::Local<v8::Value> res = CompileRun(source.start()); 2609 v8::Local<v8::Value> res = CompileRun(source.start());
2612 2610
2613 Handle<JSObject> o = 2611 Handle<JSObject> o =
2614 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2612 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2615 2613
2616 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); 2614 CHECK(CcTest::heap()->InOldSpace(o->elements()));
2617 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2615 CHECK(CcTest::heap()->InOldSpace(*o));
2618 } 2616 }
2619 2617
2620 2618
2621 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { 2619 TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
2622 i::FLAG_allow_natives_syntax = true; 2620 i::FLAG_allow_natives_syntax = true;
2623 i::FLAG_expose_gc = true; 2621 i::FLAG_expose_gc = true;
2624 CcTest::InitializeVM(); 2622 CcTest::InitializeVM();
2625 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2623 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2626 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2624 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2627 v8::HandleScope scope(CcTest::isolate()); 2625 v8::HandleScope scope(CcTest::isolate());
(...skipping 23 matching lines...) Expand all
2651 2649
2652 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); 2650 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
2653 Handle<JSObject> int_array_handle = 2651 Handle<JSObject> int_array_handle =
2654 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); 2652 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
2655 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); 2653 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
2656 Handle<JSObject> double_array_handle = 2654 Handle<JSObject> double_array_handle =
2657 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); 2655 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
2658 2656
2659 Handle<JSObject> o = 2657 Handle<JSObject> o =
2660 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2658 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2661 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2659 CHECK(CcTest::heap()->InOldSpace(*o));
2662 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); 2660 CHECK(CcTest::heap()->InOldSpace(*int_array_handle));
2663 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); 2661 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements()));
2664 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); 2662 CHECK(CcTest::heap()->InOldSpace(*double_array_handle));
2665 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); 2663 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements()));
2666 } 2664 }
2667 2665
2668 2666
2669 TEST(OptimizedPretenuringNestedObjectLiterals) { 2667 TEST(OptimizedPretenuringNestedObjectLiterals) {
2670 i::FLAG_allow_natives_syntax = true; 2668 i::FLAG_allow_natives_syntax = true;
2671 i::FLAG_expose_gc = true; 2669 i::FLAG_expose_gc = true;
2672 CcTest::InitializeVM(); 2670 CcTest::InitializeVM();
2673 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2671 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2674 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2672 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2675 v8::HandleScope scope(CcTest::isolate()); 2673 v8::HandleScope scope(CcTest::isolate());
(...skipping 24 matching lines...) Expand all
2700 2698
2701 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); 2699 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
2702 Handle<JSObject> int_array_handle_1 = 2700 Handle<JSObject> int_array_handle_1 =
2703 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); 2701 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1));
2704 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); 2702 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1"));
2705 Handle<JSObject> int_array_handle_2 = 2703 Handle<JSObject> int_array_handle_2 =
2706 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); 2704 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2));
2707 2705
2708 Handle<JSObject> o = 2706 Handle<JSObject> o =
2709 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2707 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2710 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2708 CHECK(CcTest::heap()->InOldSpace(*o));
2711 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); 2709 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1));
2712 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); 2710 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements()));
2713 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); 2711 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2));
2714 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); 2712 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements()));
2715 } 2713 }
2716 2714
2717 2715
2718 TEST(OptimizedPretenuringNestedDoubleLiterals) { 2716 TEST(OptimizedPretenuringNestedDoubleLiterals) {
2719 i::FLAG_allow_natives_syntax = true; 2717 i::FLAG_allow_natives_syntax = true;
2720 i::FLAG_expose_gc = true; 2718 i::FLAG_expose_gc = true;
2721 CcTest::InitializeVM(); 2719 CcTest::InitializeVM();
2722 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2720 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2723 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2721 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2724 v8::HandleScope scope(CcTest::isolate()); 2722 v8::HandleScope scope(CcTest::isolate());
(...skipping 26 matching lines...) Expand all
2751 v8::Object::Cast(*res)->Get(v8_str("0")); 2749 v8::Object::Cast(*res)->Get(v8_str("0"));
2752 Handle<JSObject> double_array_handle_1 = 2750 Handle<JSObject> double_array_handle_1 =
2753 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); 2751 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1));
2754 v8::Local<v8::Value> double_array_2 = 2752 v8::Local<v8::Value> double_array_2 =
2755 v8::Object::Cast(*res)->Get(v8_str("1")); 2753 v8::Object::Cast(*res)->Get(v8_str("1"));
2756 Handle<JSObject> double_array_handle_2 = 2754 Handle<JSObject> double_array_handle_2 =
2757 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2)); 2755 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2));
2758 2756
2759 Handle<JSObject> o = 2757 Handle<JSObject> o =
2760 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2758 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2761 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2759 CHECK(CcTest::heap()->InOldSpace(*o));
2762 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1)); 2760 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1));
2763 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements())); 2761 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements()));
2764 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2)); 2762 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2));
2765 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements())); 2763 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements()));
2766 } 2764 }
2767 2765
2768 2766
2769 // Make sure pretenuring feedback is gathered for constructed objects as well 2767 // Make sure pretenuring feedback is gathered for constructed objects as well
2770 // as for literals. 2768 // as for literals.
2771 TEST(OptimizedPretenuringConstructorCalls) { 2769 TEST(OptimizedPretenuringConstructorCalls) {
2772 if (!i::FLAG_pretenuring_call_new) { 2770 if (!i::FLAG_pretenuring_call_new) {
2773 // FLAG_pretenuring_call_new needs to be synced with the snapshot. 2771 // FLAG_pretenuring_call_new needs to be synced with the snapshot.
2774 return; 2772 return;
2775 } 2773 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 "%%OptimizeFunctionOnNextCall(f);" 2806 "%%OptimizeFunctionOnNextCall(f);"
2809 "f();", 2807 "f();",
2810 AllocationSite::kPretenureMinimumCreated + 2808 AllocationSite::kPretenureMinimumCreated +
2811 JSFunction::kGenerousAllocationCount); 2809 JSFunction::kGenerousAllocationCount);
2812 2810
2813 v8::Local<v8::Value> res = CompileRun(source.start()); 2811 v8::Local<v8::Value> res = CompileRun(source.start());
2814 2812
2815 Handle<JSObject> o = 2813 Handle<JSObject> o =
2816 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2814 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2817 2815
2818 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2816 CHECK(CcTest::heap()->InOldSpace(*o));
2819 } 2817 }
2820 2818
2821 2819
2822 TEST(OptimizedPretenuringCallNew) { 2820 TEST(OptimizedPretenuringCallNew) {
2823 if (!i::FLAG_pretenuring_call_new) { 2821 if (!i::FLAG_pretenuring_call_new) {
2824 // FLAG_pretenuring_call_new needs to be synced with the snapshot. 2822 // FLAG_pretenuring_call_new needs to be synced with the snapshot.
2825 return; 2823 return;
2826 } 2824 }
2827 i::FLAG_allow_natives_syntax = true; 2825 i::FLAG_allow_natives_syntax = true;
2828 i::FLAG_expose_gc = true; 2826 i::FLAG_expose_gc = true;
(...skipping 26 matching lines...) Expand all
2855 "f(); f();" 2853 "f(); f();"
2856 "%%OptimizeFunctionOnNextCall(f);" 2854 "%%OptimizeFunctionOnNextCall(f);"
2857 "f();", 2855 "f();",
2858 AllocationSite::kPretenureMinimumCreated + 2856 AllocationSite::kPretenureMinimumCreated +
2859 JSFunction::kGenerousAllocationCount); 2857 JSFunction::kGenerousAllocationCount);
2860 2858
2861 v8::Local<v8::Value> res = CompileRun(source.start()); 2859 v8::Local<v8::Value> res = CompileRun(source.start());
2862 2860
2863 Handle<JSObject> o = 2861 Handle<JSObject> o =
2864 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2862 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2865 CHECK(CcTest::heap()->InOldPointerSpace(*o)); 2863 CHECK(CcTest::heap()->InOldSpace(*o));
2866 } 2864 }
2867 2865
2868 2866
2869 // Test regular array literals allocation. 2867 // Test regular array literals allocation.
2870 TEST(OptimizedAllocationArrayLiterals) { 2868 TEST(OptimizedAllocationArrayLiterals) {
2871 i::FLAG_allow_natives_syntax = true; 2869 i::FLAG_allow_natives_syntax = true;
2872 CcTest::InitializeVM(); 2870 CcTest::InitializeVM();
2873 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 2871 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
2874 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2872 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2875 v8::HandleScope scope(CcTest::isolate()); 2873 v8::HandleScope scope(CcTest::isolate());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 AddTransitions(transitions_count); 3038 AddTransitions(transitions_count);
3041 CompileRun("var root = new F;"); 3039 CompileRun("var root = new F;");
3042 Handle<JSObject> root = GetByName("root"); 3040 Handle<JSObject> root = GetByName("root");
3043 3041
3044 // Count number of live transitions before marking. 3042 // Count number of live transitions before marking.
3045 int transitions_before = CountMapTransitions(root->map()); 3043 int transitions_before = CountMapTransitions(root->map());
3046 CHECK_EQ(transitions_count, transitions_before); 3044 CHECK_EQ(transitions_count, transitions_before);
3047 3045
3048 root = GetByName("root"); 3046 root = GetByName("root");
3049 AddPropertyTo(0, root, "prop9"); 3047 AddPropertyTo(0, root, "prop9");
3050 CcTest::i_isolate()->heap()->CollectGarbage(OLD_POINTER_SPACE); 3048 CcTest::i_isolate()->heap()->CollectGarbage(OLD_SPACE);
3051 3049
3052 // Count number of live transitions after marking. Note that one transition 3050 // Count number of live transitions after marking. Note that one transition
3053 // is left, because 'o' still holds an instance of one transition target. 3051 // is left, because 'o' still holds an instance of one transition target.
3054 int transitions_after = CountMapTransitions( 3052 int transitions_after = CountMapTransitions(
3055 Map::cast(root->map()->GetBackPointer())); 3053 Map::cast(root->map()->GetBackPointer()));
3056 CHECK_EQ(1, transitions_after); 3054 CHECK_EQ(1, transitions_after);
3057 } 3055 }
3058 3056
3059 3057
3060 TEST(TransitionArraySimpleToFull) { 3058 TEST(TransitionArraySimpleToFull) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 i::FLAG_crankshaft = false; 3176 i::FLAG_crankshaft = false;
3179 i::FLAG_always_opt = false; 3177 i::FLAG_always_opt = false;
3180 CcTest::InitializeVM(); 3178 CcTest::InitializeVM();
3181 Isolate* isolate = CcTest::i_isolate(); 3179 Isolate* isolate = CcTest::i_isolate();
3182 Factory* factory = isolate->factory(); 3180 Factory* factory = isolate->factory();
3183 Heap* heap = isolate->heap(); 3181 Heap* heap = isolate->heap();
3184 v8::HandleScope scope(CcTest::isolate()); 3182 v8::HandleScope scope(CcTest::isolate());
3185 static const int number_of_test_pages = 20; 3183 static const int number_of_test_pages = 20;
3186 3184
3187 // Prepare many pages with low live-bytes count. 3185 // Prepare many pages with low live-bytes count.
3188 PagedSpace* old_pointer_space = heap->old_pointer_space(); 3186 PagedSpace* old_space = heap->old_space();
3189 CHECK_EQ(1, old_pointer_space->CountTotalPages()); 3187 CHECK_EQ(1, old_space->CountTotalPages());
3190 for (int i = 0; i < number_of_test_pages; i++) { 3188 for (int i = 0; i < number_of_test_pages; i++) {
3191 AlwaysAllocateScope always_allocate(isolate); 3189 AlwaysAllocateScope always_allocate(isolate);
3192 SimulateFullSpace(old_pointer_space); 3190 SimulateFullSpace(old_space);
3193 factory->NewFixedArray(1, TENURED); 3191 factory->NewFixedArray(1, TENURED);
3194 } 3192 }
3195 CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); 3193 CHECK_EQ(number_of_test_pages + 1, old_space->CountTotalPages());
3196 3194
3197 // Triggering one GC will cause a lot of garbage to be discovered but 3195 // Triggering one GC will cause a lot of garbage to be discovered but
3198 // even spread across all allocated pages. 3196 // even spread across all allocated pages.
3199 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, 3197 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask,
3200 "triggered for preparation"); 3198 "triggered for preparation");
3201 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); 3199 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages());
3202 3200
3203 // Triggering subsequent GCs should cause at least half of the pages 3201 // Triggering subsequent GCs should cause at least half of the pages
3204 // to be released to the OS after at most two cycles. 3202 // to be released to the OS after at most two cycles.
3205 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); 3203 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1");
3206 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); 3204 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages());
3207 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); 3205 heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2");
3208 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); 3206 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages() * 2);
3209 3207
3210 // Triggering a last-resort GC should cause all pages to be released to the 3208 // Triggering a last-resort GC should cause all pages to be released to the
3211 // OS so that other processes can seize the memory. If we get a failure here 3209 // OS so that other processes can seize the memory. If we get a failure here
3212 // where there are 2 pages left instead of 1, then we should increase the 3210 // where there are 2 pages left instead of 1, then we should increase the
3213 // size of the first page a little in SizeOfFirstPage in spaces.cc. The 3211 // size of the first page a little in SizeOfFirstPage in spaces.cc. The
3214 // first page should be small in order to reduce memory used when the VM 3212 // first page should be small in order to reduce memory used when the VM
3215 // boots, but if the 20 small arrays don't fit on the first page then that's 3213 // boots, but if the 20 small arrays don't fit on the first page then that's
3216 // an indication that it is too small. 3214 // an indication that it is too small.
3217 heap->CollectAllAvailableGarbage("triggered really hard"); 3215 heap->CollectAllAvailableGarbage("triggered really hard");
3218 CHECK_EQ(1, old_pointer_space->CountTotalPages()); 3216 CHECK_EQ(1, old_space->CountTotalPages());
3219 } 3217 }
3220 3218
3221 3219
3222 TEST(Regress2237) { 3220 TEST(Regress2237) {
3223 i::FLAG_stress_compaction = false; 3221 i::FLAG_stress_compaction = false;
3224 CcTest::InitializeVM(); 3222 CcTest::InitializeVM();
3225 Isolate* isolate = CcTest::i_isolate(); 3223 Isolate* isolate = CcTest::i_isolate();
3226 Factory* factory = isolate->factory(); 3224 Factory* factory = isolate->factory();
3227 v8::HandleScope scope(CcTest::isolate()); 3225 v8::HandleScope scope(CcTest::isolate());
3228 Handle<String> slice(CcTest::heap()->empty_string()); 3226 Handle<String> slice(CcTest::heap()->empty_string());
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 "var array = new Array(40000);" 4974 "var array = new Array(40000);"
4977 "var tmp = new Array(100000);" 4975 "var tmp = new Array(100000);"
4978 "array[0] = 10;" 4976 "array[0] = 10;"
4979 "gc();" 4977 "gc();"
4980 "gc();" 4978 "gc();"
4981 "array.shift();" 4979 "array.shift();"
4982 "array;"); 4980 "array;");
4983 4981
4984 Handle<JSObject> o = 4982 Handle<JSObject> o =
4985 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 4983 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
4986 CHECK(heap->InOldPointerSpace(o->elements())); 4984 CHECK(heap->InOldSpace(o->elements()));
4987 CHECK(heap->InOldPointerSpace(*o)); 4985 CHECK(heap->InOldSpace(*o));
4988 Page* page = Page::FromAddress(o->elements()->address()); 4986 Page* page = Page::FromAddress(o->elements()->address());
4989 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE || 4987 CHECK(page->parallel_sweeping() <= MemoryChunk::SWEEPING_FINALIZE ||
4990 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); 4988 Marking::IsBlack(Marking::MarkBitFrom(o->elements())));
4991 } 4989 }
4992 4990
4993 4991
4994 UNINITIALIZED_TEST(PromotionQueue) { 4992 UNINITIALIZED_TEST(PromotionQueue) {
4995 i::FLAG_expose_gc = true; 4993 i::FLAG_expose_gc = true;
4996 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB); 4994 i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB);
4997 v8::Isolate* isolate = v8::Isolate::New(); 4995 v8::Isolate* isolate = v8::Isolate::New();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5090 Handle<Map> map2 = 5088 Handle<Map> map2 =
5091 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), 5089 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"),
5092 HeapType::Any(isolate), NONE, Representation::Tagged(), 5090 HeapType::Any(isolate), NONE, Representation::Tagged(),
5093 OMIT_TRANSITION).ToHandleChecked(); 5091 OMIT_TRANSITION).ToHandleChecked();
5094 5092
5095 int desired_offset = Page::kPageSize - map1->instance_size(); 5093 int desired_offset = Page::kPageSize - map1->instance_size();
5096 5094
5097 // Allocate fixed array in old pointer space so, that object allocated 5095 // Allocate fixed array in old pointer space so, that object allocated
5098 // afterwards would end at the end of the page. 5096 // afterwards would end at the end of the page.
5099 { 5097 {
5100 SimulateFullSpace(heap->old_pointer_space()); 5098 SimulateFullSpace(heap->old_space());
5101 int padding_size = desired_offset - Page::kObjectStartOffset; 5099 int padding_size = desired_offset - Page::kObjectStartOffset;
5102 int padding_array_length = 5100 int padding_array_length =
5103 (padding_size - FixedArray::kHeaderSize) / kPointerSize; 5101 (padding_size - FixedArray::kHeaderSize) / kPointerSize;
5104 5102
5105 Handle<FixedArray> temp2 = 5103 Handle<FixedArray> temp2 =
5106 factory->NewFixedArray(padding_array_length, TENURED); 5104 factory->NewFixedArray(padding_array_length, TENURED);
5107 Page* page = Page::FromAddress(temp2->address()); 5105 Page* page = Page::FromAddress(temp2->address());
5108 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); 5106 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address()));
5109 } 5107 }
5110 5108
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 5157 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
5160 } 5158 }
5161 // Stash the backing store in a handle. 5159 // Stash the backing store in a handle.
5162 Handle<Object> save(weak_map->table(), isolate); 5160 Handle<Object> save(weak_map->table(), isolate);
5163 // The following line will update the backing store. 5161 // The following line will update the backing store.
5164 CompileRun( 5162 CompileRun(
5165 "for (var i = 0; i < 50; i++) {" 5163 "for (var i = 0; i < 50; i++) {"
5166 " weak_map.set(future_keys[i], i);" 5164 " weak_map.set(future_keys[i], i);"
5167 "}"); 5165 "}");
5168 heap->incremental_marking()->set_should_hurry(true); 5166 heap->incremental_marking()->set_should_hurry(true);
5169 heap->CollectGarbage(OLD_POINTER_SPACE); 5167 heap->CollectGarbage(OLD_SPACE);
5170 } 5168 }
5171 5169
5172 5170
5173 TEST(Regress442710) { 5171 TEST(Regress442710) {
5174 CcTest::InitializeVM(); 5172 CcTest::InitializeVM();
5175 Isolate* isolate = CcTest::i_isolate(); 5173 Isolate* isolate = CcTest::i_isolate();
5176 Heap* heap = isolate->heap(); 5174 Heap* heap = isolate->heap();
5177 Factory* factory = isolate->factory(); 5175 Factory* factory = isolate->factory();
5178 5176
5179 HandleScope sc(isolate); 5177 HandleScope sc(isolate);
5180 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); 5178 Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object());
5181 Handle<JSArray> array = factory->NewJSArray(2); 5179 Handle<JSArray> array = factory->NewJSArray(2);
5182 5180
5183 Handle<String> name = factory->InternalizeUtf8String("testArray"); 5181 Handle<String> name = factory->InternalizeUtf8String("testArray");
5184 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); 5182 JSReceiver::SetProperty(global, name, array, SLOPPY).Check();
5185 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); 5183 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();");
5186 heap->CollectGarbage(OLD_POINTER_SPACE); 5184 heap->CollectGarbage(OLD_SPACE);
5187 } 5185 }
5188 5186
5189 5187
5190 TEST(NumberStringCacheSize) { 5188 TEST(NumberStringCacheSize) {
5191 // Test that the number-string cache has not been resized in the snapshot. 5189 // Test that the number-string cache has not been resized in the snapshot.
5192 CcTest::InitializeVM(); 5190 CcTest::InitializeVM();
5193 Isolate* isolate = CcTest::i_isolate(); 5191 Isolate* isolate = CcTest::i_isolate();
5194 if (!isolate->snapshot_available()) return; 5192 if (!isolate->snapshot_available()) return;
5195 Heap* heap = isolate->heap(); 5193 Heap* heap = isolate->heap();
5196 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, 5194 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5245 } 5243 }
5246 5244
5247 5245
5248 void CheckMapRetainingFor(int n) { 5246 void CheckMapRetainingFor(int n) {
5249 FLAG_retain_maps_for_n_gc = n; 5247 FLAG_retain_maps_for_n_gc = n;
5250 Isolate* isolate = CcTest::i_isolate(); 5248 Isolate* isolate = CcTest::i_isolate();
5251 Heap* heap = isolate->heap(); 5249 Heap* heap = isolate->heap();
5252 Handle<WeakCell> weak_cell = AddRetainedMap(isolate, heap); 5250 Handle<WeakCell> weak_cell = AddRetainedMap(isolate, heap);
5253 CHECK(!weak_cell->cleared()); 5251 CHECK(!weak_cell->cleared());
5254 for (int i = 0; i < n; i++) { 5252 for (int i = 0; i < n; i++) {
5255 heap->CollectGarbage(OLD_POINTER_SPACE); 5253 heap->CollectGarbage(OLD_SPACE);
5256 } 5254 }
5257 CHECK(!weak_cell->cleared()); 5255 CHECK(!weak_cell->cleared());
5258 heap->CollectGarbage(OLD_POINTER_SPACE); 5256 heap->CollectGarbage(OLD_SPACE);
5259 CHECK(weak_cell->cleared()); 5257 CHECK(weak_cell->cleared());
5260 } 5258 }
5261 5259
5262 5260
5263 TEST(MapRetaining) { 5261 TEST(MapRetaining) {
5264 CcTest::InitializeVM(); 5262 CcTest::InitializeVM();
5265 v8::HandleScope scope(CcTest::isolate()); 5263 v8::HandleScope scope(CcTest::isolate());
5266 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); 5264 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc);
5267 CheckMapRetainingFor(0); 5265 CheckMapRetainingFor(0);
5268 CheckMapRetainingFor(1); 5266 CheckMapRetainingFor(1);
5269 CheckMapRetainingFor(7); 5267 CheckMapRetainingFor(7);
5270 } 5268 }
5271 5269
5272 5270
5273 TEST(RegressArrayListGC) { 5271 TEST(RegressArrayListGC) {
5274 FLAG_retain_maps_for_n_gc = 1; 5272 FLAG_retain_maps_for_n_gc = 1;
5275 FLAG_incremental_marking = 0; 5273 FLAG_incremental_marking = 0;
5276 FLAG_gc_global = true; 5274 FLAG_gc_global = true;
5277 CcTest::InitializeVM(); 5275 CcTest::InitializeVM();
5278 v8::HandleScope scope(CcTest::isolate()); 5276 v8::HandleScope scope(CcTest::isolate());
5279 Isolate* isolate = CcTest::i_isolate(); 5277 Isolate* isolate = CcTest::i_isolate();
5280 Heap* heap = isolate->heap(); 5278 Heap* heap = isolate->heap();
5281 AddRetainedMap(isolate, heap); 5279 AddRetainedMap(isolate, heap);
5282 Handle<Map> map = Map::Create(isolate, 1); 5280 Handle<Map> map = Map::Create(isolate, 1);
5283 heap->CollectGarbage(OLD_POINTER_SPACE); 5281 heap->CollectGarbage(OLD_SPACE);
5284 // Force GC in old space on next addition of retained map. 5282 // Force GC in old space on next addition of retained map.
5285 Map::WeakCellForMap(map); 5283 Map::WeakCellForMap(map);
5286 SimulateFullSpace(CcTest::heap()->new_space()); 5284 SimulateFullSpace(CcTest::heap()->new_space());
5287 for (int i = 0; i < 10; i++) { 5285 for (int i = 0; i < 10; i++) {
5288 heap->AddRetainedMap(map); 5286 heap->AddRetainedMap(map);
5289 } 5287 }
5290 heap->CollectGarbage(OLD_POINTER_SPACE); 5288 heap->CollectGarbage(OLD_SPACE);
5291 } 5289 }
5292 5290
5293 5291
5294 #ifdef DEBUG 5292 #ifdef DEBUG
5295 TEST(PathTracer) { 5293 TEST(PathTracer) {
5296 CcTest::InitializeVM(); 5294 CcTest::InitializeVM();
5297 v8::HandleScope scope(CcTest::isolate()); 5295 v8::HandleScope scope(CcTest::isolate());
5298 5296
5299 v8::Local<v8::Value> result = CompileRun("'abc'"); 5297 v8::Local<v8::Value> result = CompileRun("'abc'");
5300 Handle<Object> o = v8::Utils::OpenHandle(*result); 5298 Handle<Object> o = v8::Utils::OpenHandle(*result);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5356 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8, 6); 5354 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8, 6);
5357 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8 - 1, 6); 5355 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8 - 1, 6);
5358 5356
5359 // 32-bit cases. 5357 // 32-bit cases.
5360 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16, 3); 5358 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16, 3);
5361 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16 - 3, 3); 5359 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16 - 3, 3);
5362 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8, 3); 5360 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8, 3);
5363 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8 - 1, 3); 5361 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8 - 1, 3);
5364 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 4, 3); 5362 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 4, 3);
5365 } 5363 }
OLDNEW
« no previous file with comments | « test/cctest/test-dictionary.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698