Commit b23abba7 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

[turbofan] Explicitly mark call sites as patchable.

TEST=cctest,mjsunit
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/514643002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23506 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 19197378
......@@ -841,10 +841,10 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
void CodeGenerator::AddNopForSmiCodeInlining() {
// On 32-bit ARM we do not insert nops for inlined Smi code.
UNREACHABLE();
}
#undef __
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -821,7 +821,7 @@ void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation,
UNREACHABLE();
return;
}
opcode |= MiscField::encode(descriptor->deoptimization_support());
opcode |= MiscField::encode(descriptor->flags());
// Emit the call instruction.
Instruction* call_instr =
......
......@@ -39,20 +39,21 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone) {
return LinkageHelper::GetRuntimeCallDescriptor<LinkageHelperTraits>(
zone, function, parameter_count, properties, can_deoptimize);
zone, function, parameter_count, properties, flags);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor::Flags flags, Zone* zone) {
return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
zone, descriptor, stack_parameter_count, can_deoptimize);
zone, descriptor, stack_parameter_count, flags);
}
......
......@@ -146,8 +146,6 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ Call(target);
}
AddSafepointAndDeopt(instr);
// Meaningless instruction for ICs to overwrite.
AddNopForSmiCodeInlining();
break;
}
case kArchCallJSFunction: {
......
......@@ -651,7 +651,7 @@ void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation,
UNREACHABLE();
return;
}
opcode |= MiscField::encode(descriptor->deoptimization_support());
opcode |= MiscField::encode(descriptor->flags());
// Emit the call instruction.
Instruction* call_instr =
......
......@@ -39,20 +39,21 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone) {
return LinkageHelper::GetRuntimeCallDescriptor<LinkageHelperTraits>(
zone, function, parameter_count, properties, can_deoptimize);
zone, function, parameter_count, properties, flags);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor::Flags flags, Zone* zone) {
return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
zone, descriptor, stack_parameter_count, can_deoptimize);
zone, descriptor, stack_parameter_count, flags);
}
......
......@@ -240,17 +240,15 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) {
CallDescriptor::DeoptimizationSupport deopt =
static_cast<CallDescriptor::DeoptimizationSupport>(
MiscField::decode(instr->opcode()));
CallDescriptor::Flags flags(MiscField::decode(instr->opcode()));
bool needs_frame_state = (deopt & CallDescriptor::kNeedsFrameState) != 0;
bool needs_frame_state = (flags & CallDescriptor::kNeedsFrameState);
Safepoint::Id safepoint_id = RecordSafepoint(
instr->pointer_map(), Safepoint::kSimple, 0,
needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt);
if ((deopt & CallDescriptor::kLazyDeoptimization) != 0) {
if (flags & CallDescriptor::kLazyDeoptimization) {
RecordLazyDeoptimizationEntry(instr, safepoint_id);
}
......@@ -274,6 +272,10 @@ void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) {
#endif
safepoints()->RecordLazyDeoptimizationIndex(deoptimization_id);
}
if (flags & CallDescriptor::kNeedsNopAfterCall) {
AddNopForSmiCodeInlining();
}
}
......
......@@ -129,7 +129,6 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag));
}
AddSafepointAndDeopt(instr);
AddNopForSmiCodeInlining();
break;
}
case kArchCallJSFunction: {
......@@ -947,6 +946,6 @@ void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); }
#undef __
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -543,7 +543,7 @@ void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation,
UNREACHABLE();
return;
}
opcode |= MiscField::encode(descriptor->deoptimization_support());
opcode |= MiscField::encode(descriptor->flags());
// Emit the call instruction.
Instruction* call_instr =
......
......@@ -35,20 +35,21 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone) {
return LinkageHelper::GetRuntimeCallDescriptor<LinkageHelperTraits>(
zone, function, parameter_count, properties, can_deoptimize);
zone, function, parameter_count, properties, flags);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor::Flags flags, Zone* zone) {
return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
zone, descriptor, stack_parameter_count, can_deoptimize);
zone, descriptor, stack_parameter_count, flags);
}
......@@ -58,6 +59,7 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(
return LinkageHelper::GetSimplifiedCDescriptor<LinkageHelperTraits>(
zone, num_params, return_type, param_types);
}
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -17,7 +17,7 @@ namespace compiler {
// TODO(mstarzinger): This is a temporary workaround for non-hydrogen stubs for
// which we don't have an interface descriptor yet. Use ReplaceWithICStubCall
// which we don't have an interface descriptor yet. Use ReplaceWithStubCall
// once these stub have been made into a HydrogenCodeStub.
template <typename T>
static CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate,
......@@ -218,28 +218,35 @@ Reduction JSGenericLowering::Reduce(Node* node) {
}
#define REPLACE_IC_STUB_CALL(op, StubDeclaration) \
Node* JSGenericLowering::Lower##op(Node* node) { \
StubDeclaration; \
ReplaceWithICStubCall(node, &stub); \
return node; \
#define REPLACE_BINARY_OP_IC_CALL(op, token) \
Node* JSGenericLowering::Lower##op(Node* node) { \
BinaryOpICStub stub(isolate(), token); \
ReplaceWithStubCall(node, &stub, \
CallDescriptor::kPatchableCallSiteWithNop); \
return node; \
}
REPLACE_BINARY_OP_IC_CALL(JSBitwiseOr, Token::BIT_OR)
REPLACE_BINARY_OP_IC_CALL(JSBitwiseXor, Token::BIT_XOR)
REPLACE_BINARY_OP_IC_CALL(JSBitwiseAnd, Token::BIT_AND)
REPLACE_BINARY_OP_IC_CALL(JSShiftLeft, Token::SHL)
REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR)
REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR)
REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD)
REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB)
REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL)
REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV)
REPLACE_BINARY_OP_IC_CALL(JSModulus, Token::MOD)
#undef REPLACE_BINARY_OP_IC_CALL
#define REPLACE_STUB_CALL(op, StubDeclaration) \
Node* JSGenericLowering::Lower##op(Node* node) { \
StubDeclaration; \
ReplaceWithStubCall(node, &stub, CallDescriptor::kNoFlags); \
return node; \
}
REPLACE_IC_STUB_CALL(JSBitwiseOr, BinaryOpICStub stub(isolate(), Token::BIT_OR))
REPLACE_IC_STUB_CALL(JSBitwiseXor,
BinaryOpICStub stub(isolate(), Token::BIT_XOR))
REPLACE_IC_STUB_CALL(JSBitwiseAnd,
BinaryOpICStub stub(isolate(), Token::BIT_AND))
REPLACE_IC_STUB_CALL(JSShiftLeft, BinaryOpICStub stub(isolate(), Token::SHL))
REPLACE_IC_STUB_CALL(JSShiftRight, BinaryOpICStub stub(isolate(), Token::SAR))
REPLACE_IC_STUB_CALL(JSShiftRightLogical,
BinaryOpICStub stub(isolate(), Token::SHR))
REPLACE_IC_STUB_CALL(JSAdd, BinaryOpICStub stub(isolate(), Token::ADD))
REPLACE_IC_STUB_CALL(JSSubtract, BinaryOpICStub stub(isolate(), Token::SUB))
REPLACE_IC_STUB_CALL(JSMultiply, BinaryOpICStub stub(isolate(), Token::MUL))
REPLACE_IC_STUB_CALL(JSDivide, BinaryOpICStub stub(isolate(), Token::DIV))
REPLACE_IC_STUB_CALL(JSModulus, BinaryOpICStub stub(isolate(), Token::MOD))
REPLACE_IC_STUB_CALL(JSToNumber, ToNumberStub stub(isolate()))
#undef REPLACE_IC_STUB_CALL
REPLACE_STUB_CALL(JSToNumber, ToNumberStub stub(isolate()))
#undef REPLACE_STUB_CALL
#define REPLACE_COMPARE_IC_CALL(op, token, pure) \
......@@ -286,16 +293,15 @@ REPLACE_UNIMPLEMENTED(JSDebugger)
#undef REPLACE_UNIMPLEMENTED
static CallDescriptor::DeoptimizationSupport DeoptimizationSupportForNode(
Node* node) {
int result = CallDescriptor::kNoDeoptimization;
static CallDescriptor::Flags FlagsForNode(Node* node) {
CallDescriptor::Flags result = CallDescriptor::kNoFlags;
if (OperatorProperties::CanLazilyDeoptimize(node->op())) {
result |= CallDescriptor::kLazyDeoptimization;
}
if (OperatorProperties::HasFrameStateInput(node->op())) {
result |= CallDescriptor::kNeedsFrameState;
}
return static_cast<CallDescriptor::DeoptimizationSupport>(result);
return result;
}
......@@ -303,7 +309,8 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
bool pure) {
BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack.
CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor();
CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(d);
CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(
d, 0, CallDescriptor::kPatchableCallSiteWithNop);
Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token);
Node* compare;
if (pure) {
......@@ -328,11 +335,11 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
}
void JSGenericLowering::ReplaceWithICStubCall(Node* node,
HydrogenCodeStub* stub) {
void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub,
CallDescriptor::Flags flags) {
CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor();
CallDescriptor* desc = linkage()->GetStubCallDescriptor(
d, 0, DeoptimizationSupportForNode(node));
CallDescriptor* desc =
linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node));
Node* stub_code = CodeConstant(stub->GetCode());
PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc));
......@@ -363,8 +370,8 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
Operator::Property props = node->op()->properties();
const Runtime::Function* fun = Runtime::FunctionForId(f);
int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(
f, nargs, props, DeoptimizationSupportForNode(node));
CallDescriptor* desc =
linkage()->GetRuntimeCallDescriptor(f, nargs, props, FlagsForNode(node));
Node* ref = ExternalConstant(ExternalReference(f, isolate()));
Node* arity = Int32Constant(nargs);
if (!centrystub_constant_.is_set()) {
......@@ -387,14 +394,14 @@ Node* JSGenericLowering::LowerBranch(Node* node) {
Node* JSGenericLowering::LowerJSUnaryNot(Node* node) {
ToBooleanStub stub(isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL);
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
Node* JSGenericLowering::LowerJSToBoolean(Node* node) {
ToBooleanStub stub(isolate(), ToBooleanStub::RESULT_AS_ODDBALL);
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
......@@ -407,7 +414,7 @@ Node* JSGenericLowering::LowerJSToObject(Node* node) {
Node* JSGenericLowering::LowerJSLoadProperty(Node* node) {
KeyedLoadICStubShim stub(isolate());
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
......@@ -416,7 +423,7 @@ Node* JSGenericLowering::LowerJSLoadNamed(Node* node) {
LoadNamedParameters p = OpParameter<LoadNamedParameters>(node);
LoadICStubShim stub(isolate(), p.contextual_mode);
PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name));
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
......@@ -424,7 +431,7 @@ Node* JSGenericLowering::LowerJSLoadNamed(Node* node) {
Node* JSGenericLowering::LowerJSStoreProperty(Node* node) {
StrictMode strict_mode = OpParameter<StrictMode>(node);
KeyedStoreICStubShim stub(isolate(), strict_mode);
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
......@@ -433,7 +440,7 @@ Node* JSGenericLowering::LowerJSStoreNamed(Node* node) {
StoreNamedParameters params = OpParameter<StoreNamedParameters>(node);
StoreICStubShim stub(isolate(), params.strict_mode);
PatchInsertInput(node, 1, jsgraph()->HeapConstant(params.name));
ReplaceWithICStubCall(node, &stub);
ReplaceWithStubCall(node, &stub, CallDescriptor::kPatchableCallSite);
return node;
}
......@@ -507,8 +514,8 @@ Node* JSGenericLowering::LowerJSCallConstruct(Node* node) {
int arity = OpParameter<int>(node);
CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS);
CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
CallDescriptor* desc = linkage()->GetStubCallDescriptor(
d, arity, DeoptimizationSupportForNode(node));
CallDescriptor* desc =
linkage()->GetStubCallDescriptor(d, arity, FlagsForNode(node));
Node* stub_code = CodeConstant(stub.GetCode());
Node* construct = NodeProperties::GetValueInput(node, 0);
PatchInsertInput(node, 0, stub_code);
......@@ -524,8 +531,8 @@ Node* JSGenericLowering::LowerJSCallFunction(Node* node) {
CallParameters p = OpParameter<CallParameters>(node);
CallFunctionStub stub(isolate(), p.arity - 2, p.flags);
CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
CallDescriptor* desc = linkage()->GetStubCallDescriptor(
d, p.arity - 1, DeoptimizationSupportForNode(node));
CallDescriptor* desc =
linkage()->GetStubCallDescriptor(d, p.arity - 1, FlagsForNode(node));
Node* stub_code = CodeConstant(stub.GetCode());
PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc));
......@@ -539,6 +546,7 @@ Node* JSGenericLowering::LowerJSCallRuntime(Node* node) {
ReplaceWithRuntimeCall(node, function, arity);
return node;
}
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -55,7 +55,8 @@ class JSGenericLowering : public Reducer {
// Helpers to replace existing nodes with a generic call.
void ReplaceWithCompareIC(Node* node, Token::Value token, bool pure);
void ReplaceWithICStubCall(Node* node, HydrogenCodeStub* stub);
void ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub,
CallDescriptor::Flags flags);
void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args);
void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
......@@ -75,8 +76,9 @@ class JSGenericLowering : public Reducer {
MachineOperatorBuilder* machine_;
SetOncePointer<Node> centrystub_constant_;
};
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_JS_GENERIC_LOWERING_H_
......@@ -63,7 +63,7 @@ class LinkageHelper {
locations, // locations
Operator::kNoProperties, // properties
kNoCalleeSaved, // callee-saved registers
CallDescriptor::kLazyDeoptimization); // deoptimization
CallDescriptor::kLazyDeoptimization); // flags
}
......@@ -71,8 +71,7 @@ class LinkageHelper {
template <typename LinkageTraits>
static CallDescriptor* GetRuntimeCallDescriptor(
Zone* zone, Runtime::FunctionId function_id, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize) {
Operator::Property properties, CallDescriptor::Flags flags) {
const int code_count = 1;
const int function_count = 1;
const int num_args_count = 1;
......@@ -118,7 +117,7 @@ class LinkageHelper {
locations, // locations
properties, // properties
kNoCalleeSaved, // callee-saved registers
can_deoptimize, // deoptimization
flags, // flags
function->name);
}
......@@ -127,8 +126,7 @@ class LinkageHelper {
template <typename LinkageTraits>
static CallDescriptor* GetStubCallDescriptor(
Zone* zone, CodeStubInterfaceDescriptor* descriptor,
int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize) {
int stack_parameter_count, CallDescriptor::Flags flags) {
int register_parameter_count = descriptor->GetEnvironmentParameterCount();
int parameter_count = register_parameter_count + stack_parameter_count;
const int code_count = 1;
......@@ -165,7 +163,7 @@ class LinkageHelper {
locations, // locations
Operator::kNoProperties, // properties
kNoCalleeSaved, // callee-saved registers
can_deoptimize, // deoptimization
flags, // flags
CodeStub::MajorName(descriptor->MajorKey(), false));
}
......@@ -194,11 +192,12 @@ class LinkageHelper {
return new (zone) CallDescriptor(
CallDescriptor::kCallAddress, 1, num_params, num_params + 1, locations,
Operator::kNoProperties, LinkageTraits::CCalleeSaveRegisters(),
CallDescriptor::kNoDeoptimization); // TODO(jarin) should deoptimize!
CallDescriptor::kNoFlags); // TODO(jarin) should deoptimize!
}
};
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_LINKAGE_IMPL_H_
......@@ -93,20 +93,20 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) {
}
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());
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags) {
return GetRuntimeCallDescriptor(function, parameter_count, properties, flags,
this->info_->zone());
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize) {
return GetStubCallDescriptor(descriptor, stack_parameter_count,
can_deoptimize, this->info_->zone());
CallDescriptor::Flags flags) {
return GetStubCallDescriptor(descriptor, stack_parameter_count, flags,
this->info_->zone());
}
......@@ -120,10 +120,11 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone) {
UNIMPLEMENTED();
return NULL;
}
......@@ -131,7 +132,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor::Flags flags, Zone* zone) {
UNIMPLEMENTED();
return NULL;
}
......
......@@ -5,8 +5,7 @@
#ifndef V8_COMPILER_LINKAGE_H_
#define V8_COMPILER_LINKAGE_H_
#include "src/v8.h"
#include "src/base/flags.h"
#include "src/code-stubs.h"
#include "src/compiler/frame.h"
#include "src/compiler/machine-type.h"
......@@ -37,24 +36,27 @@ class LinkageLocation {
};
class CallDescriptor : public ZoneObject {
class CallDescriptor V8_FINAL : public ZoneObject {
public:
// Describes whether the first parameter is a code object, a JSFunction,
// or an address--all of which require different machine sequences to call.
enum Kind { kCallCodeObject, kCallJSFunction, kCallAddress };
// TODO(jarin) kLazyDeoptimization and kNeedsFrameState should be unified.
enum DeoptimizationSupport {
kNoDeoptimization = 0,
kLazyDeoptimization = 1,
kNeedsFrameState = 2
enum Flag {
// TODO(jarin) kLazyDeoptimization and kNeedsFrameState should be unified.
kNoFlags = 0u,
kLazyDeoptimization = 1u << 0,
kNeedsFrameState = 1u << 1,
kPatchableCallSite = 1u << 2,
kNeedsNopAfterCall = 1u << 3,
kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
};
DEFINE_FLAGS(Flags, Flag);
CallDescriptor(Kind kind, int8_t return_count, int16_t parameter_count,
int16_t input_count, LinkageLocation* locations,
Operator::Property properties, RegList callee_saved_registers,
DeoptimizationSupport deoptimization_support,
const char* debug_name = "")
Flags flags, const char* debug_name = "")
: kind_(kind),
return_count_(return_count),
parameter_count_(parameter_count),
......@@ -62,7 +64,7 @@ class CallDescriptor : public ZoneObject {
locations_(locations),
properties_(properties),
callee_saved_registers_(callee_saved_registers),
deoptimization_support_(deoptimization_support),
flags_(flags),
debug_name_(debug_name) {}
// Returns the kind of this call.
Kind kind() const { return kind_; }
......@@ -81,17 +83,10 @@ class CallDescriptor : public ZoneObject {
int FrameStateCount() const { return NeedsFrameState() ? 1 : 0; }
bool CanLazilyDeoptimize() const {
return (deoptimization_support() & kLazyDeoptimization) != 0;
}
Flags flags() const { return flags_; }
bool NeedsFrameState() const {
return (deoptimization_support() & kNeedsFrameState) != 0;
}
DeoptimizationSupport deoptimization_support() const {
return deoptimization_support_;
}
bool CanLazilyDeoptimize() const { return flags() & kLazyDeoptimization; }
bool NeedsFrameState() const { return flags() & kNeedsFrameState; }
LinkageLocation GetReturnLocation(int index) {
DCHECK(index < return_count_);
......@@ -121,10 +116,12 @@ class CallDescriptor : public ZoneObject {
LinkageLocation* locations_;
Operator::Property properties_;
RegList callee_saved_registers_;
DeoptimizationSupport deoptimization_support_;
Flags flags_;
const char* debug_name_;
};
DEFINE_OPERATORS_FOR_FLAGS(CallDescriptor::Flags)
OStream& operator<<(OStream& os, const CallDescriptor& d);
OStream& operator<<(OStream& os, const CallDescriptor::Kind& k);
......@@ -155,20 +152,19 @@ class Linkage : public ZoneObject {
CallDescriptor* GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize =
CallDescriptor::kNoDeoptimization);
static CallDescriptor* GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone);
CallDescriptor::Flags flags = CallDescriptor::kNoFlags);
static CallDescriptor* GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone);
CallDescriptor* GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count = 0,
CallDescriptor::DeoptimizationSupport can_deoptimize =
CallDescriptor::kNoDeoptimization);
CallDescriptor::Flags flags = CallDescriptor::kNoFlags);
static CallDescriptor* GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone);
CallDescriptor::Flags flags, Zone* zone);
// Creates a call descriptor for simplified C calls that is appropriate
// for the host platform. This simplified calling convention only supports
......@@ -201,8 +197,9 @@ class Linkage : public ZoneObject {
CompilationInfo* info_;
CallDescriptor* incoming_;
};
}
}
} // namespace v8::internal::compiler
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_LINKAGE_H_
......@@ -94,9 +94,8 @@ Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver,
stub.InitializeInterfaceDescriptor(d);
CallDescriptor* desc = Linkage::GetStubCallDescriptor(
d, 1, static_cast<CallDescriptor::DeoptimizationSupport>(
CallDescriptor::kLazyDeoptimization |
CallDescriptor::kNeedsFrameState),
d, 1,
CallDescriptor::kLazyDeoptimization | CallDescriptor::kNeedsFrameState,
zone());
Node* stub_code = HeapConstant(stub.GetCode());
Node* call = graph()->NewNode(common()->Call(desc), stub_code, function,
......
......@@ -214,7 +214,6 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ Call(Operand(reg, entry));
}
AddSafepointAndDeopt(instr);
AddNopForSmiCodeInlining();
break;
}
case kArchCallAddress:
......
......@@ -707,7 +707,7 @@ void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation,
UNREACHABLE();
return;
}
opcode |= MiscField::encode(descriptor->deoptimization_support());
opcode |= MiscField::encode(descriptor->flags());
// Emit the call instruction.
Instruction* call_instr =
......
......@@ -54,20 +54,21 @@ CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Property properties,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor* Linkage::GetRuntimeCallDescriptor(Runtime::FunctionId function,
int parameter_count,
Operator::Property properties,
CallDescriptor::Flags flags,
Zone* zone) {
return LinkageHelper::GetRuntimeCallDescriptor<LinkageHelperTraits>(
zone, function, parameter_count, properties, can_deoptimize);
zone, function, parameter_count, properties, flags);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
CallDescriptor::Flags flags, Zone* zone) {
return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
zone, descriptor, stack_parameter_count, can_deoptimize);
zone, descriptor, stack_parameter_count, flags);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment