| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 // Clients of this interface shouldn't depend on lots of compiler internals. | 10 // Clients of this interface shouldn't depend on lots of compiler internals. |
| 11 // Do not include anything from src/compiler here! | 11 // Do not include anything from src/compiler here! |
| 12 #include "src/allocation.h" | 12 #include "src/allocation.h" |
| 13 #include "src/builtins.h" | 13 #include "src/builtins.h" |
| 14 #include "src/heap/heap.h" | 14 #include "src/heap/heap.h" |
| 15 #include "src/machine-type.h" | 15 #include "src/machine-type.h" |
| 16 #include "src/runtime/runtime.h" | 16 #include "src/runtime/runtime.h" |
| 17 #include "src/zone-containers.h" | 17 #include "src/zone-containers.h" |
| 18 | 18 |
| 19 namespace v8 { | 19 namespace v8 { |
| 20 namespace internal { | 20 namespace internal { |
| 21 | 21 |
| 22 class CallInterfaceDescriptor; | 22 class CallInterfaceDescriptor; |
| 23 class Isolate; | 23 class Isolate; |
| 24 class Factory; |
| 24 class Zone; | 25 class Zone; |
| 25 | 26 |
| 26 namespace compiler { | 27 namespace compiler { |
| 27 | 28 |
| 28 class CallDescriptor; | 29 class CallDescriptor; |
| 29 class Graph; | 30 class Graph; |
| 30 class Node; | 31 class Node; |
| 31 class Operator; | 32 class Operator; |
| 32 class RawMachineAssembler; | 33 class RawMachineAssembler; |
| 33 class RawMachineLabel; | 34 class RawMachineLabel; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 V(Word64Or) \ | 68 V(Word64Or) \ |
| 68 V(Word64And) \ | 69 V(Word64And) \ |
| 69 V(Word64Xor) \ | 70 V(Word64Xor) \ |
| 70 V(Word64Shr) \ | 71 V(Word64Shr) \ |
| 71 V(Word64Sar) \ | 72 V(Word64Sar) \ |
| 72 V(Word64Ror) \ | 73 V(Word64Ror) \ |
| 73 V(UintPtrGreaterThanOrEqual) | 74 V(UintPtrGreaterThanOrEqual) |
| 74 | 75 |
| 75 #define CODE_STUB_ASSEMBLER_UNARY_OP_LIST(V) \ | 76 #define CODE_STUB_ASSEMBLER_UNARY_OP_LIST(V) \ |
| 76 V(ChangeFloat64ToUint32) \ | 77 V(ChangeFloat64ToUint32) \ |
| 78 V(ChangeInt32ToFloat64) \ |
| 77 V(ChangeInt32ToInt64) \ | 79 V(ChangeInt32ToInt64) \ |
| 78 V(ChangeUint32ToFloat64) \ | 80 V(ChangeUint32ToFloat64) \ |
| 79 V(ChangeUint32ToUint64) | 81 V(ChangeUint32ToUint64) |
| 80 | 82 |
| 81 class CodeStubAssembler { | 83 class CodeStubAssembler { |
| 82 public: | 84 public: |
| 83 // Create with CallStub linkage. | 85 // Create with CallStub linkage. |
| 84 // |result_size| specifies the number of results returned by the stub. | 86 // |result_size| specifies the number of results returned by the stub. |
| 85 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 87 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
| 86 CodeStubAssembler(Isolate* isolate, Zone* zone, | 88 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 117 | 119 |
| 118 // Constants. | 120 // Constants. |
| 119 Node* Int32Constant(int value); | 121 Node* Int32Constant(int value); |
| 120 Node* IntPtrConstant(intptr_t value); | 122 Node* IntPtrConstant(intptr_t value); |
| 121 Node* NumberConstant(double value); | 123 Node* NumberConstant(double value); |
| 122 Node* SmiConstant(Smi* value); | 124 Node* SmiConstant(Smi* value); |
| 123 Node* HeapConstant(Handle<HeapObject> object); | 125 Node* HeapConstant(Handle<HeapObject> object); |
| 124 Node* BooleanConstant(bool value); | 126 Node* BooleanConstant(bool value); |
| 125 Node* ExternalConstant(ExternalReference address); | 127 Node* ExternalConstant(ExternalReference address); |
| 126 Node* Float64Constant(double value); | 128 Node* Float64Constant(double value); |
| 129 Node* HeapNumberMapConstant(); |
| 127 | 130 |
| 128 Node* Parameter(int value); | 131 Node* Parameter(int value); |
| 129 void Return(Node* value); | 132 void Return(Node* value); |
| 130 | 133 |
| 131 void Bind(Label* label); | 134 void Bind(Label* label); |
| 132 void Goto(Label* label); | 135 void Goto(Label* label); |
| 133 void Branch(Node* condition, Label* true_label, Label* false_label); | 136 void Branch(Node* condition, Label* true_label, Label* false_label); |
| 134 | 137 |
| 135 void Switch(Node* index, Label* default_label, int32_t* case_values, | 138 void Switch(Node* index, Label* default_label, int32_t* case_values, |
| 136 Label** case_labels, size_t case_count); | 139 Label** case_labels, size_t case_count); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 200 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 198 Node* context, Node* arg1, Node* arg2, Node* arg3, | 201 Node* context, Node* arg1, Node* arg2, Node* arg3, |
| 199 size_t result_size = 1); | 202 size_t result_size = 1); |
| 200 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 203 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 201 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 204 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 202 size_t result_size = 1); | 205 size_t result_size = 1); |
| 203 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 206 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 204 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 207 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 205 Node* arg5, size_t result_size = 1); | 208 Node* arg5, size_t result_size = 1); |
| 206 | 209 |
| 207 Node* TailCallStub(CodeStub& stub, Node** args); | 210 Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 211 Node* context, Node* arg1, Node* arg2, |
| 212 size_t result_size = 1); |
| 213 |
| 208 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 214 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
| 209 Node** args, size_t result_size = 1); | 215 Node** args, size_t result_size = 1); |
| 210 | 216 |
| 211 // =========================================================================== | 217 // =========================================================================== |
| 212 // Macros | 218 // Macros |
| 213 // =========================================================================== | 219 // =========================================================================== |
| 214 | 220 |
| 215 // Tag a Word as a Smi value. | 221 // Tag a Word as a Smi value. |
| 216 Node* SmiTag(Node* value); | 222 Node* SmiTag(Node* value); |
| 217 // Untag a Smi value as a Word. | 223 // Untag a Smi value as a Word. |
| 218 Node* SmiUntag(Node* value); | 224 Node* SmiUntag(Node* value); |
| 219 // Untag an Smi value as a 32-bit value. | 225 |
| 226 // Smi conversions. |
| 227 Node* SmiToFloat64(Node* value); |
| 220 Node* SmiToInt32(Node* value); | 228 Node* SmiToInt32(Node* value); |
| 221 | 229 |
| 222 // Smi operations. | 230 // Smi operations. |
| 223 Node* SmiAdd(Node* a, Node* b); | 231 Node* SmiAdd(Node* a, Node* b); |
| 224 Node* SmiEqual(Node* a, Node* b); | 232 Node* SmiEqual(Node* a, Node* b); |
| 225 | 233 |
| 226 // Load a value from the root array. | 234 // Load a value from the root array. |
| 227 Node* LoadRoot(Heap::RootListIndex root_index); | 235 Node* LoadRoot(Heap::RootListIndex root_index); |
| 228 | 236 |
| 229 // Check a value for smi-ness | 237 // Check a value for smi-ness |
| 230 Node* WordIsSmi(Node* a); | 238 Node* WordIsSmi(Node* a); |
| 231 | 239 |
| 232 // Load an object pointer from a buffer that isn't in the heap. | 240 // Load an object pointer from a buffer that isn't in the heap. |
| 233 Node* LoadBufferObject(Node* buffer, int offset); | 241 Node* LoadBufferObject(Node* buffer, int offset); |
| 234 // Load a field from an object on the heap. | 242 // Load a field from an object on the heap. |
| 235 Node* LoadObjectField(Node* object, int offset); | 243 Node* LoadObjectField(Node* object, int offset); |
| 236 // Load the HeapNumber value from a HeapNumber object. | 244 // Load the floating point value of a HeapNumber. |
| 237 Node* LoadHeapNumberValue(Node* object); | 245 Node* LoadHeapNumberValue(Node* object); |
| 246 // Load the instance type of a Map. |
| 247 Node* LoadMapInstanceType(Node* map); |
| 238 | 248 |
| 239 // Load an array element from a FixedArray. | 249 // Load an array element from a FixedArray. |
| 240 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 250 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
| 241 int additional_offset = 0); | 251 int additional_offset = 0); |
| 242 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 252 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
| 243 | 253 |
| 244 // Store an array element to a FixedArray. | 254 // Store an array element to a FixedArray. |
| 245 Node* StoreFixedArrayElementNoWriteBarrier(Node* object, Node* index, | 255 Node* StoreFixedArrayElementNoWriteBarrier(Node* object, Node* index, |
| 246 Node* value); | 256 Node* value); |
| 247 Node* LoadInstanceType(Node* object); | 257 Node* LoadInstanceType(Node* object); |
| 248 | 258 |
| 249 // Returns a node that is true if the given bit is set in |word32|. | 259 // Returns a node that is true if the given bit is set in |word32|. |
| 250 template <typename T> | 260 template <typename T> |
| 251 Node* BitFieldDecode(Node* word32) { | 261 Node* BitFieldDecode(Node* word32) { |
| 252 return BitFieldDecode(word32, T::kShift, T::kMask); | 262 return BitFieldDecode(word32, T::kShift, T::kMask); |
| 253 } | 263 } |
| 254 | 264 |
| 255 Node* BitFieldDecode(Node* word32, uint32_t shift, uint32_t mask); | 265 Node* BitFieldDecode(Node* word32, uint32_t shift, uint32_t mask); |
| 256 | 266 |
| 267 // Branching helpers. |
| 268 // TODO(danno): Can we be more cleverish wrt. edge-split? |
| 269 void BranchIfFloat64Equal(Node* a, Node* b, Label* if_true, Label* if_false); |
| 270 void BranchIfFloat64IsNaN(Node* value, Label* if_true, Label* if_false) { |
| 271 BranchIfFloat64Equal(value, value, if_false, if_true); |
| 272 } |
| 273 |
| 257 protected: | 274 protected: |
| 258 // Protected helpers which delegate to RawMachineAssembler. | 275 // Protected helpers which delegate to RawMachineAssembler. |
| 259 Graph* graph(); | 276 Graph* graph() const; |
| 260 Isolate* isolate(); | 277 Factory* factory() const; |
| 261 Zone* zone(); | 278 Isolate* isolate() const; |
| 279 Zone* zone() const; |
| 262 | 280 |
| 263 // Enables subclasses to perform operations before and after a call. | 281 // Enables subclasses to perform operations before and after a call. |
| 264 virtual void CallPrologue(); | 282 virtual void CallPrologue(); |
| 265 virtual void CallEpilogue(); | 283 virtual void CallEpilogue(); |
| 266 | 284 |
| 267 private: | 285 private: |
| 268 friend class CodeStubAssemblerTester; | 286 friend class CodeStubAssemblerTester; |
| 269 | 287 |
| 270 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 288 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 271 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 289 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Map of variables to the list of value nodes that have been added from each | 324 // Map of variables to the list of value nodes that have been added from each |
| 307 // merge path in their order of merging. | 325 // merge path in their order of merging. |
| 308 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 326 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
| 309 }; | 327 }; |
| 310 | 328 |
| 311 } // namespace compiler | 329 } // namespace compiler |
| 312 } // namespace internal | 330 } // namespace internal |
| 313 } // namespace v8 | 331 } // namespace v8 |
| 314 | 332 |
| 315 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 333 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |