Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: src/compiler/access-info.h

Issue 2809923002: Unify implementations of Map handles vectors and lists (Closed)
Patch Set: Review feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.cc ('k') | src/compiler/access-info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ACCESS_INFO_H_ 5 #ifndef V8_COMPILER_ACCESS_INFO_H_
6 #define V8_COMPILER_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"
(...skipping 13 matching lines...) Expand all
24 // Forward declarations. 24 // Forward declarations.
25 class Type; 25 class Type;
26 class TypeCache; 26 class TypeCache;
27 27
28 // Whether we are loading a property or storing to a property. 28 // Whether we are loading a property or storing to a property.
29 // For a store during literal creation, do not walk up the prototype chain. 29 // For a store during literal creation, do not walk up the prototype chain.
30 enum class AccessMode { kLoad, kStore, kStoreInLiteral }; 30 enum class AccessMode { kLoad, kStore, kStoreInLiteral };
31 31
32 std::ostream& operator<<(std::ostream&, AccessMode); 32 std::ostream& operator<<(std::ostream&, AccessMode);
33 33
34 typedef std::vector<Handle<Map>> MapList;
35
36 // Mapping of transition source to transition target. 34 // Mapping of transition source to transition target.
37 typedef std::vector<std::pair<Handle<Map>, Handle<Map>>> MapTransitionList; 35 typedef std::vector<std::pair<Handle<Map>, Handle<Map>>> MapTransitionList;
38 36
39 // This class encapsulates all information required to access a certain element. 37 // This class encapsulates all information required to access a certain element.
40 class ElementAccessInfo final { 38 class ElementAccessInfo final {
41 public: 39 public:
42 ElementAccessInfo(); 40 ElementAccessInfo();
43 ElementAccessInfo(MapList const& receiver_maps, ElementsKind elements_kind); 41 ElementAccessInfo(MapHandles const& receiver_maps,
42 ElementsKind elements_kind);
44 43
45 ElementsKind elements_kind() const { return elements_kind_; } 44 ElementsKind elements_kind() const { return elements_kind_; }
46 MapList const& receiver_maps() const { return receiver_maps_; } 45 MapHandles const& receiver_maps() const { return receiver_maps_; }
47 MapTransitionList& transitions() { return transitions_; } 46 MapTransitionList& transitions() { return transitions_; }
48 MapTransitionList const& transitions() const { return transitions_; } 47 MapTransitionList const& transitions() const { return transitions_; }
49 48
50 private: 49 private:
51 ElementsKind elements_kind_; 50 ElementsKind elements_kind_;
52 MapList receiver_maps_; 51 MapHandles receiver_maps_;
53 MapTransitionList transitions_; 52 MapTransitionList transitions_;
54 }; 53 };
55 54
56 // This class encapsulates all information required to access a certain 55 // This class encapsulates all information required to access a certain
57 // object property, either on the object itself or on the prototype chain. 56 // object property, either on the object itself or on the prototype chain.
58 class PropertyAccessInfo final { 57 class PropertyAccessInfo final {
59 public: 58 public:
60 enum Kind { 59 enum Kind {
61 kInvalid, 60 kInvalid,
62 kNotFound, 61 kNotFound,
63 kDataConstant, 62 kDataConstant,
64 kDataField, 63 kDataField,
65 kDataConstantField, 64 kDataConstantField,
66 kAccessorConstant 65 kAccessorConstant
67 }; 66 };
68 67
69 static PropertyAccessInfo NotFound(MapList const& receiver_maps, 68 static PropertyAccessInfo NotFound(MapHandles const& receiver_maps,
70 MaybeHandle<JSObject> holder); 69 MaybeHandle<JSObject> holder);
71 static PropertyAccessInfo DataConstant(MapList const& receiver_maps, 70 static PropertyAccessInfo DataConstant(MapHandles const& receiver_maps,
72 Handle<Object> constant, 71 Handle<Object> constant,
73 MaybeHandle<JSObject> holder); 72 MaybeHandle<JSObject> holder);
74 static PropertyAccessInfo DataField( 73 static PropertyAccessInfo DataField(
75 PropertyConstness constness, MapList const& receiver_maps, 74 PropertyConstness constness, MapHandles const& receiver_maps,
76 FieldIndex field_index, MachineRepresentation field_representation, 75 FieldIndex field_index, MachineRepresentation field_representation,
77 Type* field_type, MaybeHandle<Map> field_map = MaybeHandle<Map>(), 76 Type* field_type, MaybeHandle<Map> field_map = MaybeHandle<Map>(),
78 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(), 77 MaybeHandle<JSObject> holder = MaybeHandle<JSObject>(),
79 MaybeHandle<Map> transition_map = MaybeHandle<Map>()); 78 MaybeHandle<Map> transition_map = MaybeHandle<Map>());
80 static PropertyAccessInfo AccessorConstant(MapList const& receiver_maps, 79 static PropertyAccessInfo AccessorConstant(MapHandles const& receiver_maps,
81 Handle<Object> constant, 80 Handle<Object> constant,
82 MaybeHandle<JSObject> holder); 81 MaybeHandle<JSObject> holder);
83 82
84 PropertyAccessInfo(); 83 PropertyAccessInfo();
85 84
86 bool Merge(PropertyAccessInfo const* that, AccessMode access_mode, 85 bool Merge(PropertyAccessInfo const* that, AccessMode access_mode,
87 Zone* zone) WARN_UNUSED_RESULT; 86 Zone* zone) WARN_UNUSED_RESULT;
88 87
89 bool IsNotFound() const { return kind() == kNotFound; } 88 bool IsNotFound() const { return kind() == kNotFound; }
90 bool IsDataConstant() const { return kind() == kDataConstant; } 89 bool IsDataConstant() const { return kind() == kDataConstant; }
91 bool IsDataField() const { return kind() == kDataField; } 90 bool IsDataField() const { return kind() == kDataField; }
92 // TODO(ishell): rename to IsDataConstant() once constant field tracking 91 // TODO(ishell): rename to IsDataConstant() once constant field tracking
93 // is done. 92 // is done.
94 bool IsDataConstantField() const { return kind() == kDataConstantField; } 93 bool IsDataConstantField() const { return kind() == kDataConstantField; }
95 bool IsAccessorConstant() const { return kind() == kAccessorConstant; } 94 bool IsAccessorConstant() const { return kind() == kAccessorConstant; }
96 95
97 bool HasTransitionMap() const { return !transition_map().is_null(); } 96 bool HasTransitionMap() const { return !transition_map().is_null(); }
98 97
99 Kind kind() const { return kind_; } 98 Kind kind() const { return kind_; }
100 MaybeHandle<JSObject> holder() const { return holder_; } 99 MaybeHandle<JSObject> holder() const { return holder_; }
101 MaybeHandle<Map> transition_map() const { return transition_map_; } 100 MaybeHandle<Map> transition_map() const { return transition_map_; }
102 Handle<Object> constant() const { return constant_; } 101 Handle<Object> constant() const { return constant_; }
103 FieldIndex field_index() const { return field_index_; } 102 FieldIndex field_index() const { return field_index_; }
104 Type* field_type() const { return field_type_; } 103 Type* field_type() const { return field_type_; }
105 MachineRepresentation field_representation() const { 104 MachineRepresentation field_representation() const {
106 return field_representation_; 105 return field_representation_;
107 } 106 }
108 MaybeHandle<Map> field_map() const { return field_map_; } 107 MaybeHandle<Map> field_map() const { return field_map_; }
109 MapList const& receiver_maps() const { return receiver_maps_; } 108 MapHandles const& receiver_maps() const { return receiver_maps_; }
110 109
111 private: 110 private:
112 PropertyAccessInfo(MaybeHandle<JSObject> holder, 111 PropertyAccessInfo(MaybeHandle<JSObject> holder,
113 MapList const& receiver_maps); 112 MapHandles const& receiver_maps);
114 PropertyAccessInfo(Kind kind, MaybeHandle<JSObject> holder, 113 PropertyAccessInfo(Kind kind, MaybeHandle<JSObject> holder,
115 Handle<Object> constant, MapList const& receiver_maps); 114 Handle<Object> constant, MapHandles const& receiver_maps);
116 PropertyAccessInfo(Kind kind, MaybeHandle<JSObject> holder, 115 PropertyAccessInfo(Kind kind, MaybeHandle<JSObject> holder,
117 MaybeHandle<Map> transition_map, FieldIndex field_index, 116 MaybeHandle<Map> transition_map, FieldIndex field_index,
118 MachineRepresentation field_representation, 117 MachineRepresentation field_representation,
119 Type* field_type, MaybeHandle<Map> field_map, 118 Type* field_type, MaybeHandle<Map> field_map,
120 MapList const& receiver_maps); 119 MapHandles const& receiver_maps);
121 120
122 Kind kind_; 121 Kind kind_;
123 MapList receiver_maps_; 122 MapHandles receiver_maps_;
124 Handle<Object> constant_; 123 Handle<Object> constant_;
125 MaybeHandle<Map> transition_map_; 124 MaybeHandle<Map> transition_map_;
126 MaybeHandle<JSObject> holder_; 125 MaybeHandle<JSObject> holder_;
127 FieldIndex field_index_; 126 FieldIndex field_index_;
128 MachineRepresentation field_representation_; 127 MachineRepresentation field_representation_;
129 Type* field_type_; 128 Type* field_type_;
130 MaybeHandle<Map> field_map_; 129 MaybeHandle<Map> field_map_;
131 }; 130 };
132 131
133 132
134 // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s. 133 // Factory class for {ElementAccessInfo}s and {PropertyAccessInfo}s.
135 class AccessInfoFactory final { 134 class AccessInfoFactory final {
136 public: 135 public:
137 AccessInfoFactory(CompilationDependencies* dependencies, 136 AccessInfoFactory(CompilationDependencies* dependencies,
138 Handle<Context> native_context, Zone* zone); 137 Handle<Context> native_context, Zone* zone);
139 138
140 bool ComputeElementAccessInfo(Handle<Map> map, AccessMode access_mode, 139 bool ComputeElementAccessInfo(Handle<Map> map, AccessMode access_mode,
141 ElementAccessInfo* access_info); 140 ElementAccessInfo* access_info);
142 bool ComputeElementAccessInfos(MapHandleList const& maps, 141 bool ComputeElementAccessInfos(MapHandles const& maps, AccessMode access_mode,
143 AccessMode access_mode,
144 ZoneVector<ElementAccessInfo>* access_infos); 142 ZoneVector<ElementAccessInfo>* access_infos);
145 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name, 143 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name,
146 AccessMode access_mode, 144 AccessMode access_mode,
147 PropertyAccessInfo* access_info); 145 PropertyAccessInfo* access_info);
148 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name, 146 bool ComputePropertyAccessInfos(MapHandles const& maps, Handle<Name> name,
149 AccessMode access_mode, 147 AccessMode access_mode,
150 ZoneVector<PropertyAccessInfo>* access_infos); 148 ZoneVector<PropertyAccessInfo>* access_infos);
151 149
152 private: 150 private:
153 bool ConsolidateElementLoad(MapHandleList const& maps, 151 bool ConsolidateElementLoad(MapHandles const& maps,
154 ElementAccessInfo* access_info); 152 ElementAccessInfo* access_info);
155 bool LookupSpecialFieldAccessor(Handle<Map> map, Handle<Name> name, 153 bool LookupSpecialFieldAccessor(Handle<Map> map, Handle<Name> name,
156 PropertyAccessInfo* access_info); 154 PropertyAccessInfo* access_info);
157 bool LookupTransition(Handle<Map> map, Handle<Name> name, 155 bool LookupTransition(Handle<Map> map, Handle<Name> name,
158 MaybeHandle<JSObject> holder, 156 MaybeHandle<JSObject> holder,
159 PropertyAccessInfo* access_info); 157 PropertyAccessInfo* access_info);
160 158
161 CompilationDependencies* dependencies() const { return dependencies_; } 159 CompilationDependencies* dependencies() const { return dependencies_; }
162 Factory* factory() const; 160 Factory* factory() const;
163 Isolate* isolate() const { return isolate_; } 161 Isolate* isolate() const { return isolate_; }
164 Handle<Context> native_context() const { return native_context_; } 162 Handle<Context> native_context() const { return native_context_; }
165 Zone* zone() const { return zone_; } 163 Zone* zone() const { return zone_; }
166 164
167 CompilationDependencies* const dependencies_; 165 CompilationDependencies* const dependencies_;
168 Handle<Context> const native_context_; 166 Handle<Context> const native_context_;
169 Isolate* const isolate_; 167 Isolate* const isolate_;
170 TypeCache const& type_cache_; 168 TypeCache const& type_cache_;
171 Zone* const zone_; 169 Zone* const zone_;
172 170
173 DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory); 171 DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory);
174 }; 172 };
175 173
176 } // namespace compiler 174 } // namespace compiler
177 } // namespace internal 175 } // namespace internal
178 } // namespace v8 176 } // namespace v8
179 177
180 #endif // V8_COMPILER_ACCESS_INFO_H_ 178 #endif // V8_COMPILER_ACCESS_INFO_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/compiler/access-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698