| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 52 | 52 | 
| 53   CHECK(!map0->HasTransitionArray()); | 53   CHECK(!map0->HasTransitionArray()); | 
| 54   Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 54   Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 
| 55   CHECK(transitions->IsFullTransitionArray()); | 55   CHECK(transitions->IsFullTransitionArray()); | 
| 56 | 56 | 
| 57   int transition; | 57   int transition; | 
| 58   transitions = | 58   transitions = | 
| 59       transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); | 59       transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); | 
| 60   ConnectTransition(map0, transitions, map1); | 60   ConnectTransition(map0, transitions, map1); | 
| 61   CHECK(transitions->IsSimpleTransition()); | 61   CHECK(transitions->IsSimpleTransition()); | 
| 62   transition = transitions->Search(FIELD, *name1, attributes); | 62   transition = transitions->Search(DATA, *name1, attributes); | 
| 63   CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition); | 63   CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition); | 
| 64   CHECK_EQ(*name1, transitions->GetKey(transition)); | 64   CHECK_EQ(*name1, transitions->GetKey(transition)); | 
| 65   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 65   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 
| 66 | 66 | 
| 67   transitions = | 67   transitions = | 
| 68       transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION); | 68       transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION); | 
| 69   ConnectTransition(map0, transitions, map2); | 69   ConnectTransition(map0, transitions, map2); | 
| 70   CHECK(transitions->IsFullTransitionArray()); | 70   CHECK(transitions->IsFullTransitionArray()); | 
| 71 | 71 | 
| 72   transition = transitions->Search(FIELD, *name1, attributes); | 72   transition = transitions->Search(DATA, *name1, attributes); | 
| 73   CHECK_EQ(*name1, transitions->GetKey(transition)); | 73   CHECK_EQ(*name1, transitions->GetKey(transition)); | 
| 74   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 74   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 
| 75 | 75 | 
| 76   transition = transitions->Search(FIELD, *name2, attributes); | 76   transition = transitions->Search(DATA, *name2, attributes); | 
| 77   CHECK_EQ(*name2, transitions->GetKey(transition)); | 77   CHECK_EQ(*name2, transitions->GetKey(transition)); | 
| 78   CHECK_EQ(*map2, transitions->GetTarget(transition)); | 78   CHECK_EQ(*map2, transitions->GetTarget(transition)); | 
| 79 | 79 | 
| 80   DCHECK(transitions->IsSortedNoDuplicates()); | 80   DCHECK(transitions->IsSortedNoDuplicates()); | 
| 81 } | 81 } | 
| 82 | 82 | 
| 83 | 83 | 
| 84 TEST(TransitionArray_FullFieldTransitions) { | 84 TEST(TransitionArray_FullFieldTransitions) { | 
| 85   CcTest::InitializeVM(); | 85   CcTest::InitializeVM(); | 
| 86   v8::HandleScope scope(CcTest::isolate()); | 86   v8::HandleScope scope(CcTest::isolate()); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 102                          OMIT_TRANSITION).ToHandleChecked(); | 102                          OMIT_TRANSITION).ToHandleChecked(); | 
| 103 | 103 | 
| 104   CHECK(!map0->HasTransitionArray()); | 104   CHECK(!map0->HasTransitionArray()); | 
| 105   Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 105   Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0); | 
| 106   CHECK(transitions->IsFullTransitionArray()); | 106   CHECK(transitions->IsFullTransitionArray()); | 
| 107 | 107 | 
| 108   int transition; | 108   int transition; | 
| 109   transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION); | 109   transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION); | 
| 110   ConnectTransition(map0, transitions, map1); | 110   ConnectTransition(map0, transitions, map1); | 
| 111   CHECK(transitions->IsFullTransitionArray()); | 111   CHECK(transitions->IsFullTransitionArray()); | 
| 112   transition = transitions->Search(FIELD, *name1, attributes); | 112   transition = transitions->Search(DATA, *name1, attributes); | 
| 113   CHECK_EQ(*name1, transitions->GetKey(transition)); | 113   CHECK_EQ(*name1, transitions->GetKey(transition)); | 
| 114   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 114   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 
| 115 | 115 | 
| 116   transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION); | 116   transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION); | 
| 117   ConnectTransition(map0, transitions, map2); | 117   ConnectTransition(map0, transitions, map2); | 
| 118   CHECK(transitions->IsFullTransitionArray()); | 118   CHECK(transitions->IsFullTransitionArray()); | 
| 119 | 119 | 
| 120   transition = transitions->Search(FIELD, *name1, attributes); | 120   transition = transitions->Search(DATA, *name1, attributes); | 
| 121   CHECK_EQ(*name1, transitions->GetKey(transition)); | 121   CHECK_EQ(*name1, transitions->GetKey(transition)); | 
| 122   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 122   CHECK_EQ(*map1, transitions->GetTarget(transition)); | 
| 123 | 123 | 
| 124   transition = transitions->Search(FIELD, *name2, attributes); | 124   transition = transitions->Search(DATA, *name2, attributes); | 
| 125   CHECK_EQ(*name2, transitions->GetKey(transition)); | 125   CHECK_EQ(*name2, transitions->GetKey(transition)); | 
| 126   CHECK_EQ(*map2, transitions->GetTarget(transition)); | 126   CHECK_EQ(*map2, transitions->GetTarget(transition)); | 
| 127 | 127 | 
| 128   DCHECK(transitions->IsSortedNoDuplicates()); | 128   DCHECK(transitions->IsSortedNoDuplicates()); | 
| 129 } | 129 } | 
| 130 | 130 | 
| 131 | 131 | 
| 132 TEST(TransitionArray_DifferentFieldNames) { | 132 TEST(TransitionArray_DifferentFieldNames) { | 
| 133   CcTest::InitializeVM(); | 133   CcTest::InitializeVM(); | 
| 134   v8::HandleScope scope(CcTest::isolate()); | 134   v8::HandleScope scope(CcTest::isolate()); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 154                            attributes, Representation::Tagged(), | 154                            attributes, Representation::Tagged(), | 
| 155                            OMIT_TRANSITION).ToHandleChecked(); | 155                            OMIT_TRANSITION).ToHandleChecked(); | 
| 156     names[i] = name; | 156     names[i] = name; | 
| 157     maps[i] = map; | 157     maps[i] = map; | 
| 158 | 158 | 
| 159     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 159     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 
| 160     ConnectTransition(map0, transitions, map); | 160     ConnectTransition(map0, transitions, map); | 
| 161   } | 161   } | 
| 162 | 162 | 
| 163   for (int i = 0; i < PROPS_COUNT; i++) { | 163   for (int i = 0; i < PROPS_COUNT; i++) { | 
| 164     int transition = transitions->Search(FIELD, *names[i], attributes); | 164     int transition = transitions->Search(DATA, *names[i], attributes); | 
| 165     CHECK_EQ(*names[i], transitions->GetKey(transition)); | 165     CHECK_EQ(*names[i], transitions->GetKey(transition)); | 
| 166     CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 166     CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 
| 167   } | 167   } | 
| 168 | 168 | 
| 169   DCHECK(transitions->IsSortedNoDuplicates()); | 169   DCHECK(transitions->IsSortedNoDuplicates()); | 
| 170 } | 170 } | 
| 171 | 171 | 
| 172 | 172 | 
| 173 TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { | 173 TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) { | 
| 174   CcTest::InitializeVM(); | 174   CcTest::InitializeVM(); | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 197     attr_maps[i] = map; | 197     attr_maps[i] = map; | 
| 198 | 198 | 
| 199     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 199     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 
| 200     ConnectTransition(map0, transitions, map); | 200     ConnectTransition(map0, transitions, map); | 
| 201   } | 201   } | 
| 202 | 202 | 
| 203   // Ensure that transitions for |name| field are valid. | 203   // Ensure that transitions for |name| field are valid. | 
| 204   for (int i = 0; i < ATTRS_COUNT; i++) { | 204   for (int i = 0; i < ATTRS_COUNT; i++) { | 
| 205     PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 205     PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 
| 206 | 206 | 
| 207     int transition = transitions->Search(FIELD, *name, attributes); | 207     int transition = transitions->Search(DATA, *name, attributes); | 
| 208     CHECK_EQ(*name, transitions->GetKey(transition)); | 208     CHECK_EQ(*name, transitions->GetKey(transition)); | 
| 209     CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 209     CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 
| 210   } | 210   } | 
| 211 | 211 | 
| 212   DCHECK(transitions->IsSortedNoDuplicates()); | 212   DCHECK(transitions->IsSortedNoDuplicates()); | 
| 213 } | 213 } | 
| 214 | 214 | 
| 215 | 215 | 
| 216 TEST(TransitionArray_SameFieldNamesDifferentAttributes) { | 216 TEST(TransitionArray_SameFieldNamesDifferentAttributes) { | 
| 217   CcTest::InitializeVM(); | 217   CcTest::InitializeVM(); | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 260     attr_maps[i] = map; | 260     attr_maps[i] = map; | 
| 261 | 261 | 
| 262     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 262     transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION); | 
| 263     ConnectTransition(map0, transitions, map); | 263     ConnectTransition(map0, transitions, map); | 
| 264   } | 264   } | 
| 265 | 265 | 
| 266   // Ensure that transitions for |name| field are valid. | 266   // Ensure that transitions for |name| field are valid. | 
| 267   for (int i = 0; i < ATTRS_COUNT; i++) { | 267   for (int i = 0; i < ATTRS_COUNT; i++) { | 
| 268     PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 268     PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 
| 269 | 269 | 
| 270     int transition = transitions->Search(FIELD, *name, attributes); | 270     int transition = transitions->Search(DATA, *name, attributes); | 
| 271     CHECK_EQ(*name, transitions->GetKey(transition)); | 271     CHECK_EQ(*name, transitions->GetKey(transition)); | 
| 272     CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 272     CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition)); | 
| 273   } | 273   } | 
| 274 | 274 | 
| 275   // Ensure that info about the other fields still valid. | 275   // Ensure that info about the other fields still valid. | 
| 276   for (int i = 0; i < PROPS_COUNT; i++) { | 276   for (int i = 0; i < PROPS_COUNT; i++) { | 
| 277     int transition = transitions->Search(FIELD, *names[i], NONE); | 277     int transition = transitions->Search(DATA, *names[i], NONE); | 
| 278     CHECK_EQ(*names[i], transitions->GetKey(transition)); | 278     CHECK_EQ(*names[i], transitions->GetKey(transition)); | 
| 279     CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 279     CHECK_EQ(*maps[i], transitions->GetTarget(transition)); | 
| 280   } | 280   } | 
| 281 | 281 | 
| 282   DCHECK(transitions->IsSortedNoDuplicates()); | 282   DCHECK(transitions->IsSortedNoDuplicates()); | 
| 283 } | 283 } | 
| OLD | NEW | 
|---|