Index: src/mirror-debugger.js |
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js |
index b1f67ac7a872d416c22d7f01b69df1ce003b2404..f878f5abcd7e915372ba58e7c5e5655cbfd1b6f9 100644 |
--- a/src/mirror-debugger.js |
+++ b/src/mirror-debugger.js |
@@ -8,6 +8,14 @@ var next_transient_handle_ = -1; |
// Mirror cache. |
var mirror_cache_ = []; |
+var mirror_cache_enabled_ = true; |
+ |
+ |
+function ToggleMirrorCache(value) { |
+ mirror_cache_enabled_ = value; |
+ next_handle_ = 0; |
+ mirror_cache_ = []; |
+} |
/** |
@@ -44,7 +52,7 @@ function MakeMirror(value, opt_transient) { |
var mirror; |
// Look for non transient mirrors in the mirror cache. |
- if (!opt_transient) { |
+ if (!opt_transient && mirror_cache_enabled_) { |
for (id in mirror_cache_) { |
mirror = mirror_cache_[id]; |
if (mirror.value() === value) { |
@@ -88,7 +96,7 @@ function MakeMirror(value, opt_transient) { |
mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient); |
} |
- mirror_cache_[mirror.handle()] = mirror; |
+ if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror; |
return mirror; |
} |
@@ -101,6 +109,7 @@ function MakeMirror(value, opt_transient) { |
* undefined if no mirror with the requested handle was found |
*/ |
function LookupMirror(handle) { |
+ if (!mirror_cache_enabled_) throw new Error("Mirror cache is disabled"); |
return mirror_cache_[handle]; |
} |
@@ -424,7 +433,7 @@ Mirror.prototype.isScope = function() { |
* Allocate a handle id for this object. |
*/ |
Mirror.prototype.allocateHandle_ = function() { |
- this.handle_ = next_handle_++; |
+ if (mirror_cache_enabled_) this.handle_ = next_handle_++; |
}; |