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