| 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_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_CODE_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_CODE_ASSEMBLER_H_ | 6 #define V8_COMPILER_CODE_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 Node* target, TArgs... args); | 345 Node* target, TArgs... args); |
| 346 | 346 |
| 347 template <class... TArgs> | 347 template <class... TArgs> |
| 348 Node* CallJS(Callable const& callable, Node* context, Node* function, | 348 Node* CallJS(Callable const& callable, Node* context, Node* function, |
| 349 Node* receiver, TArgs... args) { | 349 Node* receiver, TArgs... args) { |
| 350 int argc = static_cast<int>(sizeof...(args)); | 350 int argc = static_cast<int>(sizeof...(args)); |
| 351 Node* arity = Int32Constant(argc); | 351 Node* arity = Int32Constant(argc); |
| 352 return CallStub(callable, context, function, arity, receiver, args...); | 352 return CallStub(callable, context, function, arity, receiver, args...); |
| 353 } | 353 } |
| 354 | 354 |
| 355 template <class... TArgs> |
| 356 Node* ConstructJS(Callable const& callable, Node* context, Node* new_target, |
| 357 TArgs... args) { |
| 358 int argc = static_cast<int>(sizeof...(args)); |
| 359 Node* arity = Int32Constant(argc); |
| 360 Node* receiver = LoadRoot(Heap::kUndefinedValueRootIndex); |
| 361 |
| 362 // Construct(target, new_target, arity, receiver, arguments...) |
| 363 return CallStub(callable, context, new_target, new_target, arity, receiver, |
| 364 args...); |
| 365 } |
| 366 |
| 355 // Call to a C function with two arguments. | 367 // Call to a C function with two arguments. |
| 356 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, | 368 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, |
| 357 MachineType arg1_type, Node* function, Node* arg0, | 369 MachineType arg1_type, Node* function, Node* arg0, |
| 358 Node* arg1); | 370 Node* arg1); |
| 359 | 371 |
| 360 // Call to a C function with three arguments. | 372 // Call to a C function with three arguments. |
| 361 Node* CallCFunction3(MachineType return_type, MachineType arg0_type, | 373 Node* CallCFunction3(MachineType return_type, MachineType arg0_type, |
| 362 MachineType arg1_type, MachineType arg2_type, | 374 MachineType arg1_type, MachineType arg2_type, |
| 363 Node* function, Node* arg0, Node* arg1, Node* arg2); | 375 Node* function, Node* arg0, Node* arg1, Node* arg2); |
| 364 | 376 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 Code::Flags flags, const char* name, | 474 Code::Flags flags, const char* name, |
| 463 size_t result_size = 1); | 475 size_t result_size = 1); |
| 464 | 476 |
| 465 // Create with JSCall linkage. | 477 // Create with JSCall linkage. |
| 466 CodeAssemblerState(Isolate* isolate, Zone* zone, int parameter_count, | 478 CodeAssemblerState(Isolate* isolate, Zone* zone, int parameter_count, |
| 467 Code::Flags flags, const char* name); | 479 Code::Flags flags, const char* name); |
| 468 | 480 |
| 469 ~CodeAssemblerState(); | 481 ~CodeAssemblerState(); |
| 470 | 482 |
| 471 const char* name() const { return name_; } | 483 const char* name() const { return name_; } |
| 484 int parameter_count() const; |
| 472 | 485 |
| 473 private: | 486 private: |
| 474 friend class CodeAssembler; | 487 friend class CodeAssembler; |
| 475 friend class CodeAssemblerLabel; | 488 friend class CodeAssemblerLabel; |
| 476 friend class CodeAssemblerVariable; | 489 friend class CodeAssemblerVariable; |
| 477 | 490 |
| 478 CodeAssemblerState(Isolate* isolate, Zone* zone, | 491 CodeAssemblerState(Isolate* isolate, Zone* zone, |
| 479 CallDescriptor* call_descriptor, Code::Flags flags, | 492 CallDescriptor* call_descriptor, Code::Flags flags, |
| 480 const char* name); | 493 const char* name); |
| 481 | 494 |
| 482 std::unique_ptr<RawMachineAssembler> raw_assembler_; | 495 std::unique_ptr<RawMachineAssembler> raw_assembler_; |
| 483 Code::Flags flags_; | 496 Code::Flags flags_; |
| 484 const char* name_; | 497 const char* name_; |
| 485 bool code_generated_; | 498 bool code_generated_; |
| 486 ZoneSet<CodeAssemblerVariable::Impl*> variables_; | 499 ZoneSet<CodeAssemblerVariable::Impl*> variables_; |
| 487 CodeAssemblerCallback call_prologue_; | 500 CodeAssemblerCallback call_prologue_; |
| 488 CodeAssemblerCallback call_epilogue_; | 501 CodeAssemblerCallback call_epilogue_; |
| 489 | 502 |
| 490 DISALLOW_COPY_AND_ASSIGN(CodeAssemblerState); | 503 DISALLOW_COPY_AND_ASSIGN(CodeAssemblerState); |
| 491 }; | 504 }; |
| 492 | 505 |
| 493 } // namespace compiler | 506 } // namespace compiler |
| 494 } // namespace internal | 507 } // namespace internal |
| 495 } // namespace v8 | 508 } // namespace v8 |
| 496 | 509 |
| 497 #endif // V8_COMPILER_CODE_ASSEMBLER_H_ | 510 #endif // V8_COMPILER_CODE_ASSEMBLER_H_ |
| OLD | NEW |