Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Unified Diff: src/runtime.cc

Issue 7039036: Fix calls of strict mode function with an implicit receiver. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/stub-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 88cca47baab6e36f9dd494879a295624b5f05423..922225f4d155db5c6e435840599528f01e2f6cfb 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7886,8 +7886,8 @@ static inline MaybeObject* Unhole(Heap* heap,
}
-static JSObject* ComputeReceiverForNonGlobal(Isolate* isolate,
- JSObject* holder) {
+static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
+ JSObject* holder) {
ASSERT(!holder->IsGlobalObject());
Context* top = isolate->context();
// Get the context extension function.
@@ -7899,10 +7899,11 @@ static JSObject* ComputeReceiverForNonGlobal(Isolate* isolate,
// explicitly via a with-statement.
Object* constructor = holder->map()->constructor();
if (constructor != context_extension_function) return holder;
- // Fall back to using the global object as the receiver if the
- // property turns out to be a local variable allocated in a context
- // extension object - introduced via eval.
- return top->global()->global_receiver();
+ // Fall back to using the global object as the implicit receiver if
+ // the property turns out to be a local variable allocated in a
+ // context extension object - introduced via eval. Implicit global
+ // receivers are indicated with the hole value.
+ return isolate->heap()->the_hole_value();
}
@@ -7930,9 +7931,10 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
// If the "property" we were looking for is a local variable or an
// argument in a context, the receiver is the global object; see
// ECMA-262, 3rd., 10.1.6 and 10.2.3.
- // GetElement below can cause GC.
- Handle<JSObject> receiver(
- isolate->context()->global()->global_receiver());
+ //
+ // Use the hole as the receiver to signal that the receiver is
+ // implicit and that the global receiver should be used.
+ Handle<Object> receiver = isolate->factory()->the_hole_value();
MaybeObject* value = (holder->IsContext())
? Context::cast(*holder)->get(index)
: JSObject::cast(*holder)->GetElement(index);
@@ -7943,17 +7945,19 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
if (!holder.is_null() && holder->IsJSObject()) {
ASSERT(Handle<JSObject>::cast(holder)->HasProperty(*name));
JSObject* object = JSObject::cast(*holder);
- JSObject* receiver;
+ Object* receiver;
if (object->IsGlobalObject()) {
receiver = GlobalObject::cast(object)->global_receiver();
} else if (context->is_exception_holder(*holder)) {
- receiver = isolate->context()->global()->global_receiver();
+ // Use the hole as the receiver to signal that the receiver is
+ // implicit and that the global receiver should be used.
+ receiver = isolate->heap()->the_hole_value();
} else {
receiver = ComputeReceiverForNonGlobal(isolate, object);
}
// GetProperty below can cause GC.
- Handle<JSObject> receiver_handle(receiver);
+ Handle<Object> receiver_handle(receiver);
// No need to unhole the value here. This is taken care of by the
// GetProperty function.
@@ -7968,7 +7972,7 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
HandleVector(&name, 1));
return MakePair(isolate->Throw(*reference_error), NULL);
} else {
- // The property doesn't exist - return undefined
+ // The property doesn't exist - return undefined.
return MakePair(isolate->heap()->undefined_value(),
isolate->heap()->undefined_value());
}
@@ -8480,8 +8484,7 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
// 'eval' is not bound in the global context. Just call the function
// with the given arguments. This is not necessarily the global eval.
if (receiver->IsContext() || receiver->IsJSContextExtensionObject()) {
- receiver = Handle<JSObject>(
- isolate->context()->global()->global_receiver(), isolate);
+ receiver = isolate->factory()->the_hole_value();
}
return MakePair(*callee, *receiver);
}
@@ -8490,8 +8493,7 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
// Compare it to the builtin 'GlobalEval' function to make sure.
if (*callee != isolate->global_context()->global_eval_fun() ||
!args[1]->IsString()) {
- return MakePair(*callee,
- isolate->context()->global()->global_receiver());
+ return MakePair(*callee, isolate->heap()->the_hole_value());
}
ASSERT(args[3]->IsSmi());
@@ -8513,8 +8515,7 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) {
// Compare it to the builtin 'GlobalEval' function to make sure.
if (*callee != isolate->global_context()->global_eval_fun() ||
!args[1]->IsString()) {
- return MakePair(*callee,
- isolate->context()->global()->global_receiver());
+ return MakePair(*callee, isolate->heap()->the_hole_value());
}
ASSERT(args[3]->IsSmi());
« no previous file with comments | « src/objects-inl.h ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698