OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 V(TrueValue, True) \ | 39 V(TrueValue, True) \ |
40 V(UndefinedValue, Undefined) | 40 V(UndefinedValue, Undefined) |
41 | 41 |
42 // Provides JavaScript-specific "macro-assembler" functionality on top of the | 42 // Provides JavaScript-specific "macro-assembler" functionality on top of the |
43 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, | 43 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |
44 // it's possible to add JavaScript-specific useful CodeAssembler "macros" | 44 // it's possible to add JavaScript-specific useful CodeAssembler "macros" |
45 // without modifying files in the compiler directory (and requiring a review | 45 // without modifying files in the compiler directory (and requiring a review |
46 // from a compiler directory OWNER). | 46 // from a compiler directory OWNER). |
47 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { | 47 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { |
48 public: | 48 public: |
49 typedef compiler::Node Node; | |
50 | |
51 CodeStubAssembler(compiler::CodeAssemblerState* state) | 49 CodeStubAssembler(compiler::CodeAssemblerState* state) |
52 : compiler::CodeAssembler(state) {} | 50 : compiler::CodeAssembler(state) {} |
53 | 51 |
54 enum AllocationFlag : uint8_t { | 52 enum AllocationFlag : uint8_t { |
55 kNone = 0, | 53 kNone = 0, |
56 kDoubleAlignment = 1, | 54 kDoubleAlignment = 1, |
57 kPretenured = 1 << 1 | 55 kPretenured = 1 << 1 |
58 }; | 56 }; |
59 | 57 |
60 typedef base::Flags<AllocationFlag> AllocationFlags; | 58 typedef base::Flags<AllocationFlag> AllocationFlags; |
61 | 59 |
62 // TODO(ishell): Fix all loads/stores from arrays by int32 offsets/indices | 60 // TODO(ishell): Fix all loads/stores from arrays by int32 offsets/indices |
63 // and eventually remove INTEGER_PARAMETERS in favour of INTPTR_PARAMETERS. | 61 // and eventually remove INTEGER_PARAMETERS in favour of INTPTR_PARAMETERS. |
64 enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS, INTPTR_PARAMETERS }; | 62 enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS, INTPTR_PARAMETERS }; |
65 | 63 |
66 // On 32-bit platforms, there is a slight performance advantage to doing all | 64 // On 32-bit platforms, there is a slight performance advantage to doing all |
67 // of the array offset/index arithmetic with SMIs, since it's possible | 65 // of the array offset/index arithmetic with SMIs, since it's possible |
68 // to save a few tag/untag operations without paying an extra expense when | 66 // to save a few tag/untag operations without paying an extra expense when |
69 // calculating array offset (the smi math can be folded away) and there are | 67 // calculating array offset (the smi math can be folded away) and there are |
70 // fewer live ranges. Thus only convert indices to untagged value on 64-bit | 68 // fewer live ranges. Thus only convert indices to untagged value on 64-bit |
71 // platforms. | 69 // platforms. |
72 ParameterMode OptimalParameterMode() const { | 70 ParameterMode OptimalParameterMode() const { |
73 return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS; | 71 return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS; |
74 } | 72 } |
75 | 73 |
76 Node* UntagParameter(Node* value, ParameterMode mode) { | 74 compiler::Node* UntagParameter(compiler::Node* value, ParameterMode mode) { |
77 if (mode != SMI_PARAMETERS) value = SmiUntag(value); | 75 if (mode != SMI_PARAMETERS) value = SmiUntag(value); |
78 return value; | 76 return value; |
79 } | 77 } |
80 | 78 |
81 Node* TagParameter(Node* value, ParameterMode mode) { | 79 compiler::Node* TagParameter(compiler::Node* value, ParameterMode mode) { |
82 if (mode != SMI_PARAMETERS) value = SmiTag(value); | 80 if (mode != SMI_PARAMETERS) value = SmiTag(value); |
83 return value; | 81 return value; |
84 } | 82 } |
85 | 83 |
86 Node* NoContextConstant(); | 84 compiler::Node* NoContextConstant(); |
87 #define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant(); | 85 #define HEAP_CONSTANT_ACCESSOR(rootName, name) compiler::Node* name##Constant(); |
88 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR) | 86 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR) |
89 #undef HEAP_CONSTANT_ACCESSOR | 87 #undef HEAP_CONSTANT_ACCESSOR |
90 | 88 |
91 #define HEAP_CONSTANT_TEST(rootName, name) Node* Is##name(Node* value); | 89 #define HEAP_CONSTANT_TEST(rootName, name) \ |
| 90 compiler::Node* Is##name(compiler::Node* value); |
92 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) | 91 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) |
93 #undef HEAP_CONSTANT_TEST | 92 #undef HEAP_CONSTANT_TEST |
94 | 93 |
95 Node* HashSeed(); | 94 compiler::Node* HashSeed(); |
96 Node* StaleRegisterConstant(); | 95 compiler::Node* StaleRegisterConstant(); |
97 | 96 |
98 Node* IntPtrOrSmiConstant(int value, ParameterMode mode); | 97 compiler::Node* IntPtrOrSmiConstant(int value, ParameterMode mode); |
99 | 98 |
100 Node* IntPtrAddFoldConstants(Node* left, Node* right); | 99 compiler::Node* IntPtrAddFoldConstants(compiler::Node* left, |
101 Node* IntPtrSubFoldConstants(Node* left, Node* right); | 100 compiler::Node* right); |
| 101 compiler::Node* IntPtrSubFoldConstants(compiler::Node* left, |
| 102 compiler::Node* right); |
102 // Round the 32bits payload of the provided word up to the next power of two. | 103 // Round the 32bits payload of the provided word up to the next power of two. |
103 Node* IntPtrRoundUpToPowerOfTwo32(Node* value); | 104 compiler::Node* IntPtrRoundUpToPowerOfTwo32(compiler::Node* value); |
104 Node* IntPtrMax(Node* left, Node* right); | 105 compiler::Node* IntPtrMax(compiler::Node* left, compiler::Node* right); |
105 | 106 |
106 // Float64 operations. | 107 // Float64 operations. |
107 Node* Float64Ceil(Node* x); | 108 compiler::Node* Float64Ceil(compiler::Node* x); |
108 Node* Float64Floor(Node* x); | 109 compiler::Node* Float64Floor(compiler::Node* x); |
109 Node* Float64Round(Node* x); | 110 compiler::Node* Float64Round(compiler::Node* x); |
110 Node* Float64Trunc(Node* x); | 111 compiler::Node* Float64Trunc(compiler::Node* x); |
111 | 112 |
112 // Tag a Word as a Smi value. | 113 // Tag a Word as a Smi value. |
113 Node* SmiTag(Node* value); | 114 compiler::Node* SmiTag(compiler::Node* value); |
114 // Untag a Smi value as a Word. | 115 // Untag a Smi value as a Word. |
115 Node* SmiUntag(Node* value); | 116 compiler::Node* SmiUntag(compiler::Node* value); |
116 | 117 |
117 // Smi conversions. | 118 // Smi conversions. |
118 Node* SmiToFloat64(Node* value); | 119 compiler::Node* SmiToFloat64(compiler::Node* value); |
119 Node* SmiFromWord(Node* value) { return SmiTag(value); } | 120 compiler::Node* SmiFromWord(compiler::Node* value) { return SmiTag(value); } |
120 Node* SmiFromWord32(Node* value); | 121 compiler::Node* SmiFromWord32(compiler::Node* value); |
121 Node* SmiToWord(Node* value) { return SmiUntag(value); } | 122 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } |
122 Node* SmiToWord32(Node* value); | 123 compiler::Node* SmiToWord32(compiler::Node* value); |
123 | 124 |
124 // Smi operations. | 125 // Smi operations. |
125 Node* SmiAdd(Node* a, Node* b); | 126 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); |
126 Node* SmiSub(Node* a, Node* b); | 127 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); |
127 Node* SmiEqual(Node* a, Node* b); | 128 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); |
128 Node* SmiAbove(Node* a, Node* b); | 129 compiler::Node* SmiAbove(compiler::Node* a, compiler::Node* b); |
129 Node* SmiAboveOrEqual(Node* a, Node* b); | 130 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); |
130 Node* SmiBelow(Node* a, Node* b); | 131 compiler::Node* SmiBelow(compiler::Node* a, compiler::Node* b); |
131 Node* SmiLessThan(Node* a, Node* b); | 132 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); |
132 Node* SmiLessThanOrEqual(Node* a, Node* b); | 133 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); |
133 Node* SmiMax(Node* a, Node* b); | 134 compiler::Node* SmiMax(compiler::Node* a, compiler::Node* b); |
134 Node* SmiMin(Node* a, Node* b); | 135 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
135 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 136 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
136 Node* SmiMod(Node* a, Node* b); | 137 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); |
137 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 138 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
138 Node* SmiMul(Node* a, Node* b); | 139 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); |
139 Node* SmiOr(Node* a, Node* b) { | 140 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { |
140 return BitcastWordToTaggedSigned( | 141 return BitcastWordToTaggedSigned( |
141 WordOr(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); | 142 WordOr(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); |
142 } | 143 } |
143 | 144 |
144 // Smi | HeapNumber operations. | 145 // Smi | HeapNumber operations. |
145 Node* NumberInc(Node* value); | 146 compiler::Node* NumberInc(compiler::Node* value); |
146 | 147 |
147 // Allocate an object of the given size. | 148 // Allocate an object of the given size. |
148 Node* Allocate(Node* size, AllocationFlags flags = kNone); | 149 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
149 Node* Allocate(int size, AllocationFlags flags = kNone); | 150 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
150 Node* InnerAllocate(Node* previous, int offset); | 151 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
151 Node* InnerAllocate(Node* previous, Node* offset); | 152 compiler::Node* InnerAllocate(compiler::Node* previous, |
152 Node* IsRegularHeapObjectSize(Node* size); | 153 compiler::Node* offset); |
153 | 154 compiler::Node* IsRegularHeapObjectSize(compiler::Node* size); |
154 typedef std::function<Node*()> ConditionBody; | 155 |
| 156 typedef std::function<compiler::Node*()> ConditionBody; |
155 void Assert(ConditionBody condition_body, const char* string = nullptr, | 157 void Assert(ConditionBody condition_body, const char* string = nullptr, |
156 const char* file = nullptr, int line = 0); | 158 const char* file = nullptr, int line = 0); |
157 | 159 |
158 // Check a value for smi-ness | 160 // Check a value for smi-ness |
159 Node* TaggedIsSmi(Node* a); | 161 compiler::Node* TaggedIsSmi(compiler::Node* a); |
160 // Check that the value is a non-negative smi. | 162 // Check that the value is a non-negative smi. |
161 Node* WordIsPositiveSmi(Node* a); | 163 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
162 // Check that a word has a word-aligned address. | 164 // Check that a word has a word-aligned address. |
163 Node* WordIsWordAligned(Node* word); | 165 compiler::Node* WordIsWordAligned(compiler::Node* word); |
164 Node* WordIsPowerOfTwo(Node* value); | 166 compiler::Node* WordIsPowerOfTwo(compiler::Node* value); |
165 | 167 |
166 void BranchIfSmiEqual(Node* a, Node* b, Label* if_true, Label* if_false) { | 168 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, |
| 169 Label* if_false) { |
167 Branch(SmiEqual(a, b), if_true, if_false); | 170 Branch(SmiEqual(a, b), if_true, if_false); |
168 } | 171 } |
169 | 172 |
170 void BranchIfSmiLessThan(Node* a, Node* b, Label* if_true, Label* if_false) { | 173 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, |
| 174 Label* if_false) { |
171 Branch(SmiLessThan(a, b), if_true, if_false); | 175 Branch(SmiLessThan(a, b), if_true, if_false); |
172 } | 176 } |
173 | 177 |
174 void BranchIfSmiLessThanOrEqual(Node* a, Node* b, Label* if_true, | 178 void BranchIfSmiLessThanOrEqual(compiler::Node* a, compiler::Node* b, |
175 Label* if_false) { | 179 Label* if_true, Label* if_false) { |
176 Branch(SmiLessThanOrEqual(a, b), if_true, if_false); | 180 Branch(SmiLessThanOrEqual(a, b), if_true, if_false); |
177 } | 181 } |
178 | 182 |
179 void BranchIfFloat64IsNaN(Node* value, Label* if_true, Label* if_false) { | 183 void BranchIfFloat64IsNaN(compiler::Node* value, Label* if_true, |
| 184 Label* if_false) { |
180 Branch(Float64Equal(value, value), if_false, if_true); | 185 Branch(Float64Equal(value, value), if_false, if_true); |
181 } | 186 } |
182 | 187 |
183 // Branches to {if_true} if ToBoolean applied to {value} yields true, | 188 // Branches to {if_true} if ToBoolean applied to {value} yields true, |
184 // otherwise goes to {if_false}. | 189 // otherwise goes to {if_false}. |
185 void BranchIfToBooleanIsTrue(Node* value, Label* if_true, Label* if_false); | 190 void BranchIfToBooleanIsTrue(compiler::Node* value, Label* if_true, |
186 | 191 Label* if_false); |
187 void BranchIfSimd128Equal(Node* lhs, Node* lhs_map, Node* rhs, Node* rhs_map, | 192 |
| 193 void BranchIfSimd128Equal(compiler::Node* lhs, compiler::Node* lhs_map, |
| 194 compiler::Node* rhs, compiler::Node* rhs_map, |
188 Label* if_equal, Label* if_notequal); | 195 Label* if_equal, Label* if_notequal); |
189 void BranchIfSimd128Equal(Node* lhs, Node* rhs, Label* if_equal, | 196 void BranchIfSimd128Equal(compiler::Node* lhs, compiler::Node* rhs, |
190 Label* if_notequal) { | 197 Label* if_equal, Label* if_notequal) { |
191 BranchIfSimd128Equal(lhs, LoadMap(lhs), rhs, LoadMap(rhs), if_equal, | 198 BranchIfSimd128Equal(lhs, LoadMap(lhs), rhs, LoadMap(rhs), if_equal, |
192 if_notequal); | 199 if_notequal); |
193 } | 200 } |
194 | 201 |
195 void BranchIfJSReceiver(Node* object, Label* if_true, Label* if_false); | 202 void BranchIfJSReceiver(compiler::Node* object, Label* if_true, |
196 void BranchIfJSObject(Node* object, Label* if_true, Label* if_false); | 203 Label* if_false); |
197 void BranchIfFastJSArray(Node* object, Node* context, Label* if_true, | 204 void BranchIfJSObject(compiler::Node* object, Label* if_true, |
198 Label* if_false); | 205 Label* if_false); |
| 206 void BranchIfFastJSArray(compiler::Node* object, compiler::Node* context, |
| 207 Label* if_true, Label* if_false); |
199 | 208 |
200 // Load value from current frame by given offset in bytes. | 209 // Load value from current frame by given offset in bytes. |
201 Node* LoadFromFrame(int offset, MachineType rep = MachineType::AnyTagged()); | 210 compiler::Node* LoadFromFrame(int offset, |
| 211 MachineType rep = MachineType::AnyTagged()); |
202 // Load value from current parent frame by given offset in bytes. | 212 // Load value from current parent frame by given offset in bytes. |
203 Node* LoadFromParentFrame(int offset, | 213 compiler::Node* LoadFromParentFrame( |
204 MachineType rep = MachineType::AnyTagged()); | 214 int offset, MachineType rep = MachineType::AnyTagged()); |
205 | 215 |
206 // Load an object pointer from a buffer that isn't in the heap. | 216 // Load an object pointer from a buffer that isn't in the heap. |
207 Node* LoadBufferObject(Node* buffer, int offset, | 217 compiler::Node* LoadBufferObject(compiler::Node* buffer, int offset, |
208 MachineType rep = MachineType::AnyTagged()); | 218 MachineType rep = MachineType::AnyTagged()); |
209 // Load a field from an object on the heap. | 219 // Load a field from an object on the heap. |
210 Node* LoadObjectField(Node* object, int offset, | 220 compiler::Node* LoadObjectField(compiler::Node* object, int offset, |
211 MachineType rep = MachineType::AnyTagged()); | 221 MachineType rep = MachineType::AnyTagged()); |
212 Node* LoadObjectField(Node* object, Node* offset, | 222 compiler::Node* LoadObjectField(compiler::Node* object, |
213 MachineType rep = MachineType::AnyTagged()); | 223 compiler::Node* offset, |
| 224 MachineType rep = MachineType::AnyTagged()); |
214 // Load a SMI field and untag it. | 225 // Load a SMI field and untag it. |
215 Node* LoadAndUntagObjectField(Node* object, int offset); | 226 compiler::Node* LoadAndUntagObjectField(compiler::Node* object, int offset); |
216 // Load a SMI field, untag it, and convert to Word32. | 227 // Load a SMI field, untag it, and convert to Word32. |
217 Node* LoadAndUntagToWord32ObjectField(Node* object, int offset); | 228 compiler::Node* LoadAndUntagToWord32ObjectField(compiler::Node* object, |
| 229 int offset); |
218 // Load a SMI and untag it. | 230 // Load a SMI and untag it. |
219 Node* LoadAndUntagSmi(Node* base, int index); | 231 compiler::Node* LoadAndUntagSmi(compiler::Node* base, int index); |
220 // Load a SMI root, untag it, and convert to Word32. | 232 // Load a SMI root, untag it, and convert to Word32. |
221 Node* LoadAndUntagToWord32Root(Heap::RootListIndex root_index); | 233 compiler::Node* LoadAndUntagToWord32Root(Heap::RootListIndex root_index); |
222 | 234 |
223 // Load the floating point value of a HeapNumber. | 235 // Load the floating point value of a HeapNumber. |
224 Node* LoadHeapNumberValue(Node* object); | 236 compiler::Node* LoadHeapNumberValue(compiler::Node* object); |
225 // Load the Map of an HeapObject. | 237 // Load the Map of an HeapObject. |
226 Node* LoadMap(Node* object); | 238 compiler::Node* LoadMap(compiler::Node* object); |
227 // Load the instance type of an HeapObject. | 239 // Load the instance type of an HeapObject. |
228 Node* LoadInstanceType(Node* object); | 240 compiler::Node* LoadInstanceType(compiler::Node* object); |
229 // Compare the instance the type of the object against the provided one. | 241 // Compare the instance the type of the object against the provided one. |
230 Node* HasInstanceType(Node* object, InstanceType type); | 242 compiler::Node* HasInstanceType(compiler::Node* object, InstanceType type); |
231 // Load the properties backing store of a JSObject. | 243 // Load the properties backing store of a JSObject. |
232 Node* LoadProperties(Node* object); | 244 compiler::Node* LoadProperties(compiler::Node* object); |
233 // Load the elements backing store of a JSObject. | 245 // Load the elements backing store of a JSObject. |
234 Node* LoadElements(Node* object); | 246 compiler::Node* LoadElements(compiler::Node* object); |
235 // Load the length of a JSArray instance. | 247 // Load the length of a JSArray instance. |
236 Node* LoadJSArrayLength(Node* array); | 248 compiler::Node* LoadJSArrayLength(compiler::Node* array); |
237 // Load the length of a fixed array base instance. | 249 // Load the length of a fixed array base instance. |
238 Node* LoadFixedArrayBaseLength(Node* array); | 250 compiler::Node* LoadFixedArrayBaseLength(compiler::Node* array); |
239 // Load the length of a fixed array base instance. | 251 // Load the length of a fixed array base instance. |
240 Node* LoadAndUntagFixedArrayBaseLength(Node* array); | 252 compiler::Node* LoadAndUntagFixedArrayBaseLength(compiler::Node* array); |
241 // Load the bit field of a Map. | 253 // Load the bit field of a Map. |
242 Node* LoadMapBitField(Node* map); | 254 compiler::Node* LoadMapBitField(compiler::Node* map); |
243 // Load bit field 2 of a map. | 255 // Load bit field 2 of a map. |
244 Node* LoadMapBitField2(Node* map); | 256 compiler::Node* LoadMapBitField2(compiler::Node* map); |
245 // Load bit field 3 of a map. | 257 // Load bit field 3 of a map. |
246 Node* LoadMapBitField3(Node* map); | 258 compiler::Node* LoadMapBitField3(compiler::Node* map); |
247 // Load the instance type of a map. | 259 // Load the instance type of a map. |
248 Node* LoadMapInstanceType(Node* map); | 260 compiler::Node* LoadMapInstanceType(compiler::Node* map); |
249 // Load the ElementsKind of a map. | 261 // Load the ElementsKind of a map. |
250 Node* LoadMapElementsKind(Node* map); | 262 compiler::Node* LoadMapElementsKind(compiler::Node* map); |
251 // Load the instance descriptors of a map. | 263 // Load the instance descriptors of a map. |
252 Node* LoadMapDescriptors(Node* map); | 264 compiler::Node* LoadMapDescriptors(compiler::Node* map); |
253 // Load the prototype of a map. | 265 // Load the prototype of a map. |
254 Node* LoadMapPrototype(Node* map); | 266 compiler::Node* LoadMapPrototype(compiler::Node* map); |
255 // Load the prototype info of a map. The result has to be checked if it is a | 267 // Load the prototype info of a map. The result has to be checked if it is a |
256 // prototype info object or not. | 268 // prototype info object or not. |
257 Node* LoadMapPrototypeInfo(Node* map, Label* if_has_no_proto_info); | 269 compiler::Node* LoadMapPrototypeInfo(compiler::Node* map, |
| 270 Label* if_has_no_proto_info); |
258 // Load the instance size of a Map. | 271 // Load the instance size of a Map. |
259 Node* LoadMapInstanceSize(Node* map); | 272 compiler::Node* LoadMapInstanceSize(compiler::Node* map); |
260 // Load the inobject properties count of a Map (valid only for JSObjects). | 273 // Load the inobject properties count of a Map (valid only for JSObjects). |
261 Node* LoadMapInobjectProperties(Node* map); | 274 compiler::Node* LoadMapInobjectProperties(compiler::Node* map); |
262 // Load the constructor function index of a Map (only for primitive maps). | 275 // Load the constructor function index of a Map (only for primitive maps). |
263 Node* LoadMapConstructorFunctionIndex(Node* map); | 276 compiler::Node* LoadMapConstructorFunctionIndex(compiler::Node* map); |
264 // Load the constructor of a Map (equivalent to Map::GetConstructor()). | 277 // Load the constructor of a Map (equivalent to Map::GetConstructor()). |
265 Node* LoadMapConstructor(Node* map); | 278 compiler::Node* LoadMapConstructor(compiler::Node* map); |
266 // Check if the map is set for slow properties. | 279 // Check if the map is set for slow properties. |
267 Node* IsDictionaryMap(Node* map); | 280 compiler::Node* IsDictionaryMap(compiler::Node* map); |
268 | 281 |
269 // Load the hash field of a name as an uint32 value. | 282 // Load the hash field of a name as an uint32 value. |
270 Node* LoadNameHashField(Node* name); | 283 compiler::Node* LoadNameHashField(compiler::Node* name); |
271 // Load the hash value of a name as an uint32 value. | 284 // Load the hash value of a name as an uint32 value. |
272 // If {if_hash_not_computed} label is specified then it also checks if | 285 // If {if_hash_not_computed} label is specified then it also checks if |
273 // hash is actually computed. | 286 // hash is actually computed. |
274 Node* LoadNameHash(Node* name, Label* if_hash_not_computed = nullptr); | 287 compiler::Node* LoadNameHash(compiler::Node* name, |
| 288 Label* if_hash_not_computed = nullptr); |
275 | 289 |
276 // Load length field of a String object. | 290 // Load length field of a String object. |
277 Node* LoadStringLength(Node* object); | 291 compiler::Node* LoadStringLength(compiler::Node* object); |
278 // Load value field of a JSValue object. | 292 // Load value field of a JSValue object. |
279 Node* LoadJSValueValue(Node* object); | 293 compiler::Node* LoadJSValueValue(compiler::Node* object); |
280 // Load value field of a WeakCell object. | 294 // Load value field of a WeakCell object. |
281 Node* LoadWeakCellValueUnchecked(Node* weak_cell); | 295 compiler::Node* LoadWeakCellValueUnchecked(compiler::Node* weak_cell); |
282 Node* LoadWeakCellValue(Node* weak_cell, Label* if_cleared = nullptr); | 296 compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell, |
| 297 Label* if_cleared = nullptr); |
283 | 298 |
284 // Load an array element from a FixedArray. | 299 // Load an array element from a FixedArray. |
285 Node* LoadFixedArrayElement( | 300 compiler::Node* LoadFixedArrayElement( |
286 Node* object, Node* index, int additional_offset = 0, | 301 compiler::Node* object, compiler::Node* index, int additional_offset = 0, |
287 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 302 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
288 // Load an array element from a FixedArray, untag it and return it as Word32. | 303 // Load an array element from a FixedArray, untag it and return it as Word32. |
289 Node* LoadAndUntagToWord32FixedArrayElement( | 304 compiler::Node* LoadAndUntagToWord32FixedArrayElement( |
290 Node* object, Node* index, int additional_offset = 0, | 305 compiler::Node* object, compiler::Node* index, int additional_offset = 0, |
291 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 306 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
292 // Load an array element from a FixedDoubleArray. | 307 // Load an array element from a FixedDoubleArray. |
293 Node* LoadFixedDoubleArrayElement( | 308 compiler::Node* LoadFixedDoubleArrayElement( |
294 Node* object, Node* index, MachineType machine_type, | 309 compiler::Node* object, compiler::Node* index, MachineType machine_type, |
295 int additional_offset = 0, | 310 int additional_offset = 0, |
296 ParameterMode parameter_mode = INTEGER_PARAMETERS, | 311 ParameterMode parameter_mode = INTEGER_PARAMETERS, |
297 Label* if_hole = nullptr); | 312 Label* if_hole = nullptr); |
298 | 313 |
299 // Load Float64 value by |base| + |offset| address. If the value is a double | 314 // Load Float64 value by |base| + |offset| address. If the value is a double |
300 // hole then jump to |if_hole|. If |machine_type| is None then only the hole | 315 // hole then jump to |if_hole|. If |machine_type| is None then only the hole |
301 // check is generated. | 316 // check is generated. |
302 Node* LoadDoubleWithHoleCheck( | 317 compiler::Node* LoadDoubleWithHoleCheck( |
303 Node* base, Node* offset, Label* if_hole, | 318 compiler::Node* base, compiler::Node* offset, Label* if_hole, |
304 MachineType machine_type = MachineType::Float64()); | 319 MachineType machine_type = MachineType::Float64()); |
305 Node* LoadFixedTypedArrayElement( | 320 compiler::Node* LoadFixedTypedArrayElement( |
306 Node* data_pointer, Node* index_node, ElementsKind elements_kind, | 321 compiler::Node* data_pointer, compiler::Node* index_node, |
| 322 ElementsKind elements_kind, |
307 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 323 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
308 | 324 |
309 // Context manipulation | 325 // Context manipulation |
310 Node* LoadContextElement(Node* context, int slot_index); | 326 compiler::Node* LoadContextElement(compiler::Node* context, int slot_index); |
311 Node* LoadContextElement(Node* context, Node* slot_index); | 327 compiler::Node* LoadContextElement(compiler::Node* context, |
312 Node* StoreContextElement(Node* context, int slot_index, Node* value); | 328 compiler::Node* slot_index); |
313 Node* StoreContextElement(Node* context, Node* slot_index, Node* value); | 329 compiler::Node* StoreContextElement(compiler::Node* context, int slot_index, |
314 Node* LoadNativeContext(Node* context); | 330 compiler::Node* value); |
| 331 compiler::Node* StoreContextElement(compiler::Node* context, |
| 332 compiler::Node* slot_index, |
| 333 compiler::Node* value); |
| 334 compiler::Node* LoadNativeContext(compiler::Node* context); |
315 | 335 |
316 Node* LoadJSArrayElementsMap(ElementsKind kind, Node* native_context); | 336 compiler::Node* LoadJSArrayElementsMap(ElementsKind kind, |
| 337 compiler::Node* native_context); |
317 | 338 |
318 // Store the floating point value of a HeapNumber. | 339 // Store the floating point value of a HeapNumber. |
319 Node* StoreHeapNumberValue(Node* object, Node* value); | 340 compiler::Node* StoreHeapNumberValue(compiler::Node* object, |
| 341 compiler::Node* value); |
320 // Store a field to an object on the heap. | 342 // Store a field to an object on the heap. |
321 Node* StoreObjectField(Node* object, int offset, Node* value); | 343 compiler::Node* StoreObjectField( |
322 Node* StoreObjectField(Node* object, Node* offset, Node* value); | 344 compiler::Node* object, int offset, compiler::Node* value); |
323 Node* StoreObjectFieldNoWriteBarrier( | 345 compiler::Node* StoreObjectField(compiler::Node* object, |
324 Node* object, int offset, Node* value, | 346 compiler::Node* offset, |
| 347 compiler::Node* value); |
| 348 compiler::Node* StoreObjectFieldNoWriteBarrier( |
| 349 compiler::Node* object, int offset, compiler::Node* value, |
325 MachineRepresentation rep = MachineRepresentation::kTagged); | 350 MachineRepresentation rep = MachineRepresentation::kTagged); |
326 Node* StoreObjectFieldNoWriteBarrier( | 351 compiler::Node* StoreObjectFieldNoWriteBarrier( |
327 Node* object, Node* offset, Node* value, | 352 compiler::Node* object, compiler::Node* offset, compiler::Node* value, |
328 MachineRepresentation rep = MachineRepresentation::kTagged); | 353 MachineRepresentation rep = MachineRepresentation::kTagged); |
329 // Store the Map of an HeapObject. | 354 // Store the Map of an HeapObject. |
330 Node* StoreMapNoWriteBarrier(Node* object, Node* map); | 355 compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object, |
331 Node* StoreObjectFieldRoot(Node* object, int offset, | 356 compiler::Node* map); |
332 Heap::RootListIndex root); | 357 compiler::Node* StoreObjectFieldRoot(compiler::Node* object, int offset, |
| 358 Heap::RootListIndex root); |
333 // Store an array element to a FixedArray. | 359 // Store an array element to a FixedArray. |
334 Node* StoreFixedArrayElement( | 360 compiler::Node* StoreFixedArrayElement( |
335 Node* object, int index, Node* value, | 361 compiler::Node* object, int index, compiler::Node* value, |
336 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { | 362 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { |
337 return StoreFixedArrayElement(object, IntPtrConstant(index), value, | 363 return StoreFixedArrayElement(object, IntPtrConstant(index), value, |
338 barrier_mode, 0, INTPTR_PARAMETERS); | 364 barrier_mode, 0, INTPTR_PARAMETERS); |
339 } | 365 } |
340 | 366 |
341 Node* StoreFixedArrayElement( | 367 compiler::Node* StoreFixedArrayElement( |
342 Node* object, Node* index, Node* value, | 368 compiler::Node* object, compiler::Node* index, compiler::Node* value, |
343 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 369 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
344 int additional_offset = 0, | 370 int additional_offset = 0, |
345 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 371 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
346 | 372 |
347 Node* StoreFixedDoubleArrayElement( | 373 compiler::Node* StoreFixedDoubleArrayElement( |
348 Node* object, Node* index, Node* value, | 374 compiler::Node* object, compiler::Node* index, compiler::Node* value, |
349 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 375 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
350 | 376 |
351 void StoreFieldsNoWriteBarrier(Node* start_address, Node* end_address, | 377 void StoreFieldsNoWriteBarrier(compiler::Node* start_address, |
352 Node* value); | 378 compiler::Node* end_address, |
| 379 compiler::Node* value); |
353 | 380 |
354 // Allocate a HeapNumber without initializing its value. | 381 // Allocate a HeapNumber without initializing its value. |
355 Node* AllocateHeapNumber(MutableMode mode = IMMUTABLE); | 382 compiler::Node* AllocateHeapNumber(MutableMode mode = IMMUTABLE); |
356 // Allocate a HeapNumber with a specific value. | 383 // Allocate a HeapNumber with a specific value. |
357 Node* AllocateHeapNumberWithValue(Node* value, MutableMode mode = IMMUTABLE); | 384 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, |
| 385 MutableMode mode = IMMUTABLE); |
358 // Allocate a SeqOneByteString with the given length. | 386 // Allocate a SeqOneByteString with the given length. |
359 Node* AllocateSeqOneByteString(int length, AllocationFlags flags = kNone); | 387 compiler::Node* AllocateSeqOneByteString(int length, |
360 Node* AllocateSeqOneByteString(Node* context, Node* length, | 388 AllocationFlags flags = kNone); |
361 ParameterMode mode = INTPTR_PARAMETERS, | 389 compiler::Node* AllocateSeqOneByteString( |
362 AllocationFlags flags = kNone); | 390 compiler::Node* context, compiler::Node* length, |
| 391 ParameterMode mode = INTPTR_PARAMETERS, AllocationFlags flags = kNone); |
363 // Allocate a SeqTwoByteString with the given length. | 392 // Allocate a SeqTwoByteString with the given length. |
364 Node* AllocateSeqTwoByteString(int length, AllocationFlags flags = kNone); | 393 compiler::Node* AllocateSeqTwoByteString(int length, |
365 Node* AllocateSeqTwoByteString(Node* context, Node* length, | 394 AllocationFlags flags = kNone); |
366 ParameterMode mode = INTPTR_PARAMETERS, | 395 compiler::Node* AllocateSeqTwoByteString( |
367 AllocationFlags flags = kNone); | 396 compiler::Node* context, compiler::Node* length, |
| 397 ParameterMode mode = INTPTR_PARAMETERS, AllocationFlags flags = kNone); |
368 | 398 |
369 // Allocate a SlicedOneByteString with the given length, parent and offset. | 399 // Allocate a SlicedOneByteString with the given length, parent and offset. |
370 // |length| and |offset| are expected to be tagged. | 400 // |length| and |offset| are expected to be tagged. |
371 Node* AllocateSlicedOneByteString(Node* length, Node* parent, Node* offset); | 401 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, |
| 402 compiler::Node* parent, |
| 403 compiler::Node* offset); |
372 // Allocate a SlicedTwoByteString with the given length, parent and offset. | 404 // Allocate a SlicedTwoByteString with the given length, parent and offset. |
373 // |length| and |offset| are expected to be tagged. | 405 // |length| and |offset| are expected to be tagged. |
374 Node* AllocateSlicedTwoByteString(Node* length, Node* parent, Node* offset); | 406 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, |
| 407 compiler::Node* parent, |
| 408 compiler::Node* offset); |
375 | 409 |
376 // Allocate a one-byte ConsString with the given length, first and second | 410 // Allocate a one-byte ConsString with the given length, first and second |
377 // parts. |length| is expected to be tagged, and |first| and |second| are | 411 // parts. |length| is expected to be tagged, and |first| and |second| are |
378 // expected to be one-byte strings. | 412 // expected to be one-byte strings. |
379 Node* AllocateOneByteConsString(Node* length, Node* first, Node* second, | 413 compiler::Node* AllocateOneByteConsString(compiler::Node* length, |
380 AllocationFlags flags = kNone); | 414 compiler::Node* first, |
| 415 compiler::Node* second, |
| 416 AllocationFlags flags = kNone); |
381 // Allocate a two-byte ConsString with the given length, first and second | 417 // Allocate a two-byte ConsString with the given length, first and second |
382 // parts. |length| is expected to be tagged, and |first| and |second| are | 418 // parts. |length| is expected to be tagged, and |first| and |second| are |
383 // expected to be two-byte strings. | 419 // expected to be two-byte strings. |
384 Node* AllocateTwoByteConsString(Node* length, Node* first, Node* second, | 420 compiler::Node* AllocateTwoByteConsString(compiler::Node* length, |
385 AllocationFlags flags = kNone); | 421 compiler::Node* first, |
| 422 compiler::Node* second, |
| 423 AllocationFlags flags = kNone); |
386 | 424 |
387 // Allocate an appropriate one- or two-byte ConsString with the first and | 425 // Allocate an appropriate one- or two-byte ConsString with the first and |
388 // second parts specified by |first| and |second|. | 426 // second parts specified by |first| and |second|. |
389 Node* NewConsString(Node* context, Node* length, Node* left, Node* right, | 427 compiler::Node* NewConsString(compiler::Node* context, compiler::Node* length, |
390 AllocationFlags flags = kNone); | 428 compiler::Node* left, compiler::Node* right, |
| 429 AllocationFlags flags = kNone); |
391 | 430 |
392 // Allocate a RegExpResult with the given length (the number of captures, | 431 // Allocate a RegExpResult with the given length (the number of captures, |
393 // including the match itself), index (the index where the match starts), | 432 // including the match itself), index (the index where the match starts), |
394 // and input string. |length| and |index| are expected to be tagged, and | 433 // and input string. |length| and |index| are expected to be tagged, and |
395 // |input| must be a string. | 434 // |input| must be a string. |
396 Node* AllocateRegExpResult(Node* context, Node* length, Node* index, | 435 compiler::Node* AllocateRegExpResult(compiler::Node* context, |
397 Node* input); | 436 compiler::Node* length, |
| 437 compiler::Node* index, |
| 438 compiler::Node* input); |
398 | 439 |
399 Node* AllocateNameDictionary(int capacity); | 440 compiler::Node* AllocateNameDictionary(int capacity); |
400 Node* AllocateNameDictionary(Node* capacity); | 441 compiler::Node* AllocateNameDictionary(compiler::Node* capacity); |
401 | 442 |
402 Node* AllocateJSObjectFromMap(Node* map, Node* properties = nullptr, | 443 compiler::Node* AllocateJSObjectFromMap(compiler::Node* map, |
403 Node* elements = nullptr); | 444 compiler::Node* properties = nullptr, |
| 445 compiler::Node* elements = nullptr); |
404 | 446 |
405 void InitializeJSObjectFromMap(Node* object, Node* map, Node* size, | 447 void InitializeJSObjectFromMap(compiler::Node* object, compiler::Node* map, |
406 Node* properties = nullptr, | 448 compiler::Node* size, |
407 Node* elements = nullptr); | 449 compiler::Node* properties = nullptr, |
| 450 compiler::Node* elements = nullptr); |
408 | 451 |
409 void InitializeJSObjectBody(Node* object, Node* map, Node* size, | 452 void InitializeJSObjectBody(compiler::Node* object, compiler::Node* map, |
| 453 compiler::Node* size, |
410 int start_offset = JSObject::kHeaderSize); | 454 int start_offset = JSObject::kHeaderSize); |
411 | 455 |
412 // Allocate a JSArray without elements and initialize the header fields. | 456 // Allocate a JSArray without elements and initialize the header fields. |
413 Node* AllocateUninitializedJSArrayWithoutElements(ElementsKind kind, | 457 compiler::Node* AllocateUninitializedJSArrayWithoutElements( |
414 Node* array_map, | 458 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
415 Node* length, | 459 compiler::Node* allocation_site); |
416 Node* allocation_site); | |
417 // Allocate and return a JSArray with initialized header fields and its | 460 // Allocate and return a JSArray with initialized header fields and its |
418 // uninitialized elements. | 461 // uninitialized elements. |
419 // The ParameterMode argument is only used for the capacity parameter. | 462 // The ParameterMode argument is only used for the capacity parameter. |
420 std::pair<Node*, Node*> AllocateUninitializedJSArrayWithElements( | 463 std::pair<compiler::Node*, compiler::Node*> |
421 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site, | 464 AllocateUninitializedJSArrayWithElements( |
422 Node* capacity, ParameterMode capacity_mode = INTEGER_PARAMETERS); | 465 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
| 466 compiler::Node* allocation_site, compiler::Node* capacity, |
| 467 ParameterMode capacity_mode = INTEGER_PARAMETERS); |
423 // Allocate a JSArray and fill elements with the hole. | 468 // Allocate a JSArray and fill elements with the hole. |
424 // The ParameterMode argument is only used for the capacity parameter. | 469 // The ParameterMode argument is only used for the capacity parameter. |
425 Node* AllocateJSArray(ElementsKind kind, Node* array_map, Node* capacity, | 470 compiler::Node* AllocateJSArray( |
426 Node* length, Node* allocation_site = nullptr, | 471 ElementsKind kind, compiler::Node* array_map, compiler::Node* capacity, |
427 ParameterMode capacity_mode = INTEGER_PARAMETERS); | 472 compiler::Node* length, compiler::Node* allocation_site = nullptr, |
| 473 ParameterMode capacity_mode = INTEGER_PARAMETERS); |
428 | 474 |
429 Node* AllocateFixedArray(ElementsKind kind, Node* capacity, | 475 compiler::Node* AllocateFixedArray(ElementsKind kind, |
430 ParameterMode mode = INTEGER_PARAMETERS, | 476 compiler::Node* capacity, |
431 AllocationFlags flags = kNone); | 477 ParameterMode mode = INTEGER_PARAMETERS, |
| 478 AllocationFlags flags = kNone); |
432 | 479 |
433 // Perform CreateArrayIterator (ES6 #sec-createarrayiterator). | 480 // Perform CreateArrayIterator (ES6 #sec-createarrayiterator). |
434 Node* CreateArrayIterator(Node* array, Node* array_map, Node* array_type, | 481 compiler::Node* CreateArrayIterator(compiler::Node* array, |
435 Node* context, IterationKind mode); | 482 compiler::Node* array_map, |
| 483 compiler::Node* array_type, |
| 484 compiler::Node* context, |
| 485 IterationKind mode); |
436 | 486 |
437 Node* AllocateJSArrayIterator(Node* array, Node* array_map, Node* map); | 487 compiler::Node* AllocateJSArrayIterator(compiler::Node* array, |
| 488 compiler::Node* array_map, |
| 489 compiler::Node* map); |
438 | 490 |
439 void FillFixedArrayWithValue(ElementsKind kind, Node* array, Node* from_index, | 491 void FillFixedArrayWithValue(ElementsKind kind, compiler::Node* array, |
440 Node* to_index, | 492 compiler::Node* from_index, |
| 493 compiler::Node* to_index, |
441 Heap::RootListIndex value_root_index, | 494 Heap::RootListIndex value_root_index, |
442 ParameterMode mode = INTEGER_PARAMETERS); | 495 ParameterMode mode = INTEGER_PARAMETERS); |
443 | 496 |
444 // Copies all elements from |from_array| of |length| size to | 497 // Copies all elements from |from_array| of |length| size to |
445 // |to_array| of the same size respecting the elements kind. | 498 // |to_array| of the same size respecting the elements kind. |
446 void CopyFixedArrayElements( | 499 void CopyFixedArrayElements( |
447 ElementsKind kind, Node* from_array, Node* to_array, Node* length, | 500 ElementsKind kind, compiler::Node* from_array, compiler::Node* to_array, |
| 501 compiler::Node* length, |
448 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 502 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
449 ParameterMode mode = INTEGER_PARAMETERS) { | 503 ParameterMode mode = INTEGER_PARAMETERS) { |
450 CopyFixedArrayElements(kind, from_array, kind, to_array, length, length, | 504 CopyFixedArrayElements(kind, from_array, kind, to_array, length, length, |
451 barrier_mode, mode); | 505 barrier_mode, mode); |
452 } | 506 } |
453 | 507 |
454 // Copies |element_count| elements from |from_array| to |to_array| of | 508 // Copies |element_count| elements from |from_array| to |to_array| of |
455 // |capacity| size respecting both array's elements kinds. | 509 // |capacity| size respecting both array's elements kinds. |
456 void CopyFixedArrayElements( | 510 void CopyFixedArrayElements( |
457 ElementsKind from_kind, Node* from_array, ElementsKind to_kind, | 511 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, |
458 Node* to_array, Node* element_count, Node* capacity, | 512 compiler::Node* to_array, compiler::Node* element_count, |
| 513 compiler::Node* capacity, |
459 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 514 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
460 ParameterMode mode = INTEGER_PARAMETERS); | 515 ParameterMode mode = INTEGER_PARAMETERS); |
461 | 516 |
462 // Copies |character_count| elements from |from_string| to |to_string| | 517 // Copies |character_count| elements from |from_string| to |to_string| |
463 // starting at the |from_index|'th character. |from_string| and |to_string| | 518 // starting at the |from_index|'th character. |from_string| and |to_string| |
464 // can either be one-byte strings or two-byte strings, although if | 519 // can either be one-byte strings or two-byte strings, although if |
465 // |from_string| is two-byte, then |to_string| must be two-byte. | 520 // |from_string| is two-byte, then |to_string| must be two-byte. |
466 // |from_index|, |to_index| and |character_count| must be either Smis or | 521 // |from_index|, |to_index| and |character_count| must be either Smis or |
467 // intptr_ts depending on |mode| s.t. 0 <= |from_index| <= |from_index| + | 522 // intptr_ts depending on |mode| s.t. 0 <= |from_index| <= |from_index| + |
468 // |character_count| <= from_string.length and 0 <= |to_index| <= |to_index| + | 523 // |character_count| <= from_string.length and 0 <= |to_index| <= |to_index| + |
469 // |character_count| <= to_string.length. | 524 // |character_count| <= to_string.length. |
470 void CopyStringCharacters(Node* from_string, Node* to_string, | 525 void CopyStringCharacters(compiler::Node* from_string, |
471 Node* from_index, Node* to_index, | 526 compiler::Node* to_string, |
472 Node* character_count, | 527 compiler::Node* from_index, |
| 528 compiler::Node* to_index, |
| 529 compiler::Node* character_count, |
473 String::Encoding from_encoding, | 530 String::Encoding from_encoding, |
474 String::Encoding to_encoding, ParameterMode mode); | 531 String::Encoding to_encoding, ParameterMode mode); |
475 | 532 |
476 // Loads an element from |array| of |from_kind| elements by given |offset| | 533 // Loads an element from |array| of |from_kind| elements by given |offset| |
477 // (NOTE: not index!), does a hole check if |if_hole| is provided and | 534 // (NOTE: not index!), does a hole check if |if_hole| is provided and |
478 // converts the value so that it becomes ready for storing to array of | 535 // converts the value so that it becomes ready for storing to array of |
479 // |to_kind| elements. | 536 // |to_kind| elements. |
480 Node* LoadElementAndPrepareForStore(Node* array, Node* offset, | 537 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, |
481 ElementsKind from_kind, | 538 compiler::Node* offset, |
482 ElementsKind to_kind, Label* if_hole); | 539 ElementsKind from_kind, |
| 540 ElementsKind to_kind, |
| 541 Label* if_hole); |
483 | 542 |
484 Node* CalculateNewElementsCapacity(Node* old_capacity, | 543 compiler::Node* CalculateNewElementsCapacity( |
485 ParameterMode mode = INTEGER_PARAMETERS); | 544 compiler::Node* old_capacity, ParameterMode mode = INTEGER_PARAMETERS); |
486 | 545 |
487 // Tries to grow the |elements| array of given |object| to store the |key| | 546 // Tries to grow the |elements| array of given |object| to store the |key| |
488 // or bails out if the growing gap is too big. Returns new elements. | 547 // or bails out if the growing gap is too big. Returns new elements. |
489 Node* TryGrowElementsCapacity(Node* object, Node* elements, ElementsKind kind, | 548 compiler::Node* TryGrowElementsCapacity(compiler::Node* object, |
490 Node* key, Label* bailout); | 549 compiler::Node* elements, |
| 550 ElementsKind kind, |
| 551 compiler::Node* key, Label* bailout); |
491 | 552 |
492 // Tries to grow the |capacity|-length |elements| array of given |object| | 553 // Tries to grow the |capacity|-length |elements| array of given |object| |
493 // to store the |key| or bails out if the growing gap is too big. Returns | 554 // to store the |key| or bails out if the growing gap is too big. Returns |
494 // new elements. | 555 // new elements. |
495 Node* TryGrowElementsCapacity(Node* object, Node* elements, ElementsKind kind, | 556 compiler::Node* TryGrowElementsCapacity(compiler::Node* object, |
496 Node* key, Node* capacity, ParameterMode mode, | 557 compiler::Node* elements, |
497 Label* bailout); | 558 ElementsKind kind, |
| 559 compiler::Node* key, |
| 560 compiler::Node* capacity, |
| 561 ParameterMode mode, Label* bailout); |
498 | 562 |
499 // Grows elements capacity of given object. Returns new elements. | 563 // Grows elements capacity of given object. Returns new elements. |
500 Node* GrowElementsCapacity(Node* object, Node* elements, | 564 compiler::Node* GrowElementsCapacity( |
501 ElementsKind from_kind, ElementsKind to_kind, | 565 compiler::Node* object, compiler::Node* elements, ElementsKind from_kind, |
502 Node* capacity, Node* new_capacity, | 566 ElementsKind to_kind, compiler::Node* capacity, |
503 ParameterMode mode, Label* bailout); | 567 compiler::Node* new_capacity, ParameterMode mode, Label* bailout); |
504 | 568 |
505 // Allocation site manipulation | 569 // Allocation site manipulation |
506 void InitializeAllocationMemento(Node* base_allocation, | 570 void InitializeAllocationMemento(compiler::Node* base_allocation, |
507 int base_allocation_size, | 571 int base_allocation_size, |
508 Node* allocation_site); | 572 compiler::Node* allocation_site); |
509 | 573 |
510 Node* TryTaggedToFloat64(Node* value, Label* if_valueisnotnumber); | 574 compiler::Node* TryTaggedToFloat64(compiler::Node* value, |
511 Node* TruncateTaggedToFloat64(Node* context, Node* value); | 575 Label* if_valueisnotnumber); |
512 Node* TruncateTaggedToWord32(Node* context, Node* value); | 576 compiler::Node* TruncateTaggedToFloat64(compiler::Node* context, |
| 577 compiler::Node* value); |
| 578 compiler::Node* TruncateTaggedToWord32(compiler::Node* context, |
| 579 compiler::Node* value); |
513 // Truncate the floating point value of a HeapNumber to an Int32. | 580 // Truncate the floating point value of a HeapNumber to an Int32. |
514 Node* TruncateHeapNumberValueToWord32(Node* object); | 581 compiler::Node* TruncateHeapNumberValueToWord32(compiler::Node* object); |
515 | 582 |
516 // Conversions. | 583 // Conversions. |
517 Node* ChangeFloat64ToTagged(Node* value); | 584 compiler::Node* ChangeFloat64ToTagged(compiler::Node* value); |
518 Node* ChangeInt32ToTagged(Node* value); | 585 compiler::Node* ChangeInt32ToTagged(compiler::Node* value); |
519 Node* ChangeUint32ToTagged(Node* value); | 586 compiler::Node* ChangeUint32ToTagged(compiler::Node* value); |
520 | 587 |
521 // Type conversions. | 588 // Type conversions. |
522 // Throws a TypeError for {method_name} if {value} is not coercible to Object, | 589 // Throws a TypeError for {method_name} if {value} is not coercible to Object, |
523 // or returns the {value} converted to a String otherwise. | 590 // or returns the {value} converted to a String otherwise. |
524 Node* ToThisString(Node* context, Node* value, char const* method_name); | 591 compiler::Node* ToThisString(compiler::Node* context, compiler::Node* value, |
| 592 char const* method_name); |
525 // Throws a TypeError for {method_name} if {value} is neither of the given | 593 // Throws a TypeError for {method_name} if {value} is neither of the given |
526 // {primitive_type} nor a JSValue wrapping a value of {primitive_type}, or | 594 // {primitive_type} nor a JSValue wrapping a value of {primitive_type}, or |
527 // returns the {value} (or wrapped value) otherwise. | 595 // returns the {value} (or wrapped value) otherwise. |
528 Node* ToThisValue(Node* context, Node* value, PrimitiveType primitive_type, | 596 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, |
529 char const* method_name); | 597 PrimitiveType primitive_type, |
| 598 char const* method_name); |
530 | 599 |
531 // Throws a TypeError for {method_name} if {value} is not of the given | 600 // Throws a TypeError for {method_name} if {value} is not of the given |
532 // instance type. Returns {value}'s map. | 601 // instance type. Returns {value}'s map. |
533 Node* ThrowIfNotInstanceType(Node* context, Node* value, | 602 compiler::Node* ThrowIfNotInstanceType(compiler::Node* context, |
534 InstanceType instance_type, | 603 compiler::Node* value, |
535 char const* method_name); | 604 InstanceType instance_type, |
| 605 char const* method_name); |
536 | 606 |
537 // Type checks. | 607 // Type checks. |
538 // Check whether the map is for an object with special properties, such as a | 608 // Check whether the map is for an object with special properties, such as a |
539 // JSProxy or an object with interceptors. | 609 // JSProxy or an object with interceptors. |
540 Node* IsSpecialReceiverMap(Node* map); | 610 compiler::Node* IsSpecialReceiverMap(compiler::Node* map); |
541 Node* IsSpecialReceiverInstanceType(Node* instance_type); | 611 compiler::Node* IsSpecialReceiverInstanceType(compiler::Node* instance_type); |
542 Node* IsStringInstanceType(Node* instance_type); | 612 compiler::Node* IsStringInstanceType(compiler::Node* instance_type); |
543 Node* IsString(Node* object); | 613 compiler::Node* IsString(compiler::Node* object); |
544 Node* IsJSObject(Node* object); | 614 compiler::Node* IsJSObject(compiler::Node* object); |
545 Node* IsJSGlobalProxy(Node* object); | 615 compiler::Node* IsJSGlobalProxy(compiler::Node* object); |
546 Node* IsJSReceiverInstanceType(Node* instance_type); | 616 compiler::Node* IsJSReceiverInstanceType(compiler::Node* instance_type); |
547 Node* IsJSReceiver(Node* object); | 617 compiler::Node* IsJSReceiver(compiler::Node* object); |
548 Node* IsMap(Node* object); | 618 compiler::Node* IsMap(compiler::Node* object); |
549 Node* IsCallableMap(Node* map); | 619 compiler::Node* IsCallableMap(compiler::Node* map); |
550 Node* IsName(Node* object); | 620 compiler::Node* IsName(compiler::Node* object); |
551 Node* IsJSValue(Node* object); | 621 compiler::Node* IsJSValue(compiler::Node* object); |
552 Node* IsJSArray(Node* object); | 622 compiler::Node* IsJSArray(compiler::Node* object); |
553 Node* IsNativeContext(Node* object); | 623 compiler::Node* IsNativeContext(compiler::Node* object); |
554 Node* IsWeakCell(Node* object); | 624 compiler::Node* IsWeakCell(compiler::Node* object); |
555 Node* IsFixedDoubleArray(Node* object); | 625 compiler::Node* IsFixedDoubleArray(compiler::Node* object); |
556 Node* IsHashTable(Node* object); | 626 compiler::Node* IsHashTable(compiler::Node* object); |
557 Node* IsDictionary(Node* object); | 627 compiler::Node* IsDictionary(compiler::Node* object); |
558 Node* IsUnseededNumberDictionary(Node* object); | 628 compiler::Node* IsUnseededNumberDictionary(compiler::Node* object); |
559 | 629 |
560 // ElementsKind helpers: | 630 // ElementsKind helpers: |
561 Node* IsFastElementsKind(Node* elements_kind); | 631 compiler::Node* IsFastElementsKind(compiler::Node* elements_kind); |
562 Node* IsHoleyFastElementsKind(Node* elements_kind); | 632 compiler::Node* IsHoleyFastElementsKind(compiler::Node* elements_kind); |
563 | 633 |
564 // String helpers. | 634 // String helpers. |
565 // Load a character from a String (might flatten a ConsString). | 635 // Load a character from a String (might flatten a ConsString). |
566 Node* StringCharCodeAt(Node* string, Node* smi_index); | 636 compiler::Node* StringCharCodeAt(compiler::Node* string, |
| 637 compiler::Node* smi_index); |
567 // Return the single character string with only {code}. | 638 // Return the single character string with only {code}. |
568 Node* StringFromCharCode(Node* code); | 639 compiler::Node* StringFromCharCode(compiler::Node* code); |
569 // Return a new string object which holds a substring containing the range | 640 // Return a new string object which holds a substring containing the range |
570 // [from,to[ of string. |from| and |to| are expected to be tagged. | 641 // [from,to[ of string. |from| and |to| are expected to be tagged. |
571 Node* SubString(Node* context, Node* string, Node* from, Node* to); | 642 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, |
| 643 compiler::Node* from, compiler::Node* to); |
572 | 644 |
573 // Return a new string object produced by concatenating |first| with |second|. | 645 // Return a new string object produced by concatenating |first| with |second|. |
574 Node* StringAdd(Node* context, Node* first, Node* second, | 646 compiler::Node* StringAdd(compiler::Node* context, compiler::Node* first, |
575 AllocationFlags flags = kNone); | 647 compiler::Node* second, |
| 648 AllocationFlags flags = kNone); |
576 | 649 |
577 // Return the first index >= {from} at which {needle_char} was found in | 650 // Return the first index >= {from} at which {needle_char} was found in |
578 // {string}, or -1 if such an index does not exist. The returned value is | 651 // {string}, or -1 if such an index does not exist. The returned value is |
579 // a Smi, {string} is expected to be a String, {needle_char} is an intptr, | 652 // a Smi, {string} is expected to be a String, {needle_char} is an intptr, |
580 // and {from} is expected to be tagged. | 653 // and {from} is expected to be tagged. |
581 Node* StringIndexOfChar(Node* context, Node* string, Node* needle_char, | 654 compiler::Node* StringIndexOfChar(compiler::Node* context, |
582 Node* from); | 655 compiler::Node* string, |
| 656 compiler::Node* needle_char, |
| 657 compiler::Node* from); |
583 | 658 |
584 Node* StringFromCodePoint(Node* codepoint, UnicodeEncoding encoding); | 659 compiler::Node* StringFromCodePoint(compiler::Node* codepoint, |
| 660 UnicodeEncoding encoding); |
585 | 661 |
586 // Type conversion helpers. | 662 // Type conversion helpers. |
587 // Convert a String to a Number. | 663 // Convert a String to a Number. |
588 Node* StringToNumber(Node* context, Node* input); | 664 compiler::Node* StringToNumber(compiler::Node* context, |
589 Node* NumberToString(Node* context, Node* input); | 665 compiler::Node* input); |
| 666 compiler::Node* NumberToString(compiler::Node* context, |
| 667 compiler::Node* input); |
590 // Convert an object to a name. | 668 // Convert an object to a name. |
591 Node* ToName(Node* context, Node* input); | 669 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); |
592 // Convert a Non-Number object to a Number. | 670 // Convert a Non-Number object to a Number. |
593 Node* NonNumberToNumber(Node* context, Node* input); | 671 compiler::Node* NonNumberToNumber(compiler::Node* context, |
| 672 compiler::Node* input); |
594 // Convert any object to a Number. | 673 // Convert any object to a Number. |
595 Node* ToNumber(Node* context, Node* input); | 674 compiler::Node* ToNumber(compiler::Node* context, compiler::Node* input); |
596 | 675 |
597 // Convert any object to a String. | 676 // Convert any object to a String. |
598 Node* ToString(Node* context, Node* input); | 677 compiler::Node* ToString(compiler::Node* context, compiler::Node* input); |
599 | 678 |
600 // Convert any object to a Primitive. | 679 // Convert any object to a Primitive. |
601 Node* JSReceiverToPrimitive(Node* context, Node* input); | 680 compiler::Node* JSReceiverToPrimitive(compiler::Node* context, |
| 681 compiler::Node* input); |
602 | 682 |
603 // Convert a String to a flat String. | 683 // Convert a String to a flat String. |
604 Node* FlattenString(Node* string); | 684 compiler::Node* FlattenString(compiler::Node* string); |
605 | 685 |
606 enum ToIntegerTruncationMode { | 686 enum ToIntegerTruncationMode { |
607 kNoTruncation, | 687 kNoTruncation, |
608 kTruncateMinusZero, | 688 kTruncateMinusZero, |
609 }; | 689 }; |
610 | 690 |
611 // Convert any object to an Integer. | 691 // Convert any object to an Integer. |
612 Node* ToInteger(Node* context, Node* input, | 692 compiler::Node* ToInteger(compiler::Node* context, compiler::Node* input, |
613 ToIntegerTruncationMode mode = kNoTruncation); | 693 ToIntegerTruncationMode mode = kNoTruncation); |
614 | 694 |
615 // Returns a node that contains a decoded (unsigned!) value of a bit | 695 // Returns a node that contains a decoded (unsigned!) value of a bit |
616 // field |T| in |word32|. Returns result as an uint32 node. | 696 // field |T| in |word32|. Returns result as an uint32 node. |
617 template <typename T> | 697 template <typename T> |
618 Node* DecodeWord32(Node* word32) { | 698 compiler::Node* DecodeWord32(compiler::Node* word32) { |
619 return DecodeWord32(word32, T::kShift, T::kMask); | 699 return DecodeWord32(word32, T::kShift, T::kMask); |
620 } | 700 } |
621 | 701 |
622 // Returns a node that contains a decoded (unsigned!) value of a bit | 702 // Returns a node that contains a decoded (unsigned!) value of a bit |
623 // field |T| in |word|. Returns result as a word-size node. | 703 // field |T| in |word|. Returns result as a word-size node. |
624 template <typename T> | 704 template <typename T> |
625 Node* DecodeWord(Node* word) { | 705 compiler::Node* DecodeWord(compiler::Node* word) { |
626 return DecodeWord(word, T::kShift, T::kMask); | 706 return DecodeWord(word, T::kShift, T::kMask); |
627 } | 707 } |
628 | 708 |
629 // Returns a node that contains a decoded (unsigned!) value of a bit | 709 // Returns a node that contains a decoded (unsigned!) value of a bit |
630 // field |T| in |word32|. Returns result as a word-size node. | 710 // field |T| in |word32|. Returns result as a word-size node. |
631 template <typename T> | 711 template <typename T> |
632 Node* DecodeWordFromWord32(Node* word32) { | 712 compiler::Node* DecodeWordFromWord32(compiler::Node* word32) { |
633 return DecodeWord<T>(ChangeUint32ToWord(word32)); | 713 return DecodeWord<T>(ChangeUint32ToWord(word32)); |
634 } | 714 } |
635 | 715 |
636 // Decodes an unsigned (!) value from |word32| to an uint32 node. | 716 // Decodes an unsigned (!) value from |word32| to an uint32 node. |
637 Node* DecodeWord32(Node* word32, uint32_t shift, uint32_t mask); | 717 compiler::Node* DecodeWord32(compiler::Node* word32, uint32_t shift, |
| 718 uint32_t mask); |
638 | 719 |
639 // Decodes an unsigned (!) value from |word| to a word-size node. | 720 // Decodes an unsigned (!) value from |word| to a word-size node. |
640 Node* DecodeWord(Node* word, uint32_t shift, uint32_t mask); | 721 compiler::Node* DecodeWord(compiler::Node* word, uint32_t shift, |
| 722 uint32_t mask); |
641 | 723 |
642 // Returns true if any of the |T|'s bits in given |word32| are set. | 724 // Returns true if any of the |T|'s bits in given |word32| are set. |
643 template <typename T> | 725 template <typename T> |
644 Node* IsSetWord32(Node* word32) { | 726 compiler::Node* IsSetWord32(compiler::Node* word32) { |
645 return IsSetWord32(word32, T::kMask); | 727 return IsSetWord32(word32, T::kMask); |
646 } | 728 } |
647 | 729 |
648 // Returns true if any of the mask's bits in given |word32| are set. | 730 // Returns true if any of the mask's bits in given |word32| are set. |
649 Node* IsSetWord32(Node* word32, uint32_t mask) { | 731 compiler::Node* IsSetWord32(compiler::Node* word32, uint32_t mask) { |
650 return Word32NotEqual(Word32And(word32, Int32Constant(mask)), | 732 return Word32NotEqual(Word32And(word32, Int32Constant(mask)), |
651 Int32Constant(0)); | 733 Int32Constant(0)); |
652 } | 734 } |
653 | 735 |
654 // Returns true if any of the |T|'s bits in given |word| are set. | 736 // Returns true if any of the |T|'s bits in given |word| are set. |
655 template <typename T> | 737 template <typename T> |
656 Node* IsSetWord(Node* word) { | 738 compiler::Node* IsSetWord(compiler::Node* word) { |
657 return WordNotEqual(WordAnd(word, IntPtrConstant(T::kMask)), | 739 return WordNotEqual(WordAnd(word, IntPtrConstant(T::kMask)), |
658 IntPtrConstant(0)); | 740 IntPtrConstant(0)); |
659 } | 741 } |
660 | 742 |
661 void SetCounter(StatsCounter* counter, int value); | 743 void SetCounter(StatsCounter* counter, int value); |
662 void IncrementCounter(StatsCounter* counter, int delta); | 744 void IncrementCounter(StatsCounter* counter, int delta); |
663 void DecrementCounter(StatsCounter* counter, int delta); | 745 void DecrementCounter(StatsCounter* counter, int delta); |
664 | 746 |
665 // Generates "if (false) goto label" code. Useful for marking a label as | 747 // Generates "if (false) goto label" code. Useful for marking a label as |
666 // "live" to avoid assertion failures during graph building. In the resulting | 748 // "live" to avoid assertion failures during graph building. In the resulting |
667 // code this check will be eliminated. | 749 // code this check will be eliminated. |
668 void Use(Label* label); | 750 void Use(Label* label); |
669 | 751 |
670 // Various building blocks for stubs doing property lookups. | 752 // Various building blocks for stubs doing property lookups. |
671 void TryToName(Node* key, Label* if_keyisindex, Variable* var_index, | 753 void TryToName(compiler::Node* key, Label* if_keyisindex, Variable* var_index, |
672 Label* if_keyisunique, Label* if_bailout); | 754 Label* if_keyisunique, Label* if_bailout); |
673 | 755 |
674 // Calculates array index for given dictionary entry and entry field. | 756 // Calculates array index for given dictionary entry and entry field. |
675 // See Dictionary::EntryToIndex(). | 757 // See Dictionary::EntryToIndex(). |
676 template <typename Dictionary> | 758 template <typename Dictionary> |
677 Node* EntryToIndex(Node* entry, int field_index); | 759 compiler::Node* EntryToIndex(compiler::Node* entry, int field_index); |
678 template <typename Dictionary> | 760 template <typename Dictionary> |
679 Node* EntryToIndex(Node* entry) { | 761 compiler::Node* EntryToIndex(compiler::Node* entry) { |
680 return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex); | 762 return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex); |
681 } | 763 } |
682 // Calculate a valid size for the a hash table. | 764 // Calculate a valid size for the a hash table. |
683 Node* HashTableComputeCapacity(Node* at_least_space_for); | 765 compiler::Node* HashTableComputeCapacity(compiler::Node* at_least_space_for); |
684 | 766 |
685 template <class Dictionary> | 767 template <class Dictionary> |
686 Node* GetNumberOfElements(Node* dictionary); | 768 compiler::Node* GetNumberOfElements(compiler::Node* dictionary); |
687 | 769 |
688 template <class Dictionary> | 770 template <class Dictionary> |
689 void SetNumberOfElements(Node* dictionary, Node* num_elements_smi); | 771 void SetNumberOfElements(compiler::Node* dictionary, |
| 772 compiler::Node* num_elements_smi); |
690 | 773 |
691 template <class Dictionary> | 774 template <class Dictionary> |
692 Node* GetCapacity(Node* dictionary); | 775 compiler::Node* GetCapacity(compiler::Node* dictionary); |
693 | 776 |
694 template <class Dictionary> | 777 template <class Dictionary> |
695 Node* GetNextEnumerationIndex(Node* dictionary); | 778 compiler::Node* GetNextEnumerationIndex(compiler::Node* dictionary); |
696 | 779 |
697 template <class Dictionary> | 780 template <class Dictionary> |
698 void SetNextEnumerationIndex(Node* dictionary, Node* next_enum_index_smi); | 781 void SetNextEnumerationIndex(compiler::Node* dictionary, |
| 782 compiler::Node* next_enum_index_smi); |
699 | 783 |
700 // Looks up an entry in a NameDictionaryBase successor. If the entry is found | 784 // Looks up an entry in a NameDictionaryBase successor. If the entry is found |
701 // control goes to {if_found} and {var_name_index} contains an index of the | 785 // control goes to {if_found} and {var_name_index} contains an index of the |
702 // key field of the entry found. If the key is not found control goes to | 786 // key field of the entry found. If the key is not found control goes to |
703 // {if_not_found}. | 787 // {if_not_found}. |
704 static const int kInlinedDictionaryProbes = 4; | 788 static const int kInlinedDictionaryProbes = 4; |
705 enum LookupMode { kFindExisting, kFindInsertionIndex }; | 789 enum LookupMode { kFindExisting, kFindInsertionIndex }; |
706 template <typename Dictionary> | 790 template <typename Dictionary> |
707 void NameDictionaryLookup(Node* dictionary, Node* unique_name, | 791 void NameDictionaryLookup(compiler::Node* dictionary, |
708 Label* if_found, Variable* var_name_index, | 792 compiler::Node* unique_name, Label* if_found, |
709 Label* if_not_found, | 793 Variable* var_name_index, Label* if_not_found, |
710 int inlined_probes = kInlinedDictionaryProbes, | 794 int inlined_probes = kInlinedDictionaryProbes, |
711 LookupMode mode = kFindExisting); | 795 LookupMode mode = kFindExisting); |
712 | 796 |
713 Node* ComputeIntegerHash(Node* key, Node* seed); | 797 compiler::Node* ComputeIntegerHash(compiler::Node* key, compiler::Node* seed); |
714 | 798 |
715 template <typename Dictionary> | 799 template <typename Dictionary> |
716 void NumberDictionaryLookup(Node* dictionary, Node* intptr_index, | 800 void NumberDictionaryLookup(compiler::Node* dictionary, |
717 Label* if_found, Variable* var_entry, | 801 compiler::Node* intptr_index, Label* if_found, |
718 Label* if_not_found); | 802 Variable* var_entry, Label* if_not_found); |
719 | 803 |
720 template <class Dictionary> | 804 template <class Dictionary> |
721 void FindInsertionEntry(Node* dictionary, Node* key, Variable* var_key_index); | 805 void FindInsertionEntry(compiler::Node* dictionary, compiler::Node* key, |
| 806 Variable* var_key_index); |
722 | 807 |
723 template <class Dictionary> | 808 template <class Dictionary> |
724 void InsertEntry(Node* dictionary, Node* key, Node* value, Node* index, | 809 void InsertEntry(compiler::Node* dictionary, compiler::Node* key, |
725 Node* enum_index); | 810 compiler::Node* value, compiler::Node* index, |
| 811 compiler::Node* enum_index); |
726 | 812 |
727 template <class Dictionary> | 813 template <class Dictionary> |
728 void Add(Node* dictionary, Node* key, Node* value, Label* bailout); | 814 void Add(compiler::Node* dictionary, compiler::Node* key, |
| 815 compiler::Node* value, Label* bailout); |
729 | 816 |
730 // Tries to check if {object} has own {unique_name} property. | 817 // Tries to check if {object} has own {unique_name} property. |
731 void TryHasOwnProperty(Node* object, Node* map, Node* instance_type, | 818 void TryHasOwnProperty(compiler::Node* object, compiler::Node* map, |
732 Node* unique_name, Label* if_found, | 819 compiler::Node* instance_type, |
| 820 compiler::Node* unique_name, Label* if_found, |
733 Label* if_not_found, Label* if_bailout); | 821 Label* if_not_found, Label* if_bailout); |
734 | 822 |
735 // Tries to get {object}'s own {unique_name} property value. If the property | 823 // Tries to get {object}'s own {unique_name} property value. If the property |
736 // is an accessor then it also calls a getter. If the property is a double | 824 // is an accessor then it also calls a getter. If the property is a double |
737 // field it re-wraps value in an immutable heap number. | 825 // field it re-wraps value in an immutable heap number. |
738 void TryGetOwnProperty(Node* context, Node* receiver, Node* object, Node* map, | 826 void TryGetOwnProperty(compiler::Node* context, compiler::Node* receiver, |
739 Node* instance_type, Node* unique_name, | 827 compiler::Node* object, compiler::Node* map, |
740 Label* if_found, Variable* var_value, | 828 compiler::Node* instance_type, |
741 Label* if_not_found, Label* if_bailout); | 829 compiler::Node* unique_name, Label* if_found, |
| 830 Variable* var_value, Label* if_not_found, |
| 831 Label* if_bailout); |
742 | 832 |
743 void LoadPropertyFromFastObject(Node* object, Node* map, Node* descriptors, | 833 void LoadPropertyFromFastObject(compiler::Node* object, compiler::Node* map, |
744 Node* name_index, Variable* var_details, | 834 compiler::Node* descriptors, |
745 Variable* var_value); | 835 compiler::Node* name_index, |
| 836 Variable* var_details, Variable* var_value); |
746 | 837 |
747 void LoadPropertyFromNameDictionary(Node* dictionary, Node* entry, | 838 void LoadPropertyFromNameDictionary(compiler::Node* dictionary, |
| 839 compiler::Node* entry, |
748 Variable* var_details, | 840 Variable* var_details, |
749 Variable* var_value); | 841 Variable* var_value); |
750 | 842 |
751 void LoadPropertyFromGlobalDictionary(Node* dictionary, Node* entry, | 843 void LoadPropertyFromGlobalDictionary(compiler::Node* dictionary, |
| 844 compiler::Node* entry, |
752 Variable* var_details, | 845 Variable* var_details, |
753 Variable* var_value, Label* if_deleted); | 846 Variable* var_value, Label* if_deleted); |
754 | 847 |
755 // Generic property lookup generator. If the {object} is fast and | 848 // Generic property lookup generator. If the {object} is fast and |
756 // {unique_name} property is found then the control goes to {if_found_fast} | 849 // {unique_name} property is found then the control goes to {if_found_fast} |
757 // label and {var_meta_storage} and {var_name_index} will contain | 850 // label and {var_meta_storage} and {var_name_index} will contain |
758 // DescriptorArray and an index of the descriptor's name respectively. | 851 // DescriptorArray and an index of the descriptor's name respectively. |
759 // If the {object} is slow or global then the control goes to {if_found_dict} | 852 // If the {object} is slow or global then the control goes to {if_found_dict} |
760 // or {if_found_global} and the {var_meta_storage} and {var_name_index} will | 853 // or {if_found_global} and the {var_meta_storage} and {var_name_index} will |
761 // contain a dictionary and an index of the key field of the found entry. | 854 // contain a dictionary and an index of the key field of the found entry. |
762 // If property is not found or given lookup is not supported then | 855 // If property is not found or given lookup is not supported then |
763 // the control goes to {if_not_found} or {if_bailout} respectively. | 856 // the control goes to {if_not_found} or {if_bailout} respectively. |
764 // | 857 // |
765 // Note: this code does not check if the global dictionary points to deleted | 858 // Note: this code does not check if the global dictionary points to deleted |
766 // entry! This has to be done by the caller. | 859 // entry! This has to be done by the caller. |
767 void TryLookupProperty(Node* object, Node* map, Node* instance_type, | 860 void TryLookupProperty(compiler::Node* object, compiler::Node* map, |
768 Node* unique_name, Label* if_found_fast, | 861 compiler::Node* instance_type, |
| 862 compiler::Node* unique_name, Label* if_found_fast, |
769 Label* if_found_dict, Label* if_found_global, | 863 Label* if_found_dict, Label* if_found_global, |
770 Variable* var_meta_storage, Variable* var_name_index, | 864 Variable* var_meta_storage, Variable* var_name_index, |
771 Label* if_not_found, Label* if_bailout); | 865 Label* if_not_found, Label* if_bailout); |
772 | 866 |
773 void TryLookupElement(Node* object, Node* map, Node* instance_type, | 867 void TryLookupElement(compiler::Node* object, compiler::Node* map, |
774 Node* intptr_index, Label* if_found, | 868 compiler::Node* instance_type, |
| 869 compiler::Node* intptr_index, Label* if_found, |
775 Label* if_not_found, Label* if_bailout); | 870 Label* if_not_found, Label* if_bailout); |
776 | 871 |
777 // This is a type of a lookup in holder generator function. In case of a | 872 // This is a type of a lookup in holder generator function. In case of a |
778 // property lookup the {key} is guaranteed to be a unique name and in case of | 873 // property lookup the {key} is guaranteed to be a unique name and in case of |
779 // element lookup the key is an Int32 index. | 874 // element lookup the key is an Int32 index. |
780 typedef std::function<void(Node* receiver, Node* holder, Node* map, | 875 typedef std::function<void(compiler::Node* receiver, compiler::Node* holder, |
781 Node* instance_type, Node* key, Label* next_holder, | 876 compiler::Node* map, compiler::Node* instance_type, |
| 877 compiler::Node* key, Label* next_holder, |
782 Label* if_bailout)> | 878 Label* if_bailout)> |
783 LookupInHolder; | 879 LookupInHolder; |
784 | 880 |
785 // Generic property prototype chain lookup generator. | 881 // Generic property prototype chain lookup generator. |
786 // For properties it generates lookup using given {lookup_property_in_holder} | 882 // For properties it generates lookup using given {lookup_property_in_holder} |
787 // and for elements it uses {lookup_element_in_holder}. | 883 // and for elements it uses {lookup_element_in_holder}. |
788 // Upon reaching the end of prototype chain the control goes to {if_end}. | 884 // Upon reaching the end of prototype chain the control goes to {if_end}. |
789 // If it can't handle the case {receiver}/{key} case then the control goes | 885 // If it can't handle the case {receiver}/{key} case then the control goes |
790 // to {if_bailout}. | 886 // to {if_bailout}. |
791 void TryPrototypeChainLookup(Node* receiver, Node* key, | 887 void TryPrototypeChainLookup(compiler::Node* receiver, compiler::Node* key, |
792 LookupInHolder& lookup_property_in_holder, | 888 LookupInHolder& lookup_property_in_holder, |
793 LookupInHolder& lookup_element_in_holder, | 889 LookupInHolder& lookup_element_in_holder, |
794 Label* if_end, Label* if_bailout); | 890 Label* if_end, Label* if_bailout); |
795 | 891 |
796 // Instanceof helpers. | 892 // Instanceof helpers. |
797 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) | 893 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) |
798 Node* OrdinaryHasInstance(Node* context, Node* callable, Node* object); | 894 compiler::Node* OrdinaryHasInstance(compiler::Node* context, |
| 895 compiler::Node* callable, |
| 896 compiler::Node* object); |
799 | 897 |
800 // Load type feedback vector from the stub caller's frame. | 898 // Load type feedback vector from the stub caller's frame. |
801 Node* LoadTypeFeedbackVectorForStub(); | 899 compiler::Node* LoadTypeFeedbackVectorForStub(); |
802 | 900 |
803 // Update the type feedback vector. | 901 // Update the type feedback vector. |
804 void UpdateFeedback(Node* feedback, Node* type_feedback_vector, | 902 void UpdateFeedback(compiler::Node* feedback, |
805 Node* slot_id); | 903 compiler::Node* type_feedback_vector, |
| 904 compiler::Node* slot_id); |
806 | 905 |
807 Node* LoadReceiverMap(Node* receiver); | 906 compiler::Node* LoadReceiverMap(compiler::Node* receiver); |
808 | 907 |
809 // Extends properties backing store by JSObject::kFieldsAdded elements. | 908 // Extends properties backing store by JSObject::kFieldsAdded elements. |
810 void ExtendPropertiesBackingStore(Node* object); | 909 void ExtendPropertiesBackingStore(compiler::Node* object); |
811 | 910 |
812 Node* PrepareValueForWrite(Node* value, Representation representation, | 911 compiler::Node* PrepareValueForWrite(compiler::Node* value, |
813 Label* bailout); | 912 Representation representation, |
| 913 Label* bailout); |
814 | 914 |
815 void StoreNamedField(Node* object, FieldIndex index, | 915 void StoreNamedField(compiler::Node* object, FieldIndex index, |
816 Representation representation, Node* value, | 916 Representation representation, compiler::Node* value, |
817 bool transition_to_field); | 917 bool transition_to_field); |
818 | 918 |
819 void StoreNamedField(Node* object, Node* offset, bool is_inobject, | 919 void StoreNamedField(compiler::Node* object, compiler::Node* offset, |
820 Representation representation, Node* value, | 920 bool is_inobject, Representation representation, |
821 bool transition_to_field); | 921 compiler::Node* value, bool transition_to_field); |
822 | 922 |
823 // Emits keyed sloppy arguments load. Returns either the loaded value. | 923 // Emits keyed sloppy arguments load. Returns either the loaded value. |
824 Node* LoadKeyedSloppyArguments(Node* receiver, Node* key, Label* bailout) { | 924 compiler::Node* LoadKeyedSloppyArguments(compiler::Node* receiver, |
| 925 compiler::Node* key, |
| 926 Label* bailout) { |
825 return EmitKeyedSloppyArguments(receiver, key, nullptr, bailout); | 927 return EmitKeyedSloppyArguments(receiver, key, nullptr, bailout); |
826 } | 928 } |
827 | 929 |
828 // Emits keyed sloppy arguments store. | 930 // Emits keyed sloppy arguments store. |
829 void StoreKeyedSloppyArguments(Node* receiver, Node* key, Node* value, | 931 void StoreKeyedSloppyArguments(compiler::Node* receiver, compiler::Node* key, |
830 Label* bailout) { | 932 compiler::Node* value, Label* bailout) { |
831 DCHECK_NOT_NULL(value); | 933 DCHECK_NOT_NULL(value); |
832 EmitKeyedSloppyArguments(receiver, key, value, bailout); | 934 EmitKeyedSloppyArguments(receiver, key, value, bailout); |
833 } | 935 } |
834 | 936 |
835 // Loads script context from the script context table. | 937 // Loads script context from the script context table. |
836 Node* LoadScriptContext(Node* context, int context_index); | 938 compiler::Node* LoadScriptContext(compiler::Node* context, int context_index); |
837 | 939 |
838 Node* ClampedToUint8(Node* int32_value); | 940 compiler::Node* ClampedToUint8(compiler::Node* int32_value); |
839 | 941 |
840 // Store value to an elements array with given elements kind. | 942 // Store value to an elements array with given elements kind. |
841 void StoreElement(Node* elements, ElementsKind kind, Node* index, Node* value, | 943 void StoreElement(compiler::Node* elements, ElementsKind kind, |
| 944 compiler::Node* index, compiler::Node* value, |
842 ParameterMode mode); | 945 ParameterMode mode); |
843 | 946 |
844 void EmitElementStore(Node* object, Node* key, Node* value, bool is_jsarray, | 947 void EmitElementStore(compiler::Node* object, compiler::Node* key, |
| 948 compiler::Node* value, bool is_jsarray, |
845 ElementsKind elements_kind, | 949 ElementsKind elements_kind, |
846 KeyedAccessStoreMode store_mode, Label* bailout); | 950 KeyedAccessStoreMode store_mode, Label* bailout); |
847 | 951 |
848 Node* CheckForCapacityGrow(Node* object, Node* elements, ElementsKind kind, | 952 compiler::Node* CheckForCapacityGrow(compiler::Node* object, |
849 Node* length, Node* key, ParameterMode mode, | 953 compiler::Node* elements, |
850 bool is_js_array, Label* bailout); | 954 ElementsKind kind, |
| 955 compiler::Node* length, |
| 956 compiler::Node* key, ParameterMode mode, |
| 957 bool is_js_array, Label* bailout); |
851 | 958 |
852 Node* CopyElementsOnWrite(Node* object, Node* elements, ElementsKind kind, | 959 compiler::Node* CopyElementsOnWrite(compiler::Node* object, |
853 Node* length, ParameterMode mode, Label* bailout); | 960 compiler::Node* elements, |
| 961 ElementsKind kind, compiler::Node* length, |
| 962 ParameterMode mode, Label* bailout); |
854 | 963 |
855 void TransitionElementsKind(Node* object, Node* map, ElementsKind from_kind, | 964 void TransitionElementsKind(compiler::Node* object, compiler::Node* map, |
856 ElementsKind to_kind, bool is_jsarray, | 965 ElementsKind from_kind, ElementsKind to_kind, |
857 Label* bailout); | 966 bool is_jsarray, Label* bailout); |
858 | 967 |
859 void TrapAllocationMemento(Node* object, Label* memento_found); | 968 void TrapAllocationMemento(compiler::Node* object, Label* memento_found); |
860 | 969 |
861 Node* PageFromAddress(Node* address); | 970 compiler::Node* PageFromAddress(compiler::Node* address); |
862 | 971 |
863 // Get the enumerable length from |map| and return the result as a Smi. | 972 // Get the enumerable length from |map| and return the result as a Smi. |
864 Node* EnumLength(Node* map); | 973 compiler::Node* EnumLength(compiler::Node* map); |
865 | 974 |
866 // Check the cache validity for |receiver|. Branch to |use_cache| if | 975 // Check the cache validity for |receiver|. Branch to |use_cache| if |
867 // the cache is valid, otherwise branch to |use_runtime|. | 976 // the cache is valid, otherwise branch to |use_runtime|. |
868 void CheckEnumCache(Node* receiver, CodeStubAssembler::Label* use_cache, | 977 void CheckEnumCache(compiler::Node* receiver, |
| 978 CodeStubAssembler::Label* use_cache, |
869 CodeStubAssembler::Label* use_runtime); | 979 CodeStubAssembler::Label* use_runtime); |
870 | 980 |
871 // Create a new weak cell with a specified value and install it into a | 981 // Create a new weak cell with a specified value and install it into a |
872 // feedback vector. | 982 // feedback vector. |
873 Node* CreateWeakCellInFeedbackVector(Node* feedback_vector, Node* slot, | 983 compiler::Node* CreateWeakCellInFeedbackVector( |
874 Node* value); | 984 compiler::Node* feedback_vector, compiler::Node* slot, |
| 985 compiler::Node* value); |
875 | 986 |
876 // Create a new AllocationSite and install it into a feedback vector. | 987 // Create a new AllocationSite and install it into a feedback vector. |
877 Node* CreateAllocationSiteInFeedbackVector(Node* feedback_vector, Node* slot); | 988 compiler::Node* CreateAllocationSiteInFeedbackVector( |
| 989 compiler::Node* feedback_vector, compiler::Node* slot); |
878 | 990 |
879 enum class IndexAdvanceMode { kPre, kPost }; | 991 enum class IndexAdvanceMode { kPre, kPost }; |
880 | 992 |
881 void BuildFastLoop( | 993 void BuildFastLoop( |
882 const VariableList& var_list, MachineRepresentation index_rep, | 994 const VariableList& var_list, MachineRepresentation index_rep, |
883 Node* start_index, Node* end_index, | 995 compiler::Node* start_index, compiler::Node* end_index, |
884 std::function<void(CodeStubAssembler* assembler, Node* index)> body, | 996 std::function<void(CodeStubAssembler* assembler, compiler::Node* index)> |
| 997 body, |
885 int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre); | 998 int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre); |
886 | 999 |
887 void BuildFastLoop( | 1000 void BuildFastLoop( |
888 MachineRepresentation index_rep, Node* start_index, Node* end_index, | 1001 MachineRepresentation index_rep, compiler::Node* start_index, |
889 std::function<void(CodeStubAssembler* assembler, Node* index)> body, | 1002 compiler::Node* end_index, |
| 1003 std::function<void(CodeStubAssembler* assembler, compiler::Node* index)> |
| 1004 body, |
890 int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre) { | 1005 int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre) { |
891 BuildFastLoop(VariableList(0, zone()), index_rep, start_index, end_index, | 1006 BuildFastLoop(VariableList(0, zone()), index_rep, start_index, end_index, |
892 body, increment, mode); | 1007 body, increment, mode); |
893 } | 1008 } |
894 | 1009 |
895 enum class ForEachDirection { kForward, kReverse }; | 1010 enum class ForEachDirection { kForward, kReverse }; |
896 | 1011 |
897 void BuildFastFixedArrayForEach( | 1012 void BuildFastFixedArrayForEach( |
898 Node* fixed_array, ElementsKind kind, Node* first_element_inclusive, | 1013 compiler::Node* fixed_array, ElementsKind kind, |
899 Node* last_element_exclusive, | 1014 compiler::Node* first_element_inclusive, |
900 std::function<void(CodeStubAssembler* assembler, Node* fixed_array, | 1015 compiler::Node* last_element_exclusive, |
901 Node* offset)> | 1016 std::function<void(CodeStubAssembler* assembler, |
| 1017 compiler::Node* fixed_array, compiler::Node* offset)> |
902 body, | 1018 body, |
903 ParameterMode mode = INTPTR_PARAMETERS, | 1019 ParameterMode mode = INTPTR_PARAMETERS, |
904 ForEachDirection direction = ForEachDirection::kReverse); | 1020 ForEachDirection direction = ForEachDirection::kReverse); |
905 | 1021 |
906 Node* GetArrayAllocationSize(Node* element_count, ElementsKind kind, | 1022 compiler::Node* GetArrayAllocationSize(compiler::Node* element_count, |
907 ParameterMode mode, int header_size) { | 1023 ElementsKind kind, ParameterMode mode, |
| 1024 int header_size) { |
908 return ElementOffsetFromIndex(element_count, kind, mode, header_size); | 1025 return ElementOffsetFromIndex(element_count, kind, mode, header_size); |
909 } | 1026 } |
910 | 1027 |
911 Node* GetFixedArrayAllocationSize(Node* element_count, ElementsKind kind, | 1028 compiler::Node* GetFixedArrayAllocationSize(compiler::Node* element_count, |
912 ParameterMode mode) { | 1029 ElementsKind kind, |
| 1030 ParameterMode mode) { |
913 return GetArrayAllocationSize(element_count, kind, mode, | 1031 return GetArrayAllocationSize(element_count, kind, mode, |
914 FixedArray::kHeaderSize); | 1032 FixedArray::kHeaderSize); |
915 } | 1033 } |
916 | 1034 |
917 enum RelationalComparisonMode { | 1035 enum RelationalComparisonMode { |
918 kLessThan, | 1036 kLessThan, |
919 kLessThanOrEqual, | 1037 kLessThanOrEqual, |
920 kGreaterThan, | 1038 kGreaterThan, |
921 kGreaterThanOrEqual | 1039 kGreaterThanOrEqual |
922 }; | 1040 }; |
923 | 1041 |
924 Node* RelationalComparison(RelationalComparisonMode mode, Node* lhs, | 1042 compiler::Node* RelationalComparison(RelationalComparisonMode mode, |
925 Node* rhs, Node* context); | 1043 compiler::Node* lhs, compiler::Node* rhs, |
| 1044 compiler::Node* context); |
926 | 1045 |
927 void BranchIfNumericRelationalComparison(RelationalComparisonMode mode, | 1046 void BranchIfNumericRelationalComparison(RelationalComparisonMode mode, |
928 Node* lhs, Node* rhs, Label* if_true, | 1047 compiler::Node* lhs, |
| 1048 compiler::Node* rhs, Label* if_true, |
929 Label* if_false); | 1049 Label* if_false); |
930 | 1050 |
931 void GotoUnlessNumberLessThan(Node* lhs, Node* rhs, Label* if_false); | 1051 void GotoUnlessNumberLessThan(compiler::Node* lhs, compiler::Node* rhs, |
| 1052 Label* if_false); |
932 | 1053 |
933 enum ResultMode { kDontNegateResult, kNegateResult }; | 1054 enum ResultMode { kDontNegateResult, kNegateResult }; |
934 | 1055 |
935 Node* Equal(ResultMode mode, Node* lhs, Node* rhs, Node* context); | 1056 compiler::Node* Equal(ResultMode mode, compiler::Node* lhs, |
| 1057 compiler::Node* rhs, compiler::Node* context); |
936 | 1058 |
937 Node* StrictEqual(ResultMode mode, Node* lhs, Node* rhs, Node* context); | 1059 compiler::Node* StrictEqual(ResultMode mode, compiler::Node* lhs, |
| 1060 compiler::Node* rhs, compiler::Node* context); |
938 | 1061 |
939 // ECMA#sec-samevalue | 1062 // ECMA#sec-samevalue |
940 // Similar to StrictEqual except that NaNs are treated as equal and minus zero | 1063 // Similar to StrictEqual except that NaNs are treated as equal and minus zero |
941 // differs from positive zero. | 1064 // differs from positive zero. |
942 // Unlike Equal and StrictEqual, returns a value suitable for use in Branch | 1065 // Unlike Equal and StrictEqual, returns a value suitable for use in Branch |
943 // instructions, e.g. Branch(SameValue(...), &label). | 1066 // instructions, e.g. Branch(SameValue(...), &label). |
944 Node* SameValue(Node* lhs, Node* rhs, Node* context); | 1067 compiler::Node* SameValue(compiler::Node* lhs, compiler::Node* rhs, |
| 1068 compiler::Node* context); |
945 | 1069 |
946 Node* HasProperty( | 1070 compiler::Node* HasProperty( |
947 Node* object, Node* key, Node* context, | 1071 compiler::Node* object, compiler::Node* key, compiler::Node* context, |
948 Runtime::FunctionId fallback_runtime_function_id = Runtime::kHasProperty); | 1072 Runtime::FunctionId fallback_runtime_function_id = Runtime::kHasProperty); |
949 Node* ForInFilter(Node* key, Node* object, Node* context); | 1073 compiler::Node* ForInFilter(compiler::Node* key, compiler::Node* object, |
| 1074 compiler::Node* context); |
950 | 1075 |
951 Node* Typeof(Node* value, Node* context); | 1076 compiler::Node* Typeof(compiler::Node* value, compiler::Node* context); |
952 | 1077 |
953 Node* InstanceOf(Node* object, Node* callable, Node* context); | 1078 compiler::Node* InstanceOf(compiler::Node* object, compiler::Node* callable, |
| 1079 compiler::Node* context); |
954 | 1080 |
955 // Debug helpers | 1081 // Debug helpers |
956 Node* IsDebugActive(); | 1082 compiler::Node* IsDebugActive(); |
957 | 1083 |
958 // TypedArray/ArrayBuffer helpers | 1084 // TypedArray/ArrayBuffer helpers |
959 Node* IsDetachedBuffer(Node* buffer); | 1085 compiler::Node* IsDetachedBuffer(compiler::Node* buffer); |
960 | 1086 |
961 Node* ElementOffsetFromIndex(Node* index, ElementsKind kind, | 1087 compiler::Node* ElementOffsetFromIndex(compiler::Node* index, |
962 ParameterMode mode, int base_size = 0); | 1088 ElementsKind kind, ParameterMode mode, |
| 1089 int base_size = 0); |
963 | 1090 |
964 protected: | 1091 protected: |
965 void DescriptorLookupLinear(Node* unique_name, Node* descriptors, Node* nof, | 1092 void DescriptorLookupLinear(compiler::Node* unique_name, |
| 1093 compiler::Node* descriptors, compiler::Node* nof, |
966 Label* if_found, Variable* var_name_index, | 1094 Label* if_found, Variable* var_name_index, |
967 Label* if_not_found); | 1095 Label* if_not_found); |
968 | 1096 |
969 Node* CallGetterIfAccessor(Node* value, Node* details, Node* context, | 1097 compiler::Node* CallGetterIfAccessor(compiler::Node* value, |
970 Node* receiver, Label* if_bailout); | 1098 compiler::Node* details, |
| 1099 compiler::Node* context, |
| 1100 compiler::Node* receiver, |
| 1101 Label* if_bailout); |
971 | 1102 |
972 Node* TryToIntptr(Node* key, Label* miss); | 1103 compiler::Node* TryToIntptr(compiler::Node* key, Label* miss); |
973 | 1104 |
974 void BranchIfPrototypesHaveNoElements(Node* receiver_map, | 1105 void BranchIfPrototypesHaveNoElements(compiler::Node* receiver_map, |
975 Label* definitely_no_elements, | 1106 Label* definitely_no_elements, |
976 Label* possibly_elements); | 1107 Label* possibly_elements); |
977 | 1108 |
978 private: | 1109 private: |
979 friend class CodeStubArguments; | 1110 friend class CodeStubArguments; |
980 | 1111 |
981 Node* AllocateRawAligned(Node* size_in_bytes, AllocationFlags flags, | 1112 compiler::Node* AllocateRawAligned(compiler::Node* size_in_bytes, |
982 Node* top_address, Node* limit_address); | 1113 AllocationFlags flags, |
983 Node* AllocateRawUnaligned(Node* size_in_bytes, AllocationFlags flags, | 1114 compiler::Node* top_address, |
984 Node* top_adddress, Node* limit_address); | 1115 compiler::Node* limit_address); |
| 1116 compiler::Node* AllocateRawUnaligned(compiler::Node* size_in_bytes, |
| 1117 AllocationFlags flags, |
| 1118 compiler::Node* top_adddress, |
| 1119 compiler::Node* limit_address); |
985 // Allocate and return a JSArray of given total size in bytes with header | 1120 // Allocate and return a JSArray of given total size in bytes with header |
986 // fields initialized. | 1121 // fields initialized. |
987 Node* AllocateUninitializedJSArray(ElementsKind kind, Node* array_map, | 1122 compiler::Node* AllocateUninitializedJSArray(ElementsKind kind, |
988 Node* length, Node* allocation_site, | 1123 compiler::Node* array_map, |
989 Node* size_in_bytes); | 1124 compiler::Node* length, |
| 1125 compiler::Node* allocation_site, |
| 1126 compiler::Node* size_in_bytes); |
990 | 1127 |
991 Node* SmiShiftBitsConstant(); | 1128 compiler::Node* SmiShiftBitsConstant(); |
992 | 1129 |
993 // Emits keyed sloppy arguments load if the |value| is nullptr or store | 1130 // Emits keyed sloppy arguments load if the |value| is nullptr or store |
994 // otherwise. Returns either the loaded value or |value|. | 1131 // otherwise. Returns either the loaded value or |value|. |
995 Node* EmitKeyedSloppyArguments(Node* receiver, Node* key, Node* value, | 1132 compiler::Node* EmitKeyedSloppyArguments(compiler::Node* receiver, |
996 Label* bailout); | 1133 compiler::Node* key, |
| 1134 compiler::Node* value, |
| 1135 Label* bailout); |
997 | 1136 |
998 Node* AllocateSlicedString(Heap::RootListIndex map_root_index, Node* length, | 1137 compiler::Node* AllocateSlicedString(Heap::RootListIndex map_root_index, |
999 Node* parent, Node* offset); | 1138 compiler::Node* length, |
| 1139 compiler::Node* parent, |
| 1140 compiler::Node* offset); |
1000 | 1141 |
1001 Node* AllocateConsString(Heap::RootListIndex map_root_index, Node* length, | 1142 compiler::Node* AllocateConsString(Heap::RootListIndex map_root_index, |
1002 Node* first, Node* second, AllocationFlags flags); | 1143 compiler::Node* length, |
| 1144 compiler::Node* first, |
| 1145 compiler::Node* second, |
| 1146 AllocationFlags flags); |
1003 | 1147 |
1004 static const int kElementLoopUnrollThreshold = 8; | 1148 static const int kElementLoopUnrollThreshold = 8; |
1005 }; | 1149 }; |
1006 | 1150 |
1007 class CodeStubArguments { | 1151 class CodeStubArguments { |
1008 public: | 1152 public: |
1009 typedef compiler::Node Node; | |
1010 | |
1011 // |argc| specifies the number of arguments passed to the builtin excluding | 1153 // |argc| specifies the number of arguments passed to the builtin excluding |
1012 // the receiver. | 1154 // the receiver. |
1013 CodeStubArguments(CodeStubAssembler* assembler, Node* argc, | 1155 CodeStubArguments(CodeStubAssembler* assembler, compiler::Node* argc, |
1014 CodeStubAssembler::ParameterMode mode = | 1156 CodeStubAssembler::ParameterMode mode = |
1015 CodeStubAssembler::INTPTR_PARAMETERS); | 1157 CodeStubAssembler::INTPTR_PARAMETERS); |
1016 | 1158 |
1017 Node* GetReceiver(); | 1159 compiler::Node* GetReceiver(); |
1018 | 1160 |
1019 // |index| is zero-based and does not include the receiver | 1161 // |index| is zero-based and does not include the receiver |
1020 Node* AtIndex(Node* index, CodeStubAssembler::ParameterMode mode = | 1162 compiler::Node* AtIndex(compiler::Node* index, |
1021 CodeStubAssembler::INTPTR_PARAMETERS); | 1163 CodeStubAssembler::ParameterMode mode = |
| 1164 CodeStubAssembler::INTPTR_PARAMETERS); |
1022 | 1165 |
1023 Node* AtIndex(int index); | 1166 compiler::Node* AtIndex(int index); |
1024 | 1167 |
1025 typedef std::function<void(CodeStubAssembler* assembler, Node* arg)> | 1168 typedef std::function<void(CodeStubAssembler* assembler, compiler::Node* arg)> |
1026 ForEachBodyFunction; | 1169 ForEachBodyFunction; |
1027 | 1170 |
1028 // Iteration doesn't include the receiver. |first| and |last| are zero-based. | 1171 // Iteration doesn't include the receiver. |first| and |last| are zero-based. |
1029 void ForEach(ForEachBodyFunction body, Node* first = nullptr, | 1172 void ForEach(ForEachBodyFunction body, compiler::Node* first = nullptr, |
1030 Node* last = nullptr, CodeStubAssembler::ParameterMode mode = | 1173 compiler::Node* last = nullptr, |
1031 CodeStubAssembler::INTPTR_PARAMETERS) { | 1174 CodeStubAssembler::ParameterMode mode = |
| 1175 CodeStubAssembler::INTPTR_PARAMETERS) { |
1032 CodeStubAssembler::VariableList list(0, assembler_->zone()); | 1176 CodeStubAssembler::VariableList list(0, assembler_->zone()); |
1033 ForEach(list, body, first, last); | 1177 ForEach(list, body, first, last); |
1034 } | 1178 } |
1035 | 1179 |
1036 // Iteration doesn't include the receiver. |first| and |last| are zero-based. | 1180 // Iteration doesn't include the receiver. |first| and |last| are zero-based. |
1037 void ForEach(const CodeStubAssembler::VariableList& vars, | 1181 void ForEach(const CodeStubAssembler::VariableList& vars, |
1038 ForEachBodyFunction body, Node* first = nullptr, | 1182 ForEachBodyFunction body, compiler::Node* first = nullptr, |
1039 Node* last = nullptr, CodeStubAssembler::ParameterMode mode = | 1183 compiler::Node* last = nullptr, |
1040 CodeStubAssembler::INTPTR_PARAMETERS); | 1184 CodeStubAssembler::ParameterMode mode = |
| 1185 CodeStubAssembler::INTPTR_PARAMETERS); |
1041 | 1186 |
1042 void PopAndReturn(Node* value); | 1187 void PopAndReturn(compiler::Node* value); |
1043 | 1188 |
1044 private: | 1189 private: |
1045 Node* GetArguments(); | 1190 compiler::Node* GetArguments(); |
1046 | 1191 |
1047 CodeStubAssembler* assembler_; | 1192 CodeStubAssembler* assembler_; |
1048 Node* argc_; | 1193 compiler::Node* argc_; |
1049 Node* arguments_; | 1194 compiler::Node* arguments_; |
1050 Node* fp_; | 1195 compiler::Node* fp_; |
1051 }; | 1196 }; |
1052 | 1197 |
1053 #ifdef DEBUG | 1198 #ifdef DEBUG |
1054 #define CSA_ASSERT(csa, x) \ | 1199 #define CSA_ASSERT(csa, x) \ |
1055 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) | 1200 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) |
1056 #else | 1201 #else |
1057 #define CSA_ASSERT(csa, x) ((void)0) | 1202 #define CSA_ASSERT(csa, x) ((void)0) |
1058 #endif | 1203 #endif |
1059 | 1204 |
1060 #ifdef ENABLE_SLOW_DCHECKS | 1205 #ifdef ENABLE_SLOW_DCHECKS |
1061 #define CSA_SLOW_ASSERT(csa, x) \ | 1206 #define CSA_SLOW_ASSERT(csa, x) \ |
1062 if (FLAG_enable_slow_asserts) { \ | 1207 if (FLAG_enable_slow_asserts) { \ |
1063 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__); \ | 1208 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__); \ |
1064 } | 1209 } |
1065 #else | 1210 #else |
1066 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1211 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
1067 #endif | 1212 #endif |
1068 | 1213 |
1069 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1214 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
1070 | 1215 |
1071 } // namespace internal | 1216 } // namespace internal |
1072 } // namespace v8 | 1217 } // namespace v8 |
1073 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1218 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |