Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 7257fd413422de3b43b4b146e3aa319b1e7b4264..d67ca6996d3d119cf10c3e0eba0ebdf69c9284b0 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -460,7 +460,30 @@ void BytecodeGenerator::VisitCall(Call* expr) { |
void BytecodeGenerator::VisitCallNew(CallNew* expr) { UNIMPLEMENTED(); } |
-void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { UNIMPLEMENTED(); } |
+void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
+ if (expr->is_jsruntime()) { |
+ UNIMPLEMENTED(); |
+ } |
+ |
+ // Evaluate all arguments to the runtime call. |
+ ZoneList<Expression*>* args = expr->arguments(); |
+ TemporaryRegisterScope temporary_register_scope(&builder_); |
+ // Ensure we always have a valid first_arg register even if there are no |
+ // arguments to pass. |
+ Register first_arg = temporary_register_scope.NewRegister(); |
+ for (int i = 0; i < args->length(); ++i) { |
+ Register arg = |
+ (i == 0) ? first_arg : temporary_register_scope.NewRegister(); |
+ Visit(args->at(i)); |
+ DCHECK(arg.index() - i == first_arg.index()); |
Michael Starzinger
2015/09/29 08:28:34
nit: DCHECK_EQ here?
rmcilroy
2015/10/01 17:02:45
Done.
|
+ builder().StoreAccumulatorInRegister(arg); |
+ } |
+ |
+ // TODO(rmcilroy): support multiple return values. |
+ DCHECK(expr->function()->result_size <= 1); |
oth
2015/09/29 09:33:36
nit: DCHECK_LE
rmcilroy
2015/10/01 17:02:45
Done.
|
+ Runtime::FunctionId function_id = expr->function()->function_id; |
+ builder().CallRuntime(function_id, first_arg, args->length()); |
+} |
void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |