From 6731231b23712dd26a6c4d75218e647f06c24dc0 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 30 Sep 2019 20:42:35 -0500 Subject: [PATCH] removed old profiler --- src/baseplatform.ts | 20 --------- src/platform/nes.ts | 2 +- src/recorder.ts | 65 +-------------------------- src/ui.ts | 5 --- src/views.ts | 105 +------------------------------------------- 5 files changed, 4 insertions(+), 193 deletions(-) diff --git a/src/baseplatform.ts b/src/baseplatform.ts index 6e8b5ab5..f676fe6b 100644 --- a/src/baseplatform.ts +++ b/src/baseplatform.ts @@ -169,30 +169,10 @@ export interface EmuRecorder { recordFrame(state : EmuState); } -export interface ProfilerScanline { - start,end : number; // start/end frameindex -} -export interface ProfilerFrame { - iptab : Uint32Array; // array of IPs - lines : ProfilerScanline[]; -} -export interface ProfilerOutput { - frame : ProfilerFrame; -} -export interface EmuProfiler { - start() : ProfilerOutput; - stop(); - // TODO? - logRead(a : number); - logWrite(a : number); - logInterrupt(a : number); -} - ///// export abstract class BasePlatform { recorder : EmuRecorder = null; - profiler : EmuProfiler = null; debugSymbols : DebugSymbols; abstract loadState(state : EmuState) : void; diff --git a/src/platform/nes.ts b/src/platform/nes.ts index 6197d694..a2cb3690 100644 --- a/src/platform/nes.ts +++ b/src/platform/nes.ts @@ -1,5 +1,5 @@ -import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, cpuStateToLongString_6502, getToolForFilename_6502, dumpStackToString, ProfilerOutput } from "../baseplatform"; +import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, cpuStateToLongString_6502, getToolForFilename_6502, dumpStackToString } from "../baseplatform"; import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM, KeyFlags, EmuHalt, ControllerPoller } from "../emu"; import { hex, lpad, lzgmini, byteArrayToString } from "../util"; import { CodeAnalyzer_nes } from "../analysis"; diff --git a/src/recorder.ts b/src/recorder.ts index e737ff1d..2f333cf9 100644 --- a/src/recorder.ts +++ b/src/recorder.ts @@ -1,6 +1,6 @@ import { Platform, BasePlatform, EmuState, EmuControlsState, EmuRecorder } from "./baseplatform"; -import { BaseDebugPlatform, EmuProfiler, ProfilerOutput } from "./baseplatform"; +import { BaseDebugPlatform } from "./baseplatform"; import { getNoiseSeed, setNoiseSeed } from "./emu"; // RECORDER @@ -115,69 +115,6 @@ export class StateRecorderImpl implements EmuRecorder { } } -// PROFILER - -const PROFOP_READ = 0x100000; -const PROFOP_WRITE = 0x200000; -const PROFOP_INTERRUPT = 0x400000; - -export class EmuProfilerImpl implements EmuProfiler { - - platform : Platform; - frame = null; - output = {frame:null}; - i = 0; - lastsl = 9999; - starti = 0; - - constructor(platform : Platform) { - this.platform = platform; - } - - start() : ProfilerOutput { - if (this.platform instanceof BasePlatform) this.platform.profiler = this; - this.platform.setBreakpoint('profile', () => { - var c = this.platform.getCPUState(); - this.log(c.EPC || c.PC); - return false; // profile forever - }); - this.output = {frame:null}; - return this.output; - } - - log(op : number) { - var sl = this.platform.getRasterScanline(); - if (sl != this.lastsl) { - if (this.frame) { - this.frame.lines.push({start:this.starti, end:this.i-1}); - } - if (sl < this.lastsl) { - this.output.frame = this.frame; - this.frame = {iptab:new Uint32Array(0x8000), lines:[]}; // TODO: const - this.i = 0; - } - this.starti = this.i; - this.lastsl = sl; - } - this.frame.iptab[this.i++] = op; - } - - stop() { - this.platform.clearBreakpoint('profile'); - if (this.platform instanceof BasePlatform) this.platform.profiler = null; - } - // TODO? - logRead(a : number) { - this.log(a | PROFOP_READ); - } - logWrite(a : number) { - this.log(a | PROFOP_WRITE); - } - logInterrupt(a : number) { - this.log(a | PROFOP_INTERRUPT); - } -} - ///// import { Probeable, ProbeAll } from "./devices"; diff --git a/src/ui.ts b/src/ui.ts index 5571a0d6..121e0d16 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -277,11 +277,6 @@ function refreshWindowList() { return new Views.RasterPCHeatMapView(); }); } - else if (platform.getRasterScanline && platform.setBreakpoint && platform.getCPUState) { // TODO: use profiler class to determine compat - addWindowItem("#profiler", "Profiler", () => { - return new Views.ProfileView(); - }); - } addWindowItem('#asseteditor', 'Asset Editor', () => { return new Views.AssetEditorView(); }); diff --git a/src/views.ts b/src/views.ts index 4ef1b332..eea15802 100644 --- a/src/views.ts +++ b/src/views.ts @@ -1,11 +1,11 @@ //import CodeMirror = require("codemirror"); import { SourceFile, WorkerError, Segment, FileData } from "./workertypes"; -import { Platform, EmuState, ProfilerOutput, lookupSymbol, BaseDebugPlatform } from "./baseplatform"; +import { Platform, EmuState, lookupSymbol, BaseDebugPlatform } from "./baseplatform"; import { hex, lpad, rpad, safeident, rgb2bgr } from "./util"; import { CodeAnalyzer } from "./analysis"; import { platform, platform_id, compparams, current_project, lastDebugState, projectWindows } from "./ui"; -import { EmuProfilerImpl, ProbeRecorder, ProbeFlags } from "./recorder"; +import { ProbeRecorder, ProbeFlags } from "./recorder"; import { getMousePos } from "./emu"; import * as pixed from "./pixed/pixeleditor"; declare var Mousetrap; @@ -817,107 +817,6 @@ export class MemoryMapView implements ProjectView { /// -export class ProfileView implements ProjectView { - prof : EmuProfilerImpl; - profilelist; - out : ProfilerOutput; - maindiv : HTMLElement; - symcache : Map = new Map(); - recreateOnResize = true; - - createDiv(parent : HTMLElement) { - var div = document.createElement('div'); - div.setAttribute("class", "profiler"); - parent.appendChild(div); - this.showMemoryWindow(parent, div); - return this.maindiv = div; - } - - showMemoryWindow(workspace:HTMLElement, parent:HTMLElement) { - this.profilelist = new VirtualList({ - w: $(workspace).width(), - h: $(workspace).height(), - itemHeight: getVisibleEditorLineHeight(), - totalRows: 262, - generatorFn: (row : number) => { - var linediv = document.createElement("div"); - this.addProfileLine(linediv, row); - return linediv; - } - }); - $(parent).append(this.profilelist.container); - this.symcache = new Map(); - this.refresh(); - } - - addProfileLine(div : HTMLElement, row : number) : void { - div.appendChild(createTextSpan(lpad(row+':',4), "profiler-lineno")); - if (!this.out) return; - var f = this.out.frame; - if (!f) return; - var l = f.lines[row]; - if (!l) return; - var lastsym = ''; - var canDebug = platform.runToFrameClock; - for (let i=l.start; i<=l.end; i++) { - let pc = f.iptab[i]; - let sym = this.symcache[pc]; - let op = pc >> 20; - switch (op) { // TODO: const - case 1: sym = "r$" + hex(pc & 0xffff); break; - case 2: sym = "W$" + hex(pc & 0xffff); break; - case 4: sym = "I$" + hex(pc & 0xffff); break; - } - if (!sym) { - sym = lookupSymbol(platform, pc, false); - this.symcache[pc] = sym; - } - if (sym != lastsym) { - var cls = "profiler"; - if (sym.startsWith('_')) cls = "profiler-cident"; - else if (sym.startsWith('@')) cls = "profiler-local"; - else if (/^\d*[.]/.exec(sym)) cls = "profiler-local"; - var span = createTextSpan(' '+sym, cls); - if (canDebug) { - $(span).click(() => { - platform.runToFrameClock(i); - }); - } - div.appendChild(span); - lastsym = sym; - } - } - } - - refresh() { - this.tick(); - this.symcache.clear(); - } - - tick() { - if (this.profilelist) { - $(this.maindiv).find('[data-index]').each( (i,e) => { - var div = $(e); - var row = parseInt(div.attr('data-index')); - div.empty(); - this.addProfileLine(div[0], row); - }); - } - } - - setVisible(showing : boolean) : void { - if (!this.prof) { - this.prof = new EmuProfilerImpl(platform); - } - if (showing) - this.out = this.prof.start(); - else - this.prof.stop(); - } -} - -/// - // TODO: clear buffer when scrubbing abstract class ProbeViewBase {