Commit 9c52caa8 authored by adamk@chromium.org's avatar adamk@chromium.org

Tighten up Object.observe code to ASSERT that it never deals with globals

After r21126, Object.observe no longer allows observing the global proxy
object. This patch replaces codepaths that used to handle that case with
asserts showing that no such observation happens.

R=verwaest@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21151 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3274485c
...@@ -1976,12 +1976,11 @@ void JSObject::EnqueueChangeRecord(Handle<JSObject> object, ...@@ -1976,12 +1976,11 @@ void JSObject::EnqueueChangeRecord(Handle<JSObject> object,
const char* type_str, const char* type_str,
Handle<Name> name, Handle<Name> name,
Handle<Object> old_value) { Handle<Object> old_value) {
ASSERT(!object->IsJSGlobalProxy());
ASSERT(!object->IsJSGlobalObject());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str); Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str);
if (object->IsJSGlobalObject()) {
object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate);
}
Handle<Object> args[] = { type, object, name, old_value }; Handle<Object> args[] = { type, object, name, old_value };
int argc = name.is_null() ? 2 : old_value->IsTheHole() ? 3 : 4; int argc = name.is_null() ? 2 : old_value->IsTheHole() ? 3 : 4;
...@@ -5927,6 +5926,8 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) { ...@@ -5927,6 +5926,8 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) {
void JSObject::SetObserved(Handle<JSObject> object) { void JSObject::SetObserved(Handle<JSObject> object) {
ASSERT(!object->IsJSGlobalProxy());
ASSERT(!object->IsJSGlobalObject());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
Handle<Map> new_map; Handle<Map> new_map;
Handle<Map> old_map(object->map(), isolate); Handle<Map> old_map(object->map(), isolate);
......
...@@ -14883,12 +14883,7 @@ RUNTIME_FUNCTION(Runtime_IsObserved) { ...@@ -14883,12 +14883,7 @@ RUNTIME_FUNCTION(Runtime_IsObserved) {
if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value();
CONVERT_ARG_CHECKED(JSReceiver, obj, 0); CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
if (obj->IsJSGlobalProxy()) { ASSERT(!obj->IsJSGlobalProxy() || !obj->map()->is_observed());
Object* proto = obj->GetPrototype();
if (proto->IsNull()) return isolate->heap()->false_value();
ASSERT(proto->IsJSGlobalObject());
obj = JSReceiver::cast(proto);
}
return isolate->heap()->ToBoolean(obj->map()->is_observed()); return isolate->heap()->ToBoolean(obj->map()->is_observed());
} }
...@@ -14897,12 +14892,7 @@ RUNTIME_FUNCTION(Runtime_SetIsObserved) { ...@@ -14897,12 +14892,7 @@ RUNTIME_FUNCTION(Runtime_SetIsObserved) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() == 1); ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
if (obj->IsJSGlobalProxy()) { ASSERT(!obj->IsJSGlobalProxy());
Object* proto = obj->GetPrototype();
if (proto->IsNull()) return isolate->heap()->undefined_value();
ASSERT(proto->IsJSGlobalObject());
obj = handle(JSReceiver::cast(proto));
}
if (obj->IsJSProxy()) if (obj->IsJSProxy())
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
......
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