private CompiledFunctionImpl cloneWithNewParentScope(JS.Scope s) throws IOException {
CompiledFunctionImpl ret = new JS.CompiledFunction(sourceName, firstLine, null, s);
- ret.paste(this);
+ // Reuse the same op, arg, line, and size variables for the new "instance" of the function
+ // NOTE: Neither *this* function nor the new function should be modified after this call
+ ret.op = this.op;
+ ret.arg = this.arg;
+ ret.line = this.line;
+ ret.size = this.size;
return ret;
}
try {
cx.currentCompiledFunction = (CompiledFunction)this;
int size = cx.stack.size();
- cx.stack.push(new CallMarker());
+ cx.stack.push(callMarker);
cx.stack.push(args);
eval(scope);
Object ret = cx.stack.pop();
// FunctionScope /////////////////////////////////////////////////////////////////
- private class FunctionScope extends JS.Scope {
+ private static class FunctionScope extends JS.Scope {
String sourceName;
public FunctionScope(String sourceName, Scope parentScope) { super(parentScope); this.sourceName = sourceName; }
public String getSourceName() { return sourceName; }
// Markers //////////////////////////////////////////////////////////////////////
public static class CallMarker { public CallMarker() { } }
+ private static CallMarker callMarker = new CallMarker();
public static class CatchMarker { public CatchMarker() { } }
private static CatchMarker catchMarker = new CatchMarker();