OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
11 #include "src/execution.h" | 11 #include "src/execution.h" |
12 #include "src/factory.h" | 12 #include "src/factory.h" |
13 #include "src/field-type.h" | 13 #include "src/field-type.h" |
14 #include "src/global-handles.h" | 14 #include "src/global-handles.h" |
15 #include "src/ic/ic.h" | 15 #include "src/ic/ic.h" |
16 #include "src/macro-assembler.h" | 16 #include "src/macro-assembler.h" |
17 #include "test/cctest/cctest.h" | 17 #include "test/cctest/cctest.h" |
18 #include "test/cctest/heap/utils-inl.h" | 18 #include "test/cctest/heap/heap-utils.h" |
19 | 19 |
20 using namespace v8::base; | 20 using namespace v8::base; |
21 using namespace v8::internal; | 21 using namespace v8::internal; |
22 | 22 |
23 #if V8_DOUBLE_FIELDS_UNBOXING | 23 #if V8_DOUBLE_FIELDS_UNBOXING |
24 | 24 |
25 | 25 |
26 // | 26 // |
27 // Helper functions. | 27 // Helper functions. |
28 // | 28 // |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, | 1105 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, |
1106 Representation::Tagged(), | 1106 Representation::Tagged(), |
1107 INSERT_TRANSITION).ToHandleChecked(); | 1107 INSERT_TRANSITION).ToHandleChecked(); |
1108 | 1108 |
1109 // Create |obj_value| in old space. | 1109 // Create |obj_value| in old space. |
1110 Handle<HeapObject> obj_value; | 1110 Handle<HeapObject> obj_value; |
1111 Page* ec_page; | 1111 Page* ec_page; |
1112 { | 1112 { |
1113 AlwaysAllocateScope always_allocate(isolate); | 1113 AlwaysAllocateScope always_allocate(isolate); |
1114 // Make sure |obj_value| is placed on an old-space evacuation candidate. | 1114 // Make sure |obj_value| is placed on an old-space evacuation candidate. |
1115 SimulateFullSpace(old_space); | 1115 heap::SimulateFullSpace(old_space); |
1116 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1116 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
1117 ec_page = Page::FromAddress(obj_value->address()); | 1117 ec_page = Page::FromAddress(obj_value->address()); |
1118 } | 1118 } |
1119 | 1119 |
1120 // Create object in new space. | 1120 // Create object in new space. |
1121 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 1121 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); |
1122 | 1122 |
1123 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1123 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); |
1124 obj->WriteToField(0, *heap_number); | 1124 obj->WriteToField(0, *heap_number); |
1125 obj->WriteToField(1, *obj_value); | 1125 obj->WriteToField(1, *obj_value); |
1126 | 1126 |
1127 { | 1127 { |
1128 // Ensure the object is properly set up. | 1128 // Ensure the object is properly set up. |
1129 FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); | 1129 FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); |
1130 CHECK(field_index.is_inobject() && field_index.is_double()); | 1130 CHECK(field_index.is_inobject() && field_index.is_double()); |
1131 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 1131 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); |
1132 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 1132 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); |
1133 | 1133 |
1134 field_index = FieldIndex::ForDescriptor(*map, 1); | 1134 field_index = FieldIndex::ForDescriptor(*map, 1); |
1135 CHECK(field_index.is_inobject() && !field_index.is_double()); | 1135 CHECK(field_index.is_inobject() && !field_index.is_double()); |
1136 CHECK(!map->IsUnboxedDoubleField(field_index)); | 1136 CHECK(!map->IsUnboxedDoubleField(field_index)); |
1137 } | 1137 } |
1138 CHECK(isolate->heap()->new_space()->Contains(*obj)); | 1138 CHECK(isolate->heap()->new_space()->Contains(*obj)); |
1139 | 1139 |
1140 // Heap is ready, force |ec_page| to become an evacuation candidate and | 1140 // Heap is ready, force |ec_page| to become an evacuation candidate and |
1141 // simulate incremental marking. | 1141 // simulate incremental marking. |
1142 FLAG_stress_compaction = true; | 1142 FLAG_stress_compaction = true; |
1143 FLAG_manual_evacuation_candidates_selection = true; | 1143 FLAG_manual_evacuation_candidates_selection = true; |
1144 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 1144 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
1145 SimulateIncrementalMarking(heap); | 1145 heap::SimulateIncrementalMarking(heap); |
1146 // Disable stress compaction mode in order to let GC do scavenge. | 1146 // Disable stress compaction mode in order to let GC do scavenge. |
1147 FLAG_stress_compaction = false; | 1147 FLAG_stress_compaction = false; |
1148 | 1148 |
1149 // Check that everything is ready for triggering incremental write barrier | 1149 // Check that everything is ready for triggering incremental write barrier |
1150 // during scavenge (i.e. that |obj| is black and incremental marking is | 1150 // during scavenge (i.e. that |obj| is black and incremental marking is |
1151 // in compacting mode and |obj_value|'s page is an evacuation candidate). | 1151 // in compacting mode and |obj_value|'s page is an evacuation candidate). |
1152 IncrementalMarking* marking = heap->incremental_marking(); | 1152 IncrementalMarking* marking = heap->incremental_marking(); |
1153 CHECK(marking->IsCompacting()); | 1153 CHECK(marking->IsCompacting()); |
1154 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj))); | 1154 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj))); |
1155 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); | 1155 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1444 |
1445 Handle<JSObject> obj; | 1445 Handle<JSObject> obj; |
1446 Handle<HeapObject> obj_value; | 1446 Handle<HeapObject> obj_value; |
1447 Page* ec_page; | 1447 Page* ec_page; |
1448 { | 1448 { |
1449 AlwaysAllocateScope always_allocate(isolate); | 1449 AlwaysAllocateScope always_allocate(isolate); |
1450 obj = factory->NewJSObjectFromMap(map, TENURED); | 1450 obj = factory->NewJSObjectFromMap(map, TENURED); |
1451 CHECK(old_space->Contains(*obj)); | 1451 CHECK(old_space->Contains(*obj)); |
1452 | 1452 |
1453 // Make sure |obj_value| is placed on an old-space evacuation candidate. | 1453 // Make sure |obj_value| is placed on an old-space evacuation candidate. |
1454 SimulateFullSpace(old_space); | 1454 heap::SimulateFullSpace(old_space); |
1455 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1455 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
1456 ec_page = Page::FromAddress(obj_value->address()); | 1456 ec_page = Page::FromAddress(obj_value->address()); |
1457 CHECK_NE(ec_page, Page::FromAddress(obj->address())); | 1457 CHECK_NE(ec_page, Page::FromAddress(obj->address())); |
1458 } | 1458 } |
1459 | 1459 |
1460 // Heap is ready, force |ec_page| to become an evacuation candidate and | 1460 // Heap is ready, force |ec_page| to become an evacuation candidate and |
1461 // simulate incremental marking. | 1461 // simulate incremental marking. |
1462 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 1462 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
1463 SimulateIncrementalMarking(heap); | 1463 heap::SimulateIncrementalMarking(heap); |
1464 | 1464 |
1465 // Check that everything is ready for triggering incremental write barrier | 1465 // Check that everything is ready for triggering incremental write barrier |
1466 // (i.e. that both |obj| and |obj_value| are black and the marking phase is | 1466 // (i.e. that both |obj| and |obj_value| are black and the marking phase is |
1467 // still active and |obj_value|'s page is indeed an evacuation candidate). | 1467 // still active and |obj_value|'s page is indeed an evacuation candidate). |
1468 IncrementalMarking* marking = heap->incremental_marking(); | 1468 IncrementalMarking* marking = heap->incremental_marking(); |
1469 CHECK(marking->IsMarking()); | 1469 CHECK(marking->IsMarking()); |
1470 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj))); | 1470 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj))); |
1471 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj_value))); | 1471 CHECK(Marking::IsBlack(Marking::MarkBitFrom(*obj_value))); |
1472 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); | 1472 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); |
1473 | 1473 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 | 1554 |
1555 // TODO(ishell): add respective tests for property kind reconfiguring from | 1555 // TODO(ishell): add respective tests for property kind reconfiguring from |
1556 // accessor field to double, once accessor fields are supported by | 1556 // accessor field to double, once accessor fields are supported by |
1557 // Map::ReconfigureProperty(). | 1557 // Map::ReconfigureProperty(). |
1558 | 1558 |
1559 | 1559 |
1560 // TODO(ishell): add respective tests for fast property removal case once | 1560 // TODO(ishell): add respective tests for fast property removal case once |
1561 // Map::ReconfigureProperty() supports that. | 1561 // Map::ReconfigureProperty() supports that. |
1562 | 1562 |
1563 #endif | 1563 #endif |
OLD | NEW |