Commit 40c9fa05 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[tools] Fix v8-heap-stats

Don't use deprecated HTML Imports, directly fetch the template files from
html instead.

Bug: v8:10155
Change-Id: Ic85a8b2cf227231fc6abf5adca6f1f144bf728f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2113371Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66825}
parent 31846fae
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Categories for instance types. // Categories for instance types.
const CATEGORIES = new Map([ export const CATEGORIES = new Map([
[ [
'user', new Set([ 'user', new Set([
'CONS_ONE_BYTE_STRING_TYPE', 'CONS_ONE_BYTE_STRING_TYPE',
...@@ -204,7 +204,7 @@ const CATEGORIES = new Map([ ...@@ -204,7 +204,7 @@ const CATEGORIES = new Map([
]); ]);
// Maps category to description text that is shown in html. // Maps category to description text that is shown in html.
const CATEGORY_NAMES = new Map([ export const CATEGORY_NAMES = new Map([
['user', 'JS'], ['user', 'JS'],
['system', 'Metadata'], ['system', 'Metadata'],
['code', 'Code'], ['code', 'Code'],
......
<!-- Copyright 2018 the V8 project authors. All rights reserved. <!-- Copyright 2018 the V8 project authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<template id="details-selection-template">
<style> <style>
#dataSelectionSection { #dataSelectionSection {
display: none; display: none;
...@@ -139,7 +138,3 @@ found in the LICENSE file. --> ...@@ -139,7 +138,3 @@ found in the LICENSE file. -->
<div id="categories"></div> <div id="categories"></div>
</section> </section>
</template>
<script type="text/javascript" src="categories.js"></script>
<script type="text/javascript" src="details-selection.js"></script>
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
'use strict'; 'use strict';
const details_selection_template = import {CATEGORIES, CATEGORY_NAMES} from '/categories.js';
document.currentScript.ownerDocument.querySelector(
'#details-selection-template');
const VIEW_BY_INSTANCE_TYPE = 'by-instance-type'; export const VIEW_BY_INSTANCE_TYPE = 'by-instance-type';
const VIEW_BY_INSTANCE_CATEGORY = 'by-instance-category'; export const VIEW_BY_INSTANCE_CATEGORY = 'by-instance-category';
const VIEW_BY_FIELD_TYPE = 'by-field-type'; export const VIEW_BY_FIELD_TYPE = 'by-field-type';
class DetailsSelection extends HTMLElement { defineCustomElement('details-selection', (templateText) =>
class DetailsSelection extends HTMLElement {
constructor() { constructor() {
super(); super();
const shadowRoot = this.attachShadow({mode: 'open'}); const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.appendChild(details_selection_template.content.cloneNode(true)); shadowRoot.innerHTML = templateText;
this.isolateSelect.addEventListener( this.isolateSelect.addEventListener(
'change', e => this.handleIsolateChange(e)); 'change', e => this.handleIsolateChange(e));
this.dataViewSelect.addEventListener( this.dataViewSelect.addEventListener(
...@@ -403,6 +402,4 @@ class DetailsSelection extends HTMLElement { ...@@ -403,6 +402,4 @@ class DetailsSelection extends HTMLElement {
link.click(); link.click();
this.shadowRoot.removeChild(link); this.shadowRoot.removeChild(link);
} }
} });
customElements.define('details-selection', DetailsSelection);
<!-- Copyright 2018 the V8 project authors. All rights reserved. <!-- Copyright 2018 the V8 project authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<template id="global-timeline-template">
<style> <style>
#chart { #chart {
width: 100%; width: 100%;
...@@ -12,5 +11,3 @@ found in the LICENSE file. --> ...@@ -12,5 +11,3 @@ found in the LICENSE file. -->
<h2>Timeline</h2> <h2>Timeline</h2>
<div id="chart"></div> <div id="chart"></div>
</div> </div>
</template>
<script type="text/javascript" src="global-timeline.js"></script>
\ No newline at end of file
...@@ -4,15 +4,18 @@ ...@@ -4,15 +4,18 @@
'use strict'; 'use strict';
const global_timeline_template = import {
document.currentScript.ownerDocument.querySelector( VIEW_BY_INSTANCE_TYPE,
'#global-timeline-template'); VIEW_BY_INSTANCE_CATEGORY,
VIEW_BY_FIELD_TYPE
class GlobalTimeline extends HTMLElement { } from '/details-selection.js';
defineCustomElement('global-timeline', (templateText) =>
class GlobalTimeline extends HTMLElement {
constructor() { constructor() {
super(); super();
const shadowRoot = this.attachShadow({mode: 'open'}); const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.appendChild(global_timeline_template.content.cloneNode(true)); shadowRoot.innerHTML = templateText;
} }
$(id) { $(id) {
...@@ -217,6 +220,4 @@ class GlobalTimeline extends HTMLElement { ...@@ -217,6 +220,4 @@ class GlobalTimeline extends HTMLElement {
this.show(); this.show();
chart.draw(data, google.charts.Line.convertOptions(options)); chart.draw(data, google.charts.Line.convertOptions(options));
} }
} });
customElements.define('global-timeline', GlobalTimeline);
...@@ -21,3 +21,10 @@ function formatBytes(bytes) { ...@@ -21,3 +21,10 @@ function formatBytes(bytes) {
function formatSeconds(millis) { function formatSeconds(millis) {
return (millis * kMillis2Seconds).toFixed(2) + 's'; return (millis * kMillis2Seconds).toFixed(2) + 's';
} }
function defineCustomElement(name, generator) {
let htmlTemplatePath = name + '-template.html';
fetch(htmlTemplatePath)
.then(stream => stream.text())
.then(templateText => customElements.define(name, generator(templateText)));
}
<!-- Copyright 2018 the V8 project authors. All rights reserved. <!-- Copyright 2018 the V8 project authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<template id="histogram-viewer-template">
<style> <style>
#chart { #chart {
width: 100%; width: 100%;
...@@ -15,5 +14,3 @@ found in the LICENSE file. --> ...@@ -15,5 +14,3 @@ found in the LICENSE file. -->
</ul> </ul>
<div id="chart"></div> <div id="chart"></div>
</div> </div>
</template>
<script type="text/javascript" src="histogram-viewer.js"></script>
\ No newline at end of file
...@@ -4,15 +4,18 @@ ...@@ -4,15 +4,18 @@
'use strict'; 'use strict';
const histogram_viewer_template = import {
document.currentScript.ownerDocument.querySelector( VIEW_BY_INSTANCE_TYPE,
'#histogram-viewer-template'); VIEW_BY_INSTANCE_CATEGORY,
VIEW_BY_FIELD_TYPE
class HistogramViewer extends HTMLElement { } from '/details-selection.js';
defineCustomElement('histogram-viewer', (templateText) =>
class HistogramViewer extends HTMLElement {
constructor() { constructor() {
super(); super();
const shadowRoot = this.attachShadow({mode: 'open'}); const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.appendChild(histogram_viewer_template.content.cloneNode(true)); shadowRoot.innerHTML = templateText;
} }
$(id) { $(id) {
...@@ -185,6 +188,4 @@ class HistogramViewer extends HTMLElement { ...@@ -185,6 +188,4 @@ class HistogramViewer extends HTMLElement {
this.show(); this.show();
chart.draw(data, options); chart.draw(data, options);
} }
} });
customElements.define('histogram-viewer', HistogramViewer);
...@@ -18,10 +18,10 @@ found in the LICENSE file. --> ...@@ -18,10 +18,10 @@ found in the LICENSE file. -->
<script src="helper.js"></script> <script src="helper.js"></script>
<link rel="import" href="details-selection.html"> <script type="module" src="/details-selection.js"></script>
<link rel="import" href="global-timeline.html"> <script type="module" src="/global-timeline.js"></script>
<link rel="import" href="histogram-viewer.html"> <script type="module" src="/histogram-viewer.js"></script>
<link rel="import" href="trace-file-reader.html"> <script type="module" src="/trace-file-reader.js"></script>
<style> <style>
body { body {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
'use strict'; 'use strict';
class Isolate { export class Isolate {
constructor(address) { constructor(address) {
this.address = address; this.address = address;
this.start = null; this.start = null;
......
<!-- Copyright 2018 the V8 project authors. All rights reserved. <!-- Copyright 2018 the V8 project authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<template id="trace-file-reader-template">
<style> <style>
#fileReader { #fileReader {
width: 100%; width: 100%;
...@@ -80,7 +79,3 @@ found in the LICENSE file. --> ...@@ -80,7 +79,3 @@ found in the LICENSE file. -->
<div id="spinner"></div> <div id="spinner"></div>
</div> </div>
</section> </section>
</template>
<script type="text/javascript" src="model.js"></script>
<script src="trace-file-reader.js"></script>
...@@ -4,15 +4,14 @@ ...@@ -4,15 +4,14 @@
'use strict'; 'use strict';
const trace_file_reader_template = import {Isolate} from '/model.js';
document.currentScript.ownerDocument.querySelector(
'#trace-file-reader-template');
class TraceFileReader extends HTMLElement { defineCustomElement('trace-file-reader', (templateText) =>
class TraceFileReader extends HTMLElement {
constructor() { constructor() {
super(); super();
const shadowRoot = this.attachShadow({mode: 'open'}); const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.appendChild(trace_file_reader_template.content.cloneNode(true)); shadowRoot.innerHTML = templateText;
this.addEventListener('click', e => this.handleClick(e)); this.addEventListener('click', e => this.handleClick(e));
this.addEventListener('dragover', e => this.handleDragOver(e)); this.addEventListener('dragover', e => this.handleDragOver(e));
this.addEventListener('drop', e => this.handleChange(e)); this.addEventListener('drop', e => this.handleChange(e));
...@@ -314,6 +313,4 @@ class TraceFileReader extends HTMLElement { ...@@ -314,6 +313,4 @@ class TraceFileReader extends HTMLElement {
} }
return data; return data;
} }
} });
customElements.define('trace-file-reader', TraceFileReader);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment