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

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: Use ObjectHashTable directly 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') | src/objects-inl.h » ('J')
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 dcf98d84aed1e66359b2c71d8f648733f7479922..e21ab9c1e126b80566ba4cdbc68961d389f26a34 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -30,21 +30,32 @@
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 objectObservationState = %GetObjectObservationState();
+if (IS_UNDEFINED(objectObservationState.observerInfoMap)) {
+ objectObservationState.observerInfoMap = %CreateObjectHashTable();
+ objectObservationState.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(
+ objectObservationState.observerInfoMap);
+var objectInfoMap = new InternalObjectHashTable(
+ objectObservationState.observerInfoMap);
function ObjectObserve(object, callback) {
if (!IS_SPEC_OBJECT(object))
@@ -161,4 +172,4 @@ function SetupObjectObserve() {
));
}
-SetupObjectObserve();
+SetupObjectObserve();
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698