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 #ifndef V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | 5 #ifndef V8_COMPILER_ACCESS_INFO_H_ |
6 #define V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | 6 #define V8_COMPILER_ACCESS_INFO_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/field-index.h" | 10 #include "src/field-index.h" |
11 #include "src/objects.h" | 11 #include "src/objects.h" |
12 #include "src/zone-containers.h" | 12 #include "src/zone-containers.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // Forward declarations. | 17 // Forward declarations. |
18 class CompilationDependencies; | 18 class CompilationDependencies; |
19 class Factory; | 19 class Factory; |
20 class TypeCache; | 20 class TypeCache; |
21 | 21 |
22 | 22 |
23 namespace compiler { | 23 namespace compiler { |
24 | 24 |
25 // Whether we are loading a property or storing to a property. | 25 // Whether we are loading a property or storing to a property. |
26 enum class PropertyAccessMode { kLoad, kStore }; | 26 enum class AccessMode { kLoad, kStore }; |
27 | 27 |
28 std::ostream& operator<<(std::ostream&, PropertyAccessMode); | 28 std::ostream& operator<<(std::ostream&, AccessMode); |
| 29 |
| 30 |
| 31 // This class encapsulates all information required to access a certain element. |
| 32 class ElementAccessInfo final { |
| 33 public: |
| 34 ElementAccessInfo(); |
| 35 ElementAccessInfo(Type* receiver_type, ElementsKind elements_kind, |
| 36 MaybeHandle<JSObject> holder) |
| 37 : elements_kind_(elements_kind), |
| 38 holder_(holder), |
| 39 receiver_type_(receiver_type) {} |
| 40 |
| 41 MaybeHandle<JSObject> holder() const { return holder_; } |
| 42 ElementsKind elements_kind() const { return elements_kind_; } |
| 43 Type* receiver_type() const { return receiver_type_; } |
| 44 |
| 45 private: |
| 46 ElementsKind elements_kind_; |
| 47 MaybeHandle<JSObject> holder_; |
| 48 Type* receiver_type_; |
| 49 }; |
29 | 50 |
30 | 51 |
31 // This class encapsulates all information required to access a certain | 52 // This class encapsulates all information required to access a certain |
32 // object property, either on the object itself or on the prototype chain. | 53 // object property, either on the object itself or on the prototype chain. |
33 class PropertyAccessInfo final { | 54 class PropertyAccessInfo final { |
34 public: | 55 public: |
35 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; | 56 enum Kind { kInvalid, kNotFound, kDataConstant, kDataField }; |
36 | 57 |
37 static PropertyAccessInfo NotFound(Type* receiver_type, | 58 static PropertyAccessInfo NotFound(Type* receiver_type, |
38 MaybeHandle<JSObject> holder); | 59 MaybeHandle<JSObject> holder); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 Kind kind_; | 92 Kind kind_; |
72 Type* receiver_type_; | 93 Type* receiver_type_; |
73 Handle<Object> constant_; | 94 Handle<Object> constant_; |
74 MaybeHandle<Map> transition_map_; | 95 MaybeHandle<Map> transition_map_; |
75 MaybeHandle<JSObject> holder_; | 96 MaybeHandle<JSObject> holder_; |
76 FieldIndex field_index_; | 97 FieldIndex field_index_; |
77 Type* field_type_; | 98 Type* field_type_; |
78 }; | 99 }; |
79 | 100 |
80 | 101 |
81 // Factory class for {PropertyAccessInfo}s. | 102 // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s. |
82 class PropertyAccessInfoFactory final { | 103 class AccessInfoFactory final { |
83 public: | 104 public: |
84 PropertyAccessInfoFactory(CompilationDependencies* dependencies, | 105 AccessInfoFactory(CompilationDependencies* dependencies, |
85 Handle<Context> native_context, Zone* zone); | 106 Handle<Context> native_context, Zone* zone); |
86 | 107 |
| 108 bool ComputeElementAccessInfo(Handle<Map> map, AccessMode access_mode, |
| 109 ElementAccessInfo* access_info); |
| 110 bool ComputeElementAccessInfos(MapHandleList const& maps, |
| 111 AccessMode access_mode, |
| 112 ZoneVector<ElementAccessInfo>* access_infos); |
87 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name, | 113 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name, |
88 PropertyAccessMode access_mode, | 114 AccessMode access_mode, |
89 PropertyAccessInfo* access_info); | 115 PropertyAccessInfo* access_info); |
90 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name, | 116 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name, |
91 PropertyAccessMode access_mode, | 117 AccessMode access_mode, |
92 ZoneVector<PropertyAccessInfo>* access_infos); | 118 ZoneVector<PropertyAccessInfo>* access_infos); |
93 | 119 |
94 private: | 120 private: |
95 bool LookupSpecialFieldAccessor(Handle<Map> map, Handle<Name> name, | 121 bool LookupSpecialFieldAccessor(Handle<Map> map, Handle<Name> name, |
96 PropertyAccessInfo* access_info); | 122 PropertyAccessInfo* access_info); |
97 bool LookupTransition(Handle<Map> map, Handle<Name> name, | 123 bool LookupTransition(Handle<Map> map, Handle<Name> name, |
98 MaybeHandle<JSObject> holder, | 124 MaybeHandle<JSObject> holder, |
99 PropertyAccessInfo* access_info); | 125 PropertyAccessInfo* access_info); |
100 | 126 |
101 CompilationDependencies* dependencies() const { return dependencies_; } | 127 CompilationDependencies* dependencies() const { return dependencies_; } |
102 Factory* factory() const; | 128 Factory* factory() const; |
103 Isolate* isolate() const { return isolate_; } | 129 Isolate* isolate() const { return isolate_; } |
104 Handle<Context> native_context() const { return native_context_; } | 130 Handle<Context> native_context() const { return native_context_; } |
105 Zone* zone() const { return zone_; } | 131 Zone* zone() const { return zone_; } |
106 | 132 |
107 CompilationDependencies* const dependencies_; | 133 CompilationDependencies* const dependencies_; |
108 Handle<Context> const native_context_; | 134 Handle<Context> const native_context_; |
109 Isolate* const isolate_; | 135 Isolate* const isolate_; |
110 TypeCache const& type_cache_; | 136 TypeCache const& type_cache_; |
111 Zone* const zone_; | 137 Zone* const zone_; |
112 | 138 |
113 DISALLOW_COPY_AND_ASSIGN(PropertyAccessInfoFactory); | 139 DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory); |
114 }; | 140 }; |
115 | 141 |
116 } // namespace compiler | 142 } // namespace compiler |
117 } // namespace internal | 143 } // namespace internal |
118 } // namespace v8 | 144 } // namespace v8 |
119 | 145 |
120 #endif // V8_COMPILER_PROPERTY_ACCESS_INFO_H_ | 146 #endif // V8_COMPILER_ACCESS_INFO_H_ |
OLD | NEW |