From d27f2d6e20dd937a2c24310e073b32e39572646f Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Tue, 10 Aug 2010 17:46:17 +0000 Subject: [PATCH] Improve bytecode generation. --- src/jse/org/luaj/vm2/luajc/BasicBlock.java | 54 +-------------------- src/jse/org/luaj/vm2/luajc/JavaBuilder.java | 6 +-- src/jse/org/luaj/vm2/luajc/ProtoInfo.java | 30 +++++++----- src/jse/org/luaj/vm2/luajc/UpvalInfo.java | 22 ++++++--- 4 files changed, 35 insertions(+), 77 deletions(-) diff --git a/src/jse/org/luaj/vm2/luajc/BasicBlock.java b/src/jse/org/luaj/vm2/luajc/BasicBlock.java index 2aec9efa..8c702f07 100644 --- a/src/jse/org/luaj/vm2/luajc/BasicBlock.java +++ b/src/jse/org/luaj/vm2/luajc/BasicBlock.java @@ -14,13 +14,8 @@ public class BasicBlock { BasicBlock[] prev; // previous basic blocks (0-n of these) BasicBlock[] next; // next basic blocks (0, 1, or 2 of these) - short[] ninputs; // number of input values per slot, >0 means is phi variable - VarInfo[][] inputs; // variables for each input, -1=closed/undefined, 1,2...=revisionof that variable - public BasicBlock(Prototype p, int pc0) { this.pc0 = this.pc1 = pc0; - this.ninputs = new short[p.maxstacksize]; - this.inputs = new VarInfo[p.maxstacksize][]; } public String toString() { @@ -28,18 +23,7 @@ public class BasicBlock { sb.append( (pc0+1)+"-"+(pc1+1) +(prev!=null? " prv: "+str(prev,1): "") +(next!=null? " nxt: "+str(next,0): "") - +"\n " ); - for ( int i=0; i inputs[slot].length ) { - VarInfo[] s = inputs[slot]; - inputs[slot] = new VarInfo[(n+1)*2]; - System.arraycopy(s, 0, inputs[slot], 0, n); - } - inputs[slot][n] = v; - ninputs[slot]++; - return true; - } - - boolean includesVar(int slot, VarInfo v) { - int n = ninputs[slot]; - for ( int i=0; i b.pc0 ) return pi.vars[slot][v.pc-1].upvalue != this; - if ( b.ninputs[slot] <= 0 ) - return true; - for ( int k=0, n=b.ninputs[slot]; k