From 9e9328bd56495d0cd399f0e272be852072341901 Mon Sep 17 00:00:00 2001 From: "weiliang.lin@intel.com" Date: Fri, 12 Sep 2014 08:43:27 +0000 Subject: [PATCH] X87: Eliminate Turbofan shims with CodeFactory port r23877. original commit message: Turbofan needs a code handle and a CallInterfaceDescriptor. At the same time we spread knowledge about how to create the initial IC code object too widely. Consolidate code creation and unify it with a descriptor via CodeFactory. BUG= R=weiliang.lin@intel.com Review URL: https://codereview.chromium.org/567953002 Patch from Jing Bao . git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23900 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x87/builtins-x87.cc | 3 ++- src/x87/full-codegen-x87.cc | 37 ++++++++++++++++++------------------- src/x87/lithium-codegen-x87.cc | 21 +++++++++++---------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc index 9df3bd9..3139518 100644 --- a/src/x87/builtins-x87.cc +++ b/src/x87/builtins-x87.cc @@ -6,6 +6,7 @@ #if V8_TARGET_ARCH_X87 +#include "src/code-factory.h" #include "src/codegen.h" #include "src/deoptimizer.h" #include "src/full-codegen.h" @@ -1006,7 +1007,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ mov(VectorLoadICDescriptor::SlotRegister(), Immediate(Smi::FromInt(0))); } - Handle ic = masm->isolate()->builtins()->KeyedLoadIC_Initialize(); + Handle ic = CodeFactory::KeyedLoadIC(masm->isolate()).code(); __ call(ic, RelocInfo::CODE_TARGET); // It is important that we do not have a test instruction after the // call. A test instruction after the call is used to indicate that diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index b13d02d..98f1b60 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -6,6 +6,7 @@ #if V8_TARGET_ARCH_X87 +#include "src/code-factory.h" #include "src/code-stubs.h" #include "src/codegen.h" #include "src/compiler.h" @@ -984,7 +985,8 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { // Record position before stub call for type feedback. SetSourcePosition(clause->position()); - Handle ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); + Handle ic = + CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); CallIC(ic, clause->CompareId()); patch_site.EmitPatchInfo(); @@ -2018,7 +2020,7 @@ void FullCodeGenerator::VisitYield(Yield* expr) { __ mov(VectorLoadICDescriptor::SlotRegister(), Immediate(Smi::FromInt(expr->KeyedLoadFeedbackSlot()))); } - Handle ic = isolate()->builtins()->KeyedLoadIC_Initialize(); + Handle ic = CodeFactory::KeyedLoadIC(isolate()).code(); CallIC(ic, TypeFeedbackId::None()); __ mov(edi, eax); __ mov(Operand(esp, 2 * kPointerSize), edi); @@ -2224,7 +2226,7 @@ void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { SetSourcePosition(prop->position()); - Handle ic = isolate()->builtins()->KeyedLoadIC_Initialize(); + Handle ic = CodeFactory::KeyedLoadIC(isolate()).code(); if (FLAG_vector_ics) { __ mov(VectorLoadICDescriptor::SlotRegister(), Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); @@ -2251,8 +2253,8 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, __ bind(&stub_call); __ mov(eax, ecx); - BinaryOpICStub stub(isolate(), op, mode); - CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); + Handle code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); + CallIC(code, expr->BinaryOperationFeedbackId()); patch_site.EmitPatchInfo(); __ jmp(&done, Label::kNear); @@ -2334,9 +2336,9 @@ void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op, OverwriteMode mode) { __ pop(edx); - BinaryOpICStub stub(isolate(), op, mode); + Handle code = CodeFactory::BinaryOpIC(isolate(), op, mode).code(); JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. - CallIC(stub.GetCode(), expr->BinaryOperationFeedbackId()); + CallIC(code, expr->BinaryOperationFeedbackId()); patch_site.EmitPatchInfo(); context()->Plug(eax); } @@ -2380,9 +2382,8 @@ void FullCodeGenerator::EmitAssignment(Expression* expr) { __ Move(StoreDescriptor::NameRegister(), eax); __ pop(StoreDescriptor::ReceiverRegister()); // Receiver. __ pop(StoreDescriptor::ValueRegister()); // Restore value. - Handle ic = strict_mode() == SLOPPY - ? isolate()->builtins()->KeyedStoreIC_Initialize() - : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); + Handle ic = + CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); CallIC(ic); break; } @@ -2499,9 +2500,7 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { DCHECK(StoreDescriptor::ValueRegister().is(eax)); // Record source code position before IC call. SetSourcePosition(expr->position()); - Handle ic = strict_mode() == SLOPPY - ? isolate()->builtins()->KeyedStoreIC_Initialize() - : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); + Handle ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); CallIC(ic, expr->AssignmentFeedbackId()); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); @@ -4318,8 +4317,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { __ bind(&stub_call); __ mov(edx, eax); __ mov(eax, Immediate(Smi::FromInt(1))); - BinaryOpICStub stub(isolate(), expr->binary_op(), NO_OVERWRITE); - CallIC(stub.GetCode(), expr->CountBinOpFeedbackId()); + Handle code = CodeFactory::BinaryOpIC(isolate(), expr->binary_op(), + NO_OVERWRITE).code(); + CallIC(code, expr->CountBinOpFeedbackId()); patch_site.EmitPatchInfo(); __ bind(&done); @@ -4365,9 +4365,8 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: { __ pop(StoreDescriptor::NameRegister()); __ pop(StoreDescriptor::ReceiverRegister()); - Handle ic = strict_mode() == SLOPPY - ? isolate()->builtins()->KeyedStoreIC_Initialize() - : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); + Handle ic = + CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); CallIC(ic, expr->CountStoreFeedbackId()); PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); if (expr->is_postfix()) { @@ -4556,7 +4555,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { // Record position and call the compare IC. SetSourcePosition(expr->position()); - Handle ic = CompareIC::GetUninitialized(isolate(), op); + Handle ic = CodeFactory::CompareIC(isolate(), op).code(); CallIC(ic, expr->CompareOperationFeedbackId()); patch_site.EmitPatchInfo(); diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index df22249..20fa7d3 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -7,6 +7,7 @@ #if V8_TARGET_ARCH_X87 #include "src/base/bits.h" +#include "src/code-factory.h" #include "src/code-stubs.h" #include "src/codegen.h" #include "src/deoptimizer.h" @@ -2171,8 +2172,9 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) { DCHECK(ToRegister(instr->right()).is(eax)); DCHECK(ToRegister(instr->result()).is(eax)); - BinaryOpICStub stub(isolate(), instr->op(), NO_OVERWRITE); - CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); + Handle code = + CodeFactory::BinaryOpIC(isolate(), instr->op(), NO_OVERWRITE).code(); + CallCode(code, RelocInfo::CODE_TARGET, instr); } @@ -2594,7 +2596,7 @@ static Condition ComputeCompareCondition(Token::Value op) { void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { Token::Value op = instr->op(); - Handle ic = CompareIC::GetUninitialized(isolate(), op); + Handle ic = CodeFactory::CompareIC(isolate(), op).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); Condition condition = ComputeCompareCondition(op); @@ -2866,7 +2868,7 @@ void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, void LCodeGen::DoCmpT(LCmpT* instr) { Token::Value op = instr->op(); - Handle ic = CompareIC::GetUninitialized(isolate(), op); + Handle ic = CodeFactory::CompareIC(isolate(), op).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); Condition condition = ComputeCompareCondition(op); @@ -2989,7 +2991,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { EmitVectorLoadICRegisters(instr); } ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; - Handle ic = LoadIC::initialize_stub(isolate(), mode); + Handle ic = CodeFactory::LoadIC(isolate(), mode).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -3123,7 +3125,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { if (FLAG_vector_ics) { EmitVectorLoadICRegisters(instr); } - Handle ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); + Handle ic = CodeFactory::LoadIC(isolate(), NOT_CONTEXTUAL).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -3346,7 +3348,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { EmitVectorLoadICRegisters(instr); } - Handle ic = isolate()->builtins()->KeyedLoadIC_Initialize(); + Handle ic = CodeFactory::KeyedLoadIC(isolate()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -4216,9 +4218,8 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); - Handle ic = instr->strict_mode() == STRICT - ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() - : isolate()->builtins()->KeyedStoreIC_Initialize(); + Handle ic = + CodeFactory::KeyedStoreIC(isolate(), instr->strict_mode()).code(); CallCode(ic, RelocInfo::CODE_TARGET, instr); } -- 2.7.4