Commit 6df9a22c authored by bmeurer's avatar bmeurer Committed by Commit bot

[ic] Use the CallFunction builtin to invoke accessors.

The HandlerCompiler did not properly handle the weird edge case when a
sloppy mode function was installed as an accessor on one of the value
wrapper prototypes and then accessed via a load from a primitive value.
In this case we just passed the primitive value untouched instead of
properly wrapping it first. The CallFunction builtin properly deals with
all the funny edge cases, so we use it instead of duplicating almost all
of the logic here (the performance difference is neglible).

R=verwaest@chromium.org
BUG=chromium:599073, v8:4413
LOG=n

Review URL: https://codereview.chromium.org/1845243005

Cr-Commit-Position: refs/heads/master@{#35187}
parent 59a0ad2d
......@@ -43,11 +43,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(r1, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(r1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ mov(r0, Operand(0));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -87,11 +87,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
receiver = scratch;
}
__ Push(receiver, value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(r1, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(r1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ mov(r0, Operand(1));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -263,11 +263,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
receiver = scratch;
}
__ Push(receiver, value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(x1, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(x1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Mov(x0, 1);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -304,11 +304,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ Push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(x1, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(x1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Mov(x0, 0);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -38,11 +38,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(edi, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(edi, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Set(eax, 0);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -273,11 +273,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
}
__ push(receiver);
__ push(value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(edi, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(edi, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Set(eax, 1);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -43,11 +43,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(a1, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(a1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ li(a0, Operand(0));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -85,11 +85,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
receiver = scratch;
}
__ Push(receiver, value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(a1, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(a1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ li(a0, Operand(1));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -43,11 +43,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(a1, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(a1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ li(a0, Operand(V8_INT64_C(0)));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -85,11 +85,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
receiver = scratch;
}
__ Push(receiver, value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(a1, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(a1, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ li(a0, Operand(1));
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -257,11 +257,11 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
}
__ Push(receiver);
__ Push(value());
ParameterCount actual(1);
ParameterCount expected(expected_arguments);
__ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(rdi, no_reg, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Set(rax, 1);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -303,11 +303,11 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
receiver = scratch;
}
__ Push(receiver);
ParameterCount actual(0);
ParameterCount expected(expected_arguments);
__ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(rdi, no_reg, expected, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
__ Set(rax, 0);
__ Call(masm->isolate()->builtins()->CallFunction(
ConvertReceiverMode::kNotNullOrUndefined),
RelocInfo::CODE_TARGET);
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(Boolean.prototype, "v", {get:constructor});
function foo(b) { return b.v; }
foo(true);
foo(true);
foo(true);
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(Boolean.prototype, "v", {set:constructor});
function foo(b) { b.v = 1; }
foo(true);
foo(true);
foo(true);
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(Number.prototype, "v", {get:constructor});
function foo(b) { return b.v; }
foo(2);
foo(3);
foo(4);
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(Number.prototype, "v", {set:constructor});
function foo(b) { b.v = 1; }
foo(2);
foo(3);
foo(4);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment