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