| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 class CallDescriptor; | 28 class CallDescriptor; |
| 29 class Graph; | 29 class Graph; |
| 30 class Node; | 30 class Node; |
| 31 class Operator; | 31 class Operator; |
| 32 class RawMachineAssembler; | 32 class RawMachineAssembler; |
| 33 class RawMachineLabel; | 33 class RawMachineLabel; |
| 34 class Schedule; | 34 class Schedule; |
| 35 | 35 |
| 36 #define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \ | 36 #define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \ |
| 37 V(Float64Equal) \ |
| 37 V(IntPtrAdd) \ | 38 V(IntPtrAdd) \ |
| 38 V(IntPtrSub) \ | 39 V(IntPtrSub) \ |
| 39 V(Int32Add) \ | 40 V(Int32Add) \ |
| 41 V(Int32LessThan) \ |
| 42 V(Int32GreaterThanOrEqual) \ |
| 40 V(Int32Sub) \ | 43 V(Int32Sub) \ |
| 41 V(Int32Mul) \ | 44 V(Int32Mul) \ |
| 42 V(WordEqual) \ | 45 V(WordEqual) \ |
| 43 V(WordNotEqual) \ | 46 V(WordNotEqual) \ |
| 44 V(WordOr) \ | 47 V(WordOr) \ |
| 45 V(WordAnd) \ | 48 V(WordAnd) \ |
| 46 V(WordXor) \ | 49 V(WordXor) \ |
| 47 V(WordShl) \ | 50 V(WordShl) \ |
| 48 V(WordShr) \ | 51 V(WordShr) \ |
| 49 V(WordSar) \ | 52 V(WordSar) \ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 V(Word64Equal) \ | 63 V(Word64Equal) \ |
| 61 V(Word64NotEqual) \ | 64 V(Word64NotEqual) \ |
| 62 V(Word64Or) \ | 65 V(Word64Or) \ |
| 63 V(Word64And) \ | 66 V(Word64And) \ |
| 64 V(Word64Xor) \ | 67 V(Word64Xor) \ |
| 65 V(Word64Shr) \ | 68 V(Word64Shr) \ |
| 66 V(Word64Sar) \ | 69 V(Word64Sar) \ |
| 67 V(Word64Ror) \ | 70 V(Word64Ror) \ |
| 68 V(UintPtrGreaterThanOrEqual) | 71 V(UintPtrGreaterThanOrEqual) |
| 69 | 72 |
| 73 #define CODE_STUB_ASSEMBLER_UNARY_OP_LIST(V) \ |
| 74 V(ChangeFloat64ToUint32) \ |
| 75 V(ChangeInt32ToInt64) \ |
| 76 V(ChangeUint32ToFloat64) |
| 77 |
| 70 class CodeStubAssembler { | 78 class CodeStubAssembler { |
| 71 public: | 79 public: |
| 80 // Create with CallStub linkage. |
| 72 // |result_size| specifies the number of results returned by the stub. | 81 // |result_size| specifies the number of results returned by the stub. |
| 73 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 82 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
| 74 CodeStubAssembler(Isolate* isolate, Zone* zone, | 83 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 75 const CallInterfaceDescriptor& descriptor, | 84 const CallInterfaceDescriptor& descriptor, |
| 76 Code::Flags flags, const char* name, | 85 Code::Flags flags, const char* name, |
| 77 size_t result_size = 1); | 86 size_t result_size = 1); |
| 87 |
| 88 // Create with JSCall linkage. |
| 89 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, |
| 90 Code::Flags flags, const char* name); |
| 91 |
| 78 virtual ~CodeStubAssembler(); | 92 virtual ~CodeStubAssembler(); |
| 79 | 93 |
| 80 Handle<Code> GenerateCode(); | 94 Handle<Code> GenerateCode(); |
| 81 | 95 |
| 82 class Label; | 96 class Label; |
| 83 class Variable { | 97 class Variable { |
| 84 public: | 98 public: |
| 85 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 99 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
| 86 void Bind(Node* value); | 100 void Bind(Node* value); |
| 87 Node* value() const; | 101 Node* value() const; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Node* value); | 149 Node* value); |
| 136 | 150 |
| 137 // Basic arithmetic operations. | 151 // Basic arithmetic operations. |
| 138 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); | 152 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); |
| 139 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) | 153 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) |
| 140 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP | 154 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP |
| 141 | 155 |
| 142 Node* WordShl(Node* value, int shift); | 156 Node* WordShl(Node* value, int shift); |
| 143 | 157 |
| 144 // Conversions | 158 // Conversions |
| 145 Node* ChangeInt32ToInt64(Node* value); | 159 #define DECLARE_CODE_STUB_ASSEMBER_UNARY_OP(name) Node* name(Node* a); |
| 160 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_UNARY_OP) |
| 161 #undef DECLARE_CODE_STUB_ASSEMBER_UNARY_OP |
| 146 | 162 |
| 147 // Projections | 163 // Projections |
| 148 Node* Projection(int index, Node* value); | 164 Node* Projection(int index, Node* value); |
| 149 | 165 |
| 150 // Calls | 166 // Calls |
| 167 Node* Context(); |
| 151 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); | 168 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); |
| 152 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); | 169 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); |
| 153 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 170 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 154 Node* arg2); | 171 Node* arg2); |
| 155 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 172 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 156 Node* arg2, Node* arg3); | 173 Node* arg2, Node* arg3); |
| 157 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 174 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 158 Node* arg2, Node* arg3, Node* arg4); | 175 Node* arg2, Node* arg3, Node* arg4); |
| 159 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 176 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
| 160 Node* arg2, Node* arg3, Node* arg4, Node* arg5); | 177 Node* arg2, Node* arg3, Node* arg4, Node* arg5); |
| 161 | 178 |
| 179 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context); |
| 162 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 180 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 163 Node* arg1); | 181 Node* arg1); |
| 164 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 182 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 165 Node* arg1, Node* arg2); | 183 Node* arg1, Node* arg2); |
| 166 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 184 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 167 Node* arg1, Node* arg2, Node* arg3); | 185 Node* arg1, Node* arg2, Node* arg3); |
| 168 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 186 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
| 169 Node* arg1, Node* arg2, Node* arg3, Node* arg4); | 187 Node* arg1, Node* arg2, Node* arg3, Node* arg4); |
| 170 | 188 |
| 171 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 189 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 197 // Load a value from the root array. | 215 // Load a value from the root array. |
| 198 Node* LoadRoot(Heap::RootListIndex root_index); | 216 Node* LoadRoot(Heap::RootListIndex root_index); |
| 199 | 217 |
| 200 // Check a value for smi-ness | 218 // Check a value for smi-ness |
| 201 Node* WordIsSmi(Node* a); | 219 Node* WordIsSmi(Node* a); |
| 202 | 220 |
| 203 // Load an object pointer from a buffer that isn't in the heap. | 221 // Load an object pointer from a buffer that isn't in the heap. |
| 204 Node* LoadBufferObject(Node* buffer, int offset); | 222 Node* LoadBufferObject(Node* buffer, int offset); |
| 205 // Load a field from an object on the heap. | 223 // Load a field from an object on the heap. |
| 206 Node* LoadObjectField(Node* object, int offset); | 224 Node* LoadObjectField(Node* object, int offset); |
| 225 // Load the HeapNumber value from a HeapNumber object. |
| 226 Node* LoadHeapNumber(Node* object); |
| 207 | 227 |
| 208 // Load an array element from a FixedArray. | 228 // Load an array element from a FixedArray. |
| 209 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 229 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
| 210 int additional_offset = 0); | 230 int additional_offset = 0); |
| 211 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 231 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
| 212 | 232 |
| 233 Node* InstanceType(Node* object); |
| 234 |
| 235 // Returns a node that is true if the given bit is set in |word32|. |
| 236 template <typename T> |
| 237 Node* BitFieldValue(Node* word32) { |
| 238 return BitFieldValue(word32, T::kShift, T::kMask); |
| 239 } |
| 240 |
| 241 Node* BitFieldValue(Node* word32, uint32_t shift, uint32_t mask); |
| 242 |
| 243 |
| 213 protected: | 244 protected: |
| 214 // Protected helpers which delegate to RawMachineAssembler. | 245 // Protected helpers which delegate to RawMachineAssembler. |
| 215 Graph* graph(); | 246 Graph* graph(); |
| 216 Isolate* isolate(); | 247 Isolate* isolate(); |
| 217 Zone* zone(); | 248 Zone* zone(); |
| 218 | 249 |
| 219 // Enables subclasses to perform operations before and after a call. | 250 // Enables subclasses to perform operations before and after a call. |
| 220 virtual void CallPrologue(); | 251 virtual void CallPrologue(); |
| 221 virtual void CallEpilogue(); | 252 virtual void CallEpilogue(); |
| 222 | 253 |
| 223 private: | 254 private: |
| 224 friend class CodeStubAssemblerTester; | 255 friend class CodeStubAssemblerTester; |
| 225 | 256 |
| 226 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 257 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 227 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 258 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 228 | 259 |
| 229 Node* SmiShiftBitsConstant(); | 260 Node* SmiShiftBitsConstant(); |
| 230 | 261 |
| 262 enum class LinkageDescriptorType { kStubCall, kJSCall }; |
| 263 |
| 231 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 264 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
| 232 Code::Flags flags_; | 265 Code::Flags flags_; |
| 233 const char* name_; | 266 const char* name_; |
| 234 bool code_generated_; | 267 bool code_generated_; |
| 235 ZoneVector<Variable::Impl*> variables_; | 268 ZoneVector<Variable::Impl*> variables_; |
| 269 LinkageDescriptorType linkage_type_; |
| 270 int parameter_count_; |
| 236 | 271 |
| 237 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); | 272 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
| 238 }; | 273 }; |
| 239 | 274 |
| 240 class CodeStubAssembler::Label { | 275 class CodeStubAssembler::Label { |
| 241 public: | 276 public: |
| 242 explicit Label(CodeStubAssembler* assembler); | 277 explicit Label(CodeStubAssembler* assembler); |
| 243 Label(CodeStubAssembler* assembler, int merged_variable_count, | 278 Label(CodeStubAssembler* assembler, int merged_variable_count, |
| 244 CodeStubAssembler::Variable** merged_variables); | 279 CodeStubAssembler::Variable** merged_variables); |
| 245 Label(CodeStubAssembler* assembler, | 280 Label(CodeStubAssembler* assembler, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 262 // Map of variables to the list of value nodes that have been added from each | 297 // Map of variables to the list of value nodes that have been added from each |
| 263 // merge path in their order of merging. | 298 // merge path in their order of merging. |
| 264 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 299 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
| 265 }; | 300 }; |
| 266 | 301 |
| 267 } // namespace compiler | 302 } // namespace compiler |
| 268 } // namespace internal | 303 } // namespace internal |
| 269 } // namespace v8 | 304 } // namespace v8 |
| 270 | 305 |
| 271 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 306 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |