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

Unified Diff: src/runtime.cc

Issue 12092079: Object.observe: use JSWeakMaps instead of raw ObjectHashTables in observation state (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix test, also test notifierTargetMap Created 7 years, 10 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/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 e8003b6731cc77740ed36596a90a59fcfe957027..ee0848ccd6fc5224f50c067fc96deea4a16c0532 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -863,10 +863,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) {
}
-RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) {
- HandleScope scope(isolate);
- ASSERT(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
+static JSWeakMap* WeakMapInitialize(Isolate* isolate,
+ Handle<JSWeakMap> weakmap) {
ASSERT(weakmap->map()->inobject_properties() == 0);
Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
weakmap->set_table(*table);
@@ -875,6 +873,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
+ return WeakMapInitialize(isolate, weakmap);
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) {
HandleScope scope(isolate);
ASSERT(args.length() == 2);
@@ -13404,37 +13410,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) {
}
-RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectHashTable) {
+RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) {
+ HandleScope scope(isolate);
ASSERT(args.length() == 0);
- return ObjectHashTable::Allocate(0);
+ // TODO(adamk): Currently this runtime function is only called three times per
+ // isolate. If it's called more often, the map should be moved into the
+ // strong root list.
+ Handle<Map> map =
+ isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
+ Handle<JSWeakMap> weakmap =
+ Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map));
+ return WeakMapInitialize(isolate, weakmap);
}
-RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) {
- NoHandleAllocation ha;
- 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;
-}
-
-
-RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) {
- HandleScope scope(isolate);
- 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;
+RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) {
+ ASSERT(args.length() == 1);
+ Object* object = args[0];
+ if (object->IsJSGlobalProxy()) {
+ object = object->GetPrototype();
+ if (object->IsNull()) return isolate->heap()->undefined_value();
}
- Handle<Object> value = args.at<Object>(2);
- return *PutIntoObjectHashTable(table, key, value);
+ return object;
}
« 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