Commit 8b445aaa authored by ulan@chromium.org's avatar ulan@chromium.org

Fix result of LCodeGen::DoWrapReceiver for strict functions and builtins.

BUG=362128
LOG=Y
TEST=mjsunit/regress/regress-362128
R=jacob.bramley@arm.com

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20723 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0b20d13b
......@@ -5822,7 +5822,7 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
// If the receiver is null or undefined, we have to pass the global object as
// a receiver to normal functions. Values have to be passed unchanged to
// builtins and strict-mode functions.
Label global_object, done;
Label global_object, done, copy_receiver;
if (!instr->hydrogen()->known_function()) {
__ Ldr(result, FieldMemOperand(function,
......@@ -5833,10 +5833,10 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
FieldMemOperand(result, SharedFunctionInfo::kCompilerHintsOffset));
// Do not transform the receiver to object for strict mode functions.
__ Tbnz(result, SharedFunctionInfo::kStrictModeFunction, &done);
__ Tbnz(result, SharedFunctionInfo::kStrictModeFunction, &copy_receiver);
// Do not transform the receiver to object for builtins.
__ Tbnz(result, SharedFunctionInfo::kNative, &done);
__ Tbnz(result, SharedFunctionInfo::kNative, &copy_receiver);
}
// Normal function. Replace undefined or null with global receiver.
......@@ -5846,15 +5846,17 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
// Deoptimize if the receiver is not a JS object.
DeoptimizeIfSmi(receiver, instr->environment());
__ CompareObjectType(receiver, result, result, FIRST_SPEC_OBJECT_TYPE);
__ Mov(result, receiver);
__ B(ge, &done);
__ B(ge, &copy_receiver);
Deoptimize(instr->environment());
__ Bind(&global_object);
__ Ldr(result, FieldMemOperand(function, JSFunction::kContextOffset));
__ Ldr(result, ContextMemOperand(result, Context::GLOBAL_OBJECT_INDEX));
__ Ldr(result, FieldMemOperand(result, GlobalObject::kGlobalReceiverOffset));
__ B(&done);
__ Bind(&copy_receiver);
__ Mov(result, receiver);
__ Bind(&done);
}
......
// Copyright 2014 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.
// Flags: --allow-natives-syntax
function genM() {
"use strict";
return function () {
return this.field;
};
}
function genR() {
var x = {
field: 10
}
return x;
}
method = {};
receiver = {};
method = genM("A");
receiver = genR("A");
var foo = (function () {
return function suspect (name) {
"use strict";
return method.apply(receiver, arguments);
}
})();
foo("a", "b", "c");
foo("a", "b", "c");
foo("a", "b", "c");
%OptimizeFunctionOnNextCall(foo);
foo("a", "b", "c");
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