# HG changeset patch # User Jaroslav Tulach # Date 1392475648 -3600 # Node ID ca83b2adebb5f324f654836d31b9b016db8ae865 # Parent e046cfcb8f0052ccdce27ecfa560c312a7ffe604 Enough to index by depth, no need to have separate counters for each type diff -r e046cfcb8f00 -r ca83b2adebb5 rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java Sat Feb 15 14:36:43 2014 +0100 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java Sat Feb 15 15:47:28 2014 +0100 @@ -22,19 +22,12 @@ final class StackMapper { private final TypeArray stackTypeIndexPairs; - private int[] typeCounters; - private int[] typeMaxCounters; public StackMapper() { stackTypeIndexPairs = new TypeArray(); - typeCounters = new int[VarType.LAST + 1]; - typeMaxCounters = new int[VarType.LAST + 1]; } public void clear() { - for (int type = 0; type <= VarType.LAST; ++type) { - typeCounters[type] = 0; - } stackTypeIndexPairs.clear(); } @@ -161,9 +154,8 @@ } private int pushTypeImpl(final int type) { - final int count = typeCounters[type]; + final int count = stackTypeIndexPairs.getSize(); final int value = (count << 8) | (type & 0xff); - incCounter(type); stackTypeIndexPairs.add(value); return value; @@ -173,23 +165,11 @@ final int stackSize = stackTypeIndexPairs.getSize(); for (int i = stackSize - count; i < stackSize; ++i) { final int value = stackTypeIndexPairs.get(i); - decCounter(value & 0xff); } stackTypeIndexPairs.setSize(stackSize - count); } - private void incCounter(final int type) { - final int newValue = ++typeCounters[type]; - if (typeMaxCounters[type] < newValue) { - typeMaxCounters[type] = newValue; - } - } - - private void decCounter(final int type) { - --typeCounters[type]; - } - public Variable getVariable(final int typeAndIndex) { final int type = typeAndIndex & 0xff; final int index = typeAndIndex >> 8;