Improve bytecode generation.
This commit is contained in:
@@ -334,12 +334,14 @@ public class Slots {
|
|||||||
|
|
||||||
private void markuninitialized() {
|
private void markuninitialized() {
|
||||||
for ( int j=p.numparams; j<m; j++ )
|
for ( int j=p.numparams; j<m; j++ )
|
||||||
if ( ! isreferrededtofirst(j) )
|
if ( ! needsinitialnil(j) )
|
||||||
slots[0][j] |= BIT_INVALID;
|
slots[0][j] |= BIT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isreferrededtofirst(int j) {
|
private boolean needsinitialnil(int j) {
|
||||||
for ( int i=1; i<=n; i++ ) {
|
for ( int i=1; i<=n; i++ ) {
|
||||||
|
if ( isbranchsource(i) )
|
||||||
|
return true;
|
||||||
if ( (slots[i][j] & (BIT_REFER | BIT_UP_REFER)) != 0 )
|
if ( (slots[i][j] & (BIT_REFER | BIT_UP_REFER)) != 0 )
|
||||||
return true;
|
return true;
|
||||||
if ( (slots[i][j] & (BIT_ASSIGN | BIT_UP_ASSIGN | BIT_UP_CREATE | BIT_INVALID)) != 0 )
|
if ( (slots[i][j] & (BIT_ASSIGN | BIT_UP_ASSIGN | BIT_UP_CREATE | BIT_INVALID)) != 0 )
|
||||||
@@ -348,6 +350,28 @@ public class Slots {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isbranchsource(int index) {
|
||||||
|
if (index >= p.code.length )
|
||||||
|
return false;
|
||||||
|
int ins = p.code[index];
|
||||||
|
switch ( Lua.GET_OPCODE(ins) ) {
|
||||||
|
case Lua.OP_LOADBOOL:
|
||||||
|
if ( Lua.GETARG_C(ins) == 0 )
|
||||||
|
return true;
|
||||||
|
case Lua.OP_EQ:
|
||||||
|
case Lua.OP_LT:
|
||||||
|
case Lua.OP_LE:
|
||||||
|
case Lua.OP_TEST:
|
||||||
|
case Lua.OP_TESTSET:
|
||||||
|
case Lua.OP_TFORLOOP:
|
||||||
|
case Lua.OP_JMP:
|
||||||
|
case Lua.OP_FORPREP:
|
||||||
|
case Lua.OP_FORLOOP:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void markupvalues( ) {
|
private void markupvalues( ) {
|
||||||
for ( int pc=0; pc<n; ++pc ) {
|
for ( int pc=0; pc<n; ++pc ) {
|
||||||
if ( Lua.GET_OPCODE(p.code[pc]) == Lua.OP_CLOSURE ) {
|
if ( Lua.GET_OPCODE(p.code[pc]) == Lua.OP_CLOSURE ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user