Commit 1dec2864 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Change turbolizer to ES2015 modules

Bug: v8:7327
Change-Id: If2670e2b8e64a34f5de7855615e2288b6f2f3133
Reviewed-on: https://chromium-review.googlesource.com/1131193
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54371}
parent 80508f14
...@@ -102,3 +102,6 @@ v8.ignition_dispatches_table.json ...@@ -102,3 +102,6 @@ v8.ignition_dispatches_table.json
/Default/ /Default/
node_modules node_modules
tools/turbolizer/build tools/turbolizer/build
tools/turbolizer/.rpt2_cache
tools/turbolizer/deploy
This diff is collapsed.
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
"name": "turbolizer", "name": "turbolizer",
"version": "0.1.0", "version": "0.1.0",
"description": "Visualization tool for V8 TurboFan IR graphs", "description": "Visualization tool for V8 TurboFan IR graphs",
"main": "index.html",
"scripts": { "scripts": {
"build": "tsc", "build": "rollup -c",
"watch": "tsc --watch", "watch": "tsc --watch",
"deploy": "./deploy.sh", "deploy": "./deploy.sh",
"format": "tsfmt -r" "format": "tsfmt -r"
...@@ -13,7 +12,10 @@ ...@@ -13,7 +12,10 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/d3": "^5.0.0", "@types/d3": "^5.0.0",
"d3": "^5.4.0" "d3": "^5.5.0",
"pegjs": "^0.10.0",
"rollup": "^0.62.0",
"rollup-plugin-typescript2": "^0.15.1"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import typescript from 'rollup-plugin-typescript2';
export default {
entry: "src/turbo-visualizer.ts",
format: "iife",
plugins: [typescript({abortOnError:false})],
dest: "build/turbolizer.js"
};
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
// 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.
"use strict"; import {Source,SourceResolver,sourcePositionToStringKey} from "./source-resolver.js"
import {SelectionBroker} from "./selection-broker.js"
import {View} from "./view.js"
import {MySelection} from "./selection.js"
import {anyToString,ViewElements} from "./util.js"
enum CodeMode { export enum CodeMode {
MAIN_SOURCE = "main function", MAIN_SOURCE = "main function",
INLINED_SOURCE = "inlined function" INLINED_SOURCE = "inlined function"
}; };
class CodeView extends View { export class CodeView extends View {
broker: SelectionBroker; broker: SelectionBroker;
source: Source; source: Source;
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
......
...@@ -2,25 +2,22 @@ ...@@ -2,25 +2,22 @@
// 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.
const MAX_RANK_SENTINEL = 0; export const MAX_RANK_SENTINEL = 0;
const GRAPH_MARGIN = 250; export const GRAPH_MARGIN = 250;
const WIDTH = 'width'; export const SOURCE_PANE_ID = 'left';
const HEIGHT = 'height'; export const SOURCE_COLLAPSE_ID = 'source-shrink';
const VISIBILITY = 'visibility'; export const SOURCE_EXPAND_ID = 'source-expand';
const SOURCE_PANE_ID = 'left'; export const INTERMEDIATE_PANE_ID = 'middle';
const SOURCE_COLLAPSE_ID = 'source-shrink'; export const GRAPH_PANE_ID = 'graph';
const SOURCE_EXPAND_ID = 'source-expand'; export const SCHEDULE_PANE_ID = 'schedule';
const INTERMEDIATE_PANE_ID = 'middle'; export const GENERATED_PANE_ID = 'right';
const GRAPH_PANE_ID = 'graph'; export const DISASSEMBLY_PANE_ID = 'disassembly';
const SCHEDULE_PANE_ID = 'schedule'; export const DISASSEMBLY_COLLAPSE_ID = 'disassembly-shrink';
const GENERATED_PANE_ID = 'right'; export const DISASSEMBLY_EXPAND_ID = 'disassembly-expand';
const DISASSEMBLY_PANE_ID = 'disassembly'; export const COLLAPSE_PANE_BUTTON_VISIBLE = 'button-input';
const DISASSEMBLY_COLLAPSE_ID = 'disassembly-shrink'; export const COLLAPSE_PANE_BUTTON_INVISIBLE = 'button-input-invisible';
const DISASSEMBLY_EXPAND_ID = 'disassembly-expand'; export const UNICODE_BLOCK = '&#9611;';
const COLLAPSE_PANE_BUTTON_VISIBLE = 'button-input'; export const PROF_COLS = [
const COLLAPSE_PANE_BUTTON_INVISIBLE = 'button-input-invisible';
const UNICODE_BLOCK = '&#9611;';
const PROF_COLS = [
{ perc: 0, col: { r: 255, g: 255, b: 255 } }, { perc: 0, col: { r: 255, g: 255, b: 255 } },
{ perc: 0.5, col: { r: 255, g: 255, b: 128 } }, { perc: 0.5, col: { r: 255, g: 255, b: 128 } },
{ perc: 5, col: { r: 255, g: 128, b: 0 } }, { perc: 5, col: { r: 255, g: 128, b: 0 } },
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
// 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.
"use strict"; import {PROF_COLS, UNICODE_BLOCK} from "./constants.js"
import {SelectionBroker} from "./selection-broker.js"
import {TextView} from "./text-view.js"
class DisassemblyView extends TextView { export class DisassemblyView extends TextView {
SOURCE_POSITION_HEADER_REGEX: any; SOURCE_POSITION_HEADER_REGEX: any;
addr_event_counts: any; addr_event_counts: any;
total_event_counts: any; total_event_counts: any;
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
// 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.
var MINIMUM_EDGE_SEPARATION = 20; import {GNode, DEFAULT_NODE_BUBBLE_RADIUS} from "./node.js"
function isEdgeInitiallyVisible(target, index, source, type) { export const MINIMUM_EDGE_SEPARATION = 20;
export function isEdgeInitiallyVisible(target, index, source, type) {
return type == "control" && (target.cfg || source.cfg); return type == "control" && (target.cfg || source.cfg);
} }
class Edge { export class Edge {
target: GNode; target: GNode;
source: GNode; source: GNode;
index: number; index: number;
...@@ -89,4 +91,4 @@ class Edge { ...@@ -89,4 +91,4 @@ class Edge {
} }
const edgeToStr = (e: Edge) => e.stringID(); export const edgeToStr = (e: Edge) => e.stringID();
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
// 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.
var DEFAULT_NODE_ROW_SEPARATION = 130
import {MAX_RANK_SENTINEL} from "./constants.js"
import {MINIMUM_EDGE_SEPARATION} from "./edge.js"
import {NODE_INPUT_WIDTH, MINIMUM_NODE_OUTPUT_APPROACH, DEFAULT_NODE_BUBBLE_RADIUS} from "./node.js"
const DEFAULT_NODE_ROW_SEPARATION = 130
var traceLayout = false; var traceLayout = false;
...@@ -246,7 +252,7 @@ function newGraphOccupation(graph) { ...@@ -246,7 +252,7 @@ function newGraphOccupation(graph) {
return occupation; return occupation;
} }
function layoutNodeGraph(graph) { export function layoutNodeGraph(graph) {
// First determine the set of nodes that have no outputs. Those are the // First determine the set of nodes that have no outputs. Those are the
// basis for bottom-up DFS to determine rank and node placement. // basis for bottom-up DFS to determine rank and node placement.
var endNodesHasNoOutputs = []; var endNodesHasNoOutputs = [];
......
...@@ -2,7 +2,16 @@ ...@@ -2,7 +2,16 @@
// 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.
"use strict"; import * as d3 from "d3"
import {layoutNodeGraph} from "./graph-layout.js"
import {MAX_RANK_SENTINEL} from "./constants.js"
import {GNode, nodeToStr, isNodeInitiallyVisible} from "./node.js"
import {NODE_INPUT_WIDTH, MINIMUM_NODE_OUTPUT_APPROACH} from "./node.js"
import {DEFAULT_NODE_BUBBLE_RADIUS} from "./node.js"
import {Edge, edgeToStr} from "./edge.js"
import {View, PhaseView} from "./view.js"
import {MySelection} from "./selection.js"
import {partial, alignUp} from "./util.js"
function nodeToStringKey(n) { function nodeToStringKey(n) {
return "" + n.id; return "" + n.id;
...@@ -18,7 +27,7 @@ interface GraphState { ...@@ -18,7 +27,7 @@ interface GraphState {
hideDead: boolean hideDead: boolean
} }
class GraphView extends View implements PhaseView { export class GraphView extends View implements PhaseView {
divElement: d3.Selection<any, any, any, any>; divElement: d3.Selection<any, any, any, any>;
svg: d3.Selection<any, any, any, any>; svg: d3.Selection<any, any, any, any>;
showPhaseByName: (string) => void; showPhaseByName: (string) => void;
...@@ -272,7 +281,7 @@ class GraphView extends View implements PhaseView { ...@@ -272,7 +281,7 @@ class GraphView extends View implements PhaseView {
}; };
measureText(text) { measureText(text) {
const textMeasure = document.getElementById('text-measure'); const textMeasure = document.getElementById('text-measure') as SVGTSpanElement;
textMeasure.textContent = text; textMeasure.textContent = text;
return { return {
width: textMeasure.getBBox().width, width: textMeasure.getBBox().width,
...@@ -304,7 +313,7 @@ class GraphView extends View implements PhaseView { ...@@ -304,7 +313,7 @@ class GraphView extends View implements PhaseView {
n.labelbbox = g.measureText(n.displayLabel); n.labelbbox = g.measureText(n.displayLabel);
n.typebbox = g.measureText(n.getDisplayType()); n.typebbox = g.measureText(n.getDisplayType());
var innerwidth = Math.max(n.labelbbox.width, n.typebbox.width); var innerwidth = Math.max(n.labelbbox.width, n.typebbox.width);
n.width = MoreMath.alignUp(innerwidth + NODE_INPUT_WIDTH * 2, n.width = alignUp(innerwidth + NODE_INPUT_WIDTH * 2,
NODE_INPUT_WIDTH); NODE_INPUT_WIDTH);
var innerheight = Math.max(n.labelbbox.height, n.typebbox.height); var innerheight = Math.max(n.labelbbox.height, n.typebbox.height);
n.normalheight = innerheight + 20; n.normalheight = innerheight + 20;
...@@ -748,10 +757,10 @@ class GraphView extends View implements PhaseView { ...@@ -748,10 +757,10 @@ class GraphView extends View implements PhaseView {
newGs.append("rect") newGs.append("rect")
.attr("rx", 10) .attr("rx", 10)
.attr("ry", 10) .attr("ry", 10)
.attr(WIDTH, function (d) { .attr('width', function (d) {
return d.getTotalNodeWidth(); return d.getTotalNodeWidth();
}) })
.attr(HEIGHT, function (d) { .attr('height', function (d) {
return graph.getNodeHeight(d); return graph.getNodeHeight(d);
}) })
...@@ -856,7 +865,7 @@ class GraphView extends View implements PhaseView { ...@@ -856,7 +865,7 @@ class GraphView extends View implements PhaseView {
}) })
.attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")"; }) .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")"; })
.select('rect') .select('rect')
.attr(HEIGHT, function (d) { return graph.getNodeHeight(d); }); .attr('height', function (d) { return graph.getNodeHeight(d); });
graph.visibleBubbles = d3.selectAll('circle'); graph.visibleBubbles = d3.selectAll('circle');
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
// 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.
"use strict"; import {GraphView} from "./graph-view.js"
import {ScheduleView} from "./schedule-view.js"
import {SourceResolver} from "./source-resolver.js"
import {SelectionBroker} from "./selection-broker.js"
import {View, PhaseView} from "./view.js"
class GraphMultiView extends View { export class GraphMultiView extends View {
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
selectionBroker: SelectionBroker; selectionBroker: SelectionBroker;
graph: GraphView; graph: GraphView;
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const MoreMath = {
alignUp: (raw, multiple) => {
return Math.floor((raw + multiple - 1) / multiple) * multiple;
}
};
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
// 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.
const TYPE_HEIGHT = 25; import {NodeOrigin} from "./source-resolver.js"
const DEFAULT_NODE_BUBBLE_RADIUS = 12; import {MINIMUM_EDGE_SEPARATION} from "./edge.js"
const NODE_INPUT_WIDTH = 50;
export const DEFAULT_NODE_BUBBLE_RADIUS = 12;
export const NODE_INPUT_WIDTH = 50;
export const MINIMUM_NODE_OUTPUT_APPROACH = 15;
const MINIMUM_NODE_INPUT_APPROACH = 15 + 2 * DEFAULT_NODE_BUBBLE_RADIUS; const MINIMUM_NODE_INPUT_APPROACH = 15 + 2 * DEFAULT_NODE_BUBBLE_RADIUS;
const MINIMUM_NODE_OUTPUT_APPROACH = 15;
function isNodeInitiallyVisible(node) { export function isNodeInitiallyVisible(node) {
return node.cfg; return node.cfg;
} }
...@@ -22,7 +24,7 @@ function formatOrigin(origin) { ...@@ -22,7 +24,7 @@ function formatOrigin(origin) {
return "unknown origin"; return "unknown origin";
} }
class GNode { export class GNode {
control: boolean; control: boolean;
opcode: string; opcode: string;
live: boolean; live: boolean;
...@@ -177,4 +179,4 @@ class GNode { ...@@ -177,4 +179,4 @@ class GNode {
} }
}; };
const nodeToStr = (n: GNode) => "N" + n.id; export const nodeToStr = (n: GNode) => "N" + n.id;
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
// 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.
"use strict"; import {Schedule,SourceResolver} from "./source-resolver.js"
import {isIterable} from "./util.js"
import {PhaseView} from "./view.js"
import {TextView} from "./text-view.js"
class ScheduleView extends TextView implements PhaseView { export class ScheduleView extends TextView implements PhaseView {
schedule: Schedule; schedule: Schedule;
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// 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.
class SelectionBroker { import {SourceResolver, sourcePositionValid} from "./source-resolver.js"
export class SelectionBroker {
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
sourcePositionHandlers: Array<SelectionHandler>; sourcePositionHandlers: Array<SelectionHandler>;
nodeHandlers: Array<NodeSelectionHandler>; nodeHandlers: Array<NodeSelectionHandler>;
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// 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.
class MySelection { import {isIterable} from "./util.js"
export class MySelection {
selection: any; selection: any;
stringKey: (o: any) => string; stringKey: (o: any) => string;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// 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.
import {sortUnique, anyToString} from "./util.js"
function sourcePositionLe(a, b) { function sourcePositionLe(a, b) {
if (a.inliningId == b.inliningId) { if (a.inliningId == b.inliningId) {
return a.scriptOffset - b.scriptOffset; return a.scriptOffset - b.scriptOffset;
...@@ -14,7 +16,7 @@ function sourcePositionEq(a, b) { ...@@ -14,7 +16,7 @@ function sourcePositionEq(a, b) {
a.scriptOffset == b.scriptOffset; a.scriptOffset == b.scriptOffset;
} }
function sourcePositionToStringKey(sourcePosition): string { export function sourcePositionToStringKey(sourcePosition): string {
if (!sourcePosition) return "undefined"; if (!sourcePosition) return "undefined";
if (sourcePosition.inliningId && sourcePosition.scriptOffset) if (sourcePosition.inliningId && sourcePosition.scriptOffset)
return "SP:" + sourcePosition.inliningId + ":" + sourcePosition.scriptOffset; return "SP:" + sourcePosition.inliningId + ":" + sourcePosition.scriptOffset;
...@@ -23,12 +25,12 @@ function sourcePositionToStringKey(sourcePosition): string { ...@@ -23,12 +25,12 @@ function sourcePositionToStringKey(sourcePosition): string {
return "undefined"; return "undefined";
} }
function sourcePositionValid(l) { export function sourcePositionValid(l) {
return (typeof l.scriptOffset !== undefined return (typeof l.scriptOffset !== undefined
&& typeof l.inliningId !== undefined) || typeof l.bytecodePosition != undefined; && typeof l.inliningId !== undefined) || typeof l.bytecodePosition != undefined;
} }
interface SourcePosition { export interface SourcePosition {
scriptOffset: number; scriptOffset: number;
inliningId: number; inliningId: number;
} }
...@@ -38,7 +40,7 @@ interface TurboFanOrigin { ...@@ -38,7 +40,7 @@ interface TurboFanOrigin {
reducer: string; reducer: string;
} }
interface NodeOrigin { export interface NodeOrigin {
nodeId: number; nodeId: number;
} }
...@@ -52,7 +54,7 @@ type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin; ...@@ -52,7 +54,7 @@ type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin;
type AnyPosition = SourcePosition | BytecodePosition; type AnyPosition = SourcePosition | BytecodePosition;
interface Source { export interface Source {
sourcePositions: Array<SourcePosition>; sourcePositions: Array<SourcePosition>;
sourceName: string; sourceName: string;
functionName: string; functionName: string;
...@@ -70,11 +72,11 @@ interface Phase { ...@@ -70,11 +72,11 @@ interface Phase {
data: any; data: any;
} }
interface Schedule { export interface Schedule {
nodes: Array<any>; nodes: Array<any>;
} }
class SourceResolver { export class SourceResolver {
nodePositionMap: Array<AnyPosition>; nodePositionMap: Array<AnyPosition>;
sources: Array<Source>; sources: Array<Source>;
inlinings: Array<Inlining>; inlinings: Array<Inlining>;
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// 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.
"use strict"; import {View} from "./view.js"
import {anyToString, ViewElements, isIterable} from "./util.js"
import {MySelection} from "./selection.js"
function anyToString(x: any): string { export abstract class TextView extends View {
return "" + x;
}
abstract class TextView extends View {
selectionHandler: NodeSelectionHandler; selectionHandler: NodeSelectionHandler;
blockSelectionHandler: BlockSelectionHandler; blockSelectionHandler: BlockSelectionHandler;
nodeSelectionHandler: NodeSelectionHandler; nodeSelectionHandler: NodeSelectionHandler;
......
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
// 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.
import * as C from "./constants.js"
import {SourceResolver} from "./source-resolver.js"
import {SelectionBroker} from "./selection-broker.js"
import {DisassemblyView} from "./disassembly-view.js"
import {GraphMultiView} from "./graphmultiview.js"
import {CodeMode, CodeView} from "./code-view.js"
import * as d3 from "d3"
class Snapper { class Snapper {
resizer: Resizer; resizer: Resizer;
sourceExpand: HTMLElement; sourceExpand: HTMLElement;
...@@ -12,10 +20,10 @@ class Snapper { ...@@ -12,10 +20,10 @@ class Snapper {
constructor(resizer: Resizer) { constructor(resizer: Resizer) {
const snapper = this; const snapper = this;
snapper.resizer = resizer; snapper.resizer = resizer;
snapper.sourceExpand = document.getElementById(SOURCE_EXPAND_ID); snapper.sourceExpand = document.getElementById(C.SOURCE_EXPAND_ID);
snapper.sourceCollapse = document.getElementById(SOURCE_COLLAPSE_ID); snapper.sourceCollapse = document.getElementById(C.SOURCE_COLLAPSE_ID);
snapper.disassemblyExpand = document.getElementById(DISASSEMBLY_EXPAND_ID); snapper.disassemblyExpand = document.getElementById(C.DISASSEMBLY_EXPAND_ID);
snapper.disassemblyCollapse = document.getElementById(DISASSEMBLY_COLLAPSE_ID); snapper.disassemblyCollapse = document.getElementById(C.DISASSEMBLY_COLLAPSE_ID);
document.getElementById("source-collapse").addEventListener("click", function () { document.getElementById("source-collapse").addEventListener("click", function () {
resizer.snapper.toggleSourceExpanded(); resizer.snapper.toggleSourceExpanded();
...@@ -112,9 +120,9 @@ class Resizer { ...@@ -112,9 +120,9 @@ class Resizer {
resizer.panes_updated_callback = panes_updated_callback; resizer.panes_updated_callback = panes_updated_callback;
resizer.dead_width = dead_width resizer.dead_width = dead_width
resizer.client_width = document.body.getBoundingClientRect().width; resizer.client_width = document.body.getBoundingClientRect().width;
resizer.left = document.getElementById(SOURCE_PANE_ID); resizer.left = document.getElementById(C.SOURCE_PANE_ID);
resizer.middle = document.getElementById(INTERMEDIATE_PANE_ID); resizer.middle = document.getElementById(C.INTERMEDIATE_PANE_ID);
resizer.right = document.getElementById(GENERATED_PANE_ID); resizer.right = document.getElementById(C.GENERATED_PANE_ID);
resizer.resizer_left = d3.select('.resizer-left'); resizer.resizer_left = d3.select('.resizer-left');
resizer.resizer_right = d3.select('.resizer-right'); resizer.resizer_right = d3.select('.resizer-right');
resizer.sep_left = resizer.client_width / 3; resizer.sep_left = resizer.client_width / 3;
...@@ -188,7 +196,6 @@ class Resizer { ...@@ -188,7 +196,6 @@ class Resizer {
} }
window.onload = function () { window.onload = function () {
"use strict";
var svg = null; var svg = null;
var multiview = null; var multiview = null;
var disassemblyView = null; var disassemblyView = null;
...@@ -237,24 +244,24 @@ window.onload = function () { ...@@ -237,24 +244,24 @@ window.onload = function () {
sourceResolver.setNodePositionMap(jsonObj.nodePositions); sourceResolver.setNodePositionMap(jsonObj.nodePositions);
sourceResolver.parsePhases(jsonObj.phases); sourceResolver.parsePhases(jsonObj.phases);
let sourceView = new CodeView(SOURCE_PANE_ID, selectionBroker, sourceResolver, fnc, CodeMode.MAIN_SOURCE); let sourceView = new CodeView(C.SOURCE_PANE_ID, selectionBroker, sourceResolver, fnc, CodeMode.MAIN_SOURCE);
sourceView.show(null, null); sourceView.show(null, null);
sourceViews.push(sourceView); sourceViews.push(sourceView);
sourceResolver.forEachSource((source) => { sourceResolver.forEachSource((source) => {
let sourceView = new CodeView(SOURCE_PANE_ID, selectionBroker, sourceResolver, source, CodeMode.INLINED_SOURCE); let sourceView = new CodeView(C.SOURCE_PANE_ID, selectionBroker, sourceResolver, source, CodeMode.INLINED_SOURCE);
sourceView.show(null, null); sourceView.show(null, null);
sourceViews.push(sourceView); sourceViews.push(sourceView);
}); });
disassemblyView = new DisassemblyView(GENERATED_PANE_ID, selectionBroker); disassemblyView = new DisassemblyView(C.GENERATED_PANE_ID, selectionBroker);
disassemblyView.initializeCode(fnc.sourceText); disassemblyView.initializeCode(fnc.sourceText);
if (sourceResolver.disassemblyPhase) { if (sourceResolver.disassemblyPhase) {
disassemblyView.initializePerfProfile(jsonObj.eventCounts); disassemblyView.initializePerfProfile(jsonObj.eventCounts);
disassemblyView.show(sourceResolver.disassemblyPhase.data, null); disassemblyView.show(sourceResolver.disassemblyPhase.data, null);
} }
multiview = new GraphMultiView(INTERMEDIATE_PANE_ID, selectionBroker, sourceResolver); multiview = new GraphMultiView(C.INTERMEDIATE_PANE_ID, selectionBroker, sourceResolver);
multiview.show(jsonObj); multiview.show(jsonObj);
} catch (err) { } catch (err) {
if (window.confirm("Error: Exception during load of TurboFan JSON file:\n" + if (window.confirm("Error: Exception during load of TurboFan JSON file:\n" +
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// 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.
"use strict"; export function anyToString(x: any): string {
return "" + x;
}
function computeScrollTop(container, element) { function computeScrollTop(container, element) {
const height = container.offsetHeight; const height = container.offsetHeight;
...@@ -17,7 +19,7 @@ function computeScrollTop(container, element) { ...@@ -17,7 +19,7 @@ function computeScrollTop(container, element) {
return pos; return pos;
} }
class ViewElements { export class ViewElements {
container: HTMLElement; container: HTMLElement;
scrollTop: number; scrollTop: number;
...@@ -84,7 +86,7 @@ function upperBound(a, value, compare, lookup) { ...@@ -84,7 +86,7 @@ function upperBound(a, value, compare, lookup) {
} }
function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b: T) => boolean) { export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b: T) => boolean) {
if (arr.length == 0) return arr; if (arr.length == 0) return arr;
arr = arr.sort(f); arr = arr.sort(f);
let ret = [arr[0]]; let ret = [arr[0]];
...@@ -97,14 +99,18 @@ function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b ...@@ -97,14 +99,18 @@ function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b
} }
// Partial application without binding the receiver // Partial application without binding the receiver
function partial(f, ...arguments1) { export function partial(f, ...arguments1) {
return function (...arguments2) { return function (...arguments2) {
var arguments2 = Array.from(arguments); var arguments2 = Array.from(arguments);
f.apply(this, [...arguments1, ...arguments2]); f.apply(this, [...arguments1, ...arguments2]);
} }
} }
function isIterable(obj: any): obj is Iterable<any> { export function isIterable(obj: any): obj is Iterable<any> {
return obj != null && obj != undefined return obj != null && obj != undefined
&& typeof obj != 'string' && typeof obj[Symbol.iterator] === 'function'; && typeof obj != 'string' && typeof obj[Symbol.iterator] === 'function';
} }
export function alignUp(raw:number, multiple:number):number {
return Math.floor((raw + multiple - 1) / multiple) * multiple;
}
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
// 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.
"use strict"; export abstract class View {
abstract class View {
container: HTMLElement; container: HTMLElement;
divNode: HTMLElement; divNode: HTMLElement;
abstract initializeContent(data: any, rememberedSelection: Selection): void; abstract initializeContent(data: any, rememberedSelection: Selection): void;
...@@ -32,7 +30,7 @@ abstract class View { ...@@ -32,7 +30,7 @@ abstract class View {
} }
} }
interface PhaseView { export interface PhaseView {
onresize(); onresize();
searchInputAction(searchInput: HTMLInputElement, e: Event); searchInputAction(searchInput: HTMLInputElement, e: Event);
} }
{ {
"compilerOptions": { "compilerOptions": {
"outFile": "build/turbolizer.js", "outDir": "build/",
"allowJs": true, "allowJs": false,
"target": "es2017", "target": "es2017",
"sourceMap": true "module": "es2015",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node"
}, },
"files": [ "files": [
"src/monkey.ts",
"src/util.ts", "src/util.ts",
"src/lang-disassembly.ts", "src/lang-disassembly.ts",
"src/node.ts", "src/node.ts",
...@@ -26,4 +29,4 @@ ...@@ -26,4 +29,4 @@
"src/graphmultiview.ts", "src/graphmultiview.ts",
"src/turbo-visualizer.ts" "src/turbo-visualizer.ts"
] ]
} }
\ No newline at end of file
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