State join(State other) {
            defined = defined.andSet(other.defined);
            assert stacksize == other.stacksize;
            assert nlocks == other.nlocks;
            for (int i=0; i<stacksize; ) {
                Type t = stack[i];
                Type tother = other.stack[i];
                Type result =
                    t==tother ? t :
                    types.isSubtype(t, tother) ? tother :
                    types.isSubtype(tother, t) ? t :
                    error();
                int w = width(result);
                stack[i] = result;
                if (w == 2) assert stack[i+1] == null;
                i += w;
            }
            return this;
        }