From e6995a01f45b076d4cefcb4d7c0bab4fa0e1c9a4 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 25 Aug 2014 11:20:43 +0000 Subject: [PATCH] Move "slow handler" compiler code to handler-compiler BUG= R=yangguo@chromium.org Review URL: https://codereview.chromium.org/496283004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23347 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/builtins.cc | 20 +++++++------- src/code-stubs.cc | 2 +- src/ic/arm/handler-compiler-arm.cc | 26 +++++++++++++++++++ src/ic/arm/ic-arm.cc | 24 ----------------- src/ic/arm64/handler-compiler-arm64.cc | 28 ++++++++++++++++++++ src/ic/arm64/ic-arm64.cc | 33 ----------------------- src/ic/handler-compiler.cc | 6 ----- src/ic/handler-compiler.h | 4 ++- src/ic/ia32/handler-compiler-ia32.cc | 35 +++++++++++++++++++++++++ src/ic/ia32/ic-ia32.cc | 20 -------------- src/ic/x64/handler-compiler-x64.cc | 36 ++++++++++++++++++++++++++ src/ic/x64/ic-x64.cc | 20 -------------- 12 files changed, 139 insertions(+), 115 deletions(-) diff --git a/src/builtins.cc b/src/builtins.cc index f0f62908c..7c64f65a6 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -1298,11 +1298,6 @@ static void Generate_KeyedLoadIC_SloppyArguments(MacroAssembler* masm) { } -static void Generate_StoreIC_Slow(MacroAssembler* masm) { - StoreIC::GenerateSlow(masm); -} - - static void Generate_StoreIC_Miss(MacroAssembler* masm) { StoreIC::GenerateMiss(masm); } @@ -1313,6 +1308,16 @@ static void Generate_StoreIC_Normal(MacroAssembler* masm) { } +static void Generate_StoreIC_Slow(MacroAssembler* masm) { + NamedStoreHandlerCompiler::GenerateSlow(masm); +} + + +static void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) { + ElementHandlerCompiler::GenerateStoreSlow(masm); +} + + static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm); } @@ -1333,11 +1338,6 @@ static void Generate_KeyedStoreIC_Miss(MacroAssembler* masm) { } -static void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) { - KeyedStoreIC::GenerateSlow(masm); -} - - static void Generate_KeyedStoreIC_Initialize(MacroAssembler* masm) { KeyedStoreIC::GenerateInitialize(masm); } diff --git a/src/code-stubs.cc b/src/code-stubs.cc index 20bbb475d..223f7e3be 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -690,7 +690,7 @@ void StoreElementStub::Generate(MacroAssembler* masm) { UNREACHABLE(); break; case DICTIONARY_ELEMENTS: - ElementHandlerCompiler::GenerateStoreDictionaryElement(masm); + ElementHandlerCompiler::GenerateStoreSlow(masm); break; case SLOPPY_ARGUMENTS_ELEMENTS: UNREACHABLE(); diff --git a/src/ic/arm/handler-compiler-arm.cc b/src/ic/arm/handler-compiler-arm.cc index bdb701cf1..7722af647 100644 --- a/src/ic/arm/handler-compiler-arm.cc +++ b/src/ic/arm/handler-compiler-arm.cc @@ -314,6 +314,32 @@ void ElementHandlerCompiler::GenerateLoadDictionaryElement( } +void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { + // Push receiver, key and value for runtime call. + __ Push(StoreIC::ReceiverRegister(), StoreIC::NameRegister(), + StoreIC::ValueRegister()); + + // The slow case calls into the runtime to complete the store without causing + // an IC miss that would otherwise cause a transition to the generic stub. + ExternalReference ref = + ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + +void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { + // Push receiver, key and value for runtime call. + __ Push(StoreIC::ReceiverRegister(), StoreIC::NameRegister(), + StoreIC::ValueRegister()); + + // The slow case calls into the runtime to complete the store without causing + // an IC miss that would otherwise cause a transition to the generic stub. + ExternalReference ref = + ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + #undef __ #define __ ACCESS_MASM(masm()) diff --git a/src/ic/arm/ic-arm.cc b/src/ic/arm/ic-arm.cc index 9c6b894e1..57bd5a48b 100644 --- a/src/ic/arm/ic-arm.cc +++ b/src/ic/arm/ic-arm.cc @@ -733,30 +733,6 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { } -void StoreIC::GenerateSlow(MacroAssembler* masm) { - // Push receiver, key and value for runtime call. - __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); - - // The slow case calls into the runtime to complete the store without causing - // an IC miss that would otherwise cause a transition to the generic stub. - ExternalReference ref = - ExternalReference(IC_Utility(kStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - -void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { - // Push receiver, key and value for runtime call. - __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); - - // The slow case calls into the runtime to complete the store without causing - // an IC miss that would otherwise cause a transition to the generic stub. - ExternalReference ref = - ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - static void KeyedStoreGenerateGenericHelper( MacroAssembler* masm, Label* fast_object, Label* fast_double, Label* slow, KeyedStoreCheckMap check_map, KeyedStoreIncrementLength increment_length, diff --git a/src/ic/arm64/handler-compiler-arm64.cc b/src/ic/arm64/handler-compiler-arm64.cc index e0678db68..a5d0bb47f 100644 --- a/src/ic/arm64/handler-compiler-arm64.cc +++ b/src/ic/arm64/handler-compiler-arm64.cc @@ -306,6 +306,34 @@ void ElementHandlerCompiler::GenerateLoadDictionaryElement( } +void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { + // Push receiver, name and value for runtime call. + __ Push(StoreIC::ReceiverRegister(), StoreIC::NameRegister(), + StoreIC::ValueRegister()); + + // The slow case calls into the runtime to complete the store without causing + // an IC miss that would otherwise cause a transition to the generic stub. + ExternalReference ref = + ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + +void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { + ASM_LOCATION("ElementHandlerCompiler::GenerateStoreSlow"); + + // Push receiver, key and value for runtime call. + __ Push(StoreIC::ReceiverRegister(), StoreIC::NameRegister(), + StoreIC::ValueRegister()); + + // The slow case calls into the runtime to complete the store without causing + // an IC miss that would otherwise cause a transition to the generic stub. + ExternalReference ref = + ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + #undef __ #define __ ACCESS_MASM(masm()) diff --git a/src/ic/arm64/ic-arm64.cc b/src/ic/arm64/ic-arm64.cc index bffa603cb..6985ea5d4 100644 --- a/src/ic/arm64/ic-arm64.cc +++ b/src/ic/arm64/ic-arm64.cc @@ -775,20 +775,6 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { } -void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { - ASM_LOCATION("KeyedStoreIC::GenerateSlow"); - - // Push receiver, key and value for runtime call. - __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); - - // The slow case calls into the runtime to complete the store without causing - // an IC miss that would otherwise cause a transition to the generic stub. - ExternalReference ref = - ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - static void KeyedStoreGenerateGenericHelper( MacroAssembler* masm, Label* fast_object, Label* fast_double, Label* slow, KeyedStoreCheckMap check_map, KeyedStoreIncrementLength increment_length, @@ -1069,25 +1055,6 @@ void StoreIC::GenerateNormal(MacroAssembler* masm) { } -void StoreIC::GenerateSlow(MacroAssembler* masm) { - // ---------- S t a t e -------------- - // -- x0 : value - // -- x1 : receiver - // -- x2 : name - // -- lr : return address - // ----------------------------------- - - // Push receiver, name and value for runtime call. - __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); - - // The slow case calls into the runtime to complete the store without causing - // an IC miss that would otherwise cause a transition to the generic stub. - ExternalReference ref = - ExternalReference(IC_Utility(kStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - Condition CompareIC::ComputeCondition(Token::Value op) { switch (op) { case Token::EQ_STRICT: diff --git a/src/ic/handler-compiler.cc b/src/ic/handler-compiler.cc index bbc5cd126..5c747c10f 100644 --- a/src/ic/handler-compiler.cc +++ b/src/ic/handler-compiler.cc @@ -388,11 +388,5 @@ void ElementHandlerCompiler::CompileElementHandlers( handlers->Add(cached_stub); } } - - -void ElementHandlerCompiler::GenerateStoreDictionaryElement( - MacroAssembler* masm) { - KeyedStoreIC::GenerateSlow(masm); -} } } // namespace v8::internal diff --git a/src/ic/handler-compiler.h b/src/ic/handler-compiler.h index f82e4cce6..af54e2c79 100644 --- a/src/ic/handler-compiler.h +++ b/src/ic/handler-compiler.h @@ -221,6 +221,8 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { Handle()); } + static void GenerateSlow(MacroAssembler* masm); + protected: virtual Register FrontendHeader(Register object_reg, Handle name, Label* miss); @@ -267,7 +269,7 @@ class ElementHandlerCompiler : public PropertyHandlerCompiler { CodeHandleList* handlers); static void GenerateLoadDictionaryElement(MacroAssembler* masm); - static void GenerateStoreDictionaryElement(MacroAssembler* masm); + static void GenerateStoreSlow(MacroAssembler* masm); }; } } // namespace v8::internal diff --git a/src/ic/ia32/handler-compiler-ia32.cc b/src/ic/ia32/handler-compiler-ia32.cc index 0db5485d7..48b8adc52 100644 --- a/src/ic/ia32/handler-compiler-ia32.cc +++ b/src/ic/ia32/handler-compiler-ia32.cc @@ -326,6 +326,41 @@ static void CompileCallLoadPropertyWithInterceptor( } +static void StoreIC_PushArgs(MacroAssembler* masm) { + Register receiver = StoreIC::ReceiverRegister(); + Register name = StoreIC::NameRegister(); + Register value = StoreIC::ValueRegister(); + + DCHECK(!ebx.is(receiver) && !ebx.is(name) && !ebx.is(value)); + + __ pop(ebx); + __ push(receiver); + __ push(name); + __ push(value); + __ push(ebx); +} + + +void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { + // Return address is on the stack. + StoreIC_PushArgs(masm); + + // Do tail-call to runtime routine. + ExternalReference ref(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + +void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { + // Return address is on the stack. + StoreIC_PushArgs(masm); + + // Do tail-call to runtime routine. + ExternalReference ref(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + #undef __ #define __ ACCESS_MASM(masm()) diff --git a/src/ic/ia32/ic-ia32.cc b/src/ic/ia32/ic-ia32.cc index 4dd1a934c..5f1307865 100644 --- a/src/ic/ia32/ic-ia32.cc +++ b/src/ic/ia32/ic-ia32.cc @@ -1018,26 +1018,6 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { } -void StoreIC::GenerateSlow(MacroAssembler* masm) { - // Return address is on the stack. - StoreIC_PushArgs(masm); - - // Do tail-call to runtime routine. - ExternalReference ref(IC_Utility(kStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - -void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { - // Return address is on the stack. - StoreIC_PushArgs(masm); - - // Do tail-call to runtime routine. - ExternalReference ref(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - #undef __ diff --git a/src/ic/x64/handler-compiler-x64.cc b/src/ic/x64/handler-compiler-x64.cc index 0117a9697..d332bb43f 100644 --- a/src/ic/x64/handler-compiler-x64.cc +++ b/src/ic/x64/handler-compiler-x64.cc @@ -8,6 +8,7 @@ #include "src/ic/call-optimization.h" #include "src/ic/handler-compiler.h" +#include "src/ic/ic.h" namespace v8 { namespace internal { @@ -319,6 +320,41 @@ void ElementHandlerCompiler::GenerateLoadDictionaryElement( } +static void StoreIC_PushArgs(MacroAssembler* masm) { + Register receiver = StoreIC::ReceiverRegister(); + Register name = StoreIC::NameRegister(); + Register value = StoreIC::ValueRegister(); + + DCHECK(!rbx.is(receiver) && !rbx.is(name) && !rbx.is(value)); + + __ PopReturnAddressTo(rbx); + __ Push(receiver); + __ Push(name); + __ Push(value); + __ PushReturnAddressFrom(rbx); +} + + +void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { + // Return address is on the stack. + StoreIC_PushArgs(masm); + + // Do tail-call to runtime routine. + ExternalReference ref(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + +void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { + // Return address is on the stack. + StoreIC_PushArgs(masm); + + // Do tail-call to runtime routine. + ExternalReference ref(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); + __ TailCallExternalReference(ref, 3, 1); +} + + #undef __ #define __ ACCESS_MASM((masm())) diff --git a/src/ic/x64/ic-x64.cc b/src/ic/x64/ic-x64.cc index 1abb93193..7516882bb 100644 --- a/src/ic/x64/ic-x64.cc +++ b/src/ic/x64/ic-x64.cc @@ -1012,26 +1012,6 @@ void StoreIC::GenerateNormal(MacroAssembler* masm) { } -void StoreIC::GenerateSlow(MacroAssembler* masm) { - // Return address is on the stack. - StoreIC_PushArgs(masm); - - // Do tail-call to runtime routine. - ExternalReference ref(IC_Utility(kStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - -void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { - // Return address is on the stack. - StoreIC_PushArgs(masm); - - // Do tail-call to runtime routine. - ExternalReference ref(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); - __ TailCallExternalReference(ref, 3, 1); -} - - void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { // Return address is on the stack. StoreIC_PushArgs(masm); -- 2.34.1