Commit bfa2ef1f authored by ager@chromium.org's avatar ager@chromium.org

Fix receiver for calls to strict-mode and builtin functions that are

potentially shadowed by eval.

R=sgjesse@chromium.org
TEST=mjsunit/regress/regress-124.js

Review URL: http://codereview.chromium.org/7096004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8116 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e4978961
......@@ -2300,9 +2300,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
__ bind(&done);
// Push function.
__ push(r0);
// Push global receiver.
__ ldr(r1, GlobalObjectOperand());
__ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
// The receiver is implicitly the global receiver. Indicate this
// by passing the hole to the call function stub.
__ LoadRoot(r1, Heap::kTheHoleValueRootIndex);
__ push(r1);
__ bind(&call);
}
......
......@@ -2230,9 +2230,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
__ bind(&done);
// Push function.
__ push(eax);
// Push global receiver.
__ mov(ebx, GlobalObjectOperand());
__ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
// The receiver is implicitly the global receiver. Indicate this
// by passing the hole to the call function stub.
__ push(Immediate(isolate()->factory()->the_hole_value()));
__ bind(&call);
}
......
......@@ -2206,9 +2206,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
__ bind(&done);
// Push function.
__ push(rax);
// Push global receiver.
__ movq(rbx, GlobalObjectOperand());
__ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
// The receiver is implicitly the global receiver. Indicate this
// by passing the hole to the call function stub.
__ PushRoot(Heap::kTheHoleValueRootIndex);
__ bind(&call);
}
......
......@@ -37,13 +37,13 @@ assertEquals("[object Undefined]", eval("var f; toString()"));
function F(f) {
assertEquals("[object global]", this.toString());
assertEquals("[object global]", toString());
assertEquals("[object Undefined]", toString());
assertEquals("[object global]", eval("this.toString()"));
assertEquals("[object global]", eval("toString()"));
assertEquals("[object Undefined]", eval("toString()"));
assertEquals("[object global]", eval("var f; this.toString()"));
assertEquals("[object global]", eval("var f; toString()"));
assertEquals("[object Undefined]", eval("var f; toString()"));
assertEquals("[object Undefined]", eval("f()"));
......
......@@ -53,13 +53,30 @@ assertThrows(callGlobalHasOwnProperty);
function CheckExceptionCallLocal() {
var valueOf = Object.prototype.valueOf;
var hasOwnProperty = Object.prototype.hasOwnProperty;
try { valueOf(); assertUnreachable(); } catch(e) { }
try { hasOwnProperty(); assertUnreachable(); } catch(e) { }
var exception = false;
try { valueOf(); } catch(e) { exception = true; }
assertTrue(exception);
exception = false;
try { hasOwnProperty(); } catch(e) { exception = true; }
assertTrue(exception);
}
CheckExceptionCallLocal();
function CheckExceptionCallParameter(f) {
try { f(); assertUnreachable(); } catch(e) { }
var exception = false;
try { f(); } catch(e) { exception = true; }
assertTrue(exception);
}
CheckExceptionCallParameter(Object.prototype.valueOf);
CheckExceptionCallParameter(Object.prototype.hasOwnProperty);
function CheckPotentiallyShadowedByEval() {
var exception = false;
try {
eval("hasOwnProperty('x')");
} catch(e) {
exception = true;
}
assertTrue(exception);
}
CheckPotentiallyShadowedByEval();
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