Index: src/compiler/runtime-linkage.cc |
diff --git a/src/compiler/runtime-linkage.cc b/src/compiler/runtime-linkage.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c84c100d1305db15cfc586230a9d1f65dde0e90e |
--- /dev/null |
+++ b/src/compiler/runtime-linkage.cc |
@@ -0,0 +1,82 @@ |
+// Copyright 2015 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "src/assembler.h" |
+#include "src/macro-assembler.h" |
+ |
+#include "src/compiler/linkage.h" |
+ |
+#include "src/compiler/linkage-impl.h" |
+ |
+namespace v8 { |
+namespace internal { |
+namespace compiler { |
+ |
+CallDescriptor* Linkage::GetRuntimeCallDescriptor( |
+ Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, |
+ Operator::Properties properties) { |
+ const size_t function_count = 1; |
+ const size_t num_args_count = 1; |
+ const size_t context_count = 1; |
+ const size_t parameter_count = function_count + |
+ static_cast<size_t>(js_parameter_count) + |
+ num_args_count + context_count; |
+ |
+ const Runtime::Function* function = Runtime::FunctionForId(function_id); |
+ const size_t return_count = static_cast<size_t>(function->result_size); |
+ |
+ LocationSignature::Builder locations(zone, return_count, parameter_count); |
+ MachineSignature::Builder types(zone, return_count, parameter_count); |
+ |
+ // Add returns. |
+ if (locations.return_count_ > 0) { |
+ locations.AddReturn(regloc(kReturnRegister0)); |
+ } |
+ if (locations.return_count_ > 1) { |
+ locations.AddReturn(regloc(kReturnRegister1)); |
+ } |
+ for (size_t i = 0; i < return_count; i++) { |
+ types.AddReturn(kMachAnyTagged); |
+ } |
+ |
+ // All parameters to the runtime call go on the stack. |
+ for (int i = 0; i < js_parameter_count; i++) { |
+ locations.AddParam(stackloc(i - js_parameter_count)); |
+ types.AddParam(kMachAnyTagged); |
+ } |
+ // Add runtime function itself. |
+ locations.AddParam(regloc(kRuntimeCallFunctionRegister)); |
+ types.AddParam(kMachAnyTagged); |
+ |
+ // Add runtime call argument count. |
+ locations.AddParam(regloc(kRuntimeCallArgCountRegister)); |
+ types.AddParam(kMachPtr); |
+ |
+ // Add context. |
+ locations.AddParam(regloc(kContextRegister)); |
+ types.AddParam(kMachAnyTagged); |
+ |
+ CallDescriptor::Flags flags = Linkage::FrameStateInputCount(function_id) > 0 |
+ ? CallDescriptor::kNeedsFrameState |
+ : CallDescriptor::kNoFlags; |
+ |
+ // The target for runtime calls is a code object. |
+ MachineType target_type = kMachAnyTagged; |
+ LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
+ return new (zone) CallDescriptor( // -- |
+ CallDescriptor::kCallCodeObject, // kind |
+ target_type, // target MachineType |
+ target_loc, // target location |
+ types.Build(), // machine_sig |
+ locations.Build(), // location_sig |
+ js_parameter_count, // stack_parameter_count |
+ properties, // properties |
+ kNoCalleeSaved, // callee-saved |
+ kNoCalleeSaved, // callee-saved fp |
+ flags, // flags |
+ function->name); // debug name |
+} |
+} |
+} |
+} |