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}
This commit is contained in:
parent
c5833e8596
commit
b3de173d16
@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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.
|
||||
|
@ -221,7 +221,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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.
|
||||
|
@ -442,9 +442,11 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreField(LookupIterator* it) {
|
||||
|
||||
|
||||
Handle<Code> NamedStoreHandlerCompiler::CompileStoreViaSetter(
|
||||
Handle<JSObject> object, Handle<Name> name, Handle<JSFunction> setter) {
|
||||
Frontend(name);
|
||||
GenerateStoreViaSetter(masm(), type(), receiver(), setter);
|
||||
Handle<JSObject> object, Handle<Name> 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);
|
||||
}
|
||||
|
@ -225,16 +225,18 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler {
|
||||
Handle<Code> CompileStoreCallback(Handle<JSObject> object, Handle<Name> name,
|
||||
const CallOptimization& call_optimization);
|
||||
Handle<Code> CompileStoreViaSetter(Handle<JSObject> object, Handle<Name> name,
|
||||
Handle<JSFunction> setter);
|
||||
int accessor_index,
|
||||
int expected_arguments);
|
||||
Handle<Code> CompileStoreInterceptor(Handle<Name> name);
|
||||
|
||||
static void GenerateStoreViaSetter(MacroAssembler* masm,
|
||||
Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> setter);
|
||||
Register holder, int accessor_index,
|
||||
int expected_arguments);
|
||||
|
||||
static void GenerateStoreViaSetterForDeopt(MacroAssembler* masm) {
|
||||
GenerateStoreViaSetter(masm, Handle<HeapType>::null(), no_reg,
|
||||
Handle<JSFunction>());
|
||||
GenerateStoreViaSetter(masm, Handle<HeapType>::null(), no_reg, no_reg, -1,
|
||||
-1);
|
||||
}
|
||||
|
||||
static void GenerateSlow(MacroAssembler* masm);
|
||||
|
@ -236,7 +236,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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
|
||||
|
@ -1743,8 +1743,10 @@ Handle<Code> 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<JSFunction>::cast(setter));
|
||||
lookup->GetAccessorIndex(),
|
||||
expected_arguments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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.
|
||||
|
@ -59,7 +59,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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.
|
||||
|
@ -214,7 +214,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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
|
||||
|
@ -236,7 +236,7 @@ void PropertyHandlerCompiler::GenerateCheckPropertyCell(
|
||||
|
||||
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
|
||||
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
|
||||
Handle<JSFunction> 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
|
||||
|
Loading…
Reference in New Issue
Block a user