remove localBase, which is constantly 0.

This commit is contained in:
Yuan Xulei 2015-04-02 16:33:39 +08:00
Родитель da2f45501d
Коммит 42641c7c4c
5 изменённых файлов: 23 добавлений и 26 удалений

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

@ -1066,7 +1066,7 @@ module J2ME {
!calleeTargetMethodInfo.isSynchronized &&
!calleeTargetMethodInfo.isNative &&
calleeTargetMethodInfo.state !== MethodState.Compiled) {
var calleeFrame = Frame.create(calleeTargetMethodInfo, [], 0);
var calleeFrame = Frame.create(calleeTargetMethodInfo, []);
ArrayUtilities.popManyInto(stack, calleeTargetMethodInfo.consumeArgumentSlots, calleeFrame.local);
frames.push(calleeFrame);
frame = calleeFrame;
@ -1174,7 +1174,7 @@ module J2ME {
}
// Call method directly in the interpreter if we can.
if (calleeTargetMethodInfo && !calleeTargetMethodInfo.isNative && calleeTargetMethodInfo.state !== MethodState.Compiled) {
var calleeFrame = Frame.create(calleeTargetMethodInfo, [], 0);
var calleeFrame = Frame.create(calleeTargetMethodInfo, []);
ArrayUtilities.popManyInto(stack, calleeTargetMethodInfo.consumeArgumentSlots, calleeFrame.local);
frames.push(calleeFrame);
frame = calleeFrame;

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

@ -18,7 +18,7 @@ function asyncImpl(returnKind, promise) {
}, function(exception) {
var classInfo = CLASSES.getClass("org/mozilla/internal/Sys");
var methodInfo = classInfo.getMethodByNameString("throwException", "(Ljava/lang/Exception;)V", true);
ctx.frames.push(Frame.create(methodInfo, [exception], 0));
ctx.frames.push(Frame.create(methodInfo, [exception]));
ctx.execute();
});
$.pause("Async");
@ -309,7 +309,7 @@ Native["java/lang/Class.invoke_clinit.()V"] = function() {
var className = classInfo.getClassNameSlow();
var clinit = classInfo.staticInitializer;
if (clinit && clinit.classInfo.getClassNameSlow() === className) {
$.ctx.executeFrame(Frame.create(clinit, [], 0));
$.ctx.executeFrame(Frame.create(clinit, []));
}
};
@ -538,7 +538,7 @@ Native["java/lang/Thread.start0.()V"] = function() {
var classInfo = CLASSES.getClass("org/mozilla/internal/Sys");
var run = classInfo.getMethodByNameString("runThread", "(Ljava/lang/Thread;)V", true);
newCtx.start([new Frame(run, [ this ], 0)]);
newCtx.start([Frame.create(run, [ this ])]);
}
Native["java/lang/Thread.isAlive.()Z"] = function() {

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

@ -79,7 +79,6 @@ module J2ME {
pc: number;
opPC: number;
cp: any;
localBase: number;
lockObject: java.lang.Object;
static dirtyStack: Frame [] = [];
@ -87,24 +86,24 @@ module J2ME {
/**
* Denotes the start of the context frame stack.
*/
static Start: Frame = Frame.create(null, null, 0);
static Start: Frame = Frame.create(null, null);
/**
* Marks a frame set.
*/
static Marker: Frame = Frame.create(null, null, 0);
static Marker: Frame = Frame.create(null, null);
static isMarker(frame: Frame) {
return frame.methodInfo === null;
}
constructor(methodInfo: MethodInfo, local: any [], localBase: number) {
constructor(methodInfo: MethodInfo, local: any []) {
frameCount ++;
this.stack = [];
this.reset(methodInfo, local, localBase);
this.reset(methodInfo, local);
}
reset(methodInfo: MethodInfo, local: any [], localBase: number) {
reset(methodInfo: MethodInfo, local: any []) {
this.methodInfo = methodInfo;
this.cp = methodInfo ? methodInfo.classInfo.constantPool : null;
this.code = methodInfo ? methodInfo.codeAttribute.code : null;
@ -112,18 +111,17 @@ module J2ME {
this.opPC = 0;
this.stack.length = 0;
this.local = local;
this.localBase = localBase;
this.lockObject = null;
}
static create(methodInfo: MethodInfo, local: any [], localBase: number): Frame {
static create(methodInfo: MethodInfo, local: any []): Frame {
var dirtyStack = Frame.dirtyStack;
if (dirtyStack.length) {
var frame = dirtyStack.pop();
frame.reset(methodInfo, local, localBase);
frame.reset(methodInfo, local);
return frame;
} else {
return new Frame(methodInfo, local, localBase);
return new Frame(methodInfo, local);
}
}
@ -133,16 +131,15 @@ module J2ME {
}
getLocal(i: number): any {
return this.local[this.localBase + i];
return this.local[i];
}
setLocal(i: number, value: any) {
this.local[this.localBase + i] = value;
this.local[i] = value;
}
incLocal(i: number, value: any) {
var j = this.localBase + i;
this.local[j] = this.local[j] + value | 0;
this.local[i] += value | 0;
}
read8(): number {
@ -618,7 +615,7 @@ module J2ME {
bailout(methodInfo: MethodInfo, pc: number, nextPC: number, local: any [], stack: any [], lockObject: java.lang.Object) {
// perfWriter && perfWriter.writeLn("C Unwind: " + methodInfo.implKey);
var frame = Frame.create(methodInfo, local, 0);
var frame = Frame.create(methodInfo, local);
frame.stack = stack;
frame.pc = nextPC;
frame.opPC = pc;

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

@ -38,9 +38,9 @@ module J2ME {
// The <init> frames go at the end of the array so they are executed first to initialize the thread and isolate.
ctx.start([
Frame.create(isolateClassInfo.getMethodByNameString("start", "()V"), [ isolate ], 0),
Frame.create(isolateClassInfo.getMethodByNameString("start", "()V"), [ isolate ]),
Frame.create(isolateClassInfo.getMethodByNameString("<init>", "(Ljava/lang/String;[Ljava/lang/String;)V"),
[ isolate, J2ME.newString(className.replace(/\./g, "/")), array ], 0)
[ isolate, J2ME.newString(className.replace(/\./g, "/")), array ])
]);
release || Debug.assert(!U, "Unexpected unwind during isolate initialization.");
}
@ -70,9 +70,9 @@ module J2ME {
}
ctx.start([
Frame.create(entryPoint, [ args ], 0),
Frame.create(entryPoint, [ args ]),
Frame.create(CLASSES.java_lang_Thread.getMethodByNameString("<init>", "(Ljava/lang/String;)V"),
[ runtime.mainThread, J2ME.newString("main") ], 0)
[ runtime.mainThread, J2ME.newString("main") ])
]);
release || Debug.assert(!U, "Unexpected unwind during isolate initialization.");
}

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

@ -1273,7 +1273,7 @@ module J2ME {
// Adapter for the most common case.
if (!methodInfo.isSynchronized && !methodInfo.hasTwoSlotArguments) {
var method = function fastInterpreterFrameAdapter() {
var frame = Frame.create(methodInfo, [], 0);
var frame = Frame.create(methodInfo, []);
var j = 0;
if (!methodInfo.isStatic) {
frame.setLocal(j++, this);
@ -1289,7 +1289,7 @@ module J2ME {
}
var method = function interpreterFrameAdapter() {
var frame = Frame.create(methodInfo, [], 0);
var frame = Frame.create(methodInfo, []);
var j = 0;
if (!methodInfo.isStatic) {
frame.setLocal(j++, this);