| 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 20 matching lines...) Expand all Loading... |
| 31 Isolate* isolate = CcTest::i_isolate(); | 31 Isolate* isolate = CcTest::i_isolate(); |
| 32 Factory* factory = isolate->factory(); | 32 Factory* factory = isolate->factory(); |
| 33 | 33 |
| 34 Handle<String> name1 = factory->InternalizeUtf8String("foo"); | 34 Handle<String> name1 = factory->InternalizeUtf8String("foo"); |
| 35 Handle<String> name2 = factory->InternalizeUtf8String("bar"); | 35 Handle<String> name2 = factory->InternalizeUtf8String("bar"); |
| 36 PropertyAttributes attributes = NONE; | 36 PropertyAttributes attributes = NONE; |
| 37 | 37 |
| 38 Handle<Map> map0 = Map::Create(isolate, 0); | 38 Handle<Map> map0 = Map::Create(isolate, 0); |
| 39 Handle<Map> map1 = | 39 Handle<Map> map1 = |
| 40 Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), | 40 Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), |
| 41 attributes, Representation::Tagged(), OMIT_TRANSITION) | 41 attributes, kMutable, Representation::Tagged(), |
| 42 OMIT_TRANSITION) |
| 42 .ToHandleChecked(); | 43 .ToHandleChecked(); |
| 43 Handle<Map> map2 = | 44 Handle<Map> map2 = |
| 44 Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), | 45 Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), |
| 45 attributes, Representation::Tagged(), OMIT_TRANSITION) | 46 attributes, kMutable, Representation::Tagged(), |
| 47 OMIT_TRANSITION) |
| 46 .ToHandleChecked(); | 48 .ToHandleChecked(); |
| 47 | 49 |
| 48 CHECK(map0->raw_transitions()->IsSmi()); | 50 CHECK(map0->raw_transitions()->IsSmi()); |
| 49 | 51 |
| 50 TransitionArray::Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); | 52 TransitionArray::Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION); |
| 51 CHECK(TransitionArray::IsSimpleTransition(map0->raw_transitions())); | 53 CHECK(TransitionArray::IsSimpleTransition(map0->raw_transitions())); |
| 52 CHECK_EQ(*map1, | 54 CHECK_EQ(*map1, |
| 53 TransitionArray::SearchTransition(*map0, kData, *name1, attributes)); | 55 TransitionArray::SearchTransition(*map0, kData, *name1, attributes)); |
| 54 CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions())); | 56 CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions())); |
| 55 CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0)); | 57 CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 82 Isolate* isolate = CcTest::i_isolate(); | 84 Isolate* isolate = CcTest::i_isolate(); |
| 83 Factory* factory = isolate->factory(); | 85 Factory* factory = isolate->factory(); |
| 84 | 86 |
| 85 Handle<String> name1 = factory->InternalizeUtf8String("foo"); | 87 Handle<String> name1 = factory->InternalizeUtf8String("foo"); |
| 86 Handle<String> name2 = factory->InternalizeUtf8String("bar"); | 88 Handle<String> name2 = factory->InternalizeUtf8String("bar"); |
| 87 PropertyAttributes attributes = NONE; | 89 PropertyAttributes attributes = NONE; |
| 88 | 90 |
| 89 Handle<Map> map0 = Map::Create(isolate, 0); | 91 Handle<Map> map0 = Map::Create(isolate, 0); |
| 90 Handle<Map> map1 = | 92 Handle<Map> map1 = |
| 91 Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), | 93 Map::CopyWithField(map0, name1, handle(FieldType::Any(), isolate), |
| 92 attributes, Representation::Tagged(), OMIT_TRANSITION) | 94 attributes, kMutable, Representation::Tagged(), |
| 95 OMIT_TRANSITION) |
| 93 .ToHandleChecked(); | 96 .ToHandleChecked(); |
| 94 Handle<Map> map2 = | 97 Handle<Map> map2 = |
| 95 Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), | 98 Map::CopyWithField(map0, name2, handle(FieldType::Any(), isolate), |
| 96 attributes, Representation::Tagged(), OMIT_TRANSITION) | 99 attributes, kMutable, Representation::Tagged(), |
| 100 OMIT_TRANSITION) |
| 97 .ToHandleChecked(); | 101 .ToHandleChecked(); |
| 98 | 102 |
| 99 CHECK(map0->raw_transitions()->IsSmi()); | 103 CHECK(map0->raw_transitions()->IsSmi()); |
| 100 | 104 |
| 101 TransitionArray::Insert(map0, name1, map1, PROPERTY_TRANSITION); | 105 TransitionArray::Insert(map0, name1, map1, PROPERTY_TRANSITION); |
| 102 CHECK(TransitionArray::IsFullTransitionArray(map0->raw_transitions())); | 106 CHECK(TransitionArray::IsFullTransitionArray(map0->raw_transitions())); |
| 103 CHECK_EQ(*map1, | 107 CHECK_EQ(*map1, |
| 104 TransitionArray::SearchTransition(*map0, kData, *name1, attributes)); | 108 TransitionArray::SearchTransition(*map0, kData, *name1, attributes)); |
| 105 CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions())); | 109 CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions())); |
| 106 CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0)); | 110 CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 Handle<Map> maps[PROPS_COUNT]; | 142 Handle<Map> maps[PROPS_COUNT]; |
| 139 PropertyAttributes attributes = NONE; | 143 PropertyAttributes attributes = NONE; |
| 140 | 144 |
| 141 Handle<Map> map0 = Map::Create(isolate, 0); | 145 Handle<Map> map0 = Map::Create(isolate, 0); |
| 142 CHECK(map0->raw_transitions()->IsSmi()); | 146 CHECK(map0->raw_transitions()->IsSmi()); |
| 143 | 147 |
| 144 for (int i = 0; i < PROPS_COUNT; i++) { | 148 for (int i = 0; i < PROPS_COUNT; i++) { |
| 145 EmbeddedVector<char, 64> buffer; | 149 EmbeddedVector<char, 64> buffer; |
| 146 SNPrintF(buffer, "prop%d", i); | 150 SNPrintF(buffer, "prop%d", i); |
| 147 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); | 151 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); |
| 148 Handle<Map> map = Map::CopyWithField( | 152 Handle<Map> map = |
| 149 map0, name, handle(FieldType::Any(), isolate), | 153 Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), |
| 150 attributes, Representation::Tagged(), OMIT_TRANSITION) | 154 attributes, kMutable, Representation::Tagged(), |
| 151 .ToHandleChecked(); | 155 OMIT_TRANSITION) |
| 156 .ToHandleChecked(); |
| 152 names[i] = name; | 157 names[i] = name; |
| 153 maps[i] = map; | 158 maps[i] = map; |
| 154 | 159 |
| 155 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); | 160 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); |
| 156 } | 161 } |
| 157 | 162 |
| 158 for (int i = 0; i < PROPS_COUNT; i++) { | 163 for (int i = 0; i < PROPS_COUNT; i++) { |
| 159 CHECK_EQ(*maps[i], TransitionArray::SearchTransition( | 164 CHECK_EQ(*maps[i], TransitionArray::SearchTransition( |
| 160 *map0, kData, *names[i], attributes)); | 165 *map0, kData, *names[i], attributes)); |
| 161 } | 166 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 187 | 192 |
| 188 const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1; | 193 const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1; |
| 189 STATIC_ASSERT(ATTRS_COUNT == 8); | 194 STATIC_ASSERT(ATTRS_COUNT == 8); |
| 190 Handle<Map> attr_maps[ATTRS_COUNT]; | 195 Handle<Map> attr_maps[ATTRS_COUNT]; |
| 191 Handle<String> name = factory->InternalizeUtf8String("foo"); | 196 Handle<String> name = factory->InternalizeUtf8String("foo"); |
| 192 | 197 |
| 193 // Add transitions for same field name but different attributes. | 198 // Add transitions for same field name but different attributes. |
| 194 for (int i = 0; i < ATTRS_COUNT; i++) { | 199 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 195 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 200 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); |
| 196 | 201 |
| 197 Handle<Map> map = Map::CopyWithField( | 202 Handle<Map> map = |
| 198 map0, name, handle(FieldType::Any(), isolate), | 203 Map::CopyWithField(map0, name, FieldType::Any(isolate), attributes, |
| 199 attributes, Representation::Tagged(), OMIT_TRANSITION) | 204 kMutable, Representation::Tagged(), OMIT_TRANSITION) |
| 200 .ToHandleChecked(); | 205 .ToHandleChecked(); |
| 201 attr_maps[i] = map; | 206 attr_maps[i] = map; |
| 202 | 207 |
| 203 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); | 208 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); |
| 204 } | 209 } |
| 205 | 210 |
| 206 // Ensure that transitions for |name| field are valid. | 211 // Ensure that transitions for |name| field are valid. |
| 207 for (int i = 0; i < ATTRS_COUNT; i++) { | 212 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 208 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 213 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); |
| 209 CHECK_EQ(*attr_maps[i], TransitionArray::SearchTransition( | 214 CHECK_EQ(*attr_maps[i], TransitionArray::SearchTransition( |
| 210 *map0, kData, *name, attributes)); | 215 *map0, kData, *name, attributes)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 232 Handle<Map> map0 = Map::Create(isolate, 0); | 237 Handle<Map> map0 = Map::Create(isolate, 0); |
| 233 CHECK(map0->raw_transitions()->IsSmi()); | 238 CHECK(map0->raw_transitions()->IsSmi()); |
| 234 | 239 |
| 235 // Some number of fields. | 240 // Some number of fields. |
| 236 for (int i = 0; i < PROPS_COUNT; i++) { | 241 for (int i = 0; i < PROPS_COUNT; i++) { |
| 237 EmbeddedVector<char, 64> buffer; | 242 EmbeddedVector<char, 64> buffer; |
| 238 SNPrintF(buffer, "prop%d", i); | 243 SNPrintF(buffer, "prop%d", i); |
| 239 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); | 244 Handle<String> name = factory->InternalizeUtf8String(buffer.start()); |
| 240 Handle<Map> map = | 245 Handle<Map> map = |
| 241 Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), NONE, | 246 Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), NONE, |
| 242 Representation::Tagged(), OMIT_TRANSITION) | 247 kMutable, Representation::Tagged(), OMIT_TRANSITION) |
| 243 .ToHandleChecked(); | 248 .ToHandleChecked(); |
| 244 names[i] = name; | 249 names[i] = name; |
| 245 maps[i] = map; | 250 maps[i] = map; |
| 246 | 251 |
| 247 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); | 252 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); |
| 248 } | 253 } |
| 249 | 254 |
| 250 const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1; | 255 const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1; |
| 251 STATIC_ASSERT(ATTRS_COUNT == 8); | 256 STATIC_ASSERT(ATTRS_COUNT == 8); |
| 252 Handle<Map> attr_maps[ATTRS_COUNT]; | 257 Handle<Map> attr_maps[ATTRS_COUNT]; |
| 253 Handle<String> name = factory->InternalizeUtf8String("foo"); | 258 Handle<String> name = factory->InternalizeUtf8String("foo"); |
| 254 | 259 |
| 255 // Add transitions for same field name but different attributes. | 260 // Add transitions for same field name but different attributes. |
| 256 for (int i = 0; i < ATTRS_COUNT; i++) { | 261 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 257 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); | 262 PropertyAttributes attributes = static_cast<PropertyAttributes>(i); |
| 258 | 263 |
| 259 Handle<Map> map = Map::CopyWithField( | 264 Handle<Map> map = |
| 260 map0, name, handle(FieldType::Any(), isolate), | 265 Map::CopyWithField(map0, name, handle(FieldType::Any(), isolate), |
| 261 attributes, Representation::Tagged(), OMIT_TRANSITION) | 266 attributes, kMutable, Representation::Tagged(), |
| 262 .ToHandleChecked(); | 267 OMIT_TRANSITION) |
| 268 .ToHandleChecked(); |
| 263 attr_maps[i] = map; | 269 attr_maps[i] = map; |
| 264 | 270 |
| 265 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); | 271 TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION); |
| 266 } | 272 } |
| 267 | 273 |
| 268 // Ensure that transitions for |name| field are valid. | 274 // Ensure that transitions for |name| field are valid. |
| 269 for (int i = 0; i < ATTRS_COUNT; i++) { | 275 for (int i = 0; i < ATTRS_COUNT; i++) { |
| 270 PropertyAttributes attr = static_cast<PropertyAttributes>(i); | 276 PropertyAttributes attr = static_cast<PropertyAttributes>(i); |
| 271 CHECK_EQ(*attr_maps[i], | 277 CHECK_EQ(*attr_maps[i], |
| 272 TransitionArray::SearchTransition(*map0, kData, *name, attr)); | 278 TransitionArray::SearchTransition(*map0, kData, *name, attr)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 290 break; | 296 break; |
| 291 } | 297 } |
| 292 } | 298 } |
| 293 } | 299 } |
| 294 } | 300 } |
| 295 | 301 |
| 296 #ifdef DEBUG | 302 #ifdef DEBUG |
| 297 CHECK(TransitionArray::IsSortedNoDuplicates(*map0)); | 303 CHECK(TransitionArray::IsSortedNoDuplicates(*map0)); |
| 298 #endif | 304 #endif |
| 299 } | 305 } |
| OLD | NEW |