| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 V(Word64Or) \ | 62 V(Word64Or) \ |
| 63 V(Word64And) \ | 63 V(Word64And) \ |
| 64 V(Word64Xor) \ | 64 V(Word64Xor) \ |
| 65 V(Word64Shr) \ | 65 V(Word64Shr) \ |
| 66 V(Word64Sar) \ | 66 V(Word64Sar) \ |
| 67 V(Word64Ror) \ | 67 V(Word64Ror) \ |
| 68 V(UintPtrGreaterThanOrEqual) | 68 V(UintPtrGreaterThanOrEqual) |
| 69 | 69 |
| 70 class CodeStubAssembler { | 70 class CodeStubAssembler { |
| 71 public: | 71 public: |
| 72 // CodeStubAssembler for generating stubs. |
| 72 // |result_size| specifies the number of results returned by the stub. | 73 // |result_size| specifies the number of results returned by the stub. |
| 73 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 74 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
| 74 CodeStubAssembler(Isolate* isolate, Zone* zone, | 75 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 75 const CallInterfaceDescriptor& descriptor, | 76 const CallInterfaceDescriptor& descriptor, |
| 76 Code::Flags flags, const char* name, | 77 Code::Flags flags, const char* name, |
| 77 size_t result_size = 1); | 78 size_t result_size = 1); |
| 79 |
| 80 // CodeStubAssembler for generating JS functions. |
| 81 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, |
| 82 Code::Flags flags, const char* name); |
| 83 |
| 78 virtual ~CodeStubAssembler(); | 84 virtual ~CodeStubAssembler(); |
| 79 | 85 |
| 80 Handle<Code> GenerateCode(); | 86 Handle<Code> GenerateCode(); |
| 81 | 87 |
| 82 class Label; | 88 class Label; |
| 83 class Variable { | 89 class Variable { |
| 84 public: | 90 public: |
| 85 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 91 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
| 86 void Bind(Node* value); | 92 void Bind(Node* value); |
| 87 Node* value() const; | 93 Node* value() const; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 // Base Assembler | 104 // Base Assembler |
| 99 // =========================================================================== | 105 // =========================================================================== |
| 100 | 106 |
| 101 // Constants. | 107 // Constants. |
| 102 Node* Int32Constant(int value); | 108 Node* Int32Constant(int value); |
| 103 Node* IntPtrConstant(intptr_t value); | 109 Node* IntPtrConstant(intptr_t value); |
| 104 Node* NumberConstant(double value); | 110 Node* NumberConstant(double value); |
| 105 Node* HeapConstant(Handle<HeapObject> object); | 111 Node* HeapConstant(Handle<HeapObject> object); |
| 106 Node* BooleanConstant(bool value); | 112 Node* BooleanConstant(bool value); |
| 107 Node* ExternalConstant(ExternalReference address); | 113 Node* ExternalConstant(ExternalReference address); |
| 114 Node* NullConstant(); |
| 115 Node* UndefinedConstant(); |
| 108 | 116 |
| 109 Node* Parameter(int value); | 117 Node* Parameter(int value); |
| 110 void Return(Node* value); | 118 void Return(Node* value); |
| 111 | 119 |
| 112 void Bind(Label* label); | 120 void Bind(Label* label); |
| 113 void Goto(Label* label); | 121 void Goto(Label* label); |
| 114 void Branch(Node* condition, Label* true_label, Label* false_label); | 122 void Branch(Node* condition, Label* true_label, Label* false_label); |
| 115 | 123 |
| 116 void Switch(Node* index, Label* default_label, int32_t* case_values, | 124 void Switch(Node* index, Label* default_label, int32_t* case_values, |
| 117 Label** case_labels, size_t case_count); | 125 Label** case_labels, size_t case_count); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 187 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 180 size_t result_size = 1); | 188 size_t result_size = 1); |
| 181 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 189 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
| 182 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 190 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
| 183 Node* arg5, size_t result_size = 1); | 191 Node* arg5, size_t result_size = 1); |
| 184 | 192 |
| 185 Node* TailCallStub(CodeStub& stub, Node** args); | 193 Node* TailCallStub(CodeStub& stub, Node** args); |
| 186 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 194 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
| 187 Node** args, size_t result_size = 1); | 195 Node** args, size_t result_size = 1); |
| 188 | 196 |
| 197 // Calls w/ custom CallDescriptor. Prefer the call methods above. |
| 198 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 199 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
| 200 |
| 189 // =========================================================================== | 201 // =========================================================================== |
| 190 // Macros | 202 // Macros |
| 191 // =========================================================================== | 203 // =========================================================================== |
| 192 | 204 |
| 193 // Tag and untag Smi values. | 205 // Tag and untag Smi values. |
| 194 Node* SmiTag(Node* value); | 206 Node* SmiTag(Node* value); |
| 195 Node* SmiUntag(Node* value); | 207 Node* SmiUntag(Node* value); |
| 196 | 208 |
| 197 // Load a value from the root array. | 209 // Load a value from the root array. |
| 198 Node* LoadRoot(Heap::RootListIndex root_index); | 210 Node* LoadRoot(Heap::RootListIndex root_index); |
| 199 | 211 |
| 200 // Check a value for smi-ness | 212 // Check a value for smi-ness |
| 201 Node* WordIsSmi(Node* a); | 213 Node* WordIsSmi(Node* a); |
| 202 | 214 |
| 203 // Load an object pointer from a buffer that isn't in the heap. | 215 // Load an object pointer from a buffer that isn't in the heap. |
| 204 Node* LoadBufferObject(Node* buffer, int offset); | 216 Node* LoadBufferObject(Node* buffer, int offset, |
| 217 MachineType rep = MachineType::AnyTagged()); |
| 205 // Load a field from an object on the heap. | 218 // Load a field from an object on the heap. |
| 206 Node* LoadObjectField(Node* object, int offset); | 219 Node* LoadObjectField(Node* object, int offset, |
| 220 MachineType rep = MachineType::AnyTagged()); |
| 207 | 221 |
| 208 // Load an array element from a FixedArray. | 222 // Load an array element from a FixedArray. |
| 209 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 223 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
| 210 int additional_offset = 0); | 224 int additional_offset = 0); |
| 211 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 225 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
| 212 | 226 |
| 213 protected: | 227 protected: |
| 214 // Protected helpers which delegate to RawMachineAssembler. | 228 // Protected helpers which delegate to RawMachineAssembler. |
| 215 Graph* graph(); | 229 Graph* graph(); |
| 216 Isolate* isolate(); | 230 Isolate* isolate(); |
| 217 Zone* zone(); | 231 Zone* zone(); |
| 218 | 232 |
| 219 // Enables subclasses to perform operations before and after a call. | 233 // Enables subclasses to perform operations before and after a call. |
| 220 virtual void CallPrologue(); | 234 virtual void CallPrologue(); |
| 221 virtual void CallEpilogue(); | 235 virtual void CallEpilogue(); |
| 222 | 236 |
| 223 private: | 237 private: |
| 224 friend class CodeStubAssemblerTester; | 238 friend class CodeStubAssemblerTester; |
| 225 | 239 |
| 226 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 240 CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 227 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 241 CallDescriptor* call_descriptor, Code::Flags flags, |
| 228 | 242 const char* name); |
| 229 Node* SmiShiftBitsConstant(); | 243 Node* SmiShiftBitsConstant(); |
| 230 | 244 |
| 231 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 245 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
| 232 Code::Flags flags_; | 246 Code::Flags flags_; |
| 233 const char* name_; | 247 const char* name_; |
| 234 bool code_generated_; | 248 bool code_generated_; |
| 235 ZoneVector<Variable::Impl*> variables_; | 249 ZoneVector<Variable::Impl*> variables_; |
| 236 | 250 |
| 237 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); | 251 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
| 238 }; | 252 }; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 262 // Map of variables to the list of value nodes that have been added from each | 276 // Map of variables to the list of value nodes that have been added from each |
| 263 // merge path in their order of merging. | 277 // merge path in their order of merging. |
| 264 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 278 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
| 265 }; | 279 }; |
| 266 | 280 |
| 267 } // namespace compiler | 281 } // namespace compiler |
| 268 } // namespace internal | 282 } // namespace internal |
| 269 } // namespace v8 | 283 } // namespace v8 |
| 270 | 284 |
| 271 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 285 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |