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

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: Add test for attaching via Context::New Created 8 years 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/runtime.h ('k') | test/cctest/test-object-observe.cc » ('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 c162dcbf4c847c18ccf3851949986f533de71282..f1f0fd7d444feae7ad3f7acb36670b8e760d7c25 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -13271,6 +13271,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()->false_value();
+ ASSERT(proto->IsJSGlobalObject());
+ obj = JSReceiver::cast(proto);
+ }
return isolate->heap()->ToBoolean(obj->map()->is_observed());
}
@@ -13279,6 +13285,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1);
+ if (obj->IsJSGlobalProxy()) {
+ Object* proto = obj->GetPrototype();
+ if (obj->IsNull()) return isolate->heap()->undefined_value();
+ ASSERT(proto->IsJSGlobalObject());
+ obj = JSReceiver::cast(proto);
+ }
if (obj->map()->is_observed() != is_observed) {
MaybeObject* maybe = obj->map()->Copy();
Map* map;
@@ -13314,6 +13326,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;
}
@@ -13324,21 +13340,15 @@ 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 *table;
+ }
Handle<Object> value = args.at<Object>(2);
return *PutIntoObjectHashTable(table, key, value);
}
-RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) {
- NoHandleAllocation ha;
- ASSERT(args.length() == 2);
- CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
- Object* key = args[1];
- Object* lookup = table->Lookup(key);
- return isolate->heap()->ToBoolean(!lookup->IsTheHole());
-}
-
-
// ----------------------------------------------------------------------------
// Implementation of Runtime
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698