зеркало из https://github.com/mozilla/pluotsorbet.git
Don't allocate when calling methods from the interpreter.
This commit is contained in:
Родитель
08276671f6
Коммит
624135b5ed
12
actors.ts
12
actors.ts
|
@ -90,7 +90,10 @@ module J2ME {
|
|||
exception_table: ExceptionHandler [];
|
||||
max_locals: number;
|
||||
max_stack: number;
|
||||
consumes: number;
|
||||
/**
|
||||
* If greater than -1, then the number of arguments to pop of the stack when calling this function.
|
||||
*/
|
||||
argumentSlots: number;
|
||||
signatureDescriptor: SignatureDescriptor;
|
||||
signature: string;
|
||||
implKey: string;
|
||||
|
@ -147,9 +150,10 @@ module J2ME {
|
|||
this.mangledClassAndMethodName = mangleClassAndMethod(this);
|
||||
|
||||
this.signatureDescriptor = SignatureDescriptor.makeSignatureDescriptor(this.signature);
|
||||
this.consumes = this.signatureDescriptor.getArgumentSlotCount();
|
||||
if (!this.isStatic) {
|
||||
this.consumes++;
|
||||
if (this.signatureDescriptor.hasTwoSlotArguments()) {
|
||||
this.argumentSlots = -1;
|
||||
} else {
|
||||
this.argumentSlots = this.signatureDescriptor.getArgumentSlotCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,11 +72,10 @@ module J2ME {
|
|||
return this.stack[i];
|
||||
}
|
||||
|
||||
popArguments(signatureDescriptor: SignatureDescriptor): any [] {
|
||||
popArgumentsInto(signatureDescriptor: SignatureDescriptor, args): any [] {
|
||||
var stack = this.stack;
|
||||
var typeDescriptors = signatureDescriptor.typeDescriptors;
|
||||
var argumentSlotCount = signatureDescriptor.getArgumentSlotCount();
|
||||
var args = new Array(signatureDescriptor.getArgumentCount());
|
||||
for (var i = 1, j = stack.length - argumentSlotCount, k = 0; i < typeDescriptors.length; i++) {
|
||||
var typeDescriptor = typeDescriptors[i];
|
||||
args[k++] = stack[j++];
|
||||
|
@ -86,6 +85,7 @@ module J2ME {
|
|||
}
|
||||
release || assert(j === stack.length && k === signatureDescriptor.getArgumentCount());
|
||||
stack.length -= argumentSlotCount;
|
||||
args.length = k;
|
||||
return args;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@ module J2ME {
|
|||
*/
|
||||
export var ops = 0;
|
||||
|
||||
/**
|
||||
* Temporarily used for fn.apply.
|
||||
*/
|
||||
var argArray = [];
|
||||
|
||||
export function interpret(ctx: Context) {
|
||||
var frame = ctx.current();
|
||||
|
||||
|
@ -1081,12 +1086,35 @@ module J2ME {
|
|||
fn = methodInfo.fn;
|
||||
}
|
||||
|
||||
var args = frame.popArguments(methodInfo.signatureDescriptor);
|
||||
if (!isStatic) {
|
||||
stack.pop();
|
||||
var returnValue;
|
||||
switch (methodInfo.argumentSlots) {
|
||||
case 0:
|
||||
returnValue = fn.call(obj);
|
||||
break;
|
||||
case 1:
|
||||
var a = stack.pop();
|
||||
returnValue = fn.call(obj, a);
|
||||
break;
|
||||
case 2:
|
||||
var b = stack.pop();
|
||||
var a = stack.pop();
|
||||
returnValue = fn.call(obj, a, b);
|
||||
break;
|
||||
case 3:
|
||||
var c = stack.pop();
|
||||
var b = stack.pop();
|
||||
var a = stack.pop();
|
||||
returnValue = fn.call(obj, a, b, c);
|
||||
break;
|
||||
default:
|
||||
if (methodInfo.argumentSlots > 0) {
|
||||
popManyInto(stack, methodInfo.argumentSlots, argArray);
|
||||
} else {
|
||||
frame.popArgumentsInto(methodInfo.signatureDescriptor, argArray);
|
||||
}
|
||||
|
||||
var returnValue = fn.apply(obj, args);
|
||||
var returnValue = fn.apply(obj, argArray);
|
||||
}
|
||||
if (!isStatic) stack.pop();
|
||||
|
||||
if (!release) {
|
||||
if (returnValue instanceof Promise) {
|
||||
|
|
1
jsc.ts
1
jsc.ts
|
@ -182,6 +182,7 @@ module J2ME {
|
|||
}
|
||||
}
|
||||
CLASSES.initializeBuiltinClasses();
|
||||
Bytecode.defineBytecodes();
|
||||
if (verboseOption.value) {
|
||||
writer.writeLn("Compiling Pattern: " + classFilterOption.value + " " + classFileFilterOption.value);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче