rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java
branchReducedStack
changeset 1454 ca83b2adebb5
parent 1453 e046cfcb8f00
child 1455 398911a8f401
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java	Sat Feb 15 14:36:43 2014 +0100
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java	Sat Feb 15 15:47:28 2014 +0100
     1.3 @@ -22,19 +22,12 @@
     1.4  
     1.5  final class StackMapper {
     1.6      private final TypeArray stackTypeIndexPairs;
     1.7 -    private int[] typeCounters;
     1.8 -    private int[] typeMaxCounters;
     1.9  
    1.10      public StackMapper() {
    1.11          stackTypeIndexPairs = new TypeArray();
    1.12 -        typeCounters = new int[VarType.LAST + 1];
    1.13 -        typeMaxCounters = new int[VarType.LAST + 1];
    1.14      }
    1.15  
    1.16      public void clear() {
    1.17 -        for (int type = 0; type <= VarType.LAST; ++type) {
    1.18 -            typeCounters[type] = 0;
    1.19 -        }
    1.20          stackTypeIndexPairs.clear();
    1.21      }
    1.22  
    1.23 @@ -161,9 +154,8 @@
    1.24      }
    1.25  
    1.26      private int pushTypeImpl(final int type) {
    1.27 -        final int count = typeCounters[type];
    1.28 +        final int count = stackTypeIndexPairs.getSize();
    1.29          final int value = (count << 8) | (type & 0xff);
    1.30 -        incCounter(type);
    1.31          stackTypeIndexPairs.add(value);
    1.32  
    1.33          return value;
    1.34 @@ -173,23 +165,11 @@
    1.35          final int stackSize = stackTypeIndexPairs.getSize();
    1.36          for (int i = stackSize - count; i < stackSize; ++i) {
    1.37              final int value = stackTypeIndexPairs.get(i);
    1.38 -            decCounter(value & 0xff);
    1.39          }
    1.40  
    1.41          stackTypeIndexPairs.setSize(stackSize - count);
    1.42      }
    1.43  
    1.44 -    private void incCounter(final int type) {
    1.45 -        final int newValue = ++typeCounters[type];
    1.46 -        if (typeMaxCounters[type] < newValue) {
    1.47 -            typeMaxCounters[type] = newValue;
    1.48 -        }
    1.49 -    }
    1.50 -
    1.51 -    private void decCounter(final int type) {
    1.52 -        --typeCounters[type];
    1.53 -    }
    1.54 -
    1.55      public Variable getVariable(final int typeAndIndex) {
    1.56          final int type = typeAndIndex & 0xff;
    1.57          final int index = typeAndIndex >> 8;