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 5547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(40000);" | 5568 "var array = new Array(400);" |
5569 "var tmp = new Array(100000);" | 5569 "var tmp = new Array(1000);" |
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 Loading... |
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 // Create the first huge object which will exactly fit the first semi-space | 5641 // Fill-up the first semi-space page. |
5642 // page. | 5642 FillUpOnePage(new_space); |
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)); | |
5651 | 5643 |
5652 // Create a small object to initialize the bump pointer on the second | 5644 // Create a small object to initialize the bump pointer on the second |
5653 // semi-space page. | 5645 // semi-space page. |
5654 Handle<FixedArray> small = | 5646 Handle<FixedArray> small = |
5655 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); | 5647 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); |
5656 CHECK(heap->InNewSpace(*small)); | 5648 CHECK(heap->InNewSpace(*small)); |
5657 | 5649 |
5658 | 5650 // Fill-up the second semi-space page. |
5659 // Create the second huge object of maximum allocatable second semi-space | 5651 FillUpOnePage(new_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)); | |
5669 | 5652 |
5670 // This scavenge will corrupt memory if the promotion queue is not | 5653 // This scavenge will corrupt memory if the promotion queue is not |
5671 // evacuated. | 5654 // evacuated. |
5672 heap->CollectGarbage(NEW_SPACE); | 5655 heap->CollectGarbage(NEW_SPACE); |
5673 } | 5656 } |
5674 isolate->Dispose(); | 5657 isolate->Dispose(); |
5675 } | 5658 } |
5676 | 5659 |
5677 | 5660 |
5678 TEST(Regress388880) { | 5661 TEST(Regress388880) { |
5679 i::FLAG_expose_gc = true; | 5662 i::FLAG_expose_gc = true; |
5680 CcTest::InitializeVM(); | 5663 CcTest::InitializeVM(); |
5681 v8::HandleScope scope(CcTest::isolate()); | 5664 v8::HandleScope scope(CcTest::isolate()); |
5682 Isolate* isolate = CcTest::i_isolate(); | 5665 Isolate* isolate = CcTest::i_isolate(); |
5683 Factory* factory = isolate->factory(); | 5666 Factory* factory = isolate->factory(); |
5684 Heap* heap = isolate->heap(); | 5667 Heap* heap = isolate->heap(); |
5685 | 5668 |
5686 Handle<Map> map1 = Map::Create(isolate, 1); | 5669 Handle<Map> map1 = Map::Create(isolate, 1); |
5687 Handle<Map> map2 = | 5670 Handle<Map> map2 = |
5688 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), | 5671 Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), |
5689 HeapType::Any(isolate), NONE, Representation::Tagged(), | 5672 HeapType::Any(isolate), NONE, Representation::Tagged(), |
5690 OMIT_TRANSITION).ToHandleChecked(); | 5673 OMIT_TRANSITION).ToHandleChecked(); |
5691 | 5674 |
5692 int desired_offset = Page::kPageSize - map1->instance_size(); | 5675 int desired_offset = Page::kPageSize - map1->instance_size(); |
5693 | 5676 |
5694 // Allocate fixed array in old pointer space so, that object allocated | 5677 // Allocate padding objects in old pointer space so, that object allocated |
5695 // afterwards would end at the end of the page. | 5678 // afterwards would end at the end of the page. |
5696 { | 5679 SimulateFullSpace(heap->old_space()); |
5697 SimulateFullSpace(heap->old_space()); | 5680 int padding_size = desired_offset - Page::kObjectStartOffset; |
5698 int padding_size = desired_offset - Page::kObjectStartOffset; | 5681 CreatePadding(heap, padding_size, TENURED); |
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 } | |
5707 | 5682 |
5708 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED); | 5683 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED); |
5709 o->set_properties(*factory->empty_fixed_array()); | 5684 o->set_properties(*factory->empty_fixed_array()); |
5710 | 5685 |
5711 // Ensure that the object allocated where we need it. | 5686 // Ensure that the object allocated where we need it. |
5712 Page* page = Page::FromAddress(o->address()); | 5687 Page* page = Page::FromAddress(o->address()); |
5713 CHECK_EQ(desired_offset, page->Offset(o->address())); | 5688 CHECK_EQ(desired_offset, page->Offset(o->address())); |
5714 | 5689 |
5715 // Now we have an object right at the end of the page. | 5690 // Now we have an object right at the end of the page. |
5716 | 5691 |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6449 // The CollectGarbage call above starts sweeper threads. | 6424 // The CollectGarbage call above starts sweeper threads. |
6450 // The crash will happen if the following two functions | 6425 // The crash will happen if the following two functions |
6451 // are called before sweeping finishes. | 6426 // are called before sweeping finishes. |
6452 heap->StartIncrementalMarking(); | 6427 heap->StartIncrementalMarking(); |
6453 heap->FinalizeIncrementalMarkingIfComplete("test"); | 6428 heap->FinalizeIncrementalMarkingIfComplete("test"); |
6454 } | 6429 } |
6455 | 6430 |
6456 | 6431 |
6457 } // namespace internal | 6432 } // namespace internal |
6458 } // namespace v8 | 6433 } // namespace v8 |
OLD | NEW |