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" |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 Handle<LayoutDescriptor> layout_descriptor = | 919 Handle<LayoutDescriptor> layout_descriptor = |
920 LayoutDescriptor::New(map, descriptors, kPropsCount); | 920 LayoutDescriptor::New(map, descriptors, kPropsCount); |
921 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 921 map->InitializeDescriptors(*descriptors, *layout_descriptor); |
922 | 922 |
923 Handle<JSObject> object = factory->NewJSObjectFromMap(map, TENURED); | 923 Handle<JSObject> object = factory->NewJSObjectFromMap(map, TENURED); |
924 | 924 |
925 Address fake_address = reinterpret_cast<Address>(~kHeapObjectTagMask); | 925 Address fake_address = reinterpret_cast<Address>(~kHeapObjectTagMask); |
926 HeapObject* fake_object = HeapObject::FromAddress(fake_address); | 926 HeapObject* fake_object = HeapObject::FromAddress(fake_address); |
927 CHECK(fake_object->IsHeapObject()); | 927 CHECK(fake_object->IsHeapObject()); |
928 | 928 |
929 double boom_value = bit_cast<double>(fake_object); | 929 uint64_t boom_value = bit_cast<uint64_t>(fake_object); |
930 for (int i = 0; i < kPropsCount; i++) { | 930 for (int i = 0; i < kPropsCount; i++) { |
931 FieldIndex index = FieldIndex::ForDescriptor(*map, i); | 931 FieldIndex index = FieldIndex::ForDescriptor(*map, i); |
932 CHECK(map->IsUnboxedDoubleField(index)); | 932 CHECK(map->IsUnboxedDoubleField(index)); |
933 object->RawFastDoublePropertyAtPut(index, boom_value); | 933 object->RawFastDoublePropertyAsBitsAtPut(index, boom_value); |
934 } | 934 } |
935 CHECK(object->HasFastProperties()); | 935 CHECK(object->HasFastProperties()); |
936 CHECK(!object->map()->HasFastPointerLayout()); | 936 CHECK(!object->map()->HasFastPointerLayout()); |
937 | 937 |
938 Handle<Map> normalized_map = | 938 Handle<Map> normalized_map = |
939 Map::Normalize(map, KEEP_INOBJECT_PROPERTIES, "testing"); | 939 Map::Normalize(map, KEEP_INOBJECT_PROPERTIES, "testing"); |
940 JSObject::MigrateToMap(object, normalized_map); | 940 JSObject::MigrateToMap(object, normalized_map); |
941 CHECK(!object->HasFastProperties()); | 941 CHECK(!object->HasFastProperties()); |
942 CHECK(object->map()->HasFastPointerLayout()); | 942 CHECK(object->map()->HasFastPointerLayout()); |
943 | 943 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 for (int i = 0; i < n; i++) { | 1405 for (int i = 0; i < n; i++) { |
1406 obj->FastPropertyAtPut(index, *obj_value); | 1406 obj->FastPropertyAtPut(index, *obj_value); |
1407 } | 1407 } |
1408 } | 1408 } |
1409 | 1409 |
1410 // Migrate |obj| to |new_map| which should shift fields and put the | 1410 // Migrate |obj| to |new_map| which should shift fields and put the |
1411 // |boom_value| to the slot that was earlier recorded by write barrier. | 1411 // |boom_value| to the slot that was earlier recorded by write barrier. |
1412 JSObject::MigrateToMap(obj, new_map); | 1412 JSObject::MigrateToMap(obj, new_map); |
1413 | 1413 |
1414 Address fake_object = reinterpret_cast<Address>(*obj_value) + kPointerSize; | 1414 Address fake_object = reinterpret_cast<Address>(*obj_value) + kPointerSize; |
1415 double boom_value = bit_cast<double>(fake_object); | 1415 uint64_t boom_value = bit_cast<uint64_t>(fake_object); |
1416 | 1416 |
1417 FieldIndex double_field_index = | 1417 FieldIndex double_field_index = |
1418 FieldIndex::ForDescriptor(*new_map, double_descriptor); | 1418 FieldIndex::ForDescriptor(*new_map, double_descriptor); |
1419 CHECK(obj->IsUnboxedDoubleField(double_field_index)); | 1419 CHECK(obj->IsUnboxedDoubleField(double_field_index)); |
1420 obj->RawFastDoublePropertyAtPut(double_field_index, boom_value); | 1420 obj->RawFastDoublePropertyAsBitsAtPut(double_field_index, boom_value); |
1421 | 1421 |
1422 // Trigger GC to evacuate all candidates. | 1422 // Trigger GC to evacuate all candidates. |
1423 CcTest::CollectGarbage(NEW_SPACE); | 1423 CcTest::CollectGarbage(NEW_SPACE); |
1424 | 1424 |
1425 if (check_tagged_value) { | 1425 if (check_tagged_value) { |
1426 FieldIndex tagged_field_index = | 1426 FieldIndex tagged_field_index = |
1427 FieldIndex::ForDescriptor(*new_map, tagged_descriptor); | 1427 FieldIndex::ForDescriptor(*new_map, tagged_descriptor); |
1428 CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); | 1428 CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); |
1429 } | 1429 } |
1430 CHECK_EQ(boom_value, obj->RawFastDoublePropertyAt(double_field_index)); | 1430 CHECK_EQ(boom_value, obj->RawFastDoublePropertyAsBitsAt(double_field_index)); |
1431 } | 1431 } |
1432 | 1432 |
1433 | 1433 |
1434 static void TestIncrementalWriteBarrier(Handle<Map> map, Handle<Map> new_map, | 1434 static void TestIncrementalWriteBarrier(Handle<Map> map, Handle<Map> new_map, |
1435 int tagged_descriptor, | 1435 int tagged_descriptor, |
1436 int double_descriptor, | 1436 int double_descriptor, |
1437 bool check_tagged_value = true) { | 1437 bool check_tagged_value = true) { |
1438 if (FLAG_never_compact || !FLAG_incremental_marking) return; | 1438 if (FLAG_never_compact || !FLAG_incremental_marking) return; |
1439 FLAG_manual_evacuation_candidates_selection = true; | 1439 FLAG_manual_evacuation_candidates_selection = true; |
1440 Isolate* isolate = CcTest::i_isolate(); | 1440 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 { | 1484 { |
1485 FieldIndex index = FieldIndex::ForDescriptor(*map, tagged_descriptor); | 1485 FieldIndex index = FieldIndex::ForDescriptor(*map, tagged_descriptor); |
1486 obj->FastPropertyAtPut(index, *obj_value); | 1486 obj->FastPropertyAtPut(index, *obj_value); |
1487 } | 1487 } |
1488 | 1488 |
1489 // Migrate |obj| to |new_map| which should shift fields and put the | 1489 // Migrate |obj| to |new_map| which should shift fields and put the |
1490 // |boom_value| to the slot that was earlier recorded by incremental write | 1490 // |boom_value| to the slot that was earlier recorded by incremental write |
1491 // barrier. | 1491 // barrier. |
1492 JSObject::MigrateToMap(obj, new_map); | 1492 JSObject::MigrateToMap(obj, new_map); |
1493 | 1493 |
1494 double boom_value = bit_cast<double>(UINT64_C(0xbaad0176a37c28e1)); | 1494 uint64_t boom_value = UINT64_C(0xbaad0176a37c28e1); |
1495 | 1495 |
1496 FieldIndex double_field_index = | 1496 FieldIndex double_field_index = |
1497 FieldIndex::ForDescriptor(*new_map, double_descriptor); | 1497 FieldIndex::ForDescriptor(*new_map, double_descriptor); |
1498 CHECK(obj->IsUnboxedDoubleField(double_field_index)); | 1498 CHECK(obj->IsUnboxedDoubleField(double_field_index)); |
1499 obj->RawFastDoublePropertyAtPut(double_field_index, boom_value); | 1499 obj->RawFastDoublePropertyAsBitsAtPut(double_field_index, boom_value); |
1500 | 1500 |
1501 // Trigger GC to evacuate all candidates. | 1501 // Trigger GC to evacuate all candidates. |
1502 CcTest::CollectGarbage(OLD_SPACE); | 1502 CcTest::CollectGarbage(OLD_SPACE); |
1503 | 1503 |
1504 // Ensure that the values are still there and correct. | 1504 // Ensure that the values are still there and correct. |
1505 CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); | 1505 CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(*obj_value)); |
1506 | 1506 |
1507 if (check_tagged_value) { | 1507 if (check_tagged_value) { |
1508 FieldIndex tagged_field_index = | 1508 FieldIndex tagged_field_index = |
1509 FieldIndex::ForDescriptor(*new_map, tagged_descriptor); | 1509 FieldIndex::ForDescriptor(*new_map, tagged_descriptor); |
1510 CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); | 1510 CHECK_EQ(*obj_value, obj->RawFastPropertyAt(tagged_field_index)); |
1511 } | 1511 } |
1512 CHECK_EQ(boom_value, obj->RawFastDoublePropertyAt(double_field_index)); | 1512 CHECK_EQ(boom_value, obj->RawFastDoublePropertyAsBitsAt(double_field_index)); |
1513 } | 1513 } |
1514 | 1514 |
1515 enum OldToWriteBarrierKind { | 1515 enum OldToWriteBarrierKind { |
1516 OLD_TO_OLD_WRITE_BARRIER, | 1516 OLD_TO_OLD_WRITE_BARRIER, |
1517 OLD_TO_NEW_WRITE_BARRIER | 1517 OLD_TO_NEW_WRITE_BARRIER |
1518 }; | 1518 }; |
1519 static void TestWriteBarrierObjectShiftFieldsRight( | 1519 static void TestWriteBarrierObjectShiftFieldsRight( |
1520 OldToWriteBarrierKind write_barrier_kind) { | 1520 OldToWriteBarrierKind write_barrier_kind) { |
1521 CcTest::InitializeVM(); | 1521 CcTest::InitializeVM(); |
1522 Isolate* isolate = CcTest::i_isolate(); | 1522 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 | 1562 |
1563 // TODO(ishell): add respective tests for property kind reconfiguring from | 1563 // TODO(ishell): add respective tests for property kind reconfiguring from |
1564 // accessor field to double, once accessor fields are supported by | 1564 // accessor field to double, once accessor fields are supported by |
1565 // Map::ReconfigureProperty(). | 1565 // Map::ReconfigureProperty(). |
1566 | 1566 |
1567 | 1567 |
1568 // TODO(ishell): add respective tests for fast property removal case once | 1568 // TODO(ishell): add respective tests for fast property removal case once |
1569 // Map::ReconfigureProperty() supports that. | 1569 // Map::ReconfigureProperty() supports that. |
1570 | 1570 |
1571 #endif | 1571 #endif |
OLD | NEW |