| Index: src/compiler/linkage.cc
|
| diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b08f6942e45b5178c0e750d7c326a4e733f39bbd
|
| --- /dev/null
|
| +++ b/src/compiler/linkage.cc
|
| @@ -0,0 +1,140 @@
|
| +// Copyright 2014 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/compiler/linkage.h"
|
| +
|
| +#include "src/code-stubs.h"
|
| +#include "src/compiler.h"
|
| +#include "src/compiler/node.h"
|
| +#include "src/compiler/pipeline.h"
|
| +#include "src/scopes.h"
|
| +
|
| +namespace v8 {
|
| +namespace internal {
|
| +namespace compiler {
|
| +
|
| +
|
| +OStream& operator<<(OStream& os, const CallDescriptor::Kind& k) {
|
| + switch (k) {
|
| + case CallDescriptor::kCallCodeObject:
|
| + os << "Code";
|
| + break;
|
| + case CallDescriptor::kCallJSFunction:
|
| + os << "JS";
|
| + break;
|
| + case CallDescriptor::kCallAddress:
|
| + os << "Addr";
|
| + break;
|
| + }
|
| + return os;
|
| +}
|
| +
|
| +
|
| +OStream& operator<<(OStream& os, const CallDescriptor& d) {
|
| + // TODO(svenpanne) Output properties etc. and be less cryptic.
|
| + return os << d.kind() << ":" << d.debug_name() << ":r" << d.ReturnCount()
|
| + << "p" << d.ParameterCount() << "i" << d.InputCount()
|
| + << (d.CanLazilyDeoptimize() ? "deopt" : "");
|
| +}
|
| +
|
| +
|
| +Linkage::Linkage(CompilationInfo* info) : info_(info) {
|
| + if (info->function() != NULL) {
|
| + // If we already have the function literal, use the number of parameters
|
| + // plus the receiver.
|
| + incoming_ = GetJSCallDescriptor(1 + info->function()->parameter_count());
|
| + } else if (!info->closure().is_null()) {
|
| + // If we are compiling a JS function, use a JS call descriptor,
|
| + // plus the receiver.
|
| + SharedFunctionInfo* shared = info->closure()->shared();
|
| + incoming_ = GetJSCallDescriptor(1 + shared->formal_parameter_count());
|
| + } else if (info->code_stub() != NULL) {
|
| + // Use the code stub interface descriptor.
|
| + HydrogenCodeStub* stub = info->code_stub();
|
| + CodeStubInterfaceDescriptor* descriptor =
|
| + info_->isolate()->code_stub_interface_descriptor(stub->MajorKey());
|
| + incoming_ = GetStubCallDescriptor(descriptor);
|
| + } else {
|
| + incoming_ = NULL; // TODO(titzer): ?
|
| + }
|
| +}
|
| +
|
| +
|
| +FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame, int extra) {
|
| + if (frame->GetSpillSlotCount() > 0 || incoming_->IsJSFunctionCall() ||
|
| + incoming_->kind() == CallDescriptor::kCallAddress) {
|
| + int offset;
|
| + int register_save_area_size = frame->GetRegisterSaveAreaSize();
|
| + if (spill_slot >= 0) {
|
| + // Local or spill slot. Skip the frame pointer, function, and
|
| + // context in the fixed part of the frame.
|
| + offset =
|
| + -(spill_slot + 1) * kPointerSize - register_save_area_size + extra;
|
| + } else {
|
| + // Incoming parameter. Skip the return address.
|
| + offset = -(spill_slot + 1) * kPointerSize + kFPOnStackSize +
|
| + kPCOnStackSize + extra;
|
| + }
|
| + return FrameOffset::FromFramePointer(offset);
|
| + } else {
|
| + // No frame. Retrieve all parameters relative to stack pointer.
|
| + ASSERT(spill_slot < 0); // Must be a parameter.
|
| + int register_save_area_size = frame->GetRegisterSaveAreaSize();
|
| + int offset = register_save_area_size - (spill_slot + 1) * kPointerSize +
|
| + kPCOnStackSize + extra;
|
| + return FrameOffset::FromStackPointer(offset);
|
| + }
|
| +}
|
| +
|
| +
|
| +CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) {
|
| + return GetJSCallDescriptor(parameter_count, this->info_->zone());
|
| +}
|
| +
|
| +
|
| +CallDescriptor* Linkage::GetRuntimeCallDescriptor(
|
| + Runtime::FunctionId function, int parameter_count,
|
| + Operator::Property properties,
|
| + CallDescriptor::DeoptimizationSupport can_deoptimize) {
|
| + return GetRuntimeCallDescriptor(function, parameter_count, properties,
|
| + can_deoptimize, this->info_->zone());
|
| +}
|
| +
|
| +
|
| +//==============================================================================
|
| +// Provide unimplemented methods on unsupported architectures, to at least link.
|
| +//==============================================================================
|
| +#if !V8_TURBOFAN_TARGET
|
| +CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
|
| + UNIMPLEMENTED();
|
| + return NULL;
|
| +}
|
| +
|
| +
|
| +CallDescriptor* Linkage::GetRuntimeCallDescriptor(
|
| + Runtime::FunctionId function, int parameter_count,
|
| + Operator::Property properties,
|
| + CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
|
| + UNIMPLEMENTED();
|
| + return NULL;
|
| +}
|
| +
|
| +
|
| +CallDescriptor* Linkage::GetStubCallDescriptor(
|
| + CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
|
| + UNIMPLEMENTED();
|
| + return NULL;
|
| +}
|
| +
|
| +
|
| +CallDescriptor* Linkage::GetSimplifiedCDescriptor(
|
| + Zone* zone, int num_params, MachineRepresentation return_type,
|
| + MachineRepresentation* param_types) {
|
| + UNIMPLEMENTED();
|
| + return NULL;
|
| +}
|
| +#endif // !V8_TURBOFAN_TARGET
|
| +}
|
| +}
|
| +} // namespace v8::internal::compiler
|
|
|