| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 int next_field_offset = 0; | 61 int next_field_offset = 0; |
| 62 for (int i = 0; i < kPropsCount; i++) { | 62 for (int i = 0; i < kPropsCount; i++) { |
| 63 EmbeddedVector<char, 64> buffer; | 63 EmbeddedVector<char, 64> buffer; |
| 64 SNPrintF(buffer, "prop%d", i); | 64 SNPrintF(buffer, "prop%d", i); |
| 65 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); | 65 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); |
| 66 | 66 |
| 67 TestPropertyKind kind = props[i]; | 67 TestPropertyKind kind = props[i]; |
| 68 | 68 |
| 69 if (kind == PROP_CONSTANT) { | 69 if (kind == PROP_CONSTANT) { |
| 70 ConstantDescriptor d(name, func, NONE); | 70 DataConstantDescriptor d(name, func, NONE); |
| 71 descriptors->Append(&d); | 71 descriptors->Append(&d); |
| 72 | 72 |
| 73 } else { | 73 } else { |
| 74 FieldDescriptor f(name, next_field_offset, NONE, representations[kind]); | 74 DataFieldDescriptor f(name, next_field_offset, NONE, |
| 75 representations[kind]); |
| 75 next_field_offset += f.GetDetails().field_width_in_words(); | 76 next_field_offset += f.GetDetails().field_width_in_words(); |
| 76 descriptors->Append(&f); | 77 descriptors->Append(&f); |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 return descriptors; | 80 return descriptors; |
| 80 } | 81 } |
| 81 | 82 |
| 82 | 83 |
| 83 TEST(LayoutDescriptorBasicFast) { | 84 TEST(LayoutDescriptorBasicFast) { |
| 84 CcTest::InitializeVM(); | 85 CcTest::InitializeVM(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | 535 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); |
| 535 } | 536 } |
| 536 | 537 |
| 537 { | 538 { |
| 538 int inobject_properties = kPropsCount / 2; | 539 int inobject_properties = kPropsCount / 2; |
| 539 Handle<Map> map = Map::Create(isolate, inobject_properties); | 540 Handle<Map> map = Map::Create(isolate, inobject_properties); |
| 540 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 541 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
| 541 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 542 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
| 542 CHECK(layout_descriptor->IsSlowLayout()); | 543 CHECK(layout_descriptor->IsSlowLayout()); |
| 543 for (int i = 0; i < inobject_properties; i++) { | 544 for (int i = 0; i < inobject_properties; i++) { |
| 544 // PROP_DOUBLE has index 1 among FIELD properties. | 545 // PROP_DOUBLE has index 1 among DATA_FIELD properties. |
| 545 const bool tagged = (i % (PROP_KIND_NUMBER - 1)) != 1; | 546 const bool tagged = (i % (PROP_KIND_NUMBER - 1)) != 1; |
| 546 CHECK_EQ(tagged, layout_descriptor->IsTagged(i)); | 547 CHECK_EQ(tagged, layout_descriptor->IsTagged(i)); |
| 547 } | 548 } |
| 548 // Every property after inobject_properties must be tagged. | 549 // Every property after inobject_properties must be tagged. |
| 549 for (int i = inobject_properties; i < kPropsCount; i++) { | 550 for (int i = inobject_properties; i < kPropsCount; i++) { |
| 550 CHECK_EQ(true, layout_descriptor->IsTagged(i)); | 551 CHECK_EQ(true, layout_descriptor->IsTagged(i)); |
| 551 } | 552 } |
| 552 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 553 map->InitializeDescriptors(*descriptors, *layout_descriptor); |
| 553 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | 554 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); |
| 554 | 555 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 594 |
| 594 int next_field_offset = 0; | 595 int next_field_offset = 0; |
| 595 for (int i = 0; i < kPropsCount; i++) { | 596 for (int i = 0; i < kPropsCount; i++) { |
| 596 EmbeddedVector<char, 64> buffer; | 597 EmbeddedVector<char, 64> buffer; |
| 597 SNPrintF(buffer, "prop%d", i); | 598 SNPrintF(buffer, "prop%d", i); |
| 598 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); | 599 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); |
| 599 | 600 |
| 600 Handle<LayoutDescriptor> layout_descriptor; | 601 Handle<LayoutDescriptor> layout_descriptor; |
| 601 TestPropertyKind kind = props[i]; | 602 TestPropertyKind kind = props[i]; |
| 602 if (kind == PROP_CONSTANT) { | 603 if (kind == PROP_CONSTANT) { |
| 603 ConstantDescriptor d(name, func, NONE); | 604 DataConstantDescriptor d(name, func, NONE); |
| 604 layout_descriptor = LayoutDescriptor::Append(map, d.GetDetails()); | 605 layout_descriptor = LayoutDescriptor::Append(map, d.GetDetails()); |
| 605 descriptors->Append(&d); | 606 descriptors->Append(&d); |
| 606 | 607 |
| 607 } else { | 608 } else { |
| 608 FieldDescriptor f(name, next_field_offset, NONE, representations[kind]); | 609 DataFieldDescriptor f(name, next_field_offset, NONE, |
| 610 representations[kind]); |
| 609 int field_width_in_words = f.GetDetails().field_width_in_words(); | 611 int field_width_in_words = f.GetDetails().field_width_in_words(); |
| 610 next_field_offset += field_width_in_words; | 612 next_field_offset += field_width_in_words; |
| 611 layout_descriptor = LayoutDescriptor::Append(map, f.GetDetails()); | 613 layout_descriptor = LayoutDescriptor::Append(map, f.GetDetails()); |
| 612 descriptors->Append(&f); | 614 descriptors->Append(&f); |
| 613 | 615 |
| 614 int field_index = f.GetDetails().field_index(); | 616 int field_index = f.GetDetails().field_index(); |
| 615 bool is_inobject = field_index < map->inobject_properties(); | 617 bool is_inobject = field_index < map->inobject_properties(); |
| 616 for (int bit = 0; bit < field_width_in_words; bit++) { | 618 for (int bit = 0; bit < field_width_in_words; bit++) { |
| 617 CHECK_EQ(is_inobject && (kind == PROP_DOUBLE), | 619 CHECK_EQ(is_inobject && (kind == PROP_DOUBLE), |
| 618 !layout_descriptor->IsTagged(field_index + bit)); | 620 !layout_descriptor->IsTagged(field_index + bit)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 map = Map::CopyInstallDescriptorsForTesting(map, i, descriptors, | 731 map = Map::CopyInstallDescriptorsForTesting(map, i, descriptors, |
| 730 full_layout_descriptor); | 732 full_layout_descriptor); |
| 731 | 733 |
| 732 LayoutDescriptor* layout_desc = map->layout_descriptor(); | 734 LayoutDescriptor* layout_desc = map->layout_descriptor(); |
| 733 | 735 |
| 734 if (layout_desc->IsSlowLayout()) { | 736 if (layout_desc->IsSlowLayout()) { |
| 735 switched_to_slow_mode = true; | 737 switched_to_slow_mode = true; |
| 736 CHECK_EQ(*full_layout_descriptor, layout_desc); | 738 CHECK_EQ(*full_layout_descriptor, layout_desc); |
| 737 } else { | 739 } else { |
| 738 CHECK(!switched_to_slow_mode); | 740 CHECK(!switched_to_slow_mode); |
| 739 if (details.type() == FIELD) { | 741 if (details.type() == DATA_FIELD) { |
| 740 nof++; | 742 nof++; |
| 741 int field_index = details.field_index(); | 743 int field_index = details.field_index(); |
| 742 int field_width_in_words = details.field_width_in_words(); | 744 int field_width_in_words = details.field_width_in_words(); |
| 743 | 745 |
| 744 bool is_inobject = field_index < map->inobject_properties(); | 746 bool is_inobject = field_index < map->inobject_properties(); |
| 745 for (int bit = 0; bit < field_width_in_words; bit++) { | 747 for (int bit = 0; bit < field_width_in_words; bit++) { |
| 746 CHECK_EQ(is_inobject && details.representation().IsDouble(), | 748 CHECK_EQ(is_inobject && details.representation().IsDouble(), |
| 747 !layout_desc->IsTagged(field_index + bit)); | 749 !layout_desc->IsTagged(field_index + bit)); |
| 748 } | 750 } |
| 749 CHECK(layout_desc->IsTagged(field_index + field_width_in_words)); | 751 CHECK(layout_desc->IsTagged(field_index + field_width_in_words)); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 | 966 |
| 965 LayoutDescriptorHelper helper(*map); | 967 LayoutDescriptorHelper helper(*map); |
| 966 bool all_fields_tagged = true; | 968 bool all_fields_tagged = true; |
| 967 | 969 |
| 968 int instance_size = map->instance_size(); | 970 int instance_size = map->instance_size(); |
| 969 | 971 |
| 970 int end_offset = instance_size * 2; | 972 int end_offset = instance_size * 2; |
| 971 int first_non_tagged_field_offset = end_offset; | 973 int first_non_tagged_field_offset = end_offset; |
| 972 for (int i = 0; i < number_of_descriptors; i++) { | 974 for (int i = 0; i < number_of_descriptors; i++) { |
| 973 PropertyDetails details = descriptors->GetDetails(i); | 975 PropertyDetails details = descriptors->GetDetails(i); |
| 974 if (details.type() != FIELD) continue; | 976 if (details.type() != DATA_FIELD) continue; |
| 975 FieldIndex index = FieldIndex::ForDescriptor(*map, i); | 977 FieldIndex index = FieldIndex::ForDescriptor(*map, i); |
| 976 if (!index.is_inobject()) continue; | 978 if (!index.is_inobject()) continue; |
| 977 all_fields_tagged &= !details.representation().IsDouble(); | 979 all_fields_tagged &= !details.representation().IsDouble(); |
| 978 bool expected_tagged = !index.is_double(); | 980 bool expected_tagged = !index.is_double(); |
| 979 if (!expected_tagged) { | 981 if (!expected_tagged) { |
| 980 first_non_tagged_field_offset = | 982 first_non_tagged_field_offset = |
| 981 Min(first_non_tagged_field_offset, index.offset()); | 983 Min(first_non_tagged_field_offset, index.offset()); |
| 982 } | 984 } |
| 983 | 985 |
| 984 int end_of_region_offset; | 986 int end_of_region_offset; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); | 1155 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
| 1154 chunk->set_scan_on_scavenge(true); | 1156 chunk->set_scan_on_scavenge(true); |
| 1155 | 1157 |
| 1156 // Trigger GCs and force evacuation. Should not crash there. | 1158 // Trigger GCs and force evacuation. Should not crash there. |
| 1157 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 1159 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 1158 | 1160 |
| 1159 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); | 1161 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); |
| 1160 } | 1162 } |
| 1161 | 1163 |
| 1162 #endif | 1164 #endif |
| OLD | NEW |