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

Unified Diff: src/runtime.cc

Issue 11414094: Make Object.observe on the global object functional (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 252b624024cd431bed30f75165798abfa7108b62..fb626948fbb23ac3539e07bd817b9f3f6e151ad6 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -13158,6 +13158,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
+ if (obj->IsJSGlobalProxy()) {
+ Object* proto = obj->GetPrototype();
+ if (obj->IsNull()) return isolate->heap()->undefined_value();
rossberg 2012/11/21 12:43:17 Perhaps you should return false here.
adamk 2012/11/21 17:02:57 Ah, that's probably a better plan, yes.
+ ASSERT(proto->IsJSGlobalObject());
+ obj = JSReceiver::cast(proto);
+ }
return isolate->heap()->ToBoolean(obj->map()->is_observed());
}
@@ -13166,6 +13172,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1);
+ JSGlobalProxy* global_proxy = NULL;
rossberg 2012/11/21 12:43:17 What do you need this for?
adamk 2012/11/21 17:02:57 Cruft from a previous version before I discovered
+ if (obj->IsJSGlobalProxy()) {
+ Object* proto = obj->GetPrototype();
+ if (obj->IsNull()) return isolate->heap()->undefined_value();
+ ASSERT(proto->IsJSGlobalObject());
+ global_proxy = JSGlobalProxy::cast(obj);
+ obj = JSReceiver::cast(proto);
+ }
if (obj->map()->is_observed() != is_observed) {
MaybeObject* maybe = obj->map()->Copy();
Map* map;
@@ -13201,6 +13215,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) {
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
Object* key = args[1];
+ if (key->IsJSGlobalProxy()) {
+ key = key->GetPrototype();
+ if (key->IsNull()) return isolate->heap()->undefined_value();
+ }
Object* lookup = table->Lookup(key);
return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup;
}
@@ -13211,6 +13229,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) {
ASSERT(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0);
Handle<Object> key = args.at<Object>(1);
+ if (key->IsJSGlobalProxy()) {
+ key = handle(key->GetPrototype(), isolate);
+ if (key->IsNull()) return isolate->heap()->undefined_value();
rossberg 2012/11/21 12:43:17 Return this.
adamk 2012/11/21 17:02:57 Woops, fixed. This is one that will be covered by
+ }
Handle<Object> value = args.at<Object>(2);
return *PutIntoObjectHashTable(table, key, value);
}
@@ -13221,6 +13243,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) {
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
Object* key = args[1];
+ if (key->IsJSGlobalProxy()) {
+ key = key->GetPrototype();
+ if (key->IsNull()) return isolate->heap()->undefined_value();
rossberg 2012/11/21 12:43:17 False here, too.
adamk 2012/11/21 17:02:57 This function wasn't carrying its weight, just rem
rossberg 2012/11/22 12:17:05 I'm fine with that. But note that there no longer
+ }
Object* lookup = table->Lookup(key);
return isolate->heap()->ToBoolean(!lookup->IsTheHole());
}

Powered by Google App Engine
This is Rietveld 408576698