Index: src/debug/mirrors.js |
diff --git a/src/debug/mirrors.js b/src/debug/mirrors.js |
index 31387abc95c8bc319f3a36f38444b8ea55eb310a..85ff2b2a90e3cae5eb10ee852cd8ef6f870f451f 100644 |
--- a/src/debug/mirrors.js |
+++ b/src/debug/mirrors.js |
@@ -11,7 +11,6 @@ |
var GlobalArray = global.Array; |
var IsNaN = global.isNaN; |
var JSONStringify = global.JSON.stringify; |
-var GlobalMap = global.Map; |
var MathMin = global.Math.min; |
// ---------------------------------------------------------------------------- |
@@ -74,12 +73,12 @@ |
var next_transient_handle_ = -1; |
// Mirror cache. |
-var mirror_cache_ = new GlobalMap(); |
+var mirror_cache_ = []; |
var mirror_cache_enabled_ = true; |
function MirrorCacheIsEmpty() { |
- return mirror_cache_.size === 0; |
+ return next_handle_ == 0 && mirror_cache_.length == 0; |
} |
@@ -91,7 +90,7 @@ |
function ClearMirrorCache(value) { |
next_handle_ = 0; |
- mirror_cache_.clear(); |
+ mirror_cache_ = []; |
} |
@@ -121,7 +120,17 @@ |
// Look for non transient mirrors in the mirror cache. |
if (!opt_transient && mirror_cache_enabled_) { |
- if (mirror_cache_.has(value)) return mirror_cache_.get(value); |
+ for (var id in mirror_cache_) { |
+ mirror = mirror_cache_[id]; |
+ if (mirror.value() === value) { |
+ return mirror; |
+ } |
+ // Special check for NaN as NaN == NaN is false. |
+ if (mirror.isNumber() && IsNaN(mirror.value()) && |
+ typeof value == 'number' && IsNaN(value)) { |
+ return mirror; |
+ } |
+ } |
} |
if (IS_UNDEFINED(value)) { |
@@ -162,7 +171,7 @@ |
mirror = new ObjectMirror(value, MirrorType.OBJECT_TYPE, opt_transient); |
} |
- if (mirror_cache_enabled_) mirror_cache_.set(value, mirror); |
+ if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror; |
return mirror; |
} |
@@ -178,10 +187,7 @@ |
if (!mirror_cache_enabled_) { |
throw MakeError(kDebugger, "Mirror cache is disabled"); |
} |
- for (var value of mirror_cache_.values()) { |
- if (value.handle() == handle) return value; |
- } |
- return UNDEFINED; |
+ return mirror_cache_[handle]; |
} |