This commit is contained in:
Michael Bebenita 2015-08-12 20:11:37 -07:00
Родитель 2e4dee73e5
Коммит e52f099ae0
4 изменённых файлов: 25 добавлений и 4 удалений

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

@ -873,21 +873,24 @@ module J2ME {
var object = this.pop(Kind.Reference);
this.emitNullPointerCheck(object);
args.unshift(object);
var objClass = "CI[i32[(" + object + "+" + Constants.OBJ_CLASS_ID_OFFSET + ")>>2]]";
if (opcode === Bytecodes.INVOKESPECIAL) {
methodId = methodInfo.id;
call = "(LM[" + methodId + "]||" + "GLM(" + methodId + "))(" + args.join(",") + ")";
} else if (opcode === Bytecodes.INVOKEVIRTUAL) {
methodId = objClass + ".vTable[" + methodInfo.vTableIndex + "].id";
var classId = "i32[(" + object + "|0)>>2]";
call = "(VT[" + classId + "][" + methodInfo.vTableIndex + "]||" + "GLVM(" + classId + "," + methodInfo.vTableIndex + "))(" + args.join(",") + ")";
} else if (opcode === Bytecodes.INVOKEINTERFACE) {
var objClass = "CI[i32[(" + object + "+" + Constants.OBJ_CLASS_ID_OFFSET + ")>>2]]";
methodId = objClass + ".iTable['" + methodInfo.mangledName + "'].id";
call = "(LM[" + methodId + "]||" + "GLM(" + methodId + "))(" + args.join(",") + ")";
} else {
Debug.unexpected(Bytecodes[opcode]);
}
} else {
args.unshift(String(Constants.NULL));
methodId = methodInfo.id;
call = "(LM[" + methodId + "]||" + "GLM(" + methodId + "))(" + args.join(",") + ")";
}
call = "(LM[" + methodId + "]||" + "GLM(" + methodId + "))(" + args.join(",") + ")";
if (methodInfo.implKey in inlineMethods) {
emitDebugInfoComments && this.blockEmitter.writeLn("// Inlining: " + methodInfo.implKey);

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

@ -174,7 +174,7 @@ module J2ME {
* to dictionary mode. I've experienced ION bailouts from non-dense new Arrays(), hence this helper
* method.
*/
export function makeDenseArray(length, value) {
export function makeDenseArray(length: number, value) {
var array = new Array(length);
for (var i = 0; i < length; i++) {
array[i] = value;

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

@ -1304,6 +1304,9 @@ module J2ME {
}
}
}
// Pre-allocate linkedVTableMap.
classIdToLinkedVTableMap[this.id] = ArrayUtilities.makeDenseArray(this.vTable.length, null);
}
private buildITable() {

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

@ -681,6 +681,11 @@ module J2ME {
export var methodIdToMethodInfoMap: Map<number, MethodInfo> = Object.create(null);
export var linkedMethods: Map<number, Function> = Object.create(null);
/**
* Maps classIds to vTables containing JS functions.
*/
export var classIdToLinkedVTableMap = ArrayUtilities.makeDenseArray(Constants.MAX_CLASS_ID + 1, null);
export function getClassInfo(addr: number) {
release || assert(addr !== Constants.NULL, "addr !== Constants.NULL");
release || assert(i32[addr + Constants.OBJ_CLASS_ID_OFFSET >> 2] != 0,
@ -976,6 +981,10 @@ module J2ME {
return getLinkedMethod(methodIdToMethodInfoMap[methodId]);
}
export function getLinkedVirtualMethodById(classId: number, vTableIndex: number) {
return getLinkedMethod(classIdToClassInfoMap[classId].vTable[vTableIndex]);
}
function linkMethod(methodInfo: MethodInfo) {
runtimeCounter && runtimeCounter.count("linkMethod");
var fn;
@ -1121,6 +1130,10 @@ module J2ME {
methodInfo.fn = fn;
linkedMethods[methodInfo.id] = fn;
if (methodInfo.vTableIndex >= 0) {
classIdToLinkedVTableMap[methodInfo.classInfo.id][methodInfo.vTableIndex] = fn;
}
}
/**
@ -1976,6 +1989,8 @@ var CI = J2ME.classIdToClassInfoMap;
var MI = J2ME.methodIdToMethodInfoMap;
var LM = J2ME.linkedMethods;
var GLM = J2ME.getLinkedMethodById;
var GLVM = J2ME.getLinkedVirtualMethodById;
var VT = J2ME.classIdToLinkedVTableMap;
var CIC = J2ME.classInitCheck;
var GH = J2ME.getHandle;