| Index: src/compiler/code-stub-linkage.cc
|
| diff --git a/src/compiler/code-stub-linkage.cc b/src/compiler/code-stub-linkage.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dab968d0cfbfdf7dd05d4ca55cc34e06ca19f6f1
|
| --- /dev/null
|
| +++ b/src/compiler/code-stub-linkage.cc
|
| @@ -0,0 +1,107 @@
|
| +// 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/code-stubs.h"
|
| +#include "src/macro-assembler.h"
|
| +
|
| +#include "src/compiler/linkage.h"
|
| +#include "src/compiler/linkage-impl.h"
|
| +
|
| +namespace v8 {
|
| +namespace internal {
|
| +namespace compiler {
|
| +
|
| +namespace {
|
| +MachineType reptyp(Representation representation) {
|
| + switch (representation.kind()) {
|
| + case Representation::kInteger8:
|
| + return kMachInt8;
|
| + case Representation::kUInteger8:
|
| + return kMachUint8;
|
| + case Representation::kInteger16:
|
| + return kMachInt16;
|
| + case Representation::kUInteger16:
|
| + return kMachUint16;
|
| + case Representation::kInteger32:
|
| + return kMachInt32;
|
| + case Representation::kSmi:
|
| + case Representation::kTagged:
|
| + case Representation::kHeapObject:
|
| + return kMachAnyTagged;
|
| + case Representation::kDouble:
|
| + return kMachFloat64;
|
| + case Representation::kExternal:
|
| + return kMachPtr;
|
| + case Representation::kNone:
|
| + case Representation::kNumRepresentations:
|
| + break;
|
| + }
|
| + UNREACHABLE();
|
| + return kMachNone;
|
| +}
|
| +} // namespace
|
| +
|
| +
|
| +// TODO(all): Add support for return representations/locations to
|
| +// CallInterfaceDescriptor.
|
| +// TODO(turbofan): cache call descriptors for code stub calls.
|
| +CallDescriptor* Linkage::GetStubCallDescriptor(
|
| + Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor,
|
| + int stack_parameter_count, CallDescriptor::Flags flags,
|
| + Operator::Properties properties, MachineType return_type) {
|
| + const int register_parameter_count = descriptor.GetRegisterParameterCount();
|
| + const int js_parameter_count =
|
| + register_parameter_count + stack_parameter_count;
|
| + const int context_count = 1;
|
| + const size_t return_count = 1;
|
| + const size_t parameter_count =
|
| + static_cast<size_t>(js_parameter_count + context_count);
|
| +
|
| + LocationSignature::Builder locations(zone, return_count, parameter_count);
|
| + MachineSignature::Builder types(zone, return_count, parameter_count);
|
| +
|
| + // Add return location.
|
| + locations.AddReturn(regloc(kReturnRegister0));
|
| + types.AddReturn(return_type);
|
| +
|
| + // Add parameters in registers and on the stack.
|
| + for (int i = 0; i < js_parameter_count; i++) {
|
| + if (i < register_parameter_count) {
|
| + // The first parameters go in registers.
|
| + Register reg = descriptor.GetRegisterParameter(i);
|
| + Representation rep =
|
| + RepresentationFromType(descriptor.GetParameterType(i));
|
| + locations.AddParam(regloc(reg));
|
| + types.AddParam(reptyp(rep));
|
| + } else {
|
| + // The rest of the parameters go on the stack.
|
| + int stack_slot = i - register_parameter_count - stack_parameter_count;
|
| + locations.AddParam(stackloc(stack_slot));
|
| + types.AddParam(kMachAnyTagged);
|
| + }
|
| + }
|
| + // Add context.
|
| + locations.AddParam(regloc(kContextRegister));
|
| + types.AddParam(kMachAnyTagged);
|
| +
|
| + // The target for stub 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
|
| + stack_parameter_count, // stack_parameter_count
|
| + properties, // properties
|
| + kNoCalleeSaved, // callee-saved registers
|
| + kNoCalleeSaved, // callee-saved fp
|
| + flags, // flags
|
| + descriptor.DebugName(isolate));
|
| +}
|
| +}
|
| +}
|
| +}
|
|
|