| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | |
| 6 #define V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | |
| 7 | |
| 8 #include <iosfwd> | |
| 9 | |
| 10 #include "src/field-index.h" | |
| 11 #include "src/objects.h" | |
| 12 #include "src/zone-containers.h" | |
| 13 | |
| 14 namespace v8 { | |
| 15 namespace internal { | |
| 16 | |
| 17 // Forward declarations. | |
| 18 class CompilationDependencies; | |
| 19 class Factory; | |
| 20 class TypeCache; | |
| 21 | |
| 22 | |
| 23 namespace compiler { | |
| 24 | |
| 25 // Whether we are loading a property or storing to a property. | |
| 26 enum class PropertyAccessMode { kLoad, kStore }; | |
| 27 | |
| 28 std::ostream& operator<<(std::ostream&, PropertyAccessMode); | |
| 29 | |
| 30 | |
| 31 // This class encapsulates all information required to access a certain | |
| 32 // object property, either on the object itself or on the prototype chain. | |
| 33 class PropertyAccessInfo final { | |
| 34 public: | |
| 35 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; | |
| 36 | |
| 37 static PropertyAccessInfo NotFound(Type* receiver_type, | |
| 38 MaybeHandle<JSObject> holder); | |
| 39 static PropertyAccessInfo DataConstant(Type* receiver_type, | |
| 40 Handle<Object> constant, | |
| 41 MaybeHandle<JSObject> holder); | |
| 42 static PropertyAccessInfo DataField( | |
| 43 Type* receiver_type, FieldIndex field_index, Type* field_type, | |
| 44 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), | |
| 45 MaybeHandle<Map> transition_map = MaybeHandle<Map>()); | |
| 46 | |
| 47 PropertyAccessInfo(); | |
| 48 | |
| 49 bool IsNotFound() const { return kind() == kNotFound; } | |
| 50 bool IsDataConstant() const { return kind() == kDataConstant; } | |
| 51 bool IsDataField() const { return kind() == kDataField; } | |
| 52 | |
| 53 bool HasTransitionMap() const { return !transition_map().is_null(); } | |
| 54 | |
| 55 Kind kind() const { return kind_; } | |
| 56 MaybeHandle<JSObject> holder() const { return holder_; } | |
| 57 MaybeHandle<Map> transition_map() const { return transition_map_; } | |
| 58 Handle<Object> constant() const { return constant_; } | |
| 59 FieldIndex field_index() const { return field_index_; } | |
| 60 Type* field_type() const { return field_type_; } | |
| 61 Type* receiver_type() const { return receiver_type_; } | |
| 62 | |
| 63 private: | |
| 64 PropertyAccessInfo(MaybeHandle<JSObject> holder, Type* receiver_type); | |
| 65 PropertyAccessInfo(MaybeHandle<JSObject> holder, Handle<Object> constant, | |
| 66 Type* receiver_type); | |
| 67 PropertyAccessInfo(MaybeHandle<JSObject> holder, | |
| 68 MaybeHandle<Map> transition_map, FieldIndex field_index, | |
| 69 Type* field_type, Type* receiver_type); | |
| 70 | |
| 71 Kind kind_; | |
| 72 Type* receiver_type_; | |
| 73 Handle<Object> constant_; | |
| 74 MaybeHandle<Map> transition_map_; | |
| 75 MaybeHandle<JSObject> holder_; | |
| 76 FieldIndex field_index_; | |
| 77 Type* field_type_; | |
| 78 }; | |
| 79 | |
| 80 | |
| 81 // Factory class for {PropertyAccessInfo}s. | |
| 82 class PropertyAccessInfoFactory final { | |
| 83 public: | |
| 84 PropertyAccessInfoFactory(CompilationDependencies* dependencies, | |
| 85 Handle<Context> native_context, Zone* zone); | |
| 86 | |
| 87 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name, | |
| 88 PropertyAccessMode access_mode, | |
| 89 PropertyAccessInfo* access_info); | |
| 90 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name, | |
| 91 PropertyAccessMode access_mode, | |
| 92 ZoneVector<PropertyAccessInfo>* access_infos); | |
| 93 | |
| 94 private: | |
| 95 bool LookupSpecialFieldAccessor(Handle<Map> map, Handle<Name> name, | |
| 96 PropertyAccessInfo* access_info); | |
| 97 bool LookupTransition(Handle<Map> map, Handle<Name> name, | |
| 98 MaybeHandle<JSObject> holder, | |
| 99 PropertyAccessInfo* access_info); | |
| 100 | |
| 101 CompilationDependencies* dependencies() const { return dependencies_; } | |
| 102 Factory* factory() const; | |
| 103 Isolate* isolate() const { return isolate_; } | |
| 104 Handle<Context> native_context() const { return native_context_; } | |
| 105 Zone* zone() const { return zone_; } | |
| 106 | |
| 107 CompilationDependencies* const dependencies_; | |
| 108 Handle<Context> const native_context_; | |
| 109 Isolate* const isolate_; | |
| 110 TypeCache const& type_cache_; | |
| 111 Zone* const zone_; | |
| 112 | |
| 113 DISALLOW_COPY_AND_ASSIGN(PropertyAccessInfoFactory); | |
| 114 }; | |
| 115 | |
| 116 } // namespace compiler | |
| 117 } // namespace internal | |
| 118 } // namespace v8 | |
| 119 | |
| 120 #endif // V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | |
| OLD | NEW |