mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-22 14:33:51 +00:00
removed old profiler
This commit is contained in:
parent
2a41b6b1a1
commit
6731231b23
@ -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;
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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();
|
||||
});
|
||||
|
105
src/views.ts
105
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<number,symbol> = 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 {
|
||||
|
Loading…
Reference in New Issue
Block a user