Improve bytecode generation.
This commit is contained in:
@@ -317,6 +317,7 @@ public class JavaGen {
|
||||
builder.dup();
|
||||
builder.dup();
|
||||
builder.storeLocal(pc, a);
|
||||
// builder.createUpvalues(pc, a+3, 1);
|
||||
builder.storeLocal(pc, a+3);
|
||||
builder.loadLocal(pc, a+1); // limit
|
||||
builder.loadLocal(pc, a+2); // step
|
||||
@@ -418,13 +419,6 @@ public class JavaGen {
|
||||
|
||||
// let builder process branch instructions
|
||||
builder.onEndOfLuaInstruction( pc0 );
|
||||
|
||||
// for-loops have upvalue created at top of loop
|
||||
switch ( o ) {
|
||||
case Lua.OP_FORPREP:
|
||||
builder.convertToUpvalue(pc+1, a+3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,11 +244,12 @@ public class ProtoInfo {
|
||||
case Lua.OP_FORLOOP: /* A sBx R(A)+=R(A+2);
|
||||
if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
|
||||
a = Lua.GETARG_A( ins );
|
||||
v[a][pc].isreferenced = true;
|
||||
v[a+2][pc].isreferenced = true;
|
||||
v[a][pc] = new VarInfo(a,pc);
|
||||
v[a+3][pc] = new VarInfo(a+1,pc);
|
||||
v[a][pc].isreferenced = true;
|
||||
v[a+1][pc].isreferenced = true;
|
||||
v[a+3][pc] = new VarInfo(a+3,pc);
|
||||
break;
|
||||
|
||||
case Lua.OP_LOADNIL: /* A B R(A) := ... := R(B) := nil */
|
||||
@@ -444,16 +445,9 @@ public class ProtoInfo {
|
||||
}
|
||||
|
||||
public boolean isUpvalueRefer(int pc, int slot) {
|
||||
// special case for opcodes where overlap between refer and assign
|
||||
if ( pc >= 0 ) {
|
||||
switch ( Lua.GET_OPCODE(prototype.code[pc]) ) {
|
||||
case Lua.OP_CLOSURE:
|
||||
case Lua.OP_CALL:
|
||||
case Lua.OP_TFORLOOP:
|
||||
pc -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// special case when both refer and assign in same instruction
|
||||
if ( pc >= 0 && vars[slot][pc] != null && vars[slot][pc].pc == pc )
|
||||
pc -= 1;
|
||||
VarInfo v = pc<0? params[slot]: vars[slot][pc];
|
||||
// return v.upvalue != null && v.upvalue.rw;
|
||||
return v != null && v.upvalue != null;
|
||||
|
||||
Reference in New Issue
Block a user