From b3de173d16affe8121761008f6b3267eea23cbf9 Mon Sep 17 00:00:00 2001 From: ulan Date: Wed, 28 Jan 2015 04:44:55 -0800 Subject: [PATCH] Load setter from map descriptor instead of embedding it in handler. BUG=v8:3629 LOG=N Review URL: https://codereview.chromium.org/879213003 Cr-Commit-Position: refs/heads/master@{#26306} --- src/ic/arm/handler-compiler-arm.cc | 15 ++++++++++----- src/ic/arm64/handler-compiler-arm64.cc | 15 ++++++++++----- src/ic/handler-compiler.cc | 8 +++++--- src/ic/handler-compiler.h | 10 ++++++---- src/ic/ia32/handler-compiler-ia32.cc | 14 ++++++++++---- src/ic/ic.cc | 4 +++- src/ic/mips/handler-compiler-mips.cc | 15 ++++++++++----- src/ic/mips64/handler-compiler-mips64.cc | 15 ++++++++++----- src/ic/x64/handler-compiler-x64.cc | 14 ++++++++++---- src/ic/x87/handler-compiler-x87.cc | 14 ++++++++++---- 10 files changed, 84 insertions(+), 40 deletions(-) diff --git a/src/ic/arm/handler-compiler-arm.cc b/src/ic/arm/handler-compiler-arm.cc index c4f95a4..88189aa 100644 --- a/src/ic/arm/handler-compiler-arm.cc +++ b/src/ic/arm/handler-compiler-arm.cc @@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- lr : return address // ----------------------------------- @@ -69,7 +69,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -78,9 +78,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( } __ Push(receiver, value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, - NullCallWrapper()); + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ ldr(scratch, FieldMemOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ ldr(scratch, FieldMemOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ ldr(r1, FieldMemOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(r1, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember // the place to continue after deoptimization. diff --git a/src/ic/arm64/handler-compiler-arm64.cc b/src/ic/arm64/handler-compiler-arm64.cc index 53f084b..5de315d 100644 --- a/src/ic/arm64/handler-compiler-arm64.cc +++ b/src/ic/arm64/handler-compiler-arm64.cc @@ -221,7 +221,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- lr : return address // ----------------------------------- @@ -233,7 +233,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ Push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -242,9 +242,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( } __ Push(receiver, value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, - NullCallWrapper()); + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ Ldr(scratch, FieldMemOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ Ldr(scratch, FieldMemOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ Ldr(x1, FieldMemOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(x1, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember // the place to continue after deoptimization. diff --git a/src/ic/handler-compiler.cc b/src/ic/handler-compiler.cc index b39a172..8482422 100644 --- a/src/ic/handler-compiler.cc +++ b/src/ic/handler-compiler.cc @@ -442,9 +442,11 @@ Handle NamedStoreHandlerCompiler::CompileStoreField(LookupIterator* it) { Handle NamedStoreHandlerCompiler::CompileStoreViaSetter( - Handle object, Handle name, Handle setter) { - Frontend(name); - GenerateStoreViaSetter(masm(), type(), receiver(), setter); + Handle object, Handle name, int accessor_index, + int expected_arguments) { + Register holder = Frontend(name); + GenerateStoreViaSetter(masm(), type(), receiver(), holder, accessor_index, + expected_arguments); return GetCode(kind(), Code::FAST, name); } diff --git a/src/ic/handler-compiler.h b/src/ic/handler-compiler.h index e25aed1..53bf2c6 100644 --- a/src/ic/handler-compiler.h +++ b/src/ic/handler-compiler.h @@ -225,16 +225,18 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { Handle CompileStoreCallback(Handle object, Handle name, const CallOptimization& call_optimization); Handle CompileStoreViaSetter(Handle object, Handle name, - Handle setter); + int accessor_index, + int expected_arguments); Handle CompileStoreInterceptor(Handle name); static void GenerateStoreViaSetter(MacroAssembler* masm, Handle type, Register receiver, - Handle setter); + Register holder, int accessor_index, + int expected_arguments); static void GenerateStoreViaSetterForDeopt(MacroAssembler* masm) { - GenerateStoreViaSetter(masm, Handle::null(), no_reg, - Handle()); + GenerateStoreViaSetter(masm, Handle::null(), no_reg, no_reg, -1, + -1); } static void GenerateSlow(MacroAssembler* masm); diff --git a/src/ic/ia32/handler-compiler-ia32.cc b/src/ic/ia32/handler-compiler-ia32.cc index 613198d..be6245c 100644 --- a/src/ic/ia32/handler-compiler-ia32.cc +++ b/src/ic/ia32/handler-compiler-ia32.cc @@ -236,7 +236,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- esp[0] : return address // ----------------------------------- @@ -246,7 +246,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -256,8 +256,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( __ push(receiver); __ push(value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ mov(scratch, FieldOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ mov(scratch, FieldOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ mov(edi, FieldOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember diff --git a/src/ic/ic.cc b/src/ic/ic.cc index e6b691b..f378982 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -1743,8 +1743,10 @@ Handle StoreIC::CompileHandler(LookupIterator* lookup, return compiler.CompileStoreCallback(receiver, lookup->name(), call_optimization); } + int expected_arguments = function->shared()->formal_parameter_count(); return compiler.CompileStoreViaSetter(receiver, lookup->name(), - Handle::cast(setter)); + lookup->GetAccessorIndex(), + expected_arguments); } break; } diff --git a/src/ic/mips/handler-compiler-mips.cc b/src/ic/mips/handler-compiler-mips.cc index 00c3242..4fc736f 100644 --- a/src/ic/mips/handler-compiler-mips.cc +++ b/src/ic/mips/handler-compiler-mips.cc @@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- ra : return address // ----------------------------------- @@ -69,7 +69,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -78,9 +78,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( } __ Push(receiver, value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, - NullCallWrapper()); + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ lw(scratch, FieldMemOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ lw(scratch, FieldMemOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ lw(a1, FieldMemOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember // the place to continue after deoptimization. diff --git a/src/ic/mips64/handler-compiler-mips64.cc b/src/ic/mips64/handler-compiler-mips64.cc index 56cfb15..53ef0bf 100644 --- a/src/ic/mips64/handler-compiler-mips64.cc +++ b/src/ic/mips64/handler-compiler-mips64.cc @@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- ra : return address // ----------------------------------- @@ -69,7 +69,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -78,9 +78,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( } __ Push(receiver, value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, - NullCallWrapper()); + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ ld(scratch, FieldMemOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ ld(scratch, FieldMemOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ ld(a1, FieldMemOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember // the place to continue after deoptimization. diff --git a/src/ic/x64/handler-compiler-x64.cc b/src/ic/x64/handler-compiler-x64.cc index 5750da1..ff69191 100644 --- a/src/ic/x64/handler-compiler-x64.cc +++ b/src/ic/x64/handler-compiler-x64.cc @@ -214,7 +214,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- rsp[0] : return address // ----------------------------------- @@ -224,7 +224,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ Push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -234,8 +234,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( __ Push(receiver); __ Push(value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ movp(scratch, FieldOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ movp(scratch, FieldOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ movp(rdi, FieldOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember diff --git a/src/ic/x87/handler-compiler-x87.cc b/src/ic/x87/handler-compiler-x87.cc index ccab527..d0e7dfe 100644 --- a/src/ic/x87/handler-compiler-x87.cc +++ b/src/ic/x87/handler-compiler-x87.cc @@ -236,7 +236,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell( void NamedStoreHandlerCompiler::GenerateStoreViaSetter( MacroAssembler* masm, Handle type, Register receiver, - Handle setter) { + Register holder, int accessor_index, int expected_arguments) { // ----------- S t a t e ------------- // -- esp[0] : return address // ----------------------------------- @@ -246,7 +246,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( // Save value register, so we can restore it later. __ push(value()); - if (!setter.is_null()) { + if (accessor_index >= 0) { // Call the JavaScript setter with receiver and value on the stack. if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. @@ -256,8 +256,14 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( __ push(receiver); __ push(value()); ParameterCount actual(1); - ParameterCount expected(setter); - __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, + ParameterCount expected(expected_arguments); + Register scratch = holder; + __ mov(scratch, FieldOperand(holder, HeapObject::kMapOffset)); + __ LoadInstanceDescriptors(scratch, scratch); + __ mov(scratch, FieldOperand(scratch, DescriptorArray::GetValueOffset( + accessor_index))); + __ mov(edi, FieldOperand(scratch, AccessorPair::kSetterOffset)); + __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, NullCallWrapper()); } else { // If we generate a global code snippet for deoptimization only, remember -- 2.7.4