Upgrade to V8 3.6
Merge V8 at 3.6.6.11
Simple merge required updates to makefiles only.
Bug: 5688872
Change-Id: Ib38b7ffbcd409585f6cb6fccc59c767029cecc77
diff --git a/src/execution.cc b/src/execution.cc
index bdbdca8..f36d4e4 100644
--- a/src/execution.cc
+++ b/src/execution.cc
@@ -149,12 +149,29 @@
Handle<Object> receiver,
int argc,
Object*** args,
- bool* pending_exception) {
+ bool* pending_exception,
+ bool convert_receiver) {
if (!callable->IsJSFunction()) {
callable = TryGetFunctionDelegate(callable, pending_exception);
if (*pending_exception) return callable;
}
Handle<JSFunction> func = Handle<JSFunction>::cast(callable);
+
+ // In non-strict mode, convert receiver.
+ if (convert_receiver && !receiver->IsJSReceiver() &&
+ !func->shared()->native() && !func->shared()->strict_mode()) {
+ if (receiver->IsUndefined() || receiver->IsNull()) {
+ Object* global = func->context()->global()->global_receiver();
+ // Under some circumstances, 'global' can be the JSBuiltinsObject
+ // In that case, don't rewrite.
+ // (FWIW, the same holds for GetIsolate()->global()->global_receiver().)
+ if (!global->IsJSBuiltinsObject()) receiver = Handle<Object>(global);
+ } else {
+ receiver = ToObject(receiver, pending_exception);
+ }
+ if (*pending_exception) return callable;
+ }
+
return Invoke(false, func, receiver, argc, args, pending_exception);
}
@@ -210,10 +227,17 @@
// If you return a function from here, it will be called when an
// attempt is made to call the given object as a function.
+ // If object is a function proxy, get its handler. Iterate if necessary.
+ Object* fun = *object;
+ while (fun->IsJSFunctionProxy()) {
+ fun = JSFunctionProxy::cast(fun)->call_trap();
+ }
+ if (fun->IsJSFunction()) return Handle<Object>(fun);
+
// Objects created through the API can have an instance-call handler
// that should be used when calling the object as a function.
- if (object->IsHeapObject() &&
- HeapObject::cast(*object)->map()->has_instance_call_handler()) {
+ if (fun->IsHeapObject() &&
+ HeapObject::cast(fun)->map()->has_instance_call_handler()) {
return Handle<JSFunction>(
isolate->global_context()->call_as_function_delegate());
}
@@ -227,10 +251,17 @@
ASSERT(!object->IsJSFunction());
Isolate* isolate = Isolate::Current();
+ // If object is a function proxy, get its handler. Iterate if necessary.
+ Object* fun = *object;
+ while (fun->IsJSFunctionProxy()) {
+ fun = JSFunctionProxy::cast(fun)->call_trap();
+ }
+ if (fun->IsJSFunction()) return Handle<Object>(fun);
+
// Objects created through the API can have an instance-call handler
// that should be used when calling the object as a function.
- if (object->IsHeapObject() &&
- HeapObject::cast(*object)->map()->has_instance_call_handler()) {
+ if (fun->IsHeapObject() &&
+ HeapObject::cast(fun)->map()->has_instance_call_handler()) {
return Handle<JSFunction>(
isolate->global_context()->call_as_function_delegate());
}
@@ -253,10 +284,17 @@
// If you return a function from here, it will be called when an
// attempt is made to call the given object as a constructor.
+ // If object is a function proxies, get its handler. Iterate if necessary.
+ Object* fun = *object;
+ while (fun->IsJSFunctionProxy()) {
+ fun = JSFunctionProxy::cast(fun)->call_trap();
+ }
+ if (fun->IsJSFunction()) return Handle<Object>(fun);
+
// Objects created through the API can have an instance-call handler
// that should be used when calling the object as a function.
- if (object->IsHeapObject() &&
- HeapObject::cast(*object)->map()->has_instance_call_handler()) {
+ if (fun->IsHeapObject() &&
+ HeapObject::cast(fun)->map()->has_instance_call_handler()) {
return Handle<JSFunction>(
isolate->global_context()->call_as_constructor_delegate());
}
@@ -274,10 +312,17 @@
// If you return a function from here, it will be called when an
// attempt is made to call the given object as a constructor.
+ // If object is a function proxies, get its handler. Iterate if necessary.
+ Object* fun = *object;
+ while (fun->IsJSFunctionProxy()) {
+ fun = JSFunctionProxy::cast(fun)->call_trap();
+ }
+ if (fun->IsJSFunction()) return Handle<Object>(fun);
+
// Objects created through the API can have an instance-call handler
// that should be used when calling the object as a function.
- if (object->IsHeapObject() &&
- HeapObject::cast(*object)->map()->has_instance_call_handler()) {
+ if (fun->IsHeapObject() &&
+ HeapObject::cast(fun)->map()->has_instance_call_handler()) {
return Handle<JSFunction>(
isolate->global_context()->call_as_constructor_delegate());
}
@@ -553,7 +598,7 @@
Handle<Object> Execution::ToObject(Handle<Object> obj, bool* exc) {
- if (obj->IsJSObject()) return obj;
+ if (obj->IsSpecObject()) return obj;
RETURN_NATIVE_CALL(to_object, 1, { obj.location() }, exc);
}