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

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

Issue 1376413005: Revert of [heap] Prepare code for smaller large object allocation limit than max allocatable memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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-api.cc ('k') | test/cctest/test-spaces.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 5547 matching lines...) Expand 10 before | Expand all | Expand 10 after
5558 5558
5559 5559
5560 TEST(ArrayShiftSweeping) { 5560 TEST(ArrayShiftSweeping) {
5561 i::FLAG_expose_gc = true; 5561 i::FLAG_expose_gc = true;
5562 CcTest::InitializeVM(); 5562 CcTest::InitializeVM();
5563 v8::HandleScope scope(CcTest::isolate()); 5563 v8::HandleScope scope(CcTest::isolate());
5564 Isolate* isolate = CcTest::i_isolate(); 5564 Isolate* isolate = CcTest::i_isolate();
5565 Heap* heap = isolate->heap(); 5565 Heap* heap = isolate->heap();
5566 5566
5567 v8::Local<v8::Value> result = CompileRun( 5567 v8::Local<v8::Value> result = CompileRun(
5568 "var array = new Array(400);" 5568 "var array = new Array(40000);"
5569 "var tmp = new Array(1000);" 5569 "var tmp = new Array(100000);"
5570 "array[0] = 10;" 5570 "array[0] = 10;"
5571 "gc();" 5571 "gc();"
5572 "gc();" 5572 "gc();"
5573 "array.shift();" 5573 "array.shift();"
5574 "array;"); 5574 "array;");
5575 5575
5576 Handle<JSObject> o = 5576 Handle<JSObject> o =
5577 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 5577 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
5578 CHECK(heap->InOldSpace(o->elements())); 5578 CHECK(heap->InOldSpace(o->elements()));
5579 CHECK(heap->InOldSpace(*o)); 5579 CHECK(heap->InOldSpace(*o));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
5631 // promotion queue entries at the end of the second semi-space page. 5631 // promotion queue entries at the end of the second semi-space page.
5632 const int number_handles = 12; 5632 const int number_handles = 12;
5633 Handle<FixedArray> handles[number_handles]; 5633 Handle<FixedArray> handles[number_handles];
5634 for (int i = 0; i < number_handles; i++) { 5634 for (int i = 0; i < number_handles; i++) {
5635 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED); 5635 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED);
5636 } 5636 }
5637 5637
5638 heap->CollectGarbage(NEW_SPACE); 5638 heap->CollectGarbage(NEW_SPACE);
5639 CHECK(i::FLAG_min_semi_space_size * MB == new_space->TotalCapacity()); 5639 CHECK(i::FLAG_min_semi_space_size * MB == new_space->TotalCapacity());
5640 5640
5641 // Fill-up the first semi-space page. 5641 // Create the first huge object which will exactly fit the first semi-space
5642 FillUpOnePage(new_space); 5642 // page.
5643 DisableInlineAllocationSteps(new_space);
5644 int new_linear_size =
5645 static_cast<int>(*heap->new_space()->allocation_limit_address() -
5646 *heap->new_space()->allocation_top_address());
5647 int length = (new_linear_size - FixedArray::kHeaderSize) / kPointerSize;
5648 Handle<FixedArray> first =
5649 i_isolate->factory()->NewFixedArray(length, NOT_TENURED);
5650 CHECK(heap->InNewSpace(*first));
5643 5651
5644 // Create a small object to initialize the bump pointer on the second 5652 // Create a small object to initialize the bump pointer on the second
5645 // semi-space page. 5653 // semi-space page.
5646 Handle<FixedArray> small = 5654 Handle<FixedArray> small =
5647 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); 5655 i_isolate->factory()->NewFixedArray(1, NOT_TENURED);
5648 CHECK(heap->InNewSpace(*small)); 5656 CHECK(heap->InNewSpace(*small));
5649 5657
5650 // Fill-up the second semi-space page. 5658
5651 FillUpOnePage(new_space); 5659 // Create the second huge object of maximum allocatable second semi-space
5660 // page size.
5661 DisableInlineAllocationSteps(new_space);
5662 new_linear_size =
5663 static_cast<int>(*heap->new_space()->allocation_limit_address() -
5664 *heap->new_space()->allocation_top_address());
5665 length = (new_linear_size - FixedArray::kHeaderSize) / kPointerSize;
5666 Handle<FixedArray> second =
5667 i_isolate->factory()->NewFixedArray(length, NOT_TENURED);
5668 CHECK(heap->InNewSpace(*second));
5652 5669
5653 // This scavenge will corrupt memory if the promotion queue is not 5670 // This scavenge will corrupt memory if the promotion queue is not
5654 // evacuated. 5671 // evacuated.
5655 heap->CollectGarbage(NEW_SPACE); 5672 heap->CollectGarbage(NEW_SPACE);
5656 } 5673 }
5657 isolate->Dispose(); 5674 isolate->Dispose();
5658 } 5675 }
5659 5676
5660 5677
5661 TEST(Regress388880) { 5678 TEST(Regress388880) {
5662 i::FLAG_expose_gc = true; 5679 i::FLAG_expose_gc = true;
5663 CcTest::InitializeVM(); 5680 CcTest::InitializeVM();
5664 v8::HandleScope scope(CcTest::isolate()); 5681 v8::HandleScope scope(CcTest::isolate());
5665 Isolate* isolate = CcTest::i_isolate(); 5682 Isolate* isolate = CcTest::i_isolate();
5666 Factory* factory = isolate->factory(); 5683 Factory* factory = isolate->factory();
5667 Heap* heap = isolate->heap(); 5684 Heap* heap = isolate->heap();
5668 5685
5669 Handle<Map> map1 = Map::Create(isolate, 1); 5686 Handle<Map> map1 = Map::Create(isolate, 1);
5670 Handle<Map> map2 = 5687 Handle<Map> map2 =
5671 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), 5688 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"),
5672 HeapType::Any(isolate), NONE, Representation::Tagged(), 5689 HeapType::Any(isolate), NONE, Representation::Tagged(),
5673 OMIT_TRANSITION).ToHandleChecked(); 5690 OMIT_TRANSITION).ToHandleChecked();
5674 5691
5675 int desired_offset = Page::kPageSize - map1->instance_size(); 5692 int desired_offset = Page::kPageSize - map1->instance_size();
5676 5693
5677 // Allocate padding objects in old pointer space so, that object allocated 5694 // Allocate fixed array in old pointer space so, that object allocated
5678 // afterwards would end at the end of the page. 5695 // afterwards would end at the end of the page.
5679 SimulateFullSpace(heap->old_space()); 5696 {
5680 int padding_size = desired_offset - Page::kObjectStartOffset; 5697 SimulateFullSpace(heap->old_space());
5681 CreatePadding(heap, padding_size, TENURED); 5698 int padding_size = desired_offset - Page::kObjectStartOffset;
5699 int padding_array_length =
5700 (padding_size - FixedArray::kHeaderSize) / kPointerSize;
5701
5702 Handle<FixedArray> temp2 =
5703 factory->NewFixedArray(padding_array_length, TENURED);
5704 Page* page = Page::FromAddress(temp2->address());
5705 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address()));
5706 }
5682 5707
5683 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED); 5708 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED);
5684 o->set_properties(*factory->empty_fixed_array()); 5709 o->set_properties(*factory->empty_fixed_array());
5685 5710
5686 // Ensure that the object allocated where we need it. 5711 // Ensure that the object allocated where we need it.
5687 Page* page = Page::FromAddress(o->address()); 5712 Page* page = Page::FromAddress(o->address());
5688 CHECK_EQ(desired_offset, page->Offset(o->address())); 5713 CHECK_EQ(desired_offset, page->Offset(o->address()));
5689 5714
5690 // Now we have an object right at the end of the page. 5715 // Now we have an object right at the end of the page.
5691 5716
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
6424 // The CollectGarbage call above starts sweeper threads. 6449 // The CollectGarbage call above starts sweeper threads.
6425 // The crash will happen if the following two functions 6450 // The crash will happen if the following two functions
6426 // are called before sweeping finishes. 6451 // are called before sweeping finishes.
6427 heap->StartIncrementalMarking(); 6452 heap->StartIncrementalMarking();
6428 heap->FinalizeIncrementalMarkingIfComplete("test"); 6453 heap->FinalizeIncrementalMarkingIfComplete("test");
6429 } 6454 }
6430 6455
6431 6456
6432 } // namespace internal 6457 } // namespace internal
6433 } // namespace v8 6458 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698