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