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

Unified Diff: src/object-observe.js

Issue 11274014: Store Object.observe state per-isolate rather than per-context (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added back runtime asserts 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
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/object-observe.js
diff --git a/src/object-observe.js b/src/object-observe.js
index 41d7f3c608d593631600abdf7c5c493054cbce08..bd621d85e41421f17c2abf581c5b921eab6ab3a2 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -30,21 +30,31 @@
var InternalObjectIsFrozen = $Object.isFrozen;
var InternalObjectFreeze = $Object.freeze;
-var InternalWeakMapProto = {
- __proto__: null,
- set: $WeakMap.prototype.set,
- get: $WeakMap.prototype.get,
- has: $WeakMap.prototype.has
+var observationState = %GetObservationState();
+if (IS_UNDEFINED(observationState.observerInfoMap)) {
+ observationState.observerInfoMap = %CreateObjectHashTable();
+ observationState.objectInfoMap = %CreateObjectHashTable();
}
-function createInternalWeakMap() {
- var map = new $WeakMap;
- map.__proto__ = InternalWeakMapProto;
- return map;
+function InternalObjectHashTable(table) {
+ this.table = table;
}
-var observerInfoMap = createInternalWeakMap();
-var objectInfoMap = createInternalWeakMap();
+InternalObjectHashTable.prototype = {
+ get: function(key) {
+ return %ObjectHashTableGet(this.table, key);
+ },
+ set: function(key, value) {
+ return %ObjectHashTableSet(this.table, key, value);
+ },
+ has: function(key) {
+ return %ObjectHashTableHas(this.table, key);
+ }
+};
+
+var observerInfoMap = new InternalObjectHashTable(
+ observationState.observerInfoMap);
+var objectInfoMap = new InternalObjectHashTable(observationState.objectInfoMap);
function ObjectObserve(object, callback) {
if (!IS_SPEC_OBJECT(object))
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698