| 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 23 matching lines...) Expand all Loading... |
| 34 PropertyKind kind, | 34 PropertyKind kind, |
| 35 PropertyLocation location) { | 35 PropertyLocation location) { |
| 36 int type_value = PropertyDetails::TypeField::encode(type); | 36 int type_value = PropertyDetails::TypeField::encode(type); |
| 37 int kind_location_value = PropertyDetails::KindField::encode(kind) | | 37 int kind_location_value = PropertyDetails::KindField::encode(kind) | |
| 38 PropertyDetails::LocationField::encode(location); | 38 PropertyDetails::LocationField::encode(location); |
| 39 CHECK_EQ(type_value, kind_location_value); | 39 CHECK_EQ(type_value, kind_location_value); |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 TEST(PropertyDetailsFieldsConsistency) { | 43 TEST(PropertyDetailsFieldsConsistency) { |
| 44 CheckPropertyDetailsFieldsConsistency(FIELD, DATA, IN_OBJECT); | 44 CheckPropertyDetailsFieldsConsistency(DATA, kData, kField); |
| 45 CheckPropertyDetailsFieldsConsistency(CONSTANT, DATA, IN_DESCRIPTOR); | 45 CheckPropertyDetailsFieldsConsistency(DATA_CONSTANT, kData, kDescriptor); |
| 46 CheckPropertyDetailsFieldsConsistency(ACCESSOR_FIELD, ACCESSOR, IN_OBJECT); | 46 CheckPropertyDetailsFieldsConsistency(ACCESSOR, kAccessor, kField); |
| 47 CheckPropertyDetailsFieldsConsistency(CALLBACKS, ACCESSOR, IN_DESCRIPTOR); | 47 CheckPropertyDetailsFieldsConsistency(ACCESSOR_CONSTANT, kAccessor, |
| 48 kDescriptor); |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| 51 TEST(TransitionArray_SimpleFieldTransitions) { | 52 TEST(TransitionArray_SimpleFieldTransitions) { |
| 52 CcTest::InitializeVM(); | 53 CcTest::InitializeVM(); |
| 53 v8::HandleScope scope(CcTest::isolate()); | 54 v8::HandleScope scope(CcTest::isolate()); |
| 54 Isolate* isolate = CcTest::i_isolate(); | 55 Isolate* isolate = CcTest::i_isolate(); |
| 55 Factory* factory = isolate->factory(); | 56 Factory* factory = isolate->factory(); |
| 56 | 57 |
| 57 Handle<String> name1 = factory->InternalizeUtf8String("foo"); | 58 Handle<String> name1 = factory->InternalizeUtf8String("foo"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 70 | 71 |
| 71 CHECK(!map0->HasTransitionArray()); | 72 CHECK(!map0->HasTransitionArray()); |
| 72 Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 73 Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); |
| 73 CHECK(transitions->IsFullTransitionArray()); | 74 CHECK(transitions->IsFullTransitionArray()); |
| 74 | 75 |
| 75 int transition; | 76 int transition; |
| 76 transitions = | 77 transitions = |
| 77 transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); | 78 transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); |
| 78 ConnectTransition(map0, transitions, map1); | 79 ConnectTransition(map0, transitions, map1); |
| 79 CHECK(transitions->IsSimpleTransition()); | 80 CHECK(transitions->IsSimpleTransition()); |
| 80 transition = transitions->Search(DATA, *name1, attributes); | 81 transition = transitions->Search(kData, *name1, attributes); |
| 81 CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition); | 82 CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition); |
| 82 CHECK_EQ(*name1, transitions->GetKey(transition)); | 83 CHECK_EQ(*name1, transitions->GetKey(transition)); |
| 83 CHECK_EQ(*map1, transitions->GetTarget(transition)); | 84 CHECK_EQ(*map1, transitions->GetTarget(transition)); |
| 84 | 85 |
| 85 transitions = | 86 transitions = |
| 86 transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION); | 87 transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION); |
| 87 ConnectTransition(map0, transitions, map2); | 88 ConnectTransition(map0, transitions, map2); |
| 88 CHECK(transitions->IsFullTransitionArray()); | 89 CHECK(transitions->IsFullTransitionArray()); |
| 89 | 90 |
| 90 transition = transitions->Search(DATA, *name1, attributes); | 91 transition = transitions->Search(kData, *name1, attributes); |
| 91 CHECK_EQ(*name1, transitions->GetKey(transition)); | 92 CHECK_EQ(*name1, transitions->GetKey(transition)); |
| 92 CHECK_EQ(*map1, transitions->GetTarget(transition)); | 93 CHECK_EQ(*map1, transitions->GetTarget(transition)); |
| 93 | 94 |
| 94 transition = transitions->Search(DATA, *name2, attributes); | 95 transition = transitions->Search(kData, *name2, attributes); |
| 95 CHECK_EQ(*name2, transitions->GetKey(transition)); | 96 CHECK_EQ(*name2, transitions->GetKey(transition)); |
| 96 CHECK_EQ(*map2, transitions->GetTarget(transition)); | 97 CHECK_EQ(*map2, transitions->GetTarget(transition)); |
| 97 | 98 |
| 98 DCHECK(transitions->IsSortedNoDuplicates()); | 99 DCHECK(transitions->IsSortedNoDuplicates()); |
| 99 } | 100 } |
| 100 | 101 |
| 101 | 102 |
| 102 TEST(TransitionArray_FullFieldTransitions) { | 103 TEST(TransitionArray_FullFieldTransitions) { |
| 103 CcTest::InitializeVM(); | 104 CcTest::InitializeVM(); |
| 104 v8::HandleScope scope(CcTest::isolate()); | 105 v8::HandleScope scope(CcTest::isolate()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 120 OMIT_TRANSITION).ToHandleChecked(); | 121 OMIT_TRANSITION).ToHandleChecked(); |
| 121 | 122 |
| 122 CHECK(!map0->HasTransitionArray()); | 123 CHECK(!map0->HasTransitionArray()); |
| 123 Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 124 Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); |
| 124 CHECK(transitions->IsFullTransitionArray()); | 125 CHECK(transitions->IsFullTransitionArray()); |
| 125 | 126 |
| 126 int transition; | 127 int transition; |
| 127 transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION); | 128 transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION); |
| 128 ConnectTransition(map0, transitions, map1); | 129 ConnectTransition(map0, transitions, map1); |
| 129 CHECK(transitions->IsFullTransitionArray()); | 130 CHECK(transitions->IsFullTransitionArray()); |
| 130 transition = transitions->Search(DATA, *name1, attributes); | 131 transition = transitions->Search(kData, *name1, attributes); |
| 131 CHECK_EQ(*name1, transitions->GetKey(transition)); | 132 CHECK_EQ(*name1, transitions->GetKey(transition)); |
| 132 CHECK_EQ(*map1, transitions->GetTarget(transition)); | 133 CHECK_EQ(*map1, transitions->GetTarget(transition)); |
| 133 | 134 |
| 134 transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION); | 135 transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION); |
| 135 ConnectTransition(map0, transitions, map2); | 136 ConnectTransition(map0, transitions, map2); |
| 136 CHECK(transitions->IsFullTransitionArray()); | 137 CHECK(transitions->IsFullTransitionArray()); |
| 137 | 138 |
| 138 transition = transitions->Search(DATA, *name1, attributes); | 139 transition = transitions->Search(kData, *name1, attributes); |
| 139 CHECK_EQ(*name1, transitions->GetKey(transition)); | 140 CHECK_EQ(*name1, transitions->GetKey(transition)); |
| 140 CHECK_EQ(*map1, transitions->GetTarget(transition)); | 141 CHECK_EQ(*map1, transitions->GetTarget(transition)); |
| 141 | 142 |
| 142 transition = transitions->Search(DATA, *name2, attributes); | 143 transition = transitions->Search(kData, *name2, attributes); |
| 143 CHECK_EQ(*name2, transitions->GetKey(transition)); | 144 CHECK_EQ(*name2, transitions->GetKey(transition)); |
| 144 CHECK_EQ(*map2, transitions->GetTarget(transition)); | 145 CHECK_EQ(*map2, transitions->GetTarget(transition)); |
| 145 | 146 |
| 146 DCHECK(transitions->IsSortedNoDuplicates()); | 147 DCHECK(transitions->IsSortedNoDuplicates()); |
| 147 } | 148 } |
| 148 | 149 |
| 149 | 150 |
| 150 TEST(TransitionArray_DifferentFieldNames) { | 151 TEST(TransitionArray_DifferentFieldNames) { |
| 151 CcTest::InitializeVM(); | 152 CcTest::InitializeVM(); |
| 152 v8::HandleScope scope(CcTest::isolate()); | 153 v8::HandleScope scope(CcTest::isolate()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 172 attributes, Representation::Tagged(), | 173 attributes, Representation::Tagged(), |
| 173 OMIT_TRANSITION).ToHandleChecked(); | 174 OMIT_TRANSITION).ToHandleChecked(); |
| 174 names[i] = name; | 175 names[i] = name; |
| 175 maps[i] = map; | 176 maps[i] = map; |
| 176 | 177 |
| 177 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 178 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); |
| 178 ConnectTransition(map0, transitions, map); | 179 ConnectTransition(map0, transitions, map); |
| 179 } | 180 } |
| 180 | 181 |
| 181 for (int i = 0; i < PROPS_COUNT; i++) { | 182 for (int i = 0; i < PROPS_COUNT; i++) { |
| 182 int transition = transitions->Search(DATA, *names[i], attributes); | 183 int transition = transitions->Search(kData, *names[i], attributes); |
| 183 CHECK_EQ(*names[i], transitions->GetKey(transition)); | 184 CHECK_EQ(*names[i], transitions->GetKey(transition)); |
| 184 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 185 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 DCHECK(transitions->IsSortedNoDuplicates()); | 188 DCHECK(transitions->IsSortedNoDuplicates()); |
| 188 } | 189 } |
| 189 | 190 |
| 190 | 191 |
| 191 TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { | 192 TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { |
| 192 CcTest::InitializeVM(); | 193 CcTest::InitializeVM(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 215 attr_maps[i] = map; | 216 attr_maps[i] = map; |
| 216 | 217 |
| 217 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 218 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); |
| 218 ConnectTransition(map0, transitions, map); | 219 ConnectTransition(map0, transitions, map); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // Ensure that transitions for |name| field are valid. | 222 // Ensure that transitions for |name| field are valid. |
| 222 for (int i = 0; i < ATTRS_COUNT; i++) { | 223 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 223 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 224 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); |
| 224 | 225 |
| 225 int transition = transitions->Search(DATA, *name, attributes); | 226 int transition = transitions->Search(kData, *name, attributes); |
| 226 CHECK_EQ(*name, transitions->GetKey(transition)); | 227 CHECK_EQ(*name, transitions->GetKey(transition)); |
| 227 CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 228 CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); |
| 228 } | 229 } |
| 229 | 230 |
| 230 DCHECK(transitions->IsSortedNoDuplicates()); | 231 DCHECK(transitions->IsSortedNoDuplicates()); |
| 231 } | 232 } |
| 232 | 233 |
| 233 | 234 |
| 234 TEST(TransitionArray_SameFieldNamesDifferentAttributes) { | 235 TEST(TransitionArray_SameFieldNamesDifferentAttributes) { |
| 235 CcTest::InitializeVM(); | 236 CcTest::InitializeVM(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 attr_maps[i] = map; | 279 attr_maps[i] = map; |
| 279 | 280 |
| 280 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 281 transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); |
| 281 ConnectTransition(map0, transitions, map); | 282 ConnectTransition(map0, transitions, map); |
| 282 } | 283 } |
| 283 | 284 |
| 284 // Ensure that transitions for |name| field are valid. | 285 // Ensure that transitions for |name| field are valid. |
| 285 for (int i = 0; i < ATTRS_COUNT; i++) { | 286 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 286 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 287 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); |
| 287 | 288 |
| 288 int transition = transitions->Search(DATA, *name, attributes); | 289 int transition = transitions->Search(kData, *name, attributes); |
| 289 CHECK_EQ(*name, transitions->GetKey(transition)); | 290 CHECK_EQ(*name, transitions->GetKey(transition)); |
| 290 CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 291 CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); |
| 291 } | 292 } |
| 292 | 293 |
| 293 // Ensure that info about the other fields still valid. | 294 // Ensure that info about the other fields still valid. |
| 294 for (int i = 0; i < PROPS_COUNT; i++) { | 295 for (int i = 0; i < PROPS_COUNT; i++) { |
| 295 int transition = transitions->Search(DATA, *names[i], NONE); | 296 int transition = transitions->Search(kData, *names[i], NONE); |
| 296 CHECK_EQ(*names[i], transitions->GetKey(transition)); | 297 CHECK_EQ(*names[i], transitions->GetKey(transition)); |
| 297 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 298 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); |
| 298 } | 299 } |
| 299 | 300 |
| 300 DCHECK(transitions->IsSortedNoDuplicates()); | 301 DCHECK(transitions->IsSortedNoDuplicates()); |
| 301 } | 302 } |
| OLD | NEW |