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

Unified Diff: src/debug/mirrors.js

Issue 1292023002: Revert of Debugger: use a Map to cache mirrors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/bootstrapper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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];
}
« no previous file with comments | « src/bootstrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698