Reviewers: Igor Sheludko,
Message:
Please take a look. If it is ok, I'll upload the remaining ports.
Description:
Load getter from map descriptor instead of embedding it in handler.
BUG=v8:3629
LOG=N
Please review this at https://codereview.chromium.org/872723003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+62, -28 lines):
M src/ic/arm/handler-compiler-arm.cc
M src/ic/arm64/handler-compiler-arm64.cc
M src/ic/handler-compiler.h
M src/ic/handler-compiler.cc
M src/ic/ia32/handler-compiler-ia32.cc
M src/ic/ic.cc
M src/ic/x64/handler-compiler-x64.cc
M src/lookup.h
M src/lookup.cc
Index: src/ic/arm/handler-compiler-arm.cc
diff --git a/src/ic/arm/handler-compiler-arm.cc
b/src/ic/arm/handler-compiler-arm.cc
index
c99e06a81623e62f543c31c722517ef668877a2c..c4f95a4e5d197c340aaf2caad3bd947f523ebf99
100644
--- a/src/ic/arm/handler-compiler-arm.cc
+++ b/src/ic/arm/handler-compiler-arm.cc
@@ -18,7 +18,7 @@ namespace internal {
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
- Handle<JSFunction> getter) {
+ Register holder, int accessor_index, int expected_arguments) {
// ----------- S t a t e -------------
// -- r0 : receiver
// -- r2 : name
@@ -27,7 +27,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- if (!getter.is_null()) {
+ if (accessor_index >= 0) {
// Call the JavaScript getter with the receiver on the stack.
if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
// Swap in the global receiver.
@@ -36,9 +36,14 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
}
__ push(receiver);
ParameterCount actual(0);
- ParameterCount expected(getter);
- __ InvokeFunction(getter, 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::kGetterOffset));
+ __ 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.
Index: src/ic/arm64/handler-compiler-arm64.cc
diff --git a/src/ic/arm64/handler-compiler-arm64.cc
b/src/ic/arm64/handler-compiler-arm64.cc
index
f434f2e579580fde70bb3a8b5f7ee60fb2788350..53f084b1d406f6c387201ddfa089e7aec8f89f0a
100644
--- a/src/ic/arm64/handler-compiler-arm64.cc
+++ b/src/ic/arm64/handler-compiler-arm64.cc
@@ -263,11 +263,11 @@ void
NamedStoreHandlerCompiler::GenerateStoreViaSetter(
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
- Handle<JSFunction> getter) {
+ Register holder, int accessor_index, int expected_arguments) {
{
FrameScope scope(masm, StackFrame::INTERNAL);
- if (!getter.is_null()) {
+ if (accessor_index >= 0) {
// Call the JavaScript getter with the receiver on the stack.
if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
// Swap in the global receiver.
@@ -276,9 +276,14 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
}
__ Push(receiver);
ParameterCount actual(0);
- ParameterCount expected(getter);
- __ InvokeFunction(getter, 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::kGetterOffset));
+ __ 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.
Index: src/ic/handler-compiler.cc
diff --git a/src/ic/handler-compiler.cc b/src/ic/handler-compiler.cc
index
6f8254308642467a27d0d0c26c4bc084930ac8ef..b39a1725b77e7d479617685e0d318c7297a9e680
100644
--- a/src/ic/handler-compiler.cc
+++ b/src/ic/handler-compiler.cc
@@ -353,9 +353,10 @@ void
NamedLoadHandlerCompiler::GenerateLoadPostInterceptor(
Handle<Code> NamedLoadHandlerCompiler::CompileLoadViaGetter(
- Handle<Name> name, Handle<JSFunction> getter) {
- Frontend(name);
- GenerateLoadViaGetter(masm(), type(), receiver(), getter);
+ Handle<Name> name, int accessor_index, int expected_arguments) {
+ Register holder = Frontend(name);
+ GenerateLoadViaGetter(masm(), type(), receiver(), holder, accessor_index,
+ expected_arguments);
return GetCode(kind(), Code::FAST, name);
}
Index: src/ic/handler-compiler.h
diff --git a/src/ic/handler-compiler.h b/src/ic/handler-compiler.h
index
7d6b42483868cf17421a1ae55f68ba8be5144aea..e25aed193f6210aeb90c3180cc63cc4c82150157
100644
--- a/src/ic/handler-compiler.h
+++ b/src/ic/handler-compiler.h
@@ -133,8 +133,8 @@ class NamedLoadHandlerCompiler : public
PropertyHandlerCompiler {
// inlined.
Handle<Code> CompileLoadInterceptor(LookupIterator* it);
- Handle<Code> CompileLoadViaGetter(Handle<Name> name,
- Handle<JSFunction> getter);
+ Handle<Code> CompileLoadViaGetter(Handle<Name> name, int accessor_index,
+ int expected_arguments);
Handle<Code> CompileLoadGlobal(Handle<PropertyCell> cell, Handle<Name>
name,
bool is_configurable);
@@ -144,12 +144,12 @@ class NamedLoadHandlerCompiler : public
PropertyHandlerCompiler {
Handle<HeapType> type);
static void GenerateLoadViaGetter(MacroAssembler* masm, Handle<HeapType>
type,
- Register receiver,
- Handle<JSFunction> getter);
+ Register receiver, Register holder,
+ int accessor_index, int
expected_arguments);
static void GenerateLoadViaGetterForDeopt(MacroAssembler* masm) {
- GenerateLoadViaGetter(masm, Handle<HeapType>::null(), no_reg,
- Handle<JSFunction>());
+ GenerateLoadViaGetter(masm, Handle<HeapType>::null(), no_reg, no_reg,
-1,
+ -1);
}
static void GenerateLoadFunctionPrototype(MacroAssembler* masm,
Index: src/ic/ia32/handler-compiler-ia32.cc
diff --git a/src/ic/ia32/handler-compiler-ia32.cc
b/src/ic/ia32/handler-compiler-ia32.cc
index
f20d75fba74909fb2863d999c99cd2d8b34f7a03..ffc38a46b19b91146e3c3f149a9b7f955fef0a37
100644
--- a/src/ic/ia32/handler-compiler-ia32.cc
+++ b/src/ic/ia32/handler-compiler-ia32.cc
@@ -18,11 +18,11 @@ namespace internal {
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
- Handle<JSFunction> getter) {
+ Register holder, int accessor_index, int expected_arguments) {
{
FrameScope scope(masm, StackFrame::INTERNAL);
- if (!getter.is_null()) {
+ if (accessor_index >= 0) {
// Call the JavaScript getter with the receiver on the stack.
if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
// Swap in the global receiver.
@@ -31,8 +31,14 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
}
__ push(receiver);
ParameterCount actual(0);
- ParameterCount expected(getter);
- __ InvokeFunction(getter, 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::kGetterOffset));
+ __ InvokeFunction(edi, expected, actual, CALL_FUNCTION,
NullCallWrapper());
} else {
// If we generate a global code snippet for deoptimization only,
remember
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index
8cd06868c0c3fdd215b87d76ec184bad3307c209..f6fffea5fcf5b28cc4d92ccc6a8f065ff4b57a22
100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -1229,7 +1229,9 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator*
lookup,
return compiler.CompileLoadCallback(lookup->name(),
call_optimization);
}
- return compiler.CompileLoadViaGetter(lookup->name(), function);
+ int expected_arguments =
function->shared()->formal_parameter_count();
+ return compiler.CompileLoadViaGetter(
+ lookup->name(), lookup->GetAccessorIndex(),
expected_arguments);
}
break;
}
Index: src/ic/x64/handler-compiler-x64.cc
diff --git a/src/ic/x64/handler-compiler-x64.cc
b/src/ic/x64/handler-compiler-x64.cc
index
1538f12ac8141d6ce986b44cedf29c99e0f5f6c5..13b5fa804c2280ba01404b6dbf63f3bf43fc5eb9
100644
--- a/src/ic/x64/handler-compiler-x64.cc
+++ b/src/ic/x64/handler-compiler-x64.cc
@@ -255,7 +255,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
- Handle<JSFunction> getter) {
+ Register holder, int accessor_index, int expected_arguments) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -264,7 +264,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
{
FrameScope scope(masm, StackFrame::INTERNAL);
- if (!getter.is_null()) {
+ if (accessor_index >= 0) {
// Call the JavaScript getter with the receiver on the stack.
if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
// Swap in the global receiver.
@@ -273,8 +273,14 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
}
__ Push(receiver);
ParameterCount actual(0);
- ParameterCount expected(getter);
- __ InvokeFunction(getter, 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::kGetterOffset));
+ __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION,
NullCallWrapper());
} else {
// If we generate a global code snippet for deoptimization only,
remember
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index
e4751177fd6b73624f48f8f3be80d08bbf66d855..c658a90e63fb816f831d7c82caa931579388cd01
100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -238,6 +238,14 @@ Handle<Object> LookupIterator::FetchValue() const {
}
+int LookupIterator::GetAccessorIndex() const {
+ DCHECK(has_property_);
+ DCHECK(!holder_map_->is_dictionary_map());
+ DCHECK_EQ(v8::internal::ACCESSOR_CONSTANT, property_details_.type());
+ return descriptor_number();
+}
+
+
int LookupIterator::GetConstantIndex() const {
DCHECK(has_property_);
DCHECK(!holder_map_->is_dictionary_map());
Index: src/lookup.h
diff --git a/src/lookup.h b/src/lookup.h
index
7af3d9c845e650508a507214148f84e5195ca58b..01fa766879a70102b6921ff86be40b0b5e0dcb25
100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -132,6 +132,7 @@ class LookupIterator FINAL BASE_EMBEDDED {
}
FieldIndex GetFieldIndex() const;
Handle<HeapType> GetFieldType() const;
+ int GetAccessorIndex() const;
int GetConstantIndex() const;
Handle<PropertyCell> GetPropertyCell() const;
Handle<Object> GetAccessors() const;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.