2015-05-09 07:14:44 +03:00
|
|
|
module J2ME {
|
2015-05-08 01:17:05 +03:00
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
import assert = Debug.assert;
|
2015-04-30 19:51:47 +03:00
|
|
|
import Bytecodes = Bytecode.Bytecodes;
|
2015-05-22 05:44:42 +03:00
|
|
|
import isInvoke = Bytecode.isInvoke;
|
2015-04-30 19:51:47 +03:00
|
|
|
import toHEX = IntegerUtilities.toHEX;
|
|
|
|
|
2015-05-22 05:44:42 +03:00
|
|
|
|
2015-05-08 01:17:05 +03:00
|
|
|
function toName(o) {
|
|
|
|
if (o instanceof MethodInfo) {
|
2015-05-11 02:00:43 +03:00
|
|
|
return "MI: " + o.implKey;
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
2015-05-09 10:45:07 +03:00
|
|
|
function getArrayInfo(o) {
|
|
|
|
var s = [];
|
|
|
|
var x = [];
|
2015-05-11 02:00:43 +03:00
|
|
|
for (var i = 0; i < Math.min(o.length, 8); i++) {
|
2015-05-09 10:45:07 +03:00
|
|
|
s.push(o[i]);
|
|
|
|
x.push(String.fromCharCode(o[i]));
|
|
|
|
}
|
2015-05-11 02:00:43 +03:00
|
|
|
var suffix = (o.length > 8 ? "..." : "");
|
2015-07-22 01:49:33 +03:00
|
|
|
return fromUTF8(o.classInfo.utf8Name) +
|
2015-05-11 02:00:43 +03:00
|
|
|
", length: " + o.length +
|
|
|
|
", values: [" + s.join(", ") + suffix + "]" +
|
|
|
|
", chars: \"" + x.join("") + suffix + "\"";
|
2015-05-09 10:45:07 +03:00
|
|
|
}
|
2015-05-09 07:14:44 +03:00
|
|
|
function getObjectInfo(o) {
|
2015-05-09 10:45:07 +03:00
|
|
|
if (o.length !== undefined) {
|
|
|
|
return getArrayInfo(o);
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
return fromUTF8(o.classInfo.utf8Name) + (o._address ? " " + toHEX(o._address) : "");
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
if (o && !o.classInfo) {
|
2015-05-11 04:33:23 +03:00
|
|
|
return o;
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
if (o && o.classInfo === CLASSES.java_lang_Class) {
|
|
|
|
return "[" + getObjectInfo(o) + "] " + classIdToClassInfoMap[o.vmClass].getClassNameSlow();
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
if (o && o.classInfo === CLASSES.java_lang_String) {
|
2015-07-06 22:51:15 +03:00
|
|
|
return "[" + getObjectInfo(o) + "] \"" + fromStringAddr(o._address) + "\"";
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
2015-05-09 07:14:44 +03:00
|
|
|
return o ? ("[" + getObjectInfo(o) + "]") : "null";
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
|
|
|
|
2015-05-08 03:31:22 +03:00
|
|
|
/**
|
|
|
|
* The number of opcodes executed thus far.
|
|
|
|
*/
|
|
|
|
export var bytecodeCount = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of times the interpreter method was called thus far.
|
|
|
|
*/
|
|
|
|
export var interpreterCount = 0;
|
|
|
|
|
|
|
|
export var onStackReplacementCount = 0;
|
|
|
|
|
2015-06-02 19:58:39 +03:00
|
|
|
/**
|
|
|
|
* The closest floating-point representation to this long value.
|
|
|
|
*/
|
|
|
|
export function longToNumber(l: number, h: number): number {
|
|
|
|
return h * Constants.TWO_PWR_32_DBL + ((l >= 0) ? l : Constants.TWO_PWR_32_DBL + l);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function numberToLong(v: number): number {
|
|
|
|
// TODO Extract logic from Long so we don't allocate here.
|
|
|
|
var long = Long.fromNumber(v);
|
|
|
|
tempReturn0 = long.high_;
|
|
|
|
return long.low_;
|
|
|
|
}
|
|
|
|
|
2015-05-10 13:16:41 +03:00
|
|
|
function wordsToDouble(l: number, h: number): number {
|
|
|
|
aliasedI32[0] = l;
|
|
|
|
aliasedI32[1] = h;
|
|
|
|
return aliasedF64[0];
|
|
|
|
}
|
|
|
|
|
2015-05-10 04:32:02 +03:00
|
|
|
/**
|
|
|
|
* Calling Convention:
|
|
|
|
*
|
|
|
|
* Interpreter -> Interpreter:
|
|
|
|
* This follows the JVM bytecode calling convention. This interpreter is highly
|
|
|
|
* optimized for this calling convention.
|
|
|
|
*
|
|
|
|
* Compiled / Native -> Compiled / Native:
|
|
|
|
* 64-bit floats and single word values can be encoded using only one JS value. However, 64-bit longs cannot and
|
|
|
|
* require a (low, high) JS value pair. For example, the signature: "foo.(IDJi)J" is expressed as:
|
|
|
|
*
|
|
|
|
* function foo(i, d, lowBits, highBits, i) {
|
|
|
|
* return tempReturn0 = highBits, lowBits;
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Returning longs is equally problamatic, the convention is to return the lowBits, and save the highBits in a
|
|
|
|
* global |tempReturn0| variable.
|
|
|
|
*/
|
|
|
|
|
2015-04-30 19:51:47 +03:00
|
|
|
/*
|
2015-05-10 04:32:02 +03:00
|
|
|
* Stack Frame Layout:
|
|
|
|
*
|
|
|
|
* LP ---> +--------------------------------+
|
2015-05-06 11:26:46 +03:00
|
|
|
* | Parameter 0 |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | ... |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | Parameter (P-1) |
|
|
|
|
* +--------------------------------+
|
2015-04-30 19:51:47 +03:00
|
|
|
* | Non-Parameter Local 0 |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | ... |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | Non-Parameter Local (L-1) |
|
2015-05-06 11:26:46 +03:00
|
|
|
* FP ---> +--------------------------------+
|
2015-05-16 01:22:12 +03:00
|
|
|
* | Caller Return Address | // The opPC of the caller's invoke bytecode.
|
2015-05-06 11:26:46 +03:00
|
|
|
* +--------------------------------+
|
|
|
|
* | Caller FP |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | Callee Method Info |
|
2015-04-30 19:51:47 +03:00
|
|
|
* +--------------------------------+
|
2015-05-16 04:58:19 +03:00
|
|
|
* | Monitor |
|
|
|
|
* +--------------------------------+
|
2015-04-30 19:51:47 +03:00
|
|
|
* | Stack slot 0 |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | ... |
|
|
|
|
* +--------------------------------+
|
|
|
|
* | Stack slot (S-1) |
|
|
|
|
* SP ---> +--------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum FrameLayout {
|
2015-05-06 11:26:46 +03:00
|
|
|
CalleeMethodInfoOffset = 2,
|
|
|
|
CallerFPOffset = 1,
|
|
|
|
CallerRAOffset = 0,
|
2015-05-16 04:58:19 +03:00
|
|
|
MonitorOffset = 3,
|
|
|
|
CallerSaveSize = 4
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export class FrameView {
|
|
|
|
public fp: number;
|
|
|
|
public sp: number;
|
|
|
|
public pc: number;
|
2015-05-22 05:44:42 +03:00
|
|
|
public thread: Thread;
|
2015-04-30 19:51:47 +03:00
|
|
|
constructor() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-22 05:44:42 +03:00
|
|
|
set(thread: Thread, fp: number, sp: number, pc: number) {
|
|
|
|
this.thread = thread;
|
2015-04-30 19:51:47 +03:00
|
|
|
this.fp = fp;
|
|
|
|
this.sp = sp;
|
|
|
|
this.pc = pc;
|
2015-05-05 05:46:26 +03:00
|
|
|
|
|
|
|
if (!release) {
|
2015-05-08 03:31:22 +03:00
|
|
|
var callee = ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-05-05 05:46:26 +03:00
|
|
|
assert(
|
|
|
|
callee === null ||
|
|
|
|
callee instanceof MethodInfo,
|
2015-05-08 01:17:05 +03:00
|
|
|
"Callee @" + (this.fp + FrameLayout.CalleeMethodInfoOffset) + " is not a MethodInfo, " + toName(callee)
|
2015-05-05 05:46:26 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setParameter(kind: Kind, i: number, v: any) {
|
|
|
|
switch (kind) {
|
|
|
|
case Kind.Reference:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[this.fp + this.parameterOffset + i] = v;
|
2015-05-05 05:46:26 +03:00
|
|
|
break;
|
|
|
|
case Kind.Int:
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[this.fp + this.parameterOffset + i] = v;
|
2015-05-05 05:46:26 +03:00
|
|
|
break;
|
|
|
|
default:
|
2015-05-11 02:00:43 +03:00
|
|
|
release || assert(false, "Cannot set parameter of kind: " + Kind[kind]);
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get methodInfo(): MethodInfo {
|
2015-05-08 03:31:22 +03:00
|
|
|
return ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
set methodInfo(methodInfo: MethodInfo) {
|
2015-05-08 03:31:22 +03:00
|
|
|
ref[this.fp + FrameLayout.CalleeMethodInfoOffset] = methodInfo;
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
get parameterOffset() {
|
|
|
|
return this.methodInfo ? -this.methodInfo.codeAttribute.max_locals : 0;
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
get stackOffset(): number {
|
|
|
|
return FrameLayout.CallerSaveSize;
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
traceStack(writer: IndentingWriter) {
|
|
|
|
var fp = this.fp;
|
|
|
|
var sp = this.sp;
|
|
|
|
var pc = this.pc;
|
2015-07-19 18:57:17 +03:00
|
|
|
while (this.fp > (this.thread.tp >> 2)) {
|
2015-05-05 05:46:26 +03:00
|
|
|
writer.writeLn((this.methodInfo ? this.methodInfo.implKey : "null") + ", FP: " + this.fp + ", SP: " + this.sp + ", PC: " + this.pc);
|
2015-05-22 05:44:42 +03:00
|
|
|
this.set(this.thread, i32[this.fp + FrameLayout.CallerFPOffset],
|
2015-05-06 11:26:46 +03:00
|
|
|
this.fp + this.parameterOffset,
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[this.fp + FrameLayout.CallerRAOffset]);
|
2015-05-05 05:46:26 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
this.fp = fp;
|
|
|
|
this.sp = sp;
|
|
|
|
this.pc = pc;
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
2015-05-11 02:00:43 +03:00
|
|
|
trace(writer: IndentingWriter) {
|
2015-04-30 19:51:47 +03:00
|
|
|
function toNumber(v) {
|
|
|
|
if (v < 0) {
|
|
|
|
return String(v);
|
|
|
|
} else if (v === 0) {
|
|
|
|
return " 0";
|
|
|
|
} else {
|
|
|
|
return "+" + v;
|
|
|
|
}
|
|
|
|
}
|
2015-05-08 01:17:05 +03:00
|
|
|
|
2015-05-11 02:00:43 +03:00
|
|
|
function clampString(v, n) {
|
|
|
|
if (v.length > n) {
|
|
|
|
return v.substring(0, n - 3) + "...";
|
|
|
|
}
|
|
|
|
return v;
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
2015-05-11 02:00:43 +03:00
|
|
|
|
|
|
|
writer.writeLn("Frame: " + this.methodInfo.implKey + ", FP: " + this.fp + ", SP: " + this.sp + ", PC: " + this.pc);
|
2015-05-06 11:26:46 +03:00
|
|
|
for (var i = Math.max(0, this.fp + this.parameterOffset); i < this.sp; i++) {
|
2015-04-30 19:51:47 +03:00
|
|
|
var prefix = " ";
|
|
|
|
if (i >= this.fp + this.stackOffset) {
|
|
|
|
prefix = "S" + (i - (this.fp + this.stackOffset)) + ": ";
|
2015-05-05 05:46:26 +03:00
|
|
|
} else if (i === this.fp + FrameLayout.CalleeMethodInfoOffset) {
|
2015-04-30 19:51:47 +03:00
|
|
|
prefix = "MI: ";
|
2015-05-05 05:46:26 +03:00
|
|
|
} else if (i === this.fp + FrameLayout.CallerFPOffset) {
|
|
|
|
prefix = "CF: ";
|
|
|
|
} else if (i === this.fp + FrameLayout.CallerRAOffset) {
|
2015-04-30 19:51:47 +03:00
|
|
|
prefix = "RA: ";
|
2015-05-06 11:26:46 +03:00
|
|
|
} else if (i >= this.fp + this.parameterOffset) {
|
|
|
|
prefix = "L" + (i - (this.fp + this.parameterOffset)) + ": ";
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
2015-05-11 02:00:43 +03:00
|
|
|
writer.writeLn(" " + prefix.padRight(' ', 5) + " " + toNumber(i - this.fp).padLeft(' ', 3) + " " + String(i).padLeft(' ', 4) + " " + toHEX(i << 2) + ": " +
|
2015-05-10 04:32:02 +03:00
|
|
|
String(i32[i]).padLeft(' ', 12) + " " +
|
2015-05-11 02:00:43 +03:00
|
|
|
toHEX(i32[i]) + " " +
|
2015-05-11 10:27:23 +03:00
|
|
|
((i32[i] >= 32 && i32[i] < 1024) ? String.fromCharCode(i32[i]) : "?") + " " +
|
2015-05-11 02:00:43 +03:00
|
|
|
clampString(String(f32[i]), 12).padLeft(' ', 12) + " " +
|
|
|
|
clampString(String(wordsToDouble(i32[i], i32[i + 1])), 12).padLeft(' ', 12) + " " +
|
2015-06-19 00:02:09 +03:00
|
|
|
// XXX ref[i] could be an address, so update toName to handle that.
|
2015-05-08 03:31:22 +03:00
|
|
|
toName(ref[i]));
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-09 23:37:04 +03:00
|
|
|
export var interpreterCounter = new Metrics.Counter(true);
|
|
|
|
|
2015-04-30 19:51:47 +03:00
|
|
|
export class Thread {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thread base pointer.
|
|
|
|
*/
|
|
|
|
tp: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stack base pointer.
|
|
|
|
*/
|
|
|
|
bp: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current frame pointer.
|
|
|
|
*/
|
|
|
|
fp: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current stack pointer.
|
|
|
|
*/
|
|
|
|
sp: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current program counter.
|
|
|
|
*/
|
|
|
|
pc: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Context associated with this thread.
|
|
|
|
*/
|
|
|
|
ctx: Context;
|
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
view: FrameView;
|
|
|
|
|
2015-04-30 19:51:47 +03:00
|
|
|
constructor(ctx: Context) {
|
2015-08-08 17:42:29 +03:00
|
|
|
this.tp = ASM._gcMalloc(4 * 1024);
|
2015-07-19 18:57:17 +03:00
|
|
|
this.bp = this.tp >> 2;
|
2015-05-06 11:26:46 +03:00
|
|
|
this.fp = this.bp;
|
|
|
|
this.sp = this.fp;
|
2015-05-05 05:46:26 +03:00
|
|
|
this.pc = -1;
|
|
|
|
this.view = new FrameView();
|
2015-04-30 19:51:47 +03:00
|
|
|
this.ctx = ctx;
|
2015-07-19 18:57:17 +03:00
|
|
|
release || threadWriter && threadWriter.writeLn("creatingThread: tp: " + toHEX(this.tp) + " " + toHEX(i32.byteLength));
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
2015-05-05 05:46:26 +03:00
|
|
|
|
|
|
|
set(fp: number, sp: number, pc: number) {
|
|
|
|
this.fp = fp;
|
|
|
|
this.sp = sp;
|
|
|
|
this.pc = pc;
|
|
|
|
}
|
|
|
|
|
2015-05-18 01:12:44 +03:00
|
|
|
hashFrame(): number {
|
|
|
|
var fp = this.fp << 2;
|
|
|
|
var sp = this.sp << 2;
|
|
|
|
return HashUtilities.hashBytesTo32BitsAdler(u8, fp, sp);
|
|
|
|
}
|
|
|
|
|
2015-05-17 21:35:37 +03:00
|
|
|
/**
|
|
|
|
* Advances the |pc| to the next |pc| after the current invoke bytecode.
|
|
|
|
*/
|
|
|
|
advancePastInvokeBytecode() {
|
|
|
|
var mi = ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
|
|
|
var code = mi.codeAttribute.code;
|
|
|
|
var op = code[this.pc];
|
2015-05-22 05:44:42 +03:00
|
|
|
release || assert(isInvoke(op), "The PC should be at an invoke bytecode.");
|
2015-05-17 21:35:37 +03:00
|
|
|
this.pc += (op === Bytecodes.INVOKEINTERFACE ? 5 : 3);
|
|
|
|
}
|
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
get frame(): FrameView {
|
2015-05-22 05:44:42 +03:00
|
|
|
this.view.set(this, this.fp, this.sp, this.pc);
|
2015-05-05 05:46:26 +03:00
|
|
|
return this.view;
|
|
|
|
}
|
|
|
|
|
|
|
|
pushFrame(methodInfo: MethodInfo) {
|
2015-05-06 11:26:46 +03:00
|
|
|
var fp = this.fp;
|
2015-05-05 05:46:26 +03:00
|
|
|
if (methodInfo) {
|
2015-05-06 11:26:46 +03:00
|
|
|
this.fp = this.sp + methodInfo.codeAttribute.max_locals;
|
|
|
|
} else {
|
|
|
|
this.fp = this.sp;
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
2015-05-16 04:58:19 +03:00
|
|
|
i32[this.fp + FrameLayout.CallerRAOffset] = this.pc; // Caller RA
|
|
|
|
i32[this.fp + FrameLayout.CallerFPOffset] = fp; // Caller FP
|
|
|
|
ref[this.fp + FrameLayout.CalleeMethodInfoOffset] = methodInfo; // Callee
|
2015-07-08 20:44:27 +03:00
|
|
|
i32[this.fp + FrameLayout.MonitorOffset] = Constants.NULL; // Monitor
|
2015-05-16 04:58:19 +03:00
|
|
|
this.sp = this.fp + FrameLayout.CallerSaveSize;
|
2015-05-05 05:46:26 +03:00
|
|
|
this.pc = 0;
|
|
|
|
}
|
|
|
|
|
2015-05-08 01:17:05 +03:00
|
|
|
popFrame(methodInfo: MethodInfo): MethodInfo {
|
2015-05-08 03:31:22 +03:00
|
|
|
var mi = ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-08-11 03:06:21 +03:00
|
|
|
release || assert(mi === methodInfo, "mi === methodInfo");
|
2015-05-08 03:31:22 +03:00
|
|
|
this.pc = i32[this.fp + FrameLayout.CallerRAOffset];
|
2015-05-06 11:26:46 +03:00
|
|
|
var maxLocals = mi ? mi.codeAttribute.max_locals : 0;
|
|
|
|
this.sp = this.fp - maxLocals;
|
2015-05-08 03:31:22 +03:00
|
|
|
this.fp = i32[this.fp + FrameLayout.CallerFPOffset];
|
2015-05-19 04:13:41 +03:00
|
|
|
return ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
run() {
|
|
|
|
return interpret(this);
|
|
|
|
}
|
|
|
|
|
2015-05-11 04:33:23 +03:00
|
|
|
exceptionUnwind(e: java.lang.Exception) {
|
|
|
|
release || traceWriter && traceWriter.writeLn("exceptionUnwind: " + toName(e));
|
2015-05-08 01:17:05 +03:00
|
|
|
var pc = -1;
|
2015-05-06 11:26:46 +03:00
|
|
|
var classInfo;
|
2015-05-08 03:31:22 +03:00
|
|
|
var mi = ref[this.fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-05-08 01:17:05 +03:00
|
|
|
while (mi) {
|
2015-05-11 04:33:23 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Looking for handler in: " + mi.implKey);
|
2015-05-06 11:26:46 +03:00
|
|
|
for (var i = 0; i < mi.exception_table_length; i++) {
|
|
|
|
var exceptionEntryView = mi.getExceptionEntryViewByIndex(i);
|
2015-05-16 01:22:12 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Checking catch range: " + exceptionEntryView.start_pc + " - " + exceptionEntryView.end_pc);
|
2015-05-06 11:26:46 +03:00
|
|
|
if (this.pc >= exceptionEntryView.start_pc && this.pc < exceptionEntryView.end_pc) {
|
|
|
|
if (exceptionEntryView.catch_type === 0) {
|
2015-05-08 01:17:05 +03:00
|
|
|
pc = exceptionEntryView.handler_pc;
|
2015-05-06 11:26:46 +03:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
classInfo = resolveClass(exceptionEntryView.catch_type, mi.classInfo);
|
2015-07-22 01:49:33 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Checking catch type: " + classInfo);
|
|
|
|
if (isAssignableTo(e.classInfo, classInfo)) {
|
2015-05-08 01:17:05 +03:00
|
|
|
pc = exceptionEntryView.handler_pc;
|
2015-05-06 11:26:46 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-08 01:17:05 +03:00
|
|
|
if (pc >= 0) {
|
|
|
|
this.pc = pc;
|
|
|
|
this.sp = this.fp + FrameLayout.CallerSaveSize;
|
2015-06-19 00:02:09 +03:00
|
|
|
release || assert(e instanceof Object && "_address" in e, "exception is object with address");
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[this.sp++] = e._address;
|
2015-05-06 11:26:46 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-05-19 23:54:22 +03:00
|
|
|
if (mi.isSynchronized) {
|
2015-07-08 20:44:27 +03:00
|
|
|
this.ctx.monitorExit(getMonitor(i32[this.fp + FrameLayout.MonitorOffset]));
|
2015-05-19 23:54:22 +03:00
|
|
|
}
|
2015-05-08 01:17:05 +03:00
|
|
|
mi = this.popFrame(mi);
|
2015-05-11 04:33:23 +03:00
|
|
|
release || traceWriter && traceWriter.outdent();
|
|
|
|
release || traceWriter && traceWriter.writeLn("<< I Unwind");
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Cannot catch: " + toName(e));
|
2015-05-08 01:17:05 +03:00
|
|
|
throw e;
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
2015-05-18 22:52:59 +03:00
|
|
|
|
|
|
|
classInitAndUnwindCheck(fp: number, sp: number, pc: number, classInfo: ClassInfo) {
|
|
|
|
this.set(fp, sp, pc);
|
|
|
|
classInitCheck(classInfo);
|
|
|
|
}
|
2015-05-20 09:25:42 +03:00
|
|
|
|
|
|
|
throwException(fp: number, sp: number, pc: number, type: ExceptionType, a?) {
|
|
|
|
this.set(fp, sp, pc);
|
|
|
|
switch (type) {
|
|
|
|
case ExceptionType.ArrayIndexOutOfBoundsException:
|
|
|
|
throwArrayIndexOutOfBoundsException(a);
|
|
|
|
break;
|
|
|
|
case ExceptionType.ArithmeticException:
|
|
|
|
throwArithmeticException();
|
|
|
|
break;
|
|
|
|
case ExceptionType.NegativeArraySizeException:
|
|
|
|
throwNegativeArraySizeException();
|
|
|
|
break;
|
|
|
|
case ExceptionType.NullPointerException:
|
|
|
|
throwNullPointerException();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
export function prepareInterpretedMethod(methodInfo: MethodInfo): Function {
|
|
|
|
var method = function fastInterpreterFrameAdapter() {
|
|
|
|
var thread = $.ctx.nativeThread;
|
2015-05-19 04:13:41 +03:00
|
|
|
var callerFP = thread.fp;
|
|
|
|
var callerPC = thread.pc;
|
2015-05-11 04:33:23 +03:00
|
|
|
// release || traceWriter && traceWriter.writeLn(">> I");
|
2015-05-05 05:46:26 +03:00
|
|
|
thread.pushFrame(null);
|
|
|
|
thread.pushFrame(methodInfo);
|
2015-05-19 04:13:41 +03:00
|
|
|
var calleeFP = thread.fp;
|
2015-05-06 11:26:46 +03:00
|
|
|
var frame = thread.frame;
|
2015-05-05 05:46:26 +03:00
|
|
|
var kinds = methodInfo.signatureKinds;
|
|
|
|
var index = 0;
|
|
|
|
if (!methodInfo.isStatic) {
|
2015-07-08 00:55:54 +03:00
|
|
|
frame.setParameter(Kind.Reference, index++, arguments[0]);
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
|
|
|
for (var i = 1; i < kinds.length; i++) {
|
2015-07-08 00:55:54 +03:00
|
|
|
frame.setParameter(kinds[i], index++, arguments[i]);
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
2015-05-16 04:58:19 +03:00
|
|
|
if (methodInfo.isSynchronized) {
|
2015-07-22 01:49:33 +03:00
|
|
|
var monitorAddr = methodInfo.isStatic ? $.getClassObjectAddress(methodInfo.classInfo) : arguments[0];
|
2015-07-24 21:56:19 +03:00
|
|
|
i32[calleeFP + FrameLayout.MonitorOffset] = monitorAddr;
|
2015-07-10 01:33:09 +03:00
|
|
|
$.ctx.monitorEnter(getMonitor(monitorAddr));
|
2015-05-18 21:56:37 +03:00
|
|
|
release || assert(U !== VMState.Yielding, "Monitors should never yield.");
|
2015-05-16 04:58:19 +03:00
|
|
|
if (U === VMState.Pausing || U === VMState.Stopping) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-05-08 01:17:05 +03:00
|
|
|
var v = interpret(thread);
|
2015-05-19 04:13:41 +03:00
|
|
|
if (U) {
|
|
|
|
release || assert(v === undefined, "Return value must be undefined.");
|
|
|
|
// Splice out the marker frame so the interpreter doesn't return early when execution is resumed.
|
|
|
|
i32[calleeFP + FrameLayout.CallerFPOffset] = callerFP;
|
|
|
|
i32[calleeFP + FrameLayout.CallerRAOffset] = callerPC;
|
|
|
|
return;
|
|
|
|
}
|
2015-08-11 03:06:21 +03:00
|
|
|
release || assert(callerFP === thread.fp, "callerFP === thread.fp");
|
2015-05-11 04:33:23 +03:00
|
|
|
// release || traceWriter && traceWriter.writeLn("<< I");
|
2015-05-08 01:17:05 +03:00
|
|
|
return v;
|
2015-05-05 05:46:26 +03:00
|
|
|
};
|
|
|
|
(<any>method).methodInfo = methodInfo;
|
|
|
|
return method;
|
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
function resolveClass(index: number, classInfo: ClassInfo): ClassInfo {
|
2015-07-22 01:49:33 +03:00
|
|
|
return classInfo.constantPool.resolveClass(index);
|
2015-05-05 05:46:26 +03:00
|
|
|
}
|
|
|
|
|
2015-05-10 13:16:41 +03:00
|
|
|
var args = new Array(16);
|
|
|
|
|
2015-05-20 09:25:42 +03:00
|
|
|
export enum ExceptionType {
|
2015-05-11 10:27:23 +03:00
|
|
|
ArithmeticException,
|
2015-05-19 00:36:41 +03:00
|
|
|
ArrayIndexOutOfBoundsException,
|
|
|
|
NegativeArraySizeException,
|
|
|
|
NullPointerException
|
2015-05-11 10:27:23 +03:00
|
|
|
}
|
2015-05-17 21:35:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Debugging helper to make sure native methods were implemented correctly.
|
|
|
|
*/
|
|
|
|
function checkReturnValue(methodInfo: MethodInfo, l: any, h: number) {
|
|
|
|
if (U) {
|
|
|
|
if (typeof l !== "undefined") {
|
|
|
|
assert(false, "Expected undefined return value during unwind, got " + l + " in " + methodInfo.implKey);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(getKindCheck(methodInfo.returnKind)(l, h))) {
|
|
|
|
assert(false, "Expected " + Kind[methodInfo.returnKind] + " return value, got " + l + " in " + methodInfo.implKey);
|
|
|
|
}
|
|
|
|
}
|
2015-05-11 10:27:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Main interpreter loop. This method is carefully written to avoid memory allocation and
|
2015-05-17 21:45:15 +03:00
|
|
|
* function calls on fast paths. Therefore, everything is inlined, even if it makes the code
|
|
|
|
* look ugly.
|
|
|
|
*
|
|
|
|
* The interpreter loop caches the thread state in local variables. Doing so avoids a lot of
|
|
|
|
* property accesses but also makes the code brittle since you need to manually sync up the
|
|
|
|
* thread state with the local thead state at precise points.
|
|
|
|
*
|
|
|
|
* At call sites, caller frame |pc|s are always at the beggining of invoke bytecodes. In the
|
|
|
|
* interpreter return bytecodes advance the pc past the invoke bytecode. Native code that
|
|
|
|
* unwinds and resumes execution at a later point needs to adjust the pc accordingly.
|
2015-05-19 00:36:41 +03:00
|
|
|
*
|
|
|
|
* Bytecodes that construct exception objects must save the tread state before executing any
|
|
|
|
* code that may overwrite the frame. Use the |throwException| helper method to ensure that
|
|
|
|
* the thread state is property saved.
|
2015-05-11 10:27:23 +03:00
|
|
|
*/
|
2015-04-30 19:51:47 +03:00
|
|
|
export function interpret(thread: Thread) {
|
2015-05-06 11:26:46 +03:00
|
|
|
var frame = thread.frame;
|
|
|
|
|
|
|
|
var mi = frame.methodInfo;
|
2015-05-08 03:31:22 +03:00
|
|
|
var maxLocals = mi.codeAttribute.max_locals;
|
2015-04-30 19:51:47 +03:00
|
|
|
var ci = mi.classInfo;
|
|
|
|
var cp = ci.constantPool;
|
|
|
|
|
|
|
|
var code = mi ? mi.codeAttribute.code : null;
|
|
|
|
|
|
|
|
var fp = thread.fp;
|
2015-05-08 05:29:32 +03:00
|
|
|
var lp = fp - maxLocals;
|
2015-04-30 19:51:47 +03:00
|
|
|
var sp = thread.sp;
|
2015-05-11 10:27:23 +03:00
|
|
|
var opPC = 0, pc = thread.pc;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
var tag: TAGS;
|
2015-04-30 19:51:47 +03:00
|
|
|
var type, size;
|
2015-07-22 01:49:33 +03:00
|
|
|
var value, index, arrayAddr: number, offset, buffer, tag: TAGS, targetPC;
|
2015-05-11 04:50:37 +03:00
|
|
|
var address = 0, isStatic = false;
|
2015-05-05 05:46:26 +03:00
|
|
|
var ia = 0, ib = 0; // Integer Operands
|
2015-05-09 07:14:44 +03:00
|
|
|
var ll = 0, lh = 0; // Long Low / High
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-05 05:46:26 +03:00
|
|
|
var classInfo: ClassInfo;
|
2015-07-24 00:50:06 +03:00
|
|
|
var otherClassInfo: ClassInfo;
|
2015-05-05 05:46:26 +03:00
|
|
|
var fieldInfo: FieldInfo;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-07-10 01:33:09 +03:00
|
|
|
var monitorAddr: number;
|
2015-05-16 04:58:19 +03:00
|
|
|
|
2015-05-09 07:14:44 +03:00
|
|
|
// HEAD
|
|
|
|
|
2015-04-30 19:51:47 +03:00
|
|
|
while (true) {
|
2015-05-22 05:44:42 +03:00
|
|
|
opPC = pc, op = code[pc], pc = pc + 1 | 0;
|
2015-05-05 05:46:26 +03:00
|
|
|
|
2015-05-11 10:27:23 +03:00
|
|
|
if (!release) {
|
|
|
|
assert(code === mi.codeAttribute.code, "Bad Code.");
|
|
|
|
assert(ci === mi.classInfo, "Bad Class Info.");
|
|
|
|
assert(cp === ci.constantPool, "Bad Constant Pool.");
|
|
|
|
assert(lp === fp - mi.codeAttribute.max_locals, "Bad lp.");
|
|
|
|
bytecodeCount++;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-11 10:27:23 +03:00
|
|
|
if (traceStackWriter) {
|
2015-05-22 05:44:42 +03:00
|
|
|
frame.set(thread, fp, sp, opPC); frame.trace(traceStackWriter);
|
2015-05-11 10:27:23 +03:00
|
|
|
traceStackWriter.writeLn();
|
|
|
|
traceStackWriter.greenLn(mi.implKey + ": PC: " + opPC + ", FP: " + fp + ", " + Bytecodes[op]);
|
|
|
|
}
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-05-05 05:46:26 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
try {
|
|
|
|
switch (op) {
|
|
|
|
case Bytecodes.NOP:
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ACONST_NULL:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = Constants.NULL;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ICONST_M1:
|
|
|
|
case Bytecodes.ICONST_0:
|
|
|
|
case Bytecodes.ICONST_1:
|
|
|
|
case Bytecodes.ICONST_2:
|
|
|
|
case Bytecodes.ICONST_3:
|
|
|
|
case Bytecodes.ICONST_4:
|
|
|
|
case Bytecodes.ICONST_5:
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp++] = op - Bytecodes.ICONST_0;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.FCONST_0:
|
|
|
|
case Bytecodes.FCONST_1:
|
|
|
|
case Bytecodes.FCONST_2:
|
2015-05-10 02:22:53 +03:00
|
|
|
f32[sp++] = op - Bytecodes.FCONST_0;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.DCONST_0:
|
|
|
|
i32[sp++] = 0;
|
|
|
|
i32[sp++] = 0;
|
|
|
|
continue;
|
|
|
|
case Bytecodes.DCONST_1:
|
|
|
|
i32[sp++] = 0;
|
|
|
|
i32[sp++] = 1072693248;
|
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LCONST_0:
|
|
|
|
case Bytecodes.LCONST_1:
|
2015-05-08 09:37:31 +03:00
|
|
|
i32[sp++] = op - Bytecodes.LCONST_0;
|
|
|
|
i32[sp++] = 0;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.BIPUSH:
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp++] = code[pc++] << 24 >> 24;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.SIPUSH:
|
2015-05-09 23:37:04 +03:00
|
|
|
i32[sp++] = (code[pc++] << 8 | code[pc++]) << 16 >> 16;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.LDC:
|
|
|
|
case Bytecodes.LDC_W:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = (op === Bytecodes.LDC) ? code[pc++] : code[pc++] << 8 | code[pc++];
|
2015-05-10 00:57:32 +03:00
|
|
|
offset = cp.entries[index];
|
|
|
|
buffer = cp.buffer;
|
|
|
|
tag = buffer[offset++];
|
|
|
|
if (tag === TAGS.CONSTANT_Integer || tag === TAGS.CONSTANT_Float) {
|
|
|
|
i32[sp++] = buffer[offset++] << 24 | buffer[offset++] << 16 | buffer[offset++] << 8 | buffer[offset++];
|
2015-05-06 11:26:46 +03:00
|
|
|
} else if (tag === TAGS.CONSTANT_String) {
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = ci.constantPool.resolve(index, tag, false);
|
2015-05-06 11:26:46 +03:00
|
|
|
} else {
|
2015-05-10 03:28:04 +03:00
|
|
|
release || assert(false, TAGS[tag]);
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.LDC2_W:
|
2015-05-10 00:57:32 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
|
|
|
offset = cp.entries[index];
|
|
|
|
buffer = cp.buffer;
|
|
|
|
tag = buffer[offset++];
|
|
|
|
if (tag === TAGS.CONSTANT_Long || tag === TAGS.CONSTANT_Double) {
|
|
|
|
i32[sp + 1] = buffer[offset++] << 24 | buffer[offset++] << 16 | buffer[offset++] << 8 | buffer[offset++];
|
|
|
|
i32[sp ] = buffer[offset++] << 24 | buffer[offset++] << 16 | buffer[offset++] << 8 | buffer[offset++];
|
|
|
|
sp += 2;
|
2015-05-06 11:26:46 +03:00
|
|
|
} else {
|
2015-05-10 03:28:04 +03:00
|
|
|
release || assert(false, TAGS[tag]);
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ILOAD:
|
|
|
|
case Bytecodes.FLOAD:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp++] = i32[lp + code[pc++]];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ALOAD:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[lp + code[pc++]];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LLOAD:
|
|
|
|
case Bytecodes.DLOAD:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + code[pc++];
|
|
|
|
i32[sp++] = i32[offset];
|
|
|
|
i32[sp++] = i32[offset + 1];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ILOAD_0:
|
|
|
|
case Bytecodes.ILOAD_1:
|
|
|
|
case Bytecodes.ILOAD_2:
|
|
|
|
case Bytecodes.ILOAD_3:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp++] = i32[lp + op - Bytecodes.ILOAD_0];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.FLOAD_0:
|
|
|
|
case Bytecodes.FLOAD_1:
|
|
|
|
case Bytecodes.FLOAD_2:
|
|
|
|
case Bytecodes.FLOAD_3:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp++] = i32[lp + op - Bytecodes.FLOAD_0];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ALOAD_0:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[lp];
|
2015-05-09 23:37:04 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ALOAD_1:
|
|
|
|
case Bytecodes.ALOAD_2:
|
|
|
|
case Bytecodes.ALOAD_3:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[lp + op - Bytecodes.ALOAD_0];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LLOAD_0:
|
|
|
|
case Bytecodes.LLOAD_1:
|
|
|
|
case Bytecodes.LLOAD_2:
|
|
|
|
case Bytecodes.LLOAD_3:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + op - Bytecodes.LLOAD_0;
|
|
|
|
i32[sp++] = i32[offset];
|
|
|
|
i32[sp++] = i32[offset + 1];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.DLOAD_0:
|
|
|
|
case Bytecodes.DLOAD_1:
|
|
|
|
case Bytecodes.DLOAD_2:
|
|
|
|
case Bytecodes.DLOAD_3:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + op - Bytecodes.DLOAD_0;
|
|
|
|
i32[sp++] = i32[offset];
|
|
|
|
i32[sp++] = i32[offset + 1];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.IALOAD:
|
2015-05-08 05:35:57 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[sp++] = i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.BALOAD:
|
2015-05-08 05:35:57 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[sp++] = i8[arrayAddr + Constants.ARRAY_HDR_SIZE + index];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.CALOAD:
|
2015-05-08 05:35:57 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[sp++] = u16[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 1) + index];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.SALOAD:
|
2015-05-08 05:35:57 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[sp++] = i16[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 1) + index];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.FALOAD:
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
f32[sp++] = f32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index];
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.AALOAD:
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-06-27 01:40:20 +03:00
|
|
|
|
2015-06-30 23:30:03 +03:00
|
|
|
if (arrayAddr === Constants.NULL) {
|
2015-06-27 01:40:20 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-06-27 01:40:20 +03:00
|
|
|
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index];
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.DALOAD:
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
aliasedF64[0] = f64[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 3) + index];
|
2015-05-10 02:22:53 +03:00
|
|
|
i32[sp++] = aliasedI32[0];
|
|
|
|
i32[sp++] = aliasedI32[1];
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ISTORE:
|
|
|
|
case Bytecodes.FSTORE:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[lp + code[pc++]] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ASTORE:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[lp + code[pc++]] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LSTORE:
|
|
|
|
case Bytecodes.DSTORE:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + code[pc++];
|
|
|
|
i32[offset + 1] = i32[--sp];
|
|
|
|
i32[offset] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ISTORE_0:
|
|
|
|
case Bytecodes.ISTORE_1:
|
|
|
|
case Bytecodes.ISTORE_2:
|
|
|
|
case Bytecodes.ISTORE_3:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[lp + op - Bytecodes.ISTORE_0] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.FSTORE_0:
|
|
|
|
case Bytecodes.FSTORE_1:
|
|
|
|
case Bytecodes.FSTORE_2:
|
|
|
|
case Bytecodes.FSTORE_3:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[lp + op - Bytecodes.FSTORE_0] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ASTORE_0:
|
|
|
|
case Bytecodes.ASTORE_1:
|
|
|
|
case Bytecodes.ASTORE_2:
|
|
|
|
case Bytecodes.ASTORE_3:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[lp + op - Bytecodes.ASTORE_0] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LSTORE_0:
|
|
|
|
case Bytecodes.LSTORE_1:
|
|
|
|
case Bytecodes.LSTORE_2:
|
|
|
|
case Bytecodes.LSTORE_3:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + op - Bytecodes.LSTORE_0;
|
|
|
|
i32[offset + 1] = i32[--sp];
|
|
|
|
i32[offset] = i32[--sp];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.DSTORE_0:
|
|
|
|
case Bytecodes.DSTORE_1:
|
|
|
|
case Bytecodes.DSTORE_2:
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.DSTORE_3:
|
2015-05-09 12:47:47 +03:00
|
|
|
offset = lp + op - Bytecodes.DSTORE_0;
|
|
|
|
i32[offset + 1] = i32[--sp];
|
|
|
|
i32[offset] = i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IASTORE:
|
2015-05-08 05:35:57 +03:00
|
|
|
value = i32[--sp];
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index] = value;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.FASTORE:
|
2015-05-09 07:14:44 +03:00
|
|
|
value = f32[--sp];
|
2015-05-08 05:35:57 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
f32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index] = value;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.BASTORE:
|
2015-05-08 05:35:57 +03:00
|
|
|
value = i32[--sp];
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i8[arrayAddr + Constants.ARRAY_HDR_SIZE + index] = value;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.CASTORE:
|
2015-05-08 05:35:57 +03:00
|
|
|
value = i32[--sp];
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
u16[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 1) + index] = value;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.SASTORE:
|
2015-05-08 05:35:57 +03:00
|
|
|
value = i32[--sp];
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-08 09:37:31 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i16[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 1) + index] = value;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.LASTORE:
|
|
|
|
lh = i32[--sp];
|
|
|
|
ll = i32[--sp];
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index * 2 ] = ll;
|
|
|
|
i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index * 2 + 1] = lh;
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.LALOAD:
|
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[sp++] = i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index * 2 ];
|
|
|
|
i32[sp++] = i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index * 2 + 1];
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.DASTORE:
|
2015-05-10 02:22:53 +03:00
|
|
|
aliasedI32[1] = i32[--sp];
|
|
|
|
aliasedI32[0] = i32[--sp];
|
|
|
|
value = aliasedF64[0];
|
2015-05-09 07:14:44 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-03 01:15:41 +03:00
|
|
|
f64[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 3) + index] = value;
|
2015-05-09 07:14:44 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.AASTORE:
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[--sp];
|
2015-05-09 07:14:44 +03:00
|
|
|
index = i32[--sp];
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-06-28 08:01:33 +03:00
|
|
|
|
2015-06-30 23:35:05 +03:00
|
|
|
if (arrayAddr === Constants.NULL) {
|
2015-06-28 08:01:33 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-07-03 01:15:41 +03:00
|
|
|
if ((index >>> 0) >= (i32[arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2] >>> 0)) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArrayIndexOutOfBoundsException, index);
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-06-27 01:40:20 +03:00
|
|
|
checkArrayStore(arrayAddr, address);
|
2015-07-03 01:15:41 +03:00
|
|
|
i32[(arrayAddr + Constants.ARRAY_HDR_SIZE >> 2) + index] = address;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.POP:
|
|
|
|
--sp;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.POP2:
|
|
|
|
sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-15 09:28:30 +03:00
|
|
|
case Bytecodes.DUP: // ... a -> ... a, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp] = i32[sp - 1];
|
2015-05-06 11:26:46 +03:00
|
|
|
sp++;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-15 09:28:30 +03:00
|
|
|
case Bytecodes.DUP2: // ... b, a -> ... b, a, b, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp ] = i32[sp - 2]; // b
|
|
|
|
i32[sp + 1] = i32[sp - 1]; // a
|
2015-05-09 12:47:47 +03:00
|
|
|
sp += 2;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-15 09:28:30 +03:00
|
|
|
case Bytecodes.DUP_X1: // ... b, a -> ... a, b, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp ] = i32[sp - 1]; // a
|
|
|
|
i32[sp - 1] = i32[sp - 2]; // b
|
|
|
|
i32[sp - 2] = i32[sp]; // a
|
2015-05-10 02:22:53 +03:00
|
|
|
sp++;
|
|
|
|
continue;
|
2015-05-15 09:28:30 +03:00
|
|
|
case Bytecodes.DUP_X2: // ... c, b, a -> ... a, c, b, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp ] = i32[sp - 1]; // a
|
|
|
|
i32[sp - 1] = i32[sp - 2]; // b
|
|
|
|
i32[sp - 2] = i32[sp - 3]; // c
|
|
|
|
i32[sp - 3] = i32[sp]; // a
|
2015-05-08 10:52:22 +03:00
|
|
|
sp++;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-15 09:28:30 +03:00
|
|
|
case Bytecodes.DUP2_X1: // ... c, b, a -> ... b, a, c, b, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp + 1] = i32[sp - 1]; // a
|
|
|
|
i32[sp ] = i32[sp - 2]; // b
|
|
|
|
i32[sp - 1] = i32[sp - 3]; // c
|
|
|
|
i32[sp - 2] = i32[sp + 1]; // a
|
|
|
|
i32[sp - 3] = i32[sp ]; // b
|
2015-05-15 09:28:30 +03:00
|
|
|
sp += 2;
|
|
|
|
continue;
|
|
|
|
case Bytecodes.DUP2_X2: // ... d, c, b, a -> ... b, a, d, c, b, a
|
2015-07-07 02:20:42 +03:00
|
|
|
i32[sp + 1] = i32[sp - 1]; // a
|
|
|
|
i32[sp ] = i32[sp - 2]; // b
|
|
|
|
i32[sp - 1] = i32[sp - 3]; // c
|
|
|
|
i32[sp - 2] = i32[sp - 4]; // d
|
|
|
|
i32[sp - 3] = i32[sp + 1]; // a
|
|
|
|
i32[sp - 4] = i32[sp ]; // b
|
2015-05-15 09:28:30 +03:00
|
|
|
sp += 2;
|
|
|
|
continue;
|
|
|
|
case Bytecodes.SWAP:
|
2015-07-07 02:20:42 +03:00
|
|
|
ia = i32[sp - 1];
|
|
|
|
i32[sp - 1] = i32[sp - 2];
|
|
|
|
i32[sp - 2] = ia;
|
2015-05-15 09:28:30 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.IINC:
|
|
|
|
index = code[pc++];
|
2015-05-08 09:37:31 +03:00
|
|
|
value = code[pc++] << 24 >> 24;
|
2015-05-09 23:37:04 +03:00
|
|
|
i32[lp + index] = i32[lp + index] + value | 0;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.IADD:
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp - 2] = (i32[sp - 2] + i32[sp - 1]) | 0; sp--;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LADD:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lAdd(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.FADD:
|
|
|
|
f32[sp - 2] = f32[sp - 2] + f32[sp - 1]; sp--;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.DADD:
|
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3]; ia = aliasedF64[0];
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1]; ib = aliasedF64[0];
|
|
|
|
aliasedF64[0] = ia + ib;
|
|
|
|
i32[sp - 4] = aliasedI32[0];
|
|
|
|
i32[sp - 3] = aliasedI32[1];
|
|
|
|
sp -= 2;
|
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ISUB:
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp - 2] = (i32[sp - 2] - i32[sp - 1]) | 0; sp--;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LSUB:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lSub(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.FSUB:
|
|
|
|
f32[sp - 2] = f32[sp - 2] - f32[sp - 1]; sp--;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.DSUB:
|
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3]; ia = aliasedF64[0];
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1]; ib = aliasedF64[0];
|
|
|
|
aliasedF64[0] = ia - ib;
|
|
|
|
i32[sp - 4] = aliasedI32[0];
|
|
|
|
i32[sp - 3] = aliasedI32[1];
|
|
|
|
sp -= 2;
|
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.IMUL:
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp - 2] = Math.imul(i32[sp - 2], i32[sp - 1]) | 0; sp--;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LMUL:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lMul(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.FMUL:
|
|
|
|
f32[sp - 2] = f32[sp - 2] * f32[sp - 1]; sp--;
|
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.DMUL:
|
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3]; ia = aliasedF64[0];
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1]; ib = aliasedF64[0];
|
|
|
|
aliasedF64[0] = ia * ib;
|
|
|
|
i32[sp - 4] = aliasedI32[0];
|
|
|
|
i32[sp - 3] = aliasedI32[1];
|
|
|
|
sp -= 2;
|
|
|
|
continue;
|
2015-05-08 11:19:17 +03:00
|
|
|
case Bytecodes.IDIV:
|
|
|
|
if (i32[sp - 1] === 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArithmeticException);
|
2015-05-08 11:19:17 +03:00
|
|
|
}
|
|
|
|
ia = i32[sp - 2];
|
|
|
|
ib = i32[sp - 1];
|
|
|
|
i32[sp - 2] = (ia === Constants.INT_MIN && ib === -1) ? ia : ((ia / ib) | 0); sp--;
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LDIV:
|
|
|
|
if (i32[sp - 2] === 0 && i32[sp - 1] === 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArithmeticException);
|
2015-05-08 10:52:22 +03:00
|
|
|
}
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lDiv(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.FDIV:
|
2015-05-21 02:42:01 +03:00
|
|
|
f32[sp - 2] = Math.fround(f32[sp - 2] / f32[sp - 1]); sp--;
|
2015-05-10 13:16:41 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.DDIV:
|
2015-05-10 00:57:32 +03:00
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3]; ia = aliasedF64[0];
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1]; ib = aliasedF64[0];
|
|
|
|
aliasedF64[0] = ia / ib;
|
|
|
|
i32[sp - 4] = aliasedI32[0];
|
|
|
|
i32[sp - 3] = aliasedI32[1];
|
|
|
|
sp -= 2;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 11:19:17 +03:00
|
|
|
case Bytecodes.IREM:
|
|
|
|
if (i32[sp - 1] === 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArithmeticException);
|
2015-05-08 11:19:17 +03:00
|
|
|
}
|
2015-05-09 12:47:47 +03:00
|
|
|
i32[sp - 2] = (i32[sp - 2] % i32[sp - 1]) | 0; sp--;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LREM:
|
|
|
|
if (i32[sp - 2] === 0 && i32[sp - 1] === 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.ArithmeticException);
|
2015-05-08 10:52:22 +03:00
|
|
|
}
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lRem(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 2;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.FREM:
|
2015-05-21 02:42:01 +03:00
|
|
|
f32[sp - 2] = Math.fround(f32[sp - 2] % f32[sp - 1]); sp--;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.DREM:
|
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3]; ia = aliasedF64[0];
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1]; ib = aliasedF64[0];
|
|
|
|
aliasedF64[0] = ia % ib;
|
|
|
|
i32[sp - 4] = aliasedI32[0];
|
|
|
|
i32[sp - 3] = aliasedI32[1];
|
|
|
|
sp -= 2;
|
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.INEG:
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[sp - 1] = -i32[sp - 1] | 0;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 10:45:07 +03:00
|
|
|
case Bytecodes.LNEG:
|
|
|
|
ASM._lNeg(sp - 2 << 2, sp - 2 << 2);
|
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.FNEG:
|
|
|
|
f32[sp - 1] = -f32[sp - 1];
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.DNEG:
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1];
|
|
|
|
aliasedF64[0] = -aliasedF64[0];
|
|
|
|
i32[sp - 2] = aliasedI32[0];
|
|
|
|
i32[sp - 1] = aliasedI32[1];
|
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ISHL:
|
2015-05-08 05:35:57 +03:00
|
|
|
ib = i32[--sp];
|
|
|
|
ia = i32[--sp];
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp++] = ia << ib;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LSHL:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lShl(sp - 3 << 2, sp - 3 << 2, i32[sp - 1]); sp -= 1;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.ISHR:
|
2015-05-08 05:35:57 +03:00
|
|
|
ib = i32[--sp];
|
|
|
|
ia = i32[--sp];
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp++] = ia >> ib;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LSHR:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lShr(sp - 3 << 2, sp - 3 << 2, i32[sp - 1]); sp -= 1;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IUSHR:
|
2015-05-08 05:35:57 +03:00
|
|
|
ib = i32[--sp];
|
|
|
|
ia = i32[--sp];
|
2015-05-08 05:29:32 +03:00
|
|
|
i32[sp++] = ia >>> ib;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.LUSHR:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lUshr(sp - 3 << 2, sp - 3 << 2, i32[sp - 1]); sp -= 1;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IAND:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp - 2] &= i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.LAND:
|
|
|
|
i32[sp - 4] &= i32[sp - 2];
|
|
|
|
i32[sp - 3] &= i32[sp - 1]; sp -= 2;
|
|
|
|
break;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IOR:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp - 2] |= i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.LOR:
|
|
|
|
i32[sp - 4] |= i32[sp - 2];
|
|
|
|
i32[sp - 3] |= i32[sp - 1]; sp -= 2;
|
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IXOR:
|
2015-05-08 05:35:57 +03:00
|
|
|
i32[sp - 2] ^= i32[--sp];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.LXOR:
|
|
|
|
i32[sp - 4] ^= i32[sp - 2];
|
|
|
|
i32[sp - 3] ^= i32[sp - 1]; sp -= 2;
|
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.LCMP:
|
2015-05-09 10:45:07 +03:00
|
|
|
ASM._lCmp(sp - 4 << 2, sp - 4 << 2, sp - 2 << 2); sp -= 3;
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.FCMPL:
|
|
|
|
case Bytecodes.FCMPG:
|
2015-05-21 02:42:01 +03:00
|
|
|
var FCMP_fb = f32[--sp];
|
|
|
|
var FCMP_fa = f32[--sp];
|
|
|
|
if (isNaN(FCMP_fa) || isNaN(FCMP_fb)) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = op === Bytecodes.FCMPL ? -1 : 1;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (FCMP_fa > FCMP_fb) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = 1;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (FCMP_fa < FCMP_fb) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = -1;
|
|
|
|
} else {
|
|
|
|
i32[sp++] = 0;
|
|
|
|
}
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.DCMPL:
|
|
|
|
case Bytecodes.DCMPG:
|
2015-05-10 02:22:53 +03:00
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1];
|
2015-05-21 02:42:01 +03:00
|
|
|
var DCMP_fb = aliasedF64[0];
|
2015-05-10 02:22:53 +03:00
|
|
|
aliasedI32[0] = i32[sp - 4];
|
|
|
|
aliasedI32[1] = i32[sp - 3];
|
2015-05-21 02:42:01 +03:00
|
|
|
var DCMP_fa = aliasedF64[0];
|
2015-05-09 07:14:44 +03:00
|
|
|
sp -= 4;
|
2015-05-21 02:42:01 +03:00
|
|
|
if (isNaN(DCMP_fa) || isNaN(DCMP_fb)) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = op === Bytecodes.DCMPL ? -1 : 1;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (DCMP_fa > DCMP_fb) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = 1;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (DCMP_fa < DCMP_fb) {
|
2015-05-09 07:14:44 +03:00
|
|
|
i32[sp++] = -1;
|
|
|
|
} else {
|
|
|
|
i32[sp++] = 0;
|
|
|
|
}
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFEQ:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] === 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFNE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] !== 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFLT:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] < 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFGE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] >= 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFGT:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] > 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFLE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] <= 0) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPEQ:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] === i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPNE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] !== i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPLT:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] > i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPGE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] <= i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPGT:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] < i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ICMPLE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 05:35:57 +03:00
|
|
|
if (i32[--sp] >= i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ACMPEQ:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-07-06 22:19:08 +03:00
|
|
|
if (i32[--sp] === i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IF_ACMPNE:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-07-06 22:19:08 +03:00
|
|
|
if (i32[--sp] !== i32[--sp]) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFNULL:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-07-06 22:19:08 +03:00
|
|
|
if (i32[--sp] === Constants.NULL) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.IFNONNULL:
|
2015-05-15 11:16:12 +03:00
|
|
|
targetPC = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-07-06 22:19:08 +03:00
|
|
|
if (i32[--sp] !== Constants.NULL) {
|
2015-05-06 11:26:46 +03:00
|
|
|
pc = targetPC;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.GOTO:
|
2015-05-15 11:16:12 +03:00
|
|
|
pc = opPC + ((code[pc++] << 8 | code[pc++]) << 16 >> 16);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
// case Bytecodes.GOTO_W:
|
|
|
|
// frame.pc = frame.read32Signed() - 1;
|
|
|
|
// break;
|
|
|
|
// case Bytecodes.JSR:
|
|
|
|
// pc = frame.read16();
|
|
|
|
// stack.push(frame.pc);
|
|
|
|
// frame.pc = pc;
|
|
|
|
// break;
|
|
|
|
// case Bytecodes.JSR_W:
|
|
|
|
// pc = frame.read32();
|
|
|
|
// stack.push(frame.pc);
|
|
|
|
// frame.pc = pc;
|
|
|
|
// break;
|
|
|
|
// case Bytecodes.RET:
|
|
|
|
// frame.pc = frame.local[frame.read8()];
|
|
|
|
// break;
|
|
|
|
case Bytecodes.I2L:
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[sp] = i32[sp - 1] < 0 ? -1 : 0; sp++;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.I2F:
|
|
|
|
aliasedF32[0] = i32[--sp];
|
2015-05-15 23:34:07 +03:00
|
|
|
i32[sp++] = aliasedI32[0];
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.I2D:
|
|
|
|
aliasedF64[0] = i32[--sp];
|
2015-05-15 23:34:07 +03:00
|
|
|
i32[sp++] = aliasedI32[0];
|
|
|
|
i32[sp++] = aliasedI32[1];
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
2015-05-08 10:52:22 +03:00
|
|
|
case Bytecodes.L2I:
|
|
|
|
sp--;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.L2F:
|
|
|
|
aliasedF32[0] = Math.fround(longToNumber(i32[sp - 2], i32[sp - 1]));
|
|
|
|
i32[sp - 2] = aliasedI32[0];
|
|
|
|
sp --;
|
|
|
|
continue;
|
|
|
|
case Bytecodes.L2D:
|
|
|
|
aliasedF64[0] = longToNumber(i32[sp - 2], i32[sp - 1]);
|
|
|
|
i32[sp - 2] = aliasedI32[0];
|
|
|
|
i32[sp - 1] = aliasedI32[1];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.F2I:
|
2015-05-21 02:42:01 +03:00
|
|
|
var F2I_fa = f32[sp - 1];
|
|
|
|
if (F2I_fa > Constants.INT_MAX) {
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp - 1] = Constants.INT_MAX;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (F2I_fa < Constants.INT_MIN) {
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp - 1] = Constants.INT_MIN;
|
|
|
|
} else {
|
2015-05-21 02:42:01 +03:00
|
|
|
i32[sp - 1] = F2I_fa | 0;
|
2015-05-10 13:16:41 +03:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
case Bytecodes.F2L:
|
2015-06-02 19:58:39 +03:00
|
|
|
value = Long.fromNumber(f32[--sp]);
|
|
|
|
i32[sp++] = value.low_;
|
|
|
|
i32[sp++] = value.high_;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.F2D:
|
|
|
|
aliasedF64[0] = f32[--sp];
|
2015-05-15 23:34:07 +03:00
|
|
|
i32[sp++] = aliasedI32[0];
|
|
|
|
i32[sp++] = aliasedI32[1];
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.D2I:
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1];
|
2015-05-21 02:42:01 +03:00
|
|
|
var D2I_fa = aliasedF64[0];
|
|
|
|
if (D2I_fa > Constants.INT_MAX) {
|
2015-05-10 00:57:32 +03:00
|
|
|
i32[sp - 2] = Constants.INT_MAX;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (D2I_fa < Constants.INT_MIN) {
|
2015-05-10 00:57:32 +03:00
|
|
|
i32[sp - 2] = Constants.INT_MIN;
|
|
|
|
} else {
|
2015-05-21 02:42:01 +03:00
|
|
|
i32[sp - 2] = D2I_fa | 0;
|
2015-05-10 00:57:32 +03:00
|
|
|
}
|
|
|
|
sp --;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-10 13:16:41 +03:00
|
|
|
case Bytecodes.D2L:
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1];
|
2015-05-21 02:42:01 +03:00
|
|
|
var D2L_fa = aliasedF64[0];
|
|
|
|
if (D2L_fa === Number.POSITIVE_INFINITY) {
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp - 2] = Constants.LONG_MAX_LOW;
|
|
|
|
i32[sp - 1] = Constants.LONG_MAX_HIGH;
|
2015-05-21 02:42:01 +03:00
|
|
|
} else if (D2L_fa === Number.NEGATIVE_INFINITY) {
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp - 2] = Constants.LONG_MIN_LOW;
|
|
|
|
i32[sp - 1] = Constants.LONG_MIN_HIGH;
|
|
|
|
} else {
|
2015-06-02 19:58:39 +03:00
|
|
|
value = Long.fromNumber(D2L_fa);
|
|
|
|
i32[sp - 2] = value.low_;
|
|
|
|
i32[sp - 1] = value.high_;
|
2015-05-10 13:16:41 +03:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
case Bytecodes.D2F:
|
|
|
|
aliasedI32[0] = i32[sp - 2];
|
|
|
|
aliasedI32[1] = i32[sp - 1];
|
|
|
|
f32[sp - 2] = Math.fround(aliasedF64[0]);
|
|
|
|
sp --;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.I2B:
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[sp - 1] = (i32[sp - 1] << 24) >> 24;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.I2C:
|
2015-05-08 03:31:22 +03:00
|
|
|
i32[sp - 1] &= 0xffff;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.I2S:
|
2015-05-11 10:27:23 +03:00
|
|
|
i32[sp - 1] = (i32[sp - 1] << 16) >> 16;
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 12:47:47 +03:00
|
|
|
case Bytecodes.TABLESWITCH:
|
|
|
|
pc = (pc + 3) & ~0x03; // Consume Padding
|
|
|
|
offset = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
ia = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
ib = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
value = i32[--sp];
|
|
|
|
if (value >= ia && value <= ib) {
|
|
|
|
pc += (value - ia) << 2;
|
|
|
|
offset = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
}
|
|
|
|
pc = opPC + offset;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-09 12:47:47 +03:00
|
|
|
case Bytecodes.LOOKUPSWITCH:
|
|
|
|
pc = (pc + 3) & ~0x03; // Consume Padding
|
|
|
|
offset = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
var npairs = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
value = i32[--sp];
|
|
|
|
lookup:
|
|
|
|
for (var i = 0; i < npairs; i++) {
|
|
|
|
var key = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
if (key === value) {
|
|
|
|
offset = code[pc++] << 24 | code[pc++] << 16 | code[pc++] << 8 | code[pc++];
|
|
|
|
} else {
|
|
|
|
pc += 4;
|
|
|
|
}
|
|
|
|
if (key >= value) {
|
|
|
|
break lookup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pc = opPC + offset;
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ANEWARRAY:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-08 01:17:05 +03:00
|
|
|
classInfo = resolveClass(index, ci);
|
2015-05-08 05:35:57 +03:00
|
|
|
size = i32[--sp];
|
2015-05-19 00:36:41 +03:00
|
|
|
if (size < 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NegativeArraySizeException);
|
2015-05-19 00:36:41 +03:00
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
i32[sp++] = newArray(classInfo, size);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.MULTIANEWARRAY:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-09 07:14:44 +03:00
|
|
|
classInfo = resolveClass(index, ci);
|
|
|
|
var dimensions = code[pc++];
|
|
|
|
var lengths = new Array(dimensions);
|
|
|
|
for (var i = 0; i < dimensions; i++) {
|
|
|
|
lengths[i] = i32[--sp];
|
2015-05-19 00:36:41 +03:00
|
|
|
if (size < 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NegativeArraySizeException);
|
2015-05-19 00:36:41 +03:00
|
|
|
}
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
i32[sp++] = J2ME.newMultiArray(classInfo, lengths.reverse());
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ARRAYLENGTH:
|
2015-07-06 22:19:08 +03:00
|
|
|
arrayAddr = i32[--sp];
|
2015-06-30 23:30:03 +03:00
|
|
|
if (arrayAddr === Constants.NULL) {
|
2015-06-27 01:40:20 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
i32[sp++] = i32[(arrayAddr + Constants.ARRAY_LENGTH_OFFSET >> 2)];
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.GETFIELD:
|
2015-05-09 07:14:44 +03:00
|
|
|
case Bytecodes.GETSTATIC:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-19 10:42:27 +03:00
|
|
|
fieldInfo = cp.resolved[index] || cp.resolveField(index, op === Bytecodes.GETSTATIC);
|
2015-05-09 07:14:44 +03:00
|
|
|
if (op === Bytecodes.GETSTATIC) {
|
2015-05-18 22:52:59 +03:00
|
|
|
thread.classInitAndUnwindCheck(fp, sp, opPC, fieldInfo.classInfo);
|
2015-05-16 04:58:19 +03:00
|
|
|
if (U) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
address = $.getStaticObjectAddress(fieldInfo.classInfo) + fieldInfo.byteOffset;
|
2015-06-27 01:40:20 +03:00
|
|
|
|
2015-06-30 23:30:03 +03:00
|
|
|
if (address === Constants.NULL) {
|
2015-06-27 01:40:20 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
|
|
|
}
|
2015-05-09 07:14:44 +03:00
|
|
|
} else {
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[--sp];
|
2015-06-27 01:40:20 +03:00
|
|
|
|
2015-06-30 23:30:03 +03:00
|
|
|
if (address === Constants.NULL) {
|
2015-06-27 01:40:20 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-06-19 00:02:09 +03:00
|
|
|
address += fieldInfo.byteOffset;
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-06-27 01:40:20 +03:00
|
|
|
|
2015-05-11 04:50:37 +03:00
|
|
|
switch (fieldInfo.kind) {
|
|
|
|
case Kind.Reference:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[address >> 2];
|
2015-05-11 04:50:37 +03:00
|
|
|
continue;
|
|
|
|
case Kind.Int:
|
|
|
|
case Kind.Byte:
|
|
|
|
case Kind.Char:
|
|
|
|
case Kind.Short:
|
|
|
|
case Kind.Boolean:
|
|
|
|
case Kind.Float:
|
|
|
|
i32[sp++] = i32[address >> 2];
|
|
|
|
continue;
|
|
|
|
case Kind.Long:
|
|
|
|
case Kind.Double:
|
|
|
|
i32[sp++] = i32[address >> 2];
|
|
|
|
i32[sp++] = i32[address + 4 >> 2];
|
|
|
|
continue;
|
|
|
|
default:
|
2015-08-11 03:06:21 +03:00
|
|
|
release || assert(false, "fieldInfo.kind");
|
2015-05-11 04:50:37 +03:00
|
|
|
}
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.PUTFIELD:
|
|
|
|
case Bytecodes.PUTSTATIC:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-19 10:42:27 +03:00
|
|
|
fieldInfo = cp.resolved[index] || cp.resolveField(index, op === Bytecodes.PUTSTATIC);
|
2015-05-11 04:50:37 +03:00
|
|
|
isStatic = op === Bytecodes.PUTSTATIC;
|
|
|
|
if (isStatic) {
|
2015-05-18 22:52:59 +03:00
|
|
|
thread.classInitAndUnwindCheck(fp, sp, opPC, fieldInfo.classInfo);
|
2015-05-16 04:58:19 +03:00
|
|
|
if (U) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
address = $.getStaticObjectAddress(fieldInfo.classInfo) + fieldInfo.byteOffset;
|
2015-05-09 07:14:44 +03:00
|
|
|
} else {
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[sp - (isTwoSlot(fieldInfo.kind) ? 3 : 2)];
|
2015-07-03 02:56:44 +03:00
|
|
|
|
|
|
|
if (address === Constants.NULL) {
|
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
|
|
|
continue;
|
2015-06-19 00:02:09 +03:00
|
|
|
}
|
2015-07-03 02:56:44 +03:00
|
|
|
|
2015-06-19 00:02:09 +03:00
|
|
|
address += fieldInfo.byteOffset;
|
2015-05-11 04:50:37 +03:00
|
|
|
}
|
|
|
|
switch (fieldInfo.kind) {
|
|
|
|
case Kind.Reference:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[address >> 2] = i32[--sp];
|
2015-05-11 04:50:37 +03:00
|
|
|
break;
|
|
|
|
case Kind.Int:
|
|
|
|
case Kind.Byte:
|
|
|
|
case Kind.Char:
|
|
|
|
case Kind.Short:
|
|
|
|
case Kind.Boolean:
|
|
|
|
case Kind.Float:
|
|
|
|
i32[address >> 2] = i32[--sp];
|
|
|
|
break;
|
|
|
|
case Kind.Long:
|
|
|
|
case Kind.Double:
|
|
|
|
i32[address + 4 >> 2] = i32[--sp];
|
|
|
|
i32[address >> 2] = i32[--sp];
|
|
|
|
break;
|
|
|
|
default:
|
2015-08-11 03:06:21 +03:00
|
|
|
release || assert(false, "fieldInfo.kind");
|
2015-05-11 04:50:37 +03:00
|
|
|
}
|
|
|
|
if (!isStatic) {
|
|
|
|
sp--; // Pop Reference
|
2015-05-09 07:14:44 +03:00
|
|
|
}
|
2015-05-11 02:00:43 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.NEW:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn(mi.implKey + " " + index);
|
2015-05-06 11:26:46 +03:00
|
|
|
classInfo = resolveClass(index, ci);
|
2015-05-18 22:52:59 +03:00
|
|
|
thread.classInitAndUnwindCheck(fp, sp, opPC, classInfo);
|
2015-05-06 11:26:46 +03:00
|
|
|
if (U) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
i32[sp++] = allocObject(classInfo);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.CHECKCAST:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-08 01:17:05 +03:00
|
|
|
classInfo = resolveClass(index, mi.classInfo);
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[sp - 1];
|
2015-07-02 03:52:49 +03:00
|
|
|
|
|
|
|
if (address === Constants.NULL) {
|
2015-06-19 00:02:09 +03:00
|
|
|
continue;
|
|
|
|
}
|
2015-07-02 03:52:49 +03:00
|
|
|
|
2015-07-24 00:50:06 +03:00
|
|
|
otherClassInfo = classIdToClassInfoMap[i32[address >> 2]];
|
2015-07-02 03:52:49 +03:00
|
|
|
|
2015-07-24 00:50:06 +03:00
|
|
|
if (!isAssignableTo(otherClassInfo, classInfo)) {
|
2015-05-19 09:17:39 +03:00
|
|
|
thread.set(fp, sp, opPC);
|
2015-05-08 01:17:05 +03:00
|
|
|
throw $.newClassCastException (
|
2015-07-24 00:50:06 +03:00
|
|
|
otherClassInfo.getClassNameSlow() + " is not assignable to " + classInfo.getClassNameSlow()
|
2015-05-08 01:17:05 +03:00
|
|
|
);
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.INSTANCEOF:
|
2015-05-09 23:37:04 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-08 01:17:05 +03:00
|
|
|
classInfo = resolveClass(index, ci);
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[--sp];
|
2015-07-02 03:52:49 +03:00
|
|
|
|
|
|
|
if (address === Constants.NULL) {
|
2015-06-19 00:02:09 +03:00
|
|
|
i32[sp++] = 0;
|
|
|
|
} else {
|
2015-07-24 00:50:06 +03:00
|
|
|
otherClassInfo = classIdToClassInfoMap[i32[address >> 2]];
|
|
|
|
i32[sp++] = isAssignableTo(otherClassInfo, classInfo) ? 1 : 0;
|
2015-06-19 00:02:09 +03:00
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.ATHROW:
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[--sp];
|
|
|
|
if (address === Constants.NULL) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
2015-05-08 01:17:05 +03:00
|
|
|
}
|
2015-06-19 00:02:09 +03:00
|
|
|
throw getHandle(address);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.MONITORENTER:
|
2015-07-06 22:19:08 +03:00
|
|
|
thread.ctx.monitorEnter(getMonitor(i32[--sp]));
|
2015-05-18 21:56:37 +03:00
|
|
|
release || assert(U !== VMState.Yielding, "Monitors should never yield.");
|
2015-05-06 11:26:46 +03:00
|
|
|
if (U === VMState.Pausing || U === VMState.Stopping) {
|
2015-05-18 21:56:37 +03:00
|
|
|
thread.set(fp, sp, pc); // We need to resume past the MONITORENTER bytecode.
|
2015-05-06 11:26:46 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.MONITOREXIT:
|
2015-07-06 22:19:08 +03:00
|
|
|
thread.ctx.monitorExit(getMonitor(i32[--sp]));
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-10 00:57:32 +03:00
|
|
|
case Bytecodes.WIDE:
|
|
|
|
var op = code[pc++];
|
|
|
|
switch (op) {
|
|
|
|
case Bytecodes.ILOAD:
|
|
|
|
case Bytecodes.FLOAD:
|
|
|
|
i32[sp++] = i32[lp + (code[pc++] << 8 | code[pc++])];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.ALOAD:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[lp + (code[pc++] << 8 | code[pc++])];
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.LLOAD:
|
|
|
|
case Bytecodes.DLOAD:
|
|
|
|
offset = lp + (code[pc++] << 8 | code[pc++]);
|
|
|
|
i32[sp++] = i32[offset];
|
|
|
|
i32[sp++] = i32[offset + 1];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.ISTORE:
|
|
|
|
case Bytecodes.FSTORE:
|
|
|
|
i32[lp + (code[pc++] << 8 | code[pc++])] = i32[--sp];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.ASTORE:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[lp + (code[pc++] << 8 | code[pc++])] = i32[--sp];
|
2015-05-10 00:57:32 +03:00
|
|
|
continue;
|
|
|
|
case Bytecodes.LSTORE:
|
|
|
|
case Bytecodes.DSTORE:
|
|
|
|
offset = lp + (code[pc++] << 8 | code[pc++]);
|
|
|
|
i32[offset + 1] = i32[--sp];
|
|
|
|
i32[offset] = i32[--sp];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.IINC:
|
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-16 00:36:01 +03:00
|
|
|
value = (code[pc++] << 8 | code[pc++]) << 16 >> 16;
|
2015-05-10 00:57:32 +03:00
|
|
|
i32[lp + index] = i32[lp + index] + value | 0;
|
|
|
|
continue;
|
|
|
|
//case Bytecodes.RET:
|
|
|
|
// this.pc = this.local[this.read16()];
|
|
|
|
// break;
|
|
|
|
default:
|
|
|
|
var opName = Bytecodes[op];
|
|
|
|
throw new Error("Wide opcode " + opName + " [" + op + "] not supported.");
|
|
|
|
}
|
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.NEWARRAY:
|
|
|
|
type = code[pc++];
|
2015-05-08 05:35:57 +03:00
|
|
|
size = i32[--sp];
|
2015-05-19 00:36:41 +03:00
|
|
|
if (size < 0) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NegativeArraySizeException);
|
2015-05-19 00:36:41 +03:00
|
|
|
}
|
2015-07-22 01:49:33 +03:00
|
|
|
i32[sp++] = newArray(PrimitiveClassInfo["????ZCFDBSIJ"[type]], size);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-08 01:17:05 +03:00
|
|
|
case Bytecodes.LRETURN:
|
|
|
|
case Bytecodes.DRETURN:
|
|
|
|
case Bytecodes.IRETURN:
|
|
|
|
case Bytecodes.FRETURN:
|
|
|
|
case Bytecodes.ARETURN:
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.RETURN:
|
2015-05-10 02:41:11 +03:00
|
|
|
var lastSP = sp;
|
2015-05-11 10:27:23 +03:00
|
|
|
var lastMI = mi;
|
2015-05-22 05:44:42 +03:00
|
|
|
var lastOP = op;
|
2015-05-19 21:13:27 +03:00
|
|
|
if (lastMI.isSynchronized) {
|
2015-07-08 20:44:27 +03:00
|
|
|
$.ctx.monitorExit(getMonitor(i32[fp + FrameLayout.MonitorOffset]));
|
2015-05-19 21:13:27 +03:00
|
|
|
}
|
2015-05-16 01:22:12 +03:00
|
|
|
opPC = i32[fp + FrameLayout.CallerRAOffset];
|
2015-05-10 02:41:11 +03:00
|
|
|
sp = fp - maxLocals;
|
2015-05-08 03:31:22 +03:00
|
|
|
fp = i32[fp + FrameLayout.CallerFPOffset];
|
|
|
|
mi = ref[fp + FrameLayout.CalleeMethodInfoOffset];
|
2015-05-06 11:26:46 +03:00
|
|
|
if (mi === null) {
|
2015-05-16 01:22:12 +03:00
|
|
|
thread.set(fp, sp, opPC);
|
2015-05-06 11:26:46 +03:00
|
|
|
thread.popFrame(null);
|
2015-05-10 02:41:11 +03:00
|
|
|
// REDUX: What do we do about the return value here?
|
2015-05-06 11:26:46 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-05-08 03:31:22 +03:00
|
|
|
maxLocals = mi.codeAttribute.max_locals;
|
2015-05-08 05:29:32 +03:00
|
|
|
lp = fp - maxLocals;
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.outdent();
|
2015-05-11 10:27:23 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("<< I " + lastMI.implKey);
|
2015-05-06 11:26:46 +03:00
|
|
|
ci = mi.classInfo;
|
|
|
|
cp = ci.constantPool;
|
|
|
|
code = mi.codeAttribute.code;
|
2015-05-22 05:44:42 +03:00
|
|
|
var op = code[opPC];
|
|
|
|
if (op >= Bytecodes.FIRST_INVOKE && op <= Bytecodes.LAST_INVOKE) {
|
|
|
|
// Calculate the PC based on the size of the caller's invoke bytecode.
|
|
|
|
pc = opPC + (code[opPC] === Bytecodes.INVOKEINTERFACE ? 5 : 3);
|
|
|
|
// Push return value.
|
|
|
|
switch (lastOP) {
|
|
|
|
case Bytecodes.LRETURN:
|
|
|
|
case Bytecodes.DRETURN:
|
|
|
|
i32[sp++] = i32[lastSP - 2]; // Low Bits
|
2015-05-10 13:16:41 +03:00
|
|
|
// Fallthrough
|
2015-05-22 05:44:42 +03:00
|
|
|
case Bytecodes.IRETURN:
|
|
|
|
case Bytecodes.FRETURN:
|
|
|
|
i32[sp++] = i32[lastSP - 1];
|
|
|
|
continue;
|
|
|
|
case Bytecodes.ARETURN:
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = i32[lastSP - 1];
|
2015-05-22 05:44:42 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We are returning to a bytecode that trapped.
|
|
|
|
// REDUX: I need to think through this some more, why do we need to subtract the CallerSaveSize? Is it
|
|
|
|
// because of the the null frame? This frame should have been spliced out, ... is this a coincidence?
|
|
|
|
sp -= FrameLayout.CallerSaveSize;
|
|
|
|
pc = opPC;
|
2015-05-10 02:41:11 +03:00
|
|
|
}
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.INVOKEVIRTUAL:
|
|
|
|
case Bytecodes.INVOKESPECIAL:
|
|
|
|
case Bytecodes.INVOKESTATIC:
|
|
|
|
case Bytecodes.INVOKEINTERFACE:
|
2015-05-08 11:19:17 +03:00
|
|
|
index = code[pc++] << 8 | code[pc++];
|
2015-05-06 11:26:46 +03:00
|
|
|
if (op === Bytecodes.INVOKEINTERFACE) {
|
|
|
|
pc += 2; // Args Number & Zero
|
|
|
|
}
|
2015-05-11 04:50:37 +03:00
|
|
|
isStatic = (op === Bytecodes.INVOKESTATIC);
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
// Resolve method and do the class init check if necessary.
|
2015-07-07 02:49:45 +03:00
|
|
|
var calleeMethodInfo: MethodInfo = cp.resolved[index] || cp.resolveMethod(index, isStatic);
|
2015-05-16 04:58:19 +03:00
|
|
|
var calleeTargetMethodInfo: MethodInfo = null;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
var callee = null;
|
2015-06-19 00:02:09 +03:00
|
|
|
|
|
|
|
if (isStatic) {
|
2015-07-03 13:52:41 +03:00
|
|
|
address = Constants.NULL;
|
2015-06-19 00:02:09 +03:00
|
|
|
} else {
|
2015-07-06 22:19:08 +03:00
|
|
|
address = i32[sp - calleeMethodInfo.argumentSlots];
|
2015-07-22 01:49:33 +03:00
|
|
|
classInfo = (address !== Constants.NULL) ? classIdToClassInfoMap[i32[address >> 2]] : null;
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
2015-05-16 04:58:19 +03:00
|
|
|
|
|
|
|
if (isStatic) {
|
2015-05-18 22:52:59 +03:00
|
|
|
thread.classInitAndUnwindCheck(fp, sp, opPC, calleeMethodInfo.classInfo);
|
2015-05-16 04:58:19 +03:00
|
|
|
if (U) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
switch (op) {
|
|
|
|
case Bytecodes.INVOKESPECIAL:
|
2015-07-03 13:52:41 +03:00
|
|
|
if (address === Constants.NULL) {
|
2015-05-20 09:25:42 +03:00
|
|
|
thread.throwException(fp, sp, opPC, ExceptionType.NullPointerException);
|
2015-05-19 00:36:41 +03:00
|
|
|
}
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.INVOKESTATIC:
|
2015-05-09 07:14:44 +03:00
|
|
|
calleeTargetMethodInfo = calleeMethodInfo;
|
2015-05-06 11:26:46 +03:00
|
|
|
break;
|
|
|
|
case Bytecodes.INVOKEVIRTUAL:
|
2015-07-22 01:49:33 +03:00
|
|
|
calleeTargetMethodInfo = classInfo.vTable[calleeMethodInfo.vTableIndex];
|
2015-05-09 07:14:44 +03:00
|
|
|
break;
|
2015-05-06 11:26:46 +03:00
|
|
|
case Bytecodes.INVOKEINTERFACE:
|
2015-07-22 01:49:33 +03:00
|
|
|
calleeTargetMethodInfo = classInfo.iTable[calleeMethodInfo.mangledName];
|
2015-05-06 11:26:46 +03:00
|
|
|
break;
|
|
|
|
default:
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Not Implemented: " + Bytecodes[op]);
|
2015-05-06 11:26:46 +03:00
|
|
|
assert(false, "Not Implemented: " + Bytecodes[op]);
|
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
// Call Native or Compiled Method.
|
|
|
|
if (calleeTargetMethodInfo.isNative || calleeTargetMethodInfo.state === MethodState.Compiled) {
|
2015-05-21 02:42:01 +03:00
|
|
|
var kind = Kind.Void;
|
2015-05-10 13:16:41 +03:00
|
|
|
var signatureKinds = calleeTargetMethodInfo.signatureKinds;
|
2015-05-09 07:14:44 +03:00
|
|
|
callee = calleeTargetMethodInfo.fn || getLinkedMethod(calleeTargetMethodInfo);
|
2015-05-28 20:15:32 +03:00
|
|
|
var returnValue;
|
|
|
|
|
|
|
|
// Fast path for the no-argument case.
|
|
|
|
if (signatureKinds.length === 1) {
|
|
|
|
if (!isStatic) {
|
|
|
|
--sp; // Pop Reference
|
|
|
|
}
|
2015-05-18 01:12:44 +03:00
|
|
|
|
2015-05-28 20:15:32 +03:00
|
|
|
thread.set(fp, sp, opPC);
|
2015-05-18 01:12:44 +03:00
|
|
|
|
2015-07-03 13:46:09 +03:00
|
|
|
returnValue = callee(address);
|
2015-05-28 20:15:32 +03:00
|
|
|
} else {
|
|
|
|
args.length = 0;
|
|
|
|
|
|
|
|
for (var i = signatureKinds.length - 1; i > 0; i--) {
|
|
|
|
kind = signatureKinds[i];
|
|
|
|
switch (kind) {
|
|
|
|
case Kind.Double: // Doubles are passed in as a number value.
|
|
|
|
aliasedI32[1] = i32[--sp];
|
|
|
|
aliasedI32[0] = i32[--sp];
|
|
|
|
args.unshift(aliasedF64[0]);
|
|
|
|
break;
|
|
|
|
case Kind.Float:
|
|
|
|
args.unshift(f32[--sp]);
|
|
|
|
break;
|
|
|
|
case Kind.Long:
|
|
|
|
args.unshift(i32[--sp]); // High Bits
|
|
|
|
// Fallthrough
|
|
|
|
case Kind.Int:
|
|
|
|
case Kind.Byte:
|
|
|
|
case Kind.Char:
|
|
|
|
case Kind.Short:
|
|
|
|
case Kind.Boolean:
|
|
|
|
args.unshift(i32[--sp]);
|
|
|
|
break;
|
|
|
|
case Kind.Reference:
|
2015-07-07 19:00:06 +03:00
|
|
|
args.unshift(i32[--sp]);
|
2015-05-28 20:15:32 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
release || assert(false, "Invalid Kind: " + Kind[kind]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isStatic) {
|
|
|
|
--sp; // Pop Reference
|
|
|
|
}
|
|
|
|
|
|
|
|
thread.set(fp, sp, opPC);
|
|
|
|
|
|
|
|
if (!release) {
|
|
|
|
// assert(callee.length === args.length, "Function " + callee + " (" + calleeTargetMethodInfo.implKey + "), should have " + args.length + " arguments.");
|
|
|
|
}
|
|
|
|
|
2015-06-30 04:37:22 +03:00
|
|
|
args.unshift(address);
|
2015-07-03 02:28:27 +03:00
|
|
|
returnValue = callee.apply(null, args);
|
2015-05-28 20:15:32 +03:00
|
|
|
}
|
2015-05-15 04:09:45 +03:00
|
|
|
|
2015-05-17 21:35:37 +03:00
|
|
|
if (!release) {
|
2015-06-19 00:02:09 +03:00
|
|
|
// checkReturnValue(calleeMethodInfo, returnValue, tempReturn0);
|
2015-05-17 21:35:37 +03:00
|
|
|
}
|
2015-05-15 04:09:45 +03:00
|
|
|
|
|
|
|
if (U) {
|
2015-05-18 21:56:37 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("<< U Unwind: " + VMState[U]);
|
2015-05-15 04:09:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-10 13:16:41 +03:00
|
|
|
kind = signatureKinds[0];
|
|
|
|
|
|
|
|
// Push return value.
|
|
|
|
switch (kind) {
|
|
|
|
case Kind.Double: // Doubles are passed in as a number value.
|
2015-05-17 21:35:37 +03:00
|
|
|
aliasedF64[0] = returnValue;
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp++] = aliasedI32[0];
|
|
|
|
i32[sp++] = aliasedI32[1];
|
|
|
|
continue;
|
|
|
|
case Kind.Float:
|
2015-05-17 21:35:37 +03:00
|
|
|
f32[sp++] = returnValue;
|
2015-05-10 13:16:41 +03:00
|
|
|
continue;
|
|
|
|
case Kind.Long:
|
2015-05-17 21:35:37 +03:00
|
|
|
i32[sp++] = returnValue;
|
2015-05-10 13:16:41 +03:00
|
|
|
i32[sp++] = tempReturn0;
|
|
|
|
continue;
|
|
|
|
case Kind.Int:
|
|
|
|
case Kind.Byte:
|
|
|
|
case Kind.Char:
|
|
|
|
case Kind.Short:
|
|
|
|
case Kind.Boolean:
|
2015-05-17 21:35:37 +03:00
|
|
|
i32[sp++] = returnValue;
|
2015-05-10 13:16:41 +03:00
|
|
|
continue;
|
|
|
|
case Kind.Reference:
|
2015-07-03 02:12:45 +03:00
|
|
|
release || assert(returnValue !== "number", "native return value is a number");
|
2015-07-06 22:19:08 +03:00
|
|
|
i32[sp++] = returnValue;
|
2015-05-10 13:16:41 +03:00
|
|
|
continue;
|
|
|
|
case Kind.Void:
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
release || assert(false, "Invalid Kind: " + Kind[kind]);
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
|
|
|
continue;
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
|
2015-05-18 21:56:37 +03:00
|
|
|
// Call Interpreted Method.
|
2015-05-19 10:42:27 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn(">> I " + calleeTargetMethodInfo.implKey);
|
2015-05-06 11:26:46 +03:00
|
|
|
mi = calleeTargetMethodInfo;
|
2015-05-08 03:31:22 +03:00
|
|
|
maxLocals = mi.codeAttribute.max_locals;
|
2015-05-06 11:26:46 +03:00
|
|
|
ci = mi.classInfo;
|
|
|
|
cp = ci.constantPool;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-16 04:58:19 +03:00
|
|
|
var callerFPOffset = fp;
|
2015-05-06 11:26:46 +03:00
|
|
|
// Reserve space for non-parameter locals.
|
2015-05-16 04:58:19 +03:00
|
|
|
lp = sp - mi.argumentSlots;
|
|
|
|
fp = lp + maxLocals;
|
|
|
|
sp = fp + FrameLayout.CallerSaveSize;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
// Caller saved values.
|
2015-05-16 04:58:19 +03:00
|
|
|
i32[fp + FrameLayout.CallerRAOffset] = opPC;
|
|
|
|
i32[fp + FrameLayout.CallerFPOffset] = callerFPOffset;
|
|
|
|
ref[fp + FrameLayout.CalleeMethodInfoOffset] = mi;
|
2015-07-08 20:44:27 +03:00
|
|
|
i32[fp + FrameLayout.MonitorOffset] = Constants.NULL; // Monitor
|
2015-05-16 04:58:19 +03:00
|
|
|
|
2015-05-18 21:56:37 +03:00
|
|
|
// Reset PC.
|
|
|
|
opPC = pc = 0;
|
|
|
|
|
2015-05-16 04:58:19 +03:00
|
|
|
if (calleeTargetMethodInfo.isSynchronized) {
|
2015-07-10 01:33:09 +03:00
|
|
|
monitorAddr = calleeTargetMethodInfo.isStatic
|
2015-07-22 01:49:33 +03:00
|
|
|
? $.getClassObjectAddress(calleeTargetMethodInfo.classInfo)
|
2015-07-10 01:33:09 +03:00
|
|
|
: address;
|
|
|
|
i32[fp + FrameLayout.MonitorOffset] = monitorAddr;
|
|
|
|
$.ctx.monitorEnter(getMonitor(monitorAddr));
|
2015-05-18 21:56:37 +03:00
|
|
|
release || assert(U !== VMState.Yielding, "Monitors should never yield.");
|
2015-05-16 04:58:19 +03:00
|
|
|
if (U === VMState.Pausing || U === VMState.Stopping) {
|
2015-05-20 02:42:12 +03:00
|
|
|
thread.set(fp, sp, opPC);
|
2015-05-16 04:58:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-06 11:26:46 +03:00
|
|
|
code = mi.codeAttribute.code;
|
2015-04-30 19:51:47 +03:00
|
|
|
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.indent();
|
2015-05-06 11:26:46 +03:00
|
|
|
continue;
|
|
|
|
default:
|
2015-05-10 03:28:04 +03:00
|
|
|
release || traceWriter && traceWriter.writeLn("Not Implemented: " + Bytecodes[op] + ", PC: " + opPC + ", CODE: " + code.length);
|
|
|
|
release || assert(false, "Not Implemented: " + Bytecodes[op]);
|
2015-05-08 10:57:48 +03:00
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2015-05-11 04:33:23 +03:00
|
|
|
release || traceWriter && traceWriter.redLn("XXX I Caught: " + e + ", details: " + toName(e));
|
|
|
|
// release || traceWriter && traceWriter.writeLns(e.stack);
|
2015-05-10 03:28:04 +03:00
|
|
|
// release || traceWriter && traceWriter.writeLn(jsGlobal.getBacktrace());
|
2015-05-11 04:33:23 +03:00
|
|
|
|
|
|
|
thread.set(fp, sp, opPC);
|
2015-05-08 01:17:05 +03:00
|
|
|
e = translateException(e);
|
2015-07-22 01:49:33 +03:00
|
|
|
if (!e.classInfo) {
|
2015-05-11 04:33:23 +03:00
|
|
|
// A non-java exception was thrown. Rethrow so it is not handled by exceptionUnwind.
|
2015-05-08 01:17:05 +03:00
|
|
|
throw e;
|
|
|
|
}
|
2015-05-11 04:33:23 +03:00
|
|
|
thread.exceptionUnwind(e);
|
2015-05-18 22:52:59 +03:00
|
|
|
|
|
|
|
// Load thread state after exception unwind.
|
|
|
|
fp = thread.fp;
|
|
|
|
sp = thread.sp;
|
|
|
|
pc = thread.pc;
|
2015-05-08 01:17:05 +03:00
|
|
|
|
|
|
|
mi = thread.frame.methodInfo;
|
2015-05-08 03:31:22 +03:00
|
|
|
maxLocals = mi.codeAttribute.max_locals;
|
2015-05-08 05:29:32 +03:00
|
|
|
lp = fp - maxLocals;
|
2015-05-08 01:17:05 +03:00
|
|
|
ci = mi.classInfo;
|
|
|
|
cp = ci.constantPool;
|
|
|
|
code = mi.codeAttribute.code;
|
|
|
|
continue;
|
2015-05-06 11:26:46 +03:00
|
|
|
}
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|
|
|
|
}
|
2015-05-09 12:47:47 +03:00
|
|
|
|
|
|
|
// print(disassemble(interpret));
|
2015-04-30 19:51:47 +03:00
|
|
|
}
|