| 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 #include "src/compiler/code-assembler.h" | 5 #include "src/compiler/code-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| 11 #include "src/compiler/instruction-selector.h" | 11 #include "src/compiler/instruction-selector.h" |
| 12 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
| 13 #include "src/compiler/node-matchers.h" | 13 #include "src/compiler/node-matchers.h" |
| 14 #include "src/compiler/pipeline.h" | 14 #include "src/compiler/pipeline.h" |
| 15 #include "src/compiler/raw-machine-assembler.h" | 15 #include "src/compiler/raw-machine-assembler.h" |
| 16 #include "src/compiler/schedule.h" | 16 #include "src/compiler/schedule.h" |
| 17 #include "src/frames.h" | 17 #include "src/frames.h" |
| 18 #include "src/interface-descriptors.h" | 18 #include "src/interface-descriptors.h" |
| 19 #include "src/interpreter/bytecodes.h" | 19 #include "src/interpreter/bytecodes.h" |
| 20 #include "src/machine-type.h" | 20 #include "src/machine-type.h" |
| 21 #include "src/macro-assembler.h" | 21 #include "src/macro-assembler.h" |
| 22 #include "src/utils.h" | 22 #include "src/utils.h" |
| 23 #include "src/zone/zone.h" | 23 #include "src/zone/zone.h" |
| 24 | 24 |
| 25 #define REPEAT_1_TO_2(V, T) V(T) V(T, T) |
| 26 #define REPEAT_1_TO_3(V, T) REPEAT_1_TO_2(V, T) V(T, T, T) |
| 27 #define REPEAT_1_TO_4(V, T) REPEAT_1_TO_3(V, T) V(T, T, T, T) |
| 28 #define REPEAT_1_TO_5(V, T) REPEAT_1_TO_4(V, T) V(T, T, T, T, T) |
| 29 #define REPEAT_1_TO_6(V, T) REPEAT_1_TO_5(V, T) V(T, T, T, T, T, T) |
| 30 #define REPEAT_1_TO_7(V, T) REPEAT_1_TO_6(V, T) V(T, T, T, T, T, T) |
| 31 #define REPEAT_1_TO_8(V, T) REPEAT_1_TO_7(V, T) V(T, T, T, T, T, T, T) |
| 32 #define REPEAT_1_TO_9(V, T) REPEAT_1_TO_8(V, T) V(T, T, T, T, T, T, T, T) |
| 33 |
| 25 namespace v8 { | 34 namespace v8 { |
| 26 namespace internal { | 35 namespace internal { |
| 27 namespace compiler { | 36 namespace compiler { |
| 28 | 37 |
| 29 CodeAssemblerState::CodeAssemblerState( | 38 CodeAssemblerState::CodeAssemblerState( |
| 30 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, | 39 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, |
| 31 Code::Flags flags, const char* name, size_t result_size) | 40 Code::Flags flags, const char* name, size_t result_size) |
| 32 : CodeAssemblerState( | 41 : CodeAssemblerState( |
| 33 isolate, zone, | 42 isolate, zone, |
| 34 Linkage::GetStubCallDescriptor( | 43 Linkage::GetStubCallDescriptor( |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 Node* return_value = raw_assembler()->CallN(descriptor, code_target, args); | 411 Node* return_value = raw_assembler()->CallN(descriptor, code_target, args); |
| 403 CallEpilogue(); | 412 CallEpilogue(); |
| 404 return return_value; | 413 return return_value; |
| 405 } | 414 } |
| 406 | 415 |
| 407 Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target, | 416 Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target, |
| 408 Node** args) { | 417 Node** args) { |
| 409 return raw_assembler()->TailCallN(descriptor, code_target, args); | 418 return raw_assembler()->TailCallN(descriptor, code_target, args); |
| 410 } | 419 } |
| 411 | 420 |
| 412 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, | 421 template <class... TArgs> |
| 413 Node* context) { | 422 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function, Node* context, |
| 423 TArgs... args) { |
| 414 CallPrologue(); | 424 CallPrologue(); |
| 415 Node* return_value = raw_assembler()->CallRuntime0(function_id, context); | 425 Node* return_value = raw_assembler()->CallRuntime(function, context, args...); |
| 416 CallEpilogue(); | 426 CallEpilogue(); |
| 417 return return_value; | 427 return return_value; |
| 418 } | 428 } |
| 419 | 429 |
| 420 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context, | 430 // Instantiate CallRuntime() with up to 5 arguments. |
| 421 Node* arg1) { | 431 #define INSTANTIATE(...) \ |
| 422 CallPrologue(); | 432 template V8_EXPORT_PRIVATE Node* CodeAssembler::CallRuntime( \ |
| 423 Node* return_value = | 433 Runtime::FunctionId, __VA_ARGS__); |
| 424 raw_assembler()->CallRuntime1(function_id, arg1, context); | 434 REPEAT_1_TO_6(INSTANTIATE, Node*) |
| 425 CallEpilogue(); | 435 #undef INSTANTIATE |
| 426 return return_value; | |
| 427 } | |
| 428 | |
| 429 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context, | |
| 430 Node* arg1, Node* arg2) { | |
| 431 CallPrologue(); | |
| 432 Node* return_value = | |
| 433 raw_assembler()->CallRuntime2(function_id, arg1, arg2, context); | |
| 434 CallEpilogue(); | |
| 435 return return_value; | |
| 436 } | |
| 437 | |
| 438 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context, | |
| 439 Node* arg1, Node* arg2, Node* arg3) { | |
| 440 CallPrologue(); | |
| 441 Node* return_value = | |
| 442 raw_assembler()->CallRuntime3(function_id, arg1, arg2, arg3, context); | |
| 443 CallEpilogue(); | |
| 444 return return_value; | |
| 445 } | |
| 446 | |
| 447 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context, | |
| 448 Node* arg1, Node* arg2, Node* arg3, | |
| 449 Node* arg4) { | |
| 450 CallPrologue(); | |
| 451 Node* return_value = raw_assembler()->CallRuntime4(function_id, arg1, arg2, | |
| 452 arg3, arg4, context); | |
| 453 CallEpilogue(); | |
| 454 return return_value; | |
| 455 } | |
| 456 | |
| 457 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context, | |
| 458 Node* arg1, Node* arg2, Node* arg3, Node* arg4, | |
| 459 Node* arg5) { | |
| 460 CallPrologue(); | |
| 461 Node* return_value = raw_assembler()->CallRuntime5(function_id, arg1, arg2, | |
| 462 arg3, arg4, arg5, context); | |
| 463 CallEpilogue(); | |
| 464 return return_value; | |
| 465 } | |
| 466 | 436 |
| 467 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id, | 437 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
| 468 Node* context) { | 438 Node* context) { |
| 469 return raw_assembler()->TailCallRuntime0(function_id, context); | 439 return raw_assembler()->TailCallRuntime0(function_id, context); |
| 470 } | 440 } |
| 471 | 441 |
| 472 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id, | 442 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
| 473 Node* context, Node* arg1) { | 443 Node* context, Node* arg1) { |
| 474 return raw_assembler()->TailCallRuntime1(function_id, arg1, context); | 444 return raw_assembler()->TailCallRuntime1(function_id, arg1, context); |
| 475 } | 445 } |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 } | 1183 } |
| 1214 } | 1184 } |
| 1215 } | 1185 } |
| 1216 | 1186 |
| 1217 bound_ = true; | 1187 bound_ = true; |
| 1218 } | 1188 } |
| 1219 | 1189 |
| 1220 } // namespace compiler | 1190 } // namespace compiler |
| 1221 } // namespace internal | 1191 } // namespace internal |
| 1222 } // namespace v8 | 1192 } // namespace v8 |
| OLD | NEW |