| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/compiler/js-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/compilation-dependencies.h" | 8 #include "src/compilation-dependencies.h" |
| 9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // TODO(verwaest): Whitelist contexts to which we have access. | 306 // TODO(verwaest): Whitelist contexts to which we have access. |
| 307 !map->is_access_check_needed(); | 307 !map->is_access_check_needed(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace | 310 } // namespace |
| 311 | 311 |
| 312 | 312 |
| 313 bool JSNativeContextSpecialization::ComputePropertyAccessInfo( | 313 bool JSNativeContextSpecialization::ComputePropertyAccessInfo( |
| 314 Handle<Map> map, Handle<Name> name, PropertyAccessInfo* access_info) { | 314 Handle<Map> map, Handle<Name> name, PropertyAccessInfo* access_info) { |
| 315 MaybeHandle<JSObject> holder; | 315 MaybeHandle<JSObject> holder; |
| 316 Handle<Map> receiver_map = map; | 316 Type* receiver_type = Type::Class(map, graph()->zone()); |
| 317 Type* receiver_type = Type::Class(receiver_map, graph()->zone()); | |
| 318 while (CanInlinePropertyAccess(map)) { | 317 while (CanInlinePropertyAccess(map)) { |
| 319 // Check for special JSObject field accessors. | 318 // Check for special JSObject field accessors. |
| 320 int offset; | 319 int offset; |
| 321 if (Accessors::IsJSObjectFieldAccessor(map, name, &offset)) { | 320 if (Accessors::IsJSObjectFieldAccessor(map, name, &offset)) { |
| 322 FieldIndex field_index = FieldIndex::ForInObjectOffset(offset); | 321 FieldIndex field_index = FieldIndex::ForInObjectOffset(offset); |
| 323 Representation field_representation = Representation::Tagged(); | 322 Representation field_representation = Representation::Tagged(); |
| 324 Type* field_type = Type::Tagged(); | 323 Type* field_type = Type::Tagged(); |
| 325 if (receiver_type->Is(Type::String())) { | 324 if (map->IsStringMap()) { |
| 326 DCHECK(Name::Equals(factory()->length_string(), name)); | 325 DCHECK(Name::Equals(factory()->length_string(), name)); |
| 327 // The String::length property is always a smi in the range | 326 // The String::length property is always a smi in the range |
| 328 // [0, String::kMaxLength]. | 327 // [0, String::kMaxLength]. |
| 329 field_representation = Representation::Smi(); | 328 field_representation = Representation::Smi(); |
| 330 field_type = Type::Intersect( | 329 field_type = Type::Intersect( |
| 331 Type::Range(0.0, String::kMaxLength, graph()->zone()), | 330 Type::Range(0.0, String::kMaxLength, graph()->zone()), |
| 332 Type::TaggedSigned(), graph()->zone()); | 331 Type::TaggedSigned(), graph()->zone()); |
| 333 } else if (receiver_map->IsJSArrayMap()) { | 332 } else if (map->IsJSArrayMap()) { |
| 334 DCHECK(Name::Equals(factory()->length_string(), name)); | 333 DCHECK(Name::Equals(factory()->length_string(), name)); |
| 335 // The JSArray::length property is a smi in the range | 334 // The JSArray::length property is a smi in the range |
| 336 // [0, FixedDoubleArray::kMaxLength] in case of fast double | 335 // [0, FixedDoubleArray::kMaxLength] in case of fast double |
| 337 // elements, a smi in the range [0, FixedArray::kMaxLength] | 336 // elements, a smi in the range [0, FixedArray::kMaxLength] |
| 338 // in case of other fast elements, and [0, kMaxUInt32-1] in | 337 // in case of other fast elements, and [0, kMaxUInt32-1] in |
| 339 // case of other arrays. | 338 // case of other arrays. |
| 340 double field_type_upper = kMaxUInt32 - 1; | 339 double field_type_upper = kMaxUInt32 - 1; |
| 341 if (IsFastElementsKind(receiver_map->elements_kind())) { | 340 if (IsFastElementsKind(map->elements_kind())) { |
| 342 field_representation = Representation::Smi(); | 341 field_representation = Representation::Smi(); |
| 343 field_type_upper = | 342 field_type_upper = IsFastDoubleElementsKind(map->elements_kind()) |
| 344 IsFastDoubleElementsKind(receiver_map->elements_kind()) | 343 ? FixedDoubleArray::kMaxLength |
| 345 ? FixedDoubleArray::kMaxLength | 344 : FixedArray::kMaxLength; |
| 346 : FixedArray::kMaxLength; | |
| 347 } | 345 } |
| 348 field_type = | 346 field_type = |
| 349 Type::Intersect(Type::Range(0.0, field_type_upper, graph()->zone()), | 347 Type::Intersect(Type::Range(0.0, field_type_upper, graph()->zone()), |
| 350 Type::TaggedSigned(), graph()->zone()); | 348 Type::TaggedSigned(), graph()->zone()); |
| 351 } | 349 } |
| 352 *access_info = PropertyAccessInfo::Data( | 350 *access_info = PropertyAccessInfo::Data( |
| 353 receiver_type, field_index, field_representation, field_type, holder); | 351 receiver_type, field_index, field_representation, field_type, holder); |
| 354 return true; | 352 return true; |
| 355 } | 353 } |
| 356 | 354 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 } | 708 } |
| 711 | 709 |
| 712 | 710 |
| 713 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 711 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
| 714 return jsgraph()->simplified(); | 712 return jsgraph()->simplified(); |
| 715 } | 713 } |
| 716 | 714 |
| 717 } // namespace compiler | 715 } // namespace compiler |
| 718 } // namespace internal | 716 } // namespace internal |
| 719 } // namespace v8 | 717 } // namespace v8 |
| OLD | NEW |