зеркало из https://github.com/mozilla/pluotsorbet.git
Make unwind flag global so that it can be optimized by the JIT.
This commit is contained in:
Родитель
5d41042625
Коммит
8abc167fda
22
context.ts
22
context.ts
|
@ -191,7 +191,7 @@ module J2ME {
|
||||||
traceWriter.enter("> " + MethodType[MethodType.Interpreted][0] + " " + frameDetails);
|
traceWriter.enter("> " + MethodType[MethodType.Interpreted][0] + " " + frameDetails);
|
||||||
}
|
}
|
||||||
var returnValue = VM.execute(this);
|
var returnValue = VM.execute(this);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
flattenFrameSet();
|
flattenFrameSet();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -287,16 +287,16 @@ module J2ME {
|
||||||
this.setCurrent();
|
this.setCurrent();
|
||||||
do {
|
do {
|
||||||
VM.execute(this);
|
VM.execute(this);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
Array.prototype.push.apply(this.frames, this.bailoutFrames);
|
Array.prototype.push.apply(this.frames, this.bailoutFrames);
|
||||||
this.bailoutFrames = [];
|
this.bailoutFrames = [];
|
||||||
}
|
}
|
||||||
if ($.Y === VmState.Yielding) {
|
if (U === VMState.Yielding) {
|
||||||
// Ignore the yield and continue executing instructions on this thread.
|
// Ignore the yield and continue executing instructions on this thread.
|
||||||
$.Y = VmState.Running;
|
U = VMState.Running;
|
||||||
continue;
|
continue;
|
||||||
} else if ($.Y === VmState.Pausing) {
|
} else if (U === VMState.Pausing) {
|
||||||
$.Y = VmState.Running;
|
U = VMState.Running;
|
||||||
Instrument.callPauseHooks(this.current());
|
Instrument.callPauseHooks(this.current());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -308,16 +308,16 @@ module J2ME {
|
||||||
this.setCurrent();
|
this.setCurrent();
|
||||||
Instrument.callResumeHooks(ctx.current());
|
Instrument.callResumeHooks(ctx.current());
|
||||||
VM.execute(ctx);
|
VM.execute(ctx);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
Array.prototype.push.apply(this.frames, this.bailoutFrames);
|
Array.prototype.push.apply(this.frames, this.bailoutFrames);
|
||||||
this.bailoutFrames = [];
|
this.bailoutFrames = [];
|
||||||
}
|
}
|
||||||
if ($.Y === VmState.Pausing) {
|
if (U === VMState.Pausing) {
|
||||||
$.Y = VmState.Running;
|
U = VMState.Running;
|
||||||
Instrument.callPauseHooks(this.current());
|
Instrument.callPauseHooks(this.current());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.Y = VmState.Running;
|
U = VMState.Running;
|
||||||
Instrument.callPauseHooks(ctx.current());
|
Instrument.callPauseHooks(ctx.current());
|
||||||
|
|
||||||
if (ctx.frames.length === 0) {
|
if (ctx.frames.length === 0) {
|
||||||
|
@ -364,7 +364,7 @@ module J2ME {
|
||||||
} else {
|
} else {
|
||||||
while (this.lockLevel-- > 0) {
|
while (this.lockLevel-- > 0) {
|
||||||
this.monitorEnter(obj);
|
this.monitorEnter(obj);
|
||||||
if ($.Y === VmState.Pausing) {
|
if (U === VMState.Pausing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ module J2ME {
|
||||||
return;
|
return;
|
||||||
ctx.pushClassInitFrame(classInfo);
|
ctx.pushClassInitFrame(classInfo);
|
||||||
|
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
frame.bci = ip;
|
frame.bci = ip;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +923,7 @@ module J2ME {
|
||||||
if (field.tag)
|
if (field.tag)
|
||||||
field = resolve(idx, true);
|
field = resolve(idx, true);
|
||||||
classInitCheck(field.classInfo, frame.bci - 3);
|
classInitCheck(field.classInfo, frame.bci - 3);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var value = field.getStatic();
|
var value = field.getStatic();
|
||||||
|
@ -938,7 +938,7 @@ module J2ME {
|
||||||
if (field.tag)
|
if (field.tag)
|
||||||
field = resolve(idx, true);
|
field = resolve(idx, true);
|
||||||
classInitCheck(field.classInfo, frame.bci - 3);
|
classInitCheck(field.classInfo, frame.bci - 3);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
field.setStatic(stack.popType(field.signature));
|
field.setStatic(stack.popType(field.signature));
|
||||||
|
@ -949,7 +949,7 @@ module J2ME {
|
||||||
if (classInfo.tag)
|
if (classInfo.tag)
|
||||||
classInfo = resolve(idx);
|
classInfo = resolve(idx);
|
||||||
classInitCheck(classInfo, frame.bci - 3);
|
classInitCheck(classInfo, frame.bci - 3);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stack.push(util.newObject(classInfo));
|
stack.push(util.newObject(classInfo));
|
||||||
|
@ -988,7 +988,7 @@ module J2ME {
|
||||||
throw ctx.createException("java/lang/NullPointerException");
|
throw ctx.createException("java/lang/NullPointerException");
|
||||||
}
|
}
|
||||||
ctx.monitorEnter(obj);
|
ctx.monitorEnter(obj);
|
||||||
if ($.Y === VmState.Pausing) {
|
if (U === VMState.Pausing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1048,7 +1048,7 @@ module J2ME {
|
||||||
methodInfo = resolve(idx, isStatic);
|
methodInfo = resolve(idx, isStatic);
|
||||||
if (isStatic) {
|
if (isStatic) {
|
||||||
classInitCheck(methodInfo.classInfo, startip);
|
classInitCheck(methodInfo.classInfo, startip);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1079,7 +1079,7 @@ module J2ME {
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnValue = fn.apply(obj, args);
|
var returnValue = fn.apply(obj, args);
|
||||||
if ($.Y) {
|
if (U) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -520,11 +520,11 @@ module J2ME.C4.Backend {
|
||||||
var to = id(this.variable.name);
|
var to = id(this.variable.name);
|
||||||
cx.useVariable(this.variable);
|
cx.useVariable(this.variable);
|
||||||
block.body.push(new AST.ExpressionStatement(assignment(to, result)));
|
block.body.push(new AST.ExpressionStatement(assignment(to, result)));
|
||||||
var ifYield = new AST.IfStatement(property(id("$"), "Y"), new AST.BlockStatement([
|
var ifUnwind = new AST.IfStatement(id("U"), new AST.BlockStatement([
|
||||||
new AST.ExpressionStatement(call(property(id("$"), "B"), compileState(this.state, cx))),
|
new AST.ExpressionStatement(call(property(id("$"), "B"), compileState(this.state, cx))),
|
||||||
new AST.ReturnStatement(undefined)
|
new AST.ReturnStatement(undefined)
|
||||||
]));
|
]));
|
||||||
block.body.push(ifYield);
|
block.body.push(ifUnwind);
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
6
jvm.ts
6
jvm.ts
|
@ -21,10 +21,10 @@ module J2ME {
|
||||||
|
|
||||||
var array = newStringArray(args.length);
|
var array = newStringArray(args.length);
|
||||||
for (var n = 0; n < args.length; ++n)
|
for (var n = 0; n < args.length; ++n)
|
||||||
array[n] = args[n] ? util.newString(args[n]) : null;
|
array[n] = args[n] ? J2ME.newString(args[n]) : null;
|
||||||
|
|
||||||
ctx.frames.push(new Frame(CLASSES.getMethod(isolateClassInfo, "I.<init>.(Ljava/lang/String;[Ljava/lang/String;)V"),
|
ctx.frames.push(new Frame(CLASSES.getMethod(isolateClassInfo, "I.<init>.(Ljava/lang/String;[Ljava/lang/String;)V"),
|
||||||
[ isolate, util.newString(className.replace(/\./g, "/")), array ], 0));
|
[ isolate, J2ME.newString(className.replace(/\./g, "/")), array ], 0));
|
||||||
ctx.execute();
|
ctx.execute();
|
||||||
|
|
||||||
ctx.frames.push(new Frame(CLASSES.getMethod(isolateClassInfo, "I.start.()V"), [ isolate ], 0));
|
ctx.frames.push(new Frame(CLASSES.getMethod(isolateClassInfo, "I.start.()V"), [ isolate ], 0));
|
||||||
|
@ -55,7 +55,7 @@ module J2ME {
|
||||||
ctx.thread.alive = true;
|
ctx.thread.alive = true;
|
||||||
|
|
||||||
ctx.frames.push(new Frame(CLASSES.getMethod(CLASSES.java_lang_Thread, "I.<init>.(Ljava/lang/String;)V"),
|
ctx.frames.push(new Frame(CLASSES.getMethod(CLASSES.java_lang_Thread, "I.<init>.(Ljava/lang/String;)V"),
|
||||||
[ runtime.mainThread, util.newString("main") ], 0));
|
[ runtime.mainThread, J2ME.newString("main") ], 0));
|
||||||
var oldCtx = $.ctx;
|
var oldCtx = $.ctx;
|
||||||
ctx.execute();
|
ctx.execute();
|
||||||
oldCtx.setCurrent();
|
oldCtx.setCurrent();
|
||||||
|
|
24
runtime.ts
24
runtime.ts
|
@ -271,7 +271,7 @@ module J2ME {
|
||||||
if (internedStrings.has(s)) {
|
if (internedStrings.has(s)) {
|
||||||
return internedStrings.get(s);
|
return internedStrings.get(s);
|
||||||
}
|
}
|
||||||
var obj = util.newString(s);
|
var obj = J2ME.newString(s);
|
||||||
internedStrings.set(s, obj);
|
internedStrings.set(s, obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ module J2ME {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum VmState {
|
export enum VMState {
|
||||||
Running = 0,
|
Running = 0,
|
||||||
Yielding = 1,
|
Yielding = 1,
|
||||||
Pausing = 2
|
Pausing = 2
|
||||||
|
@ -295,11 +295,6 @@ module J2ME {
|
||||||
private static _nextId: number = 0;
|
private static _nextId: number = 0;
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* Are we currently unwinding the stack because of a Yield?
|
|
||||||
*/
|
|
||||||
Y: VmState = VmState.Running;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bailout callback whenever a JIT frame is unwound.
|
* Bailout callback whenever a JIT frame is unwound.
|
||||||
*/
|
*/
|
||||||
|
@ -308,11 +303,11 @@ module J2ME {
|
||||||
}
|
}
|
||||||
|
|
||||||
yield() {
|
yield() {
|
||||||
this.Y = VmState.Yielding;
|
U = VMState.Yielding;
|
||||||
}
|
}
|
||||||
|
|
||||||
pause() {
|
pause() {
|
||||||
this.Y = VmState.Pausing;
|
U = VMState.Pausing;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(jvm: JVM) {
|
constructor(jvm: JVM) {
|
||||||
|
@ -504,7 +499,7 @@ module J2ME {
|
||||||
});
|
});
|
||||||
initWriter && initWriter.writeLn("Running Static Constructor: " + classInfo.className);
|
initWriter && initWriter.writeLn("Running Static Constructor: " + classInfo.className);
|
||||||
$.ctx.pushClassInitFrame(classInfo);
|
$.ctx.pushClassInitFrame(classInfo);
|
||||||
assert(!$.Y);
|
assert(!U);
|
||||||
//// TODO: monitorEnter
|
//// TODO: monitorEnter
|
||||||
//if (klass.staticInitializer) {
|
//if (klass.staticInitializer) {
|
||||||
// klass.staticInitializer.call(runtimeKlass);
|
// klass.staticInitializer.call(runtimeKlass);
|
||||||
|
@ -742,7 +737,7 @@ module J2ME {
|
||||||
: frame.getLocal(0);
|
: frame.getLocal(0);
|
||||||
}
|
}
|
||||||
$.ctx.monitorEnter(frame.lockObject);
|
$.ctx.monitorEnter(frame.lockObject);
|
||||||
if ($.Y === VmState.Pausing) {
|
if (U === VMState.Pausing) {
|
||||||
$.ctx.frames.push(frame);
|
$.ctx.frames.push(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1026,6 +1021,13 @@ module J2ME {
|
||||||
var Runtime = J2ME.Runtime;
|
var Runtime = J2ME.Runtime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are we currently unwinding the stack because of a Yield? This technically
|
||||||
|
* belonges to a context but we store it in the global object because it is
|
||||||
|
* read very often.
|
||||||
|
*/
|
||||||
|
var U: J2ME.VMState = J2ME.VMState.Running;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runtime exports for compiled code.
|
* Runtime exports for compiled code.
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче