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