This commit is contained in:
Michael Bebenita 2015-03-06 14:55:44 -08:00
Родитель fda1b8ad7d
Коммит 39398003a3
2 изменённых файлов: 65 добавлений и 24 удалений

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

@ -565,7 +565,7 @@ module J2ME {
if (needsOSREntryPoint) {
// Are we doing an OSR?
this.bodyEmitter.enter("if(O){");
this.bodyEmitter.writeLn("var _ = O.local;");
this.bodyEmitter.writeLn("var _=O.local;");
// Restore locals.
var restoreLocals = [];
@ -982,9 +982,14 @@ module J2ME {
private emitUnwind(emitter: Emitter, pc: string, nextPC: string, forceInline: boolean = false) {
// Only emit throw unwinds if it saves on code size.
if (!forceInline && this.blockMap.invokeCount > 2 && this.stack.length < 256) {
if (!forceInline && this.blockMap.invokeCount > 2 &&
this.stack.length < 8) {
this.flushBlockStack();
emitter.writeLn("U&&TU(" + UnwindThrowLocation.encode(pc, nextPC, this.sp) + ");");
if (<any>nextPC - <any>pc === 3) {
emitter.writeLn("U&&B" + this.sp + "(" + pc + ");");
} else {
emitter.writeLn("U&&B" + this.sp + "(" + pc + "," + nextPC + ");");
}
this.hasUnwindThrow = true;
} else {
var local = this.local.join(",");

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

@ -1878,36 +1878,65 @@ module J2ME {
export class UnwindThrowLocation {
static instance: UnwindThrowLocation = new UnwindThrowLocation();
pc: number;
sp: number;
nextPC: number;
constructor() {
this.location = 0;
this.pc = 0;
this.sp = 0;
this.nextPC = 0;
}
static encode(pc, nextPC, sp) {
var delta = nextPC - pc;
release || assert (delta >= 0 && delta < 8, delta);
release || assert (sp >= 0 && sp < 256, sp);
return pc << 11 | delta << 8 | sp;
}
location: number;
set(location: number) {
this.location = location;
setLocation(pc: number, nextPC: number, sp: number) {
this.pc = pc;
this.sp = sp;
this.nextPC = nextPC;
return this;
}
getPC() {
return (this.location >> 11) & 0xffff;
}
getNextPC() {
return this.getPC() + ((this.location >> 8) & 0x07);
return this.pc;
}
getSP() {
return this.location & 0xff;
return this.sp;
}
getNextPC() {
return this.nextPC;
}
}
export function throwUnwind(location: number) {
if (location === 0) {
debugger;
}
throw UnwindThrowLocation.instance.set(location);
export function throwUnwind(pc: number, nextPC: number = pc + 3, sp: number = 0) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, sp);
}
export function throwUnwind0(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 0);
}
export function throwUnwind1(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 1);
}
export function throwUnwind2(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 2);
}
export function throwUnwind3(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 3);
}
export function throwUnwind4(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 4);
}
export function throwUnwind5(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 5);
}
export function throwUnwind6(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 6);
}
export function throwUnwind7(pc: number, nextPC: number = pc + 3) {
throw UnwindThrowLocation.instance.setLocation(pc, nextPC, 7);
}
}
@ -1922,7 +1951,14 @@ var AOTMD = J2ME.aotMetaData;
*/
var U: J2ME.VMState = J2ME.VMState.Running;
var TU = J2ME.throwUnwind;
var B0 = J2ME.throwUnwind0;
var B1 = J2ME.throwUnwind1;
var B2 = J2ME.throwUnwind2;
var B3 = J2ME.throwUnwind3;
var B4 = J2ME.throwUnwind4;
var B5 = J2ME.throwUnwind5;
var B6 = J2ME.throwUnwind6;
var B7 = J2ME.throwUnwind7;
/**
* OSR Frame.