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 12 matching lines...) Expand all Loading... |
23 static void ConnectTransition(Handle<Map> parent, | 23 static void ConnectTransition(Handle<Map> parent, |
24 Handle<TransitionArray> transitions, | 24 Handle<TransitionArray> transitions, |
25 Handle<Map> child) { | 25 Handle<Map> child) { |
26 if (!parent->HasTransitionArray() || *transitions != parent->transitions()) { | 26 if (!parent->HasTransitionArray() || *transitions != parent->transitions()) { |
27 parent->set_transitions(*transitions); | 27 parent->set_transitions(*transitions); |
28 } | 28 } |
29 child->SetBackPointer(*parent); | 29 child->SetBackPointer(*parent); |
30 } | 30 } |
31 | 31 |
32 | 32 |
| 33 static void CheckPropertyDetailsFieldsConsistency(PropertyType type, |
| 34 PropertyKind kind, |
| 35 PropertyLocation location) { |
| 36 int type_value = PropertyDetails::TypeField::encode(type); |
| 37 int kind_location_value = PropertyDetails::KindField::encode(kind) | |
| 38 PropertyDetails::LocationField::encode(location); |
| 39 CHECK_EQ(type_value, kind_location_value); |
| 40 } |
| 41 |
| 42 |
| 43 TEST(PropertyDetailsFieldsConsistency) { |
| 44 CheckPropertyDetailsFieldsConsistency(FIELD, DATA, IN_OBJECT); |
| 45 CheckPropertyDetailsFieldsConsistency(CONSTANT, DATA, IN_DESCRIPTOR); |
| 46 CheckPropertyDetailsFieldsConsistency(ACCESSOR_FIELD, ACCESSOR, IN_OBJECT); |
| 47 CheckPropertyDetailsFieldsConsistency(CALLBACKS, ACCESSOR, IN_DESCRIPTOR); |
| 48 } |
| 49 |
| 50 |
33 TEST(TransitionArray_SimpleFieldTransitions) { | 51 TEST(TransitionArray_SimpleFieldTransitions) { |
34 CcTest::InitializeVM(); | 52 CcTest::InitializeVM(); |
35 v8::HandleScope scope(CcTest::isolate()); | 53 v8::HandleScope scope(CcTest::isolate()); |
36 Isolate* isolate = CcTest::i_isolate(); | 54 Isolate* isolate = CcTest::i_isolate(); |
37 Factory* factory = isolate->factory(); | 55 Factory* factory = isolate->factory(); |
38 | 56 |
39 Handle<String> name1 = factory->InternalizeUtf8String("foo"); | 57 Handle<String> name1 = factory->InternalizeUtf8String("foo"); |
40 Handle<String> name2 = factory->InternalizeUtf8String("bar"); | 58 Handle<String> name2 = factory->InternalizeUtf8String("bar"); |
41 PropertyAttributes attributes = NONE; | 59 PropertyAttributes attributes = NONE; |
42 | 60 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 292 |
275 // Ensure that info about the other fields still valid. | 293 // Ensure that info about the other fields still valid. |
276 for (int i = 0; i < PROPS_COUNT; i++) { | 294 for (int i = 0; i < PROPS_COUNT; i++) { |
277 int transition = transitions->Search(DATA, *names[i], NONE); | 295 int transition = transitions->Search(DATA, *names[i], NONE); |
278 CHECK_EQ(*names[i], transitions->GetKey(transition)); | 296 CHECK_EQ(*names[i], transitions->GetKey(transition)); |
279 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 297 CHECK_EQ(*maps[i], transitions->GetTarget(transition)); |
280 } | 298 } |
281 | 299 |
282 DCHECK(transitions->IsSortedNoDuplicates()); | 300 DCHECK(transitions->IsSortedNoDuplicates()); |
283 } | 301 } |
OLD | NEW |