| 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. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 V(WordXor) \ | 46 V(WordXor) \ |
| 47 V(WordShl) \ | 47 V(WordShl) \ |
| 48 V(WordShr) \ | 48 V(WordShr) \ |
| 49 V(WordSar) \ | 49 V(WordSar) \ |
| 50 V(WordRor) \ | 50 V(WordRor) \ |
| 51 V(Word32Equal) \ | 51 V(Word32Equal) \ |
| 52 V(Word32NotEqual) \ | 52 V(Word32NotEqual) \ |
| 53 V(Word32Or) \ | 53 V(Word32Or) \ |
| 54 V(Word32And) \ | 54 V(Word32And) \ |
| 55 V(Word32Xor) \ | 55 V(Word32Xor) \ |
| 56 V(Word32Shl) \ |
| 56 V(Word32Shr) \ | 57 V(Word32Shr) \ |
| 57 V(Word32Sar) \ | 58 V(Word32Sar) \ |
| 58 V(Word32Ror) \ | 59 V(Word32Ror) \ |
| 59 V(Word64Equal) \ | 60 V(Word64Equal) \ |
| 60 V(Word64NotEqual) \ | 61 V(Word64NotEqual) \ |
| 61 V(Word64Or) \ | 62 V(Word64Or) \ |
| 62 V(Word64And) \ | 63 V(Word64And) \ |
| 63 V(Word64Xor) \ | 64 V(Word64Xor) \ |
| 64 V(Word64Shr) \ | 65 V(Word64Shr) \ |
| 65 V(Word64Sar) \ | 66 V(Word64Sar) \ |
| 66 V(Word64Ror) | 67 V(Word64Ror) \ |
| 68 V(UintPtrGreaterThanOrEqual) |
| 67 | 69 |
| 68 class CodeStubAssembler { | 70 class CodeStubAssembler { |
| 69 public: | 71 public: |
| 72 // |result_size| specifies the number of results returned by the stub. |
| 73 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
| 70 CodeStubAssembler(Isolate* isolate, Zone* zone, | 74 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 71 const CallInterfaceDescriptor& descriptor, | 75 const CallInterfaceDescriptor& descriptor, |
| 72 Code::Flags flags, const char* name); | 76 Code::Flags flags, const char* name, |
| 77 size_t result_size = 1); |
| 73 virtual ~CodeStubAssembler(); | 78 virtual ~CodeStubAssembler(); |
| 74 | 79 |
| 75 Handle<Code> GenerateCode(); | 80 Handle<Code> GenerateCode(); |
| 76 | 81 |
| 77 class Label; | 82 class Label; |
| 78 class Variable { | 83 class Variable { |
| 79 public: | 84 public: |
| 80 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 85 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
| 81 void Bind(Node* value); | 86 void Bind(Node* value); |
| 82 Node* value() const; | 87 Node* value() const; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 108 void Goto(Label* label); | 113 void Goto(Label* label); |
| 109 void Branch(Node* condition, Label* true_label, Label* false_label); | 114 void Branch(Node* condition, Label* true_label, Label* false_label); |
| 110 | 115 |
| 111 void Switch(Node* index, Label* default_label, int32_t* case_values, | 116 void Switch(Node* index, Label* default_label, int32_t* case_values, |
| 112 Label** case_labels, size_t case_count); | 117 Label** case_labels, size_t case_count); |
| 113 | 118 |
| 114 // Access to the frame pointer | 119 // Access to the frame pointer |
| 115 Node* LoadFramePointer(); | 120 Node* LoadFramePointer(); |
| 116 Node* LoadParentFramePointer(); | 121 Node* LoadParentFramePointer(); |
| 117 | 122 |
| 123 // Access to the stack pointer |
| 124 Node* LoadStackPointer(); |
| 125 |
| 126 // Load raw memory location. |
| 127 Node* Load(MachineType rep, Node* base); |
| 128 Node* Load(MachineType rep, Node* base, Node* index); |
| 129 |
| 130 // Store value to raw memory location. |
| 131 Node* Store(MachineRepresentation rep, Node* base, Node* value); |
| 132 Node* Store(MachineRepresentation rep, Node* base, Node* index, Node* value); |
| 133 Node* StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* value); |
| 134 Node* StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* index, |
| 135 Node* value); |
| 136 |
| 118 // Basic arithmetic operations. | 137 // Basic arithmetic operations. |
| 119 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); | 138 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); |
| 120 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) | 139 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) |
| 121 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP | 140 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP |
| 122 | 141 |
| 123 Node* WordShl(Node* value, int shift); | 142 Node* WordShl(Node* value, int shift); |
| 124 | 143 |
| 144 // Conversions |
| 145 Node* ChangeInt32ToInt64(Node* value); |
| 146 |
| 147 // Projections |
| 148 Node* Projection(int index, Node* value); |
| 149 |
| 125 // Calls | 150 // Calls |
| 151 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); |
| 126 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); | 152 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); |
| 127 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 153 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 128 Node* arg2); | 154 Node* arg2); |
| 155 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 156 Node* arg2, Node* arg3); |
| 157 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 158 Node* arg2, Node* arg3, Node* arg4); |
| 159 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 160 Node* arg2, Node* arg3, Node* arg4, Node* arg5); |
| 129 | 161 |
| 130 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 162 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 131 Node* arg1); | 163 Node* arg1); |
| 132 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 164 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 133 Node* arg1, Node* arg2); | 165 Node* arg1, Node* arg2); |
| 134 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 166 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 135 Node* arg1, Node* arg2, Node* arg3); | 167 Node* arg1, Node* arg2, Node* arg3); |
| 136 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 168 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 137 Node* arg1, Node* arg2, Node* arg3, Node* arg4); | 169 Node* arg1, Node* arg2, Node* arg3, Node* arg4); |
| 138 | 170 |
| 171 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 172 Node* context, Node* arg1, size_t result_size = 1); |
| 173 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 174 Node* context, Node* arg1, Node* arg2, size_t result_size = 1); |
| 175 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 176 Node* context, Node* arg1, Node* arg2, Node* arg3, |
| 177 size_t result_size = 1); |
| 178 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 179 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 180 size_t result_size = 1); |
| 181 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 182 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 183 Node* arg5, size_t result_size = 1); |
| 184 |
| 139 Node* TailCallStub(CodeStub& stub, Node** args); | 185 Node* TailCallStub(CodeStub& stub, Node** args); |
| 140 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 186 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
| 141 Node** args); | 187 Node** args, size_t result_size = 1); |
| 142 | 188 |
| 143 // =========================================================================== | 189 // =========================================================================== |
| 144 // Macros | 190 // Macros |
| 145 // =========================================================================== | 191 // =========================================================================== |
| 146 | 192 |
| 147 // Tag and untag Smi values. | 193 // Tag and untag Smi values. |
| 148 Node* SmiTag(Node* value); | 194 Node* SmiTag(Node* value); |
| 149 Node* SmiUntag(Node* value); | 195 Node* SmiUntag(Node* value); |
| 150 | 196 |
| 151 // Load a value from the root array. | 197 // Load a value from the root array. |
| 152 Node* LoadRoot(Heap::RootListIndex root_index); | 198 Node* LoadRoot(Heap::RootListIndex root_index); |
| 153 | 199 |
| 154 // Check a value for smi-ness | 200 // Check a value for smi-ness |
| 155 Node* WordIsSmi(Node* a); | 201 Node* WordIsSmi(Node* a); |
| 156 | 202 |
| 157 // Load an object pointer from a buffer that isn't in the heap. | 203 // Load an object pointer from a buffer that isn't in the heap. |
| 158 Node* LoadBufferObject(Node* buffer, int offset); | 204 Node* LoadBufferObject(Node* buffer, int offset); |
| 159 // Load a field from an object on the heap. | 205 // Load a field from an object on the heap. |
| 160 Node* LoadObjectField(Node* object, int offset); | 206 Node* LoadObjectField(Node* object, int offset); |
| 161 | 207 |
| 162 // Load an array element from a FixedArray. | 208 // Load an array element from a FixedArray. |
| 163 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 209 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
| 164 int additional_offset = 0); | 210 int additional_offset = 0); |
| 165 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 211 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
| 166 | 212 |
| 213 protected: |
| 214 // Protected helpers which delegate to RawMachineAssembler. |
| 215 Graph* graph(); |
| 216 Isolate* isolate(); |
| 217 Zone* zone(); |
| 218 |
| 219 // Enables subclasses to perform operations before and after a call. |
| 220 virtual void CallPrologue(); |
| 221 virtual void CallEpilogue(); |
| 222 |
| 167 private: | 223 private: |
| 168 friend class CodeStubAssemblerTester; | 224 friend class CodeStubAssemblerTester; |
| 169 | 225 |
| 170 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 226 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 171 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 227 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 172 | 228 |
| 173 Node* SmiShiftBitsConstant(); | 229 Node* SmiShiftBitsConstant(); |
| 174 | 230 |
| 175 // Private helpers which delegate to RawMachineAssembler. | |
| 176 Graph* graph(); | |
| 177 Isolate* isolate(); | |
| 178 Zone* zone(); | |
| 179 | |
| 180 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 231 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
| 181 Code::Flags flags_; | 232 Code::Flags flags_; |
| 182 const char* name_; | 233 const char* name_; |
| 183 bool code_generated_; | 234 bool code_generated_; |
| 184 ZoneVector<Variable::Impl*> variables_; | 235 ZoneVector<Variable::Impl*> variables_; |
| 185 | 236 |
| 186 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); | 237 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
| 187 }; | 238 }; |
| 188 | 239 |
| 189 class CodeStubAssembler::Label { | 240 class CodeStubAssembler::Label { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 211 // Map of variables to the list of value nodes that have been added from each | 262 // Map of variables to the list of value nodes that have been added from each |
| 212 // merge path in their order of merging. | 263 // merge path in their order of merging. |
| 213 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 264 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
| 214 }; | 265 }; |
| 215 | 266 |
| 216 } // namespace compiler | 267 } // namespace compiler |
| 217 } // namespace internal | 268 } // namespace internal |
| 218 } // namespace v8 | 269 } // namespace v8 |
| 219 | 270 |
| 220 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 271 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |