Remove old instrumentation and profiling code. Fixes #989.

This commit is contained in:
Marco Castelluccio 2015-01-31 19:54:20 +01:00
Родитель 2a91e265b3
Коммит 8e2b1f9f05
8 изменённых файлов: 0 добавлений и 224 удалений

Просмотреть файл

@ -143,17 +143,6 @@ Modelines for JS files:
One way to profile j2me.js is to use the JS profiler available in Firefox Dev Tools. This will tell us how well the JVM is working and how well natives work. This type of profiling will not measure time that is taken waiting for async callbacks to be called (for example, when using the native JS filesystem API).
When debugging using the WebIDE, enable the option "select an iframe as the currently targeted document" and select the iframe containing main.html as the debugging target. NB: you need to connect to a target device running FxOS 2.1 or up to use this feature in WebIDE.
Use these JS calls within the console to start and stop profiling (TODO: I haven't actually gotten these to work):
Instrument.startProfile()
Instrument.stopProfile()
It can be helpful to increase this `about:config` option: `devtools.hud.loglimit.console`
Alternatively, use the "Performance" tab of the Firefox Developer Tools.
### Java profiling
j2me.js includes its own profiler that is capable of measuring the performance of Java methods running inside its JVM.

Просмотреть файл

@ -21,7 +21,6 @@
* network_mcc
* network_mnc
* platform
* profile
* fgMidletClass
* autosize
* fontSize

Просмотреть файл

@ -10,7 +10,6 @@ module J2ME {
import assert = Debug.assert;
import Bytecodes = Bytecode.Bytecodes;
declare var VM;
declare var Instrument;
declare var setZeroTimeout;
export enum WriterFlags {

Просмотреть файл

@ -1,193 +0,0 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
'use strict';
var Instrument = {
enter: {},
exit: {},
profiling: false,
profile: null,
asyncProfile: null,
enabled: "instrument" in config && !/no|0/.test(config.instrument),
callEnterHooks: function(methodInfo, caller, callee) {
if (this.enabled) {
var key = methodInfo.implKey;
if (Instrument.enter[key]) {
Instrument.enter[key](caller, callee);
}
}
if (this.profiling) {
var now = performance.now();
if (caller.profileData && caller.profileData.then) {
caller.profileData.cost += now - caller.profileData.then;
caller.profileData.then = null;
}
callee.profileData = {
cost: 0,
then: now,
};
}
},
callExitHooks: function(methodInfo, caller, callee) {
var key = methodInfo.implKey;
if (this.profiling) {
var now = performance.now();
if (callee.profileData) {
if (callee.profileData.then) {
callee.profileData.cost += now - callee.profileData.then;
callee.profileData.then = null;
}
var methodProfileData = this.profile[key] || (this.profile[key] = { count: 0, cost: 0 });
methodProfileData.count++;
methodProfileData.cost += callee.profileData.cost;
}
if (caller.profileData) {
caller.profileData.then = now;
}
}
if (this.enabled) {
if (Instrument.exit[key]) {
Instrument.exit[key](caller, callee);
}
}
},
callPauseHooks: function(frame) {
if (this.profiling && frame.profileData && frame.profileData.then) {
frame.profileData.cost += performance.now() - frame.profileData.then;
frame.profileData.then = null;
}
},
callResumeHooks: function(frame) {
if (this.profiling && frame.profileData) {
frame.profileData.then = performance.now();
}
},
enterAsyncNative: function(key, promise) {
var profileData = this.asyncProfile[key] || (this.asyncProfile[key] = { count: 0, cost: 0 });
promise.startTime = performance.now();
},
exitAsyncNative: function(key, promise) {
var profileData = this.asyncProfile[key];
if (!profileData || !promise.startTime) {
// Ignore native without profile data, which can happen when you start
// profiling while the native is pending.
return;
}
profileData.count++;
profileData.cost += performance.now() - promise.startTime;
},
startProfile: function() {
this.profile = {};
this.asyncProfile = {};
this.profiling = true;
},
printProfile: function(aProfile, aProfileName) {
var methods = [];
for (var key in aProfile) {
methods.push({
key: key,
count: aProfile[key].count,
cost: aProfile[key].cost,
});
}
methods.sort(function(a, b) { return b.cost - a.cost });
console.log(aProfileName + ":");
methods.forEach(function(method) {
console.log(Math.round(method.cost) + "ms " + method.count + " " + method.key);
});
},
stopProfile: function() {
this.printProfile(this.profile, "Profile");
this.printProfile(this.asyncProfile, "Async natives profile");
this.profiling = false;
},
measure: function(alternateImpl, ctx, methodInfo) {
var key = methodInfo.implKey;
if (this.profiling) {
var then = performance.now();
alternateImpl.call(null, ctx, ctx.current().stack, methodInfo.isStatic);
var methodProfileData = this.profile[key] || (this.profile[key] = { count: 0, cost: 0 });
methodProfileData.count++;
methodProfileData.cost += performance.now() - then;
} else {
alternateImpl.call(null, ctx, ctx.current().stack, methodInfo.isStatic);
}
},
};
Instrument.enter["com/sun/midp/ssl/SSLStreamConnection.<init>.(Ljava/lang/String;ILjava/io/InputStream;Ljava/io/OutputStream;Lcom/sun/midp/pki/CertStore;)V"] = function(caller, callee) {
var _this = callee.locals.read(6), port = callee.locals.read(4), host = util.fromJavaString(callee.locals.read(5));
_this.logBuffer = "SSLStreamConnection to " + host + ":" + port + ":\n";
};
Instrument.enter["com/sun/midp/ssl/Out.write.(I)V"] = function(caller, callee) {
var _this = callee.locals.read(3);
var connection = _this.klass.classInfo.getField("I.ssc.Lcom/sun/midp/ssl/SSLStreamConnection;").get(_this);
connection.logBuffer += String.fromCharCode(callee.stack.read(1));
};
Instrument.enter["com/sun/midp/ssl/Out.write.([BII)V"] = function(caller, callee) {
var len = callee.locals.read(1), off = callee.locals.read(2), b = callee.locals.read(3), _this = callee.locals.read(4);
var connection = _this.klass.classInfo.getField("I.ssc.Lcom/sun/midp/ssl/SSLStreamConnection;").get(_this);
var range = b.subarray(off, off + len);
for (var i = 0; i < range.length; i++) {
if (range[i] == 0) {
break;
}
connection.logBuffer += String.fromCharCode(range[i] & 0xff);
}
};
Instrument.exit["com/sun/midp/ssl/In.read.()I"] = function(caller, callee) {
// We can't use caller.stack.read() here, because the length of the caller's
// stack differs depending on whether or not In.read threw an exception.
var _this = caller.stack[2];
var connection = _this.klass.classInfo.getField("I.ssc.Lcom/sun/midp/ssl/SSLStreamConnection;").get(_this);
connection.logBuffer += String.fromCharCode(callee.stack.read(1));
};
Instrument.exit["com/sun/midp/ssl/In.read.([BII)I"] = function(caller, callee) {
var len = callee.locals.read(4), off = callee.locals.read(5), b = callee.locals.read(6), _this = callee.locals.read(7);
var connection = _this.klass.classInfo.getField("I.ssc.Lcom/sun/midp/ssl/SSLStreamConnection;").get(_this);
var range = b.subarray(off, off + len);
for (var i = 0; i < range.length; i++) {
if (range[i] == 0) {
break;
}
connection.logBuffer += String.fromCharCode(range[i] & 0xff);
}
};
Instrument.enter["com/sun/midp/ssl/SSLStreamConnection.close.()V"] = function(caller, callee) {
var _this = callee.locals.read(1);
if ("logBuffer" in _this) {
console.log(_this.logBuffer);
delete _this.logBuffer;
}
};

Просмотреть файл

@ -1,6 +1,5 @@
module J2ME {
declare var util;
declare var Instrument;
declare var Promise;
import BytecodeStream = Bytecode.BytecodeStream;

Просмотреть файл

@ -130,7 +130,6 @@
<button id="clearCompiledMethodCache">Clear Compiled Method Cache</button>
<button id="trace">Trace: OFF</button>
<button id="printAllExceptions">Print all exceptions: OFF</button>
<button id="profile">Profile: OFF</button>
<button id="clearCounters">Clear Counters</button>
<button id="dumpCounters">Dump Counters</button>
<button id="sampleCounters1">One sample for 1s</button>

15
main.js
Просмотреть файл

@ -344,23 +344,8 @@ window.onload = function() {
}
setTimeout(sample, 2000); // Wait 2s before starting.
};
document.getElementById("profile").onclick = function() {
if (getIsOff(this)) {
Instrument.startProfile();
} else {
Instrument.stopProfile();
}
toggle(this);
};
if (Instrument.profiling) {
toggle(document.getElementById("profile"));
}
};
if (config.profile && !/no|0/.test(config.profile)) {
Instrument.startProfile();
}
function requestTimelineBuffers(fn) {
if (J2ME.timeline) {
fn([

Просмотреть файл

@ -30,7 +30,6 @@ declare var throwYield;
module J2ME {
declare var Native, Override;
declare var VM;
declare var Instrument;
declare var CompiledMethodCache;
/**