From af5f156d40a743792ddf160f34be01de53affeb2 Mon Sep 17 00:00:00 2001 From: zeynepCankara Date: Thu, 18 Jun 2020 12:47:13 +0300 Subject: [PATCH] [tools] Map search bar feature added, map id changed from int to string Change-Id: Icc37fc091086a3239a1b080ca2829efcda97f328 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2245601 Commit-Queue: Sathya Gunasekaran Reviewed-by: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#68406} --- AUTHORS | 1 + tools/ic-explorer.html | 7 +++++++ tools/map-processor.html | 28 ++++++++++++++++++++++++++++ tools/map-processor.js | 39 +++++++++++++++++++++++++++------------ 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/AUTHORS b/AUTHORS index d6d9ffb1ed..7c43c60fc1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -216,3 +216,4 @@ Zhongping Wang 柳荣一 Yanbo Li Gilang Mentari Hamidy +Zeynep Cankara \ No newline at end of file diff --git a/tools/ic-explorer.html b/tools/ic-explorer.html index 4c725163c5..67bfd1dc2d 100644 --- a/tools/ic-explorer.html +++ b/tools/ic-explorer.html @@ -337,8 +337,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file. details.style.display = display; } + function removeOptions(selectElement) { + while(selectElement.options.length > 0) { + selectElement.remove(0); + } + } + function initGroupKeySelect() { let select = document.getElementById("group-key"); + removeOptions(select); for (let i in properties) { let option = document.createElement("option"); option.text = properties[i]; diff --git a/tools/map-processor.html b/tools/map-processor.html index 37ee0f5ac3..b2bc3d57df 100644 --- a/tools/map-processor.html +++ b/tools/map-processor.html @@ -369,6 +369,10 @@ dd { z-index: 100; display: none; } +#searchBarInput { + width: 200px; +} + @@ -503,8 +507,23 @@ define(Array.prototype, "histogram", function(mapFn) { return histogram; }); + // ========================================================================= // EventHandlers +function handleSearchBar(){ + let searchBar = $('searchBarInput'); + let searchBarInput = searchBar.value; + let selectedMap = V8Map.get(searchBarInput); + //removeAllChildren($('mapIdList')); + if(selectedMap){ + let map = selectedMap; + document.state.map = map; + searchBar.className = "green"; + } else { + searchBar.className = "red"; + } +} + function handleBodyLoad() { let upload = $('fileReader'); upload.onclick = (e) => $("file").click(); @@ -1253,6 +1272,15 @@ function transitionTypeToColor(type) {

+ +

Search Map by Address

+ + + +
    +
+ +

Selected Map

diff --git a/tools/map-processor.js b/tools/map-processor.js index 6cc050ba3d..9b261c7d1b 100644 --- a/tools/map-processor.js +++ b/tools/map-processor.js @@ -43,17 +43,17 @@ class MapProcessor extends LogReader { processor: this.processFunctionMove }, 'map-create': { - parsers: [parseInt, parseInt, parseString], + parsers: [parseInt, parseString], processor: this.processMapCreate }, 'map': { - parsers: [parseString, parseInt, parseInt, parseInt, parseInt, parseInt, + parsers: [parseString, parseInt, parseString, parseString, parseInt, parseInt, parseString, parseString, parseString ], processor: this.processMap }, 'map-details': { - parsers: [parseInt, parseInt, parseString], + parsers: [parseInt, parseString, parseString], processor: this.processMapDetails } }; @@ -183,17 +183,16 @@ class MapProcessor extends LogReader { this.getExistingMap(id, time).deprecate(); } - processMapCreate(time, id, string) { + processMapCreate(time, id) { // map-create events might override existing maps if the addresses get - // rcycled. Hence we do not check for existing maps. + // recycled. Hence we do not check for existing maps. let map = this.createMap(id, time); - map.description = string; } processMapDetails(time, id, string) { //TODO(cbruni): fix initial map logging. let map = this.getExistingMap(id, time); - if (!map.description) map.description = string; + map.description = string; } createMap(id, time) { @@ -203,8 +202,8 @@ class MapProcessor extends LogReader { } getExistingMap(id, time) { - if (id === 0) return undefined; - let map = V8Map.get(id); + if (id === "0x000000000000") return undefined; + let map = V8Map.get(id, time); if (map === undefined) { console.error("No map details provided: id=" + id); // Manually patch in a map to continue running. @@ -332,18 +331,34 @@ class V8Map { return parents; } - static get(id) { - return this.cache.get(id); + + static get(id, time = undefined) { + let maps = this.cache.get(id); + if(maps){ + for (let i = 0; i < maps.length; i++) { + //TODO: Implement time based map search + if(maps[i].time === time){ + return maps[i]; + } + } + // default return the latest + return maps[maps.length-1]; + } } static set(id, map) { - this.cache.set(id, map); + if(this.cache.has(id)){ + this.cache.get(id).push(map); + } else { + this.cache.set(id, [map]); + } } } V8Map.cache = new Map(); + // =========================================================================== class Edge { constructor(type, name, reason, time, from, to) {