1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.jvm;
  27 
  28 import com.sun.tools.javac.code.*;
  29 import com.sun.tools.javac.code.Symbol.*;
  30 import com.sun.tools.javac.code.Types.UniqueType;
  31 import com.sun.tools.javac.tree.JCTree;
  32 import com.sun.tools.javac.util.*;
  33 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
  34 
  35 import static com.sun.tools.javac.code.TypeTag.BOT;
  36 import static com.sun.tools.javac.code.TypeTag.INT;
  37 import static com.sun.tools.javac.jvm.ByteCodes.*;
  38 import static com.sun.tools.javac.jvm.UninitializedType.*;
  39 import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame;
  40 
  41 /** An internal structure that corresponds to the code attribute of
  42  *  methods in a classfile. The class also provides some utility operations to
  43  *  generate bytecode instructions.
  44  *
  45  *  <p><b>This is NOT part of any supported API.
  46  *  If you write code that depends on this, you do so at your own risk.
  47  *  This code and its internal interfaces are subject to change or
  48  *  deletion without notice.</b>
  49  */
  50 public class Code {
  51 
  52     public final boolean debugCode;
  53     public final boolean needStackMap;
  54 
  55     public enum StackMapFormat {
  56         NONE,
  57         CLDC {
  58             Name getAttributeName(Names names) {
  59                 return names.StackMap;
  60             }
  61         },
  62         JSR202 {
  63             Name getAttributeName(Names names) {
  64                 return names.StackMapTable;
  65             }
  66         };
  67         Name getAttributeName(Names names) {
  68             return names.empty;
  69         }
  70     }
  71 
  72     final Types types;
  73     final Symtab syms;
  74 
  75 /*---------- classfile fields: --------------- */
  76 
  77     /** The maximum stack size.
  78      */
  79     public int max_stack = 0;
  80 
  81     /** The maximum number of local variable slots.
  82      */
  83     public int max_locals = 0;
  84 
  85     /** The code buffer.
  86      */
  87     public byte[] code = new byte[64];
  88 
  89     /** the current code pointer.
  90      */
  91     public int cp = 0;
  92 
  93     /** Check the code against VM spec limits; if
  94      *  problems report them and return true.
  95      */
  96     public boolean checkLimits(DiagnosticPosition pos, Log log) {
  97         if (cp > ClassFile.MAX_CODE) {
  98             log.error(pos, "limit.code");
  99             return true;
 100         }
 101         if (max_locals > ClassFile.MAX_LOCALS) {
 102             log.error(pos, "limit.locals");
 103             return true;
 104         }
 105         if (max_stack > ClassFile.MAX_STACK) {
 106             log.error(pos, "limit.stack");
 107             return true;
 108         }
 109         return false;
 110     }
 111 
 112     /** A buffer for expression catch data. Each enter is a vector
 113      *  of four unsigned shorts.
 114      */
 115     ListBuffer<char[]> catchInfo = new ListBuffer<>();
 116 
 117     /** A buffer for line number information. Each entry is a vector
 118      *  of two unsigned shorts.
 119      */
 120     List<char[]> lineInfo = List.nil(); // handled in stack fashion
 121 
 122     /** The CharacterRangeTable
 123      */
 124     public CRTable crt;
 125 
 126 /*---------- internal fields: --------------- */
 127 
 128     /** Are we generating code with jumps &ge; 32K?
 129      */
 130     public boolean fatcode;
 131 
 132     /** Code generation enabled?
 133      */
 134     private boolean alive = true;
 135 
 136     /** The current machine state (registers and stack).
 137      */
 138     State state;
 139 
 140     /** Is it forbidden to compactify code, because something is
 141      *  pointing to current location?
 142      */
 143     private boolean fixedPc = false;
 144 
 145     /** The next available register.
 146      */
 147     public int nextreg = 0;
 148 
 149     /** A chain for jumps to be resolved before the next opcode is emitted.
 150      *  We do this lazily to avoid jumps to jumps.
 151      */
 152     Chain pendingJumps = null;
 153 
 154     /** The position of the currently statement, if we are at the
 155      *  start of this statement, NOPOS otherwise.
 156      *  We need this to emit line numbers lazily, which we need to do
 157      *  because of jump-to-jump optimization.
 158      */
 159     int pendingStatPos = Position.NOPOS;
 160 
 161     /** Set true when a stackMap is needed at the current PC. */
 162     boolean pendingStackMap = false;
 163 
 164     /** The stack map format to be generated. */
 165     StackMapFormat stackMap;
 166 
 167     /** Switch: emit variable debug info.
 168      */
 169     boolean varDebugInfo;
 170 
 171     /** Switch: emit line number info.
 172      */
 173     boolean lineDebugInfo;
 174 
 175     /** Emit line number info if map supplied
 176      */
 177     Position.LineMap lineMap;
 178 
 179     /** The constant pool of the current class.
 180      */
 181     final Pool pool;
 182 
 183     final MethodSymbol meth;
 184 
 185     /** Construct a code object, given the settings of the fatcode,
 186      *  debugging info switches and the CharacterRangeTable.
 187      */
 188     public Code(MethodSymbol meth,
 189                 boolean fatcode,
 190                 Position.LineMap lineMap,
 191                 boolean varDebugInfo,
 192                 StackMapFormat stackMap,
 193                 boolean debugCode,
 194                 CRTable crt,
 195                 Symtab syms,
 196                 Types types,
 197                 Pool pool) {
 198         this.meth = meth;
 199         this.fatcode = fatcode;
 200         this.lineMap = lineMap;
 201         this.lineDebugInfo = lineMap != null;
 202         this.varDebugInfo = varDebugInfo;
 203         this.crt = crt;
 204         this.syms = syms;
 205         this.types = types;
 206         this.debugCode = debugCode;
 207         this.stackMap = stackMap;
 208         switch (stackMap) {
 209         case CLDC:
 210         case JSR202:
 211             this.needStackMap = true;
 212             break;
 213         default:
 214             this.needStackMap = false;
 215         }
 216         state = new State();
 217         lvar = new LocalVar[20];
 218         this.pool = pool;
 219     }
 220 
 221 
 222 /* **************************************************************************
 223  * Typecodes & related stuff
 224  ****************************************************************************/
 225 
 226     /** Given a type, return its type code (used implicitly in the
 227      *  JVM architecture).
 228      */
 229     public static int typecode(Type type) {
 230         switch (type.getTag()) {
 231         case BYTE: return BYTEcode;
 232         case SHORT: return SHORTcode;
 233         case CHAR: return CHARcode;
 234         case INT: return INTcode;
 235         case LONG: return LONGcode;
 236         case FLOAT: return FLOATcode;
 237         case DOUBLE: return DOUBLEcode;
 238         case BOOLEAN: return BYTEcode;
 239         case VOID: return VOIDcode;
 240         case CLASS:
 241         case ARRAY:
 242         case METHOD:
 243         case BOT:
 244         case TYPEVAR:
 245         case UNINITIALIZED_THIS:
 246         case UNINITIALIZED_OBJECT:
 247             return OBJECTcode;
 248         default: throw new AssertionError("typecode " + type.getTag());
 249         }
 250     }
 251 
 252     /** Collapse type code for subtypes of int to INTcode.
 253      */
 254     public static int truncate(int tc) {
 255         switch (tc) {
 256         case BYTEcode: case SHORTcode: case CHARcode: return INTcode;
 257         default: return tc;
 258         }
 259     }
 260 
 261     /** The width in bytes of objects of the type.
 262      */
 263     public static int width(int typecode) {
 264         switch (typecode) {
 265         case LONGcode: case DOUBLEcode: return 2;
 266         case VOIDcode: return 0;
 267         default: return 1;
 268         }
 269     }
 270 
 271     public static int width(Type type) {
 272         return type == null ? 1 : width(typecode(type));
 273     }
 274 
 275     /** The total width taken up by a vector of objects.
 276      */
 277     public static int width(List<Type> types) {
 278         int w = 0;
 279         for (List<Type> l = types; l.nonEmpty(); l = l.tail)
 280             w = w + width(l.head);
 281         return w;
 282     }
 283 
 284     /** Given a type, return its code for allocating arrays of that type.
 285      */
 286     public static int arraycode(Type type) {
 287         switch (type.getTag()) {
 288         case BYTE: return 8;
 289         case BOOLEAN: return 4;
 290         case SHORT: return 9;
 291         case CHAR: return 5;
 292         case INT: return 10;
 293         case LONG: return 11;
 294         case FLOAT: return 6;
 295         case DOUBLE: return 7;
 296         case CLASS: return 0;
 297         case ARRAY: return 1;
 298         default: throw new AssertionError("arraycode " + type);
 299         }
 300     }
 301 
 302 
 303 /* **************************************************************************
 304  * Emit code
 305  ****************************************************************************/
 306 
 307     /** The current output code pointer.
 308      */
 309     public int curCP() {
 310         /*
 311          * This method has side-effects because calling it can indirectly provoke
 312          *  extra code generation, like goto instructions, depending on the context
 313          *  where it's called.
 314          *  Use with care or even better avoid using it.
 315          */
 316         if (pendingJumps != null) {
 317             resolvePending();
 318         }
 319         if (pendingStatPos != Position.NOPOS) {
 320             markStatBegin();
 321         }
 322         fixedPc = true;
 323         return cp;
 324     }
 325 
 326     /** Emit a byte of code.
 327      */
 328     private  void emit1(int od) {
 329         if (!alive) return;
 330         code = ArrayUtils.ensureCapacity(code, cp);
 331         code[cp++] = (byte)od;
 332     }
 333 
 334     /** Emit two bytes of code.
 335      */
 336     private void emit2(int od) {
 337         if (!alive) return;
 338         if (cp + 2 > code.length) {
 339             emit1(od >> 8);
 340             emit1(od);
 341         } else {
 342             code[cp++] = (byte)(od >> 8);
 343             code[cp++] = (byte)od;
 344         }
 345     }
 346 
 347     /** Emit four bytes of code.
 348      */
 349     public void emit4(int od) {
 350         if (!alive) return;
 351         if (cp + 4 > code.length) {
 352             emit1(od >> 24);
 353             emit1(od >> 16);
 354             emit1(od >> 8);
 355             emit1(od);
 356         } else {
 357             code[cp++] = (byte)(od >> 24);
 358             code[cp++] = (byte)(od >> 16);
 359             code[cp++] = (byte)(od >> 8);
 360             code[cp++] = (byte)od;
 361         }
 362     }
 363 
 364     /** Emit an opcode.
 365      */
 366     private void emitop(int op) {
 367         if (pendingJumps != null) resolvePending();
 368         if (alive) {
 369             if (pendingStatPos != Position.NOPOS)
 370                 markStatBegin();
 371             if (pendingStackMap) {
 372                 pendingStackMap = false;
 373                 emitStackMap();
 374             }
 375             if (debugCode)
 376                 System.err.println("emit@" + cp + " stack=" +
 377                                    state.stacksize + ": " +
 378                                    mnem(op));
 379             emit1(op);
 380         }
 381     }
 382 
 383     void postop() {
 384         Assert.check(alive || state.stacksize == 0);
 385     }
 386 
 387     /** Emit a ldc (or ldc_w) instruction, taking into account operand size
 388     */
 389     public void emitLdc(int od) {
 390         if (od <= 255) {
 391             emitop1(ldc1, od);
 392         }
 393         else {
 394             emitop2(ldc2, od);
 395         }
 396     }
 397 
 398     /** Emit a multinewarray instruction.
 399      */
 400     public void emitMultianewarray(int ndims, int type, Type arrayType) {
 401         emitop(multianewarray);
 402         if (!alive) return;
 403         emit2(type);
 404         emit1(ndims);
 405         state.pop(ndims);
 406         state.push(arrayType);
 407     }
 408 
 409     /** Emit newarray.
 410      */
 411     public void emitNewarray(int elemcode, Type arrayType) {
 412         emitop(newarray);
 413         if (!alive) return;
 414         emit1(elemcode);
 415         state.pop(1); // count
 416         state.push(arrayType);
 417     }
 418 
 419     /** Emit anewarray.
 420      */
 421     public void emitAnewarray(int od, Type arrayType) {
 422         emitop(anewarray);
 423         if (!alive) return;
 424         emit2(od);
 425         state.pop(1);
 426         state.push(arrayType);
 427     }
 428 
 429     /** Emit an invokeinterface instruction.
 430      */
 431     public void emitInvokeinterface(int meth, Type mtype) {
 432         int argsize = width(mtype.getParameterTypes());
 433         emitop(invokeinterface);
 434         if (!alive) return;
 435         emit2(meth);
 436         emit1(argsize + 1);
 437         emit1(0);
 438         state.pop(argsize + 1);
 439         state.push(mtype.getReturnType());
 440     }
 441 
 442     /** Emit an invokespecial instruction.
 443      */
 444     public void emitInvokespecial(int meth, Type mtype) {
 445         int argsize = width(mtype.getParameterTypes());
 446         emitop(invokespecial);
 447         if (!alive) return;
 448         emit2(meth);
 449         Symbol sym = (Symbol)pool.pool[meth];
 450         state.pop(argsize);
 451         if (sym.isConstructor())
 452             state.markInitialized((UninitializedType)state.peek());
 453         state.pop(1);
 454         state.push(mtype.getReturnType());
 455     }
 456 
 457     /** Emit an invokestatic instruction.
 458      */
 459     public void emitInvokestatic(int meth, Type mtype) {
 460         int argsize = width(mtype.getParameterTypes());
 461         emitop(invokestatic);
 462         if (!alive) return;
 463         emit2(meth);
 464         state.pop(argsize);
 465         state.push(mtype.getReturnType());
 466     }
 467 
 468     /** Emit an invokevirtual instruction.
 469      */
 470     public void emitInvokevirtual(int meth, Type mtype) {
 471         int argsize = width(mtype.getParameterTypes());
 472         emitop(invokevirtual);
 473         if (!alive) return;
 474         emit2(meth);
 475         state.pop(argsize + 1);
 476         state.push(mtype.getReturnType());
 477     }
 478 
 479     /** Emit an invokedynamic instruction.
 480      */
 481     public void emitInvokedynamic(int desc, Type mtype) {
 482         int argsize = width(mtype.getParameterTypes());
 483         emitop(invokedynamic);
 484         if (!alive) return;
 485         emit2(desc);
 486         emit2(0);
 487         state.pop(argsize);
 488         state.push(mtype.getReturnType());
 489     }
 490 
 491     /** Emit an opcode with no operand field.
 492      */
 493     public void emitop0(int op) {
 494         emitop(op);
 495         if (!alive) return;
 496         switch (op) {
 497         case vaload:
 498         case aaload: {
 499             state.pop(1);// index
 500             Type a = state.stack[state.stacksize-1];
 501             Assert.check(!a.hasTag(BOT)); // null type as is cannot be indexed.
 502             state.pop(1);
 503             state.push(types.erasure(types.elemtype(a))); }
 504             break;
 505         case goto_:
 506             markDead();
 507             break;
 508         case nop:
 509         case ineg:
 510         case lneg:
 511         case fneg:
 512         case dneg:
 513             break;
 514         case aconst_null:
 515             state.push(syms.botType);
 516             break;
 517         case iconst_m1:
 518         case iconst_0:
 519         case iconst_1:
 520         case iconst_2:
 521         case iconst_3:
 522         case iconst_4:
 523         case iconst_5:
 524         case iload_0:
 525         case iload_1:
 526         case iload_2:
 527         case iload_3:
 528             state.push(syms.intType);
 529             break;
 530         case lconst_0:
 531         case lconst_1:
 532         case lload_0:
 533         case lload_1:
 534         case lload_2:
 535         case lload_3:
 536             state.push(syms.longType);
 537             break;
 538         case fconst_0:
 539         case fconst_1:
 540         case fconst_2:
 541         case fload_0:
 542         case fload_1:
 543         case fload_2:
 544         case fload_3:
 545             state.push(syms.floatType);
 546             break;
 547         case dconst_0:
 548         case dconst_1:
 549         case dload_0:
 550         case dload_1:
 551         case dload_2:
 552         case dload_3:
 553             state.push(syms.doubleType);
 554             break;
 555         case aload_0:
 556             state.push(lvar[0].sym.type);
 557             break;
 558         case aload_1:
 559             state.push(lvar[1].sym.type);
 560             break;
 561         case aload_2:
 562             state.push(lvar[2].sym.type);
 563             break;
 564         case aload_3:
 565             state.push(lvar[3].sym.type);
 566             break;
 567         case iaload:
 568         case baload:
 569         case caload:
 570         case saload:
 571             state.pop(2);
 572             state.push(syms.intType);
 573             break;
 574         case laload:
 575             state.pop(2);
 576             state.push(syms.longType);
 577             break;
 578         case faload:
 579             state.pop(2);
 580             state.push(syms.floatType);
 581             break;
 582         case daload:
 583             state.pop(2);
 584             state.push(syms.doubleType);
 585             break;
 586         case istore_0:
 587         case istore_1:
 588         case istore_2:
 589         case istore_3:
 590         case fstore_0:
 591         case fstore_1:
 592         case fstore_2:
 593         case fstore_3:
 594         case astore_0:
 595         case astore_1:
 596         case astore_2:
 597         case astore_3:
 598         case pop:
 599         case lshr:
 600         case lshl:
 601         case lushr:
 602             state.pop(1);
 603             break;
 604         case vreturn:
 605         case areturn:
 606         case ireturn:
 607         case freturn:
 608             Assert.check(state.nlocks == 0);
 609             state.pop(1);
 610             markDead();
 611             break;
 612         case athrow:
 613             state.pop(1);
 614             markDead();
 615             break;
 616         case lstore_0:
 617         case lstore_1:
 618         case lstore_2:
 619         case lstore_3:
 620         case dstore_0:
 621         case dstore_1:
 622         case dstore_2:
 623         case dstore_3:
 624         case pop2:
 625             state.pop(2);
 626             break;
 627         case lreturn:
 628         case dreturn:
 629             Assert.check(state.nlocks == 0);
 630             state.pop(2);
 631             markDead();
 632             break;
 633         case dup:
 634             state.push(state.stack[state.stacksize-1]);
 635             break;
 636         case return_:
 637             Assert.check(state.nlocks == 0);
 638             markDead();
 639             break;
 640         case arraylength:
 641             state.pop(1);
 642             state.push(syms.intType);
 643             break;
 644         case isub:
 645         case iadd:
 646         case imul:
 647         case idiv:
 648         case imod:
 649         case ishl:
 650         case ishr:
 651         case iushr:
 652         case iand:
 653         case ior:
 654         case ixor:
 655             state.pop(1);
 656             // state.pop(1);
 657             // state.push(syms.intType);
 658             break;
 659         case vastore:
 660         case aastore:
 661             state.pop(3);
 662             break;
 663         case land:
 664         case lor:
 665         case lxor:
 666         case lmod:
 667         case ldiv:
 668         case lmul:
 669         case lsub:
 670         case ladd:
 671             state.pop(2);
 672             break;
 673         case lcmp:
 674             state.pop(4);
 675             state.push(syms.intType);
 676             break;
 677         case l2i:
 678             state.pop(2);
 679             state.push(syms.intType);
 680             break;
 681         case i2l:
 682             state.pop(1);
 683             state.push(syms.longType);
 684             break;
 685         case i2f:
 686             state.pop(1);
 687             state.push(syms.floatType);
 688             break;
 689         case i2d:
 690             state.pop(1);
 691             state.push(syms.doubleType);
 692             break;
 693         case l2f:
 694             state.pop(2);
 695             state.push(syms.floatType);
 696             break;
 697         case l2d:
 698             state.pop(2);
 699             state.push(syms.doubleType);
 700             break;
 701         case f2i:
 702             state.pop(1);
 703             state.push(syms.intType);
 704             break;
 705         case f2l:
 706             state.pop(1);
 707             state.push(syms.longType);
 708             break;
 709         case f2d:
 710             state.pop(1);
 711             state.push(syms.doubleType);
 712             break;
 713         case d2i:
 714             state.pop(2);
 715             state.push(syms.intType);
 716             break;
 717         case d2l:
 718             state.pop(2);
 719             state.push(syms.longType);
 720             break;
 721         case d2f:
 722             state.pop(2);
 723             state.push(syms.floatType);
 724             break;
 725         case tableswitch:
 726         case lookupswitch:
 727             state.pop(1);
 728             // the caller is responsible for patching up the state
 729             break;
 730         case dup_x1: {
 731             Type val1 = state.pop1();
 732             Type val2 = state.pop1();
 733             state.push(val1);
 734             state.push(val2);
 735             state.push(val1);
 736             break;
 737         }
 738         case bastore:
 739             state.pop(3);
 740             break;
 741         case int2byte:
 742         case int2char:
 743         case int2short:
 744             break;
 745         case fmul:
 746         case fadd:
 747         case fsub:
 748         case fdiv:
 749         case fmod:
 750             state.pop(1);
 751             break;
 752         case castore:
 753         case iastore:
 754         case fastore:
 755         case sastore:
 756             state.pop(3);
 757             break;
 758         case lastore:
 759         case dastore:
 760             state.pop(4);
 761             break;
 762         case dup2:
 763             if (state.stack[state.stacksize-1] != null) {
 764                 Type value1 = state.pop1();
 765                 Type value2 = state.pop1();
 766                 state.push(value2);
 767                 state.push(value1);
 768                 state.push(value2);
 769                 state.push(value1);
 770             } else {
 771                 Type value = state.pop2();
 772                 state.push(value);
 773                 state.push(value);
 774             }
 775             break;
 776         case dup2_x1:
 777             if (state.stack[state.stacksize-1] != null) {
 778                 Type value1 = state.pop1();
 779                 Type value2 = state.pop1();
 780                 Type value3 = state.pop1();
 781                 state.push(value2);
 782                 state.push(value1);
 783                 state.push(value3);
 784                 state.push(value2);
 785                 state.push(value1);
 786             } else {
 787                 Type value1 = state.pop2();
 788                 Type value2 = state.pop1();
 789                 state.push(value1);
 790                 state.push(value2);
 791                 state.push(value1);
 792             }
 793             break;
 794         case dup2_x2:
 795             if (state.stack[state.stacksize-1] != null) {
 796                 Type value1 = state.pop1();
 797                 Type value2 = state.pop1();
 798                 if (state.stack[state.stacksize-1] != null) {
 799                     // form 1
 800                     Type value3 = state.pop1();
 801                     Type value4 = state.pop1();
 802                     state.push(value2);
 803                     state.push(value1);
 804                     state.push(value4);
 805                     state.push(value3);
 806                     state.push(value2);
 807                     state.push(value1);
 808                 } else {
 809                     // form 3
 810                     Type value3 = state.pop2();
 811                     state.push(value2);
 812                     state.push(value1);
 813                     state.push(value3);
 814                     state.push(value2);
 815                     state.push(value1);
 816                 }
 817             } else {
 818                 Type value1 = state.pop2();
 819                 if (state.stack[state.stacksize-1] != null) {
 820                     // form 2
 821                     Type value2 = state.pop1();
 822                     Type value3 = state.pop1();
 823                     state.push(value1);
 824                     state.push(value3);
 825                     state.push(value2);
 826                     state.push(value1);
 827                 } else {
 828                     // form 4
 829                     Type value2 = state.pop2();
 830                     state.push(value1);
 831                     state.push(value2);
 832                     state.push(value1);
 833                 }
 834             }
 835             break;
 836         case dup_x2: {
 837             Type value1 = state.pop1();
 838             if (state.stack[state.stacksize-1] != null) {
 839                 // form 1
 840                 Type value2 = state.pop1();
 841                 Type value3 = state.pop1();
 842                 state.push(value1);
 843                 state.push(value3);
 844                 state.push(value2);
 845                 state.push(value1);
 846             } else {
 847                 // form 2
 848                 Type value2 = state.pop2();
 849                 state.push(value1);
 850                 state.push(value2);
 851                 state.push(value1);
 852             }
 853         }
 854             break;
 855         case fcmpl:
 856         case fcmpg:
 857             state.pop(2);
 858             state.push(syms.intType);
 859             break;
 860         case dcmpl:
 861         case dcmpg:
 862             state.pop(4);
 863             state.push(syms.intType);
 864             break;
 865         case swap: {
 866             Type value1 = state.pop1();
 867             Type value2 = state.pop1();
 868             state.push(value1);
 869             state.push(value2);
 870             break;
 871         }
 872         case dadd:
 873         case dsub:
 874         case dmul:
 875         case ddiv:
 876         case dmod:
 877             state.pop(2);
 878             break;
 879         case ret:
 880             markDead();
 881             break;
 882         case wide:
 883             // must be handled by the caller.
 884             return;
 885         case monitorenter:
 886         case monitorexit:
 887             state.pop(1);
 888             break;
 889 
 890         default:
 891             throw new AssertionError(mnem(op));
 892         }
 893         postop();
 894     }
 895 
 896     /** Emit an opcode with a one-byte operand field.
 897      */
 898     public void emitop1(int op, int od) {
 899         emitop(op);
 900         if (!alive) return;
 901         emit1(od);
 902         switch (op) {
 903         case bipush:
 904             state.push(syms.intType);
 905             break;
 906         case ldc1:
 907             state.push(typeForPool(pool.pool[od]));
 908             break;
 909         default:
 910             throw new AssertionError(mnem(op));
 911         }
 912         postop();
 913     }
 914 
 915     /** The type of a constant pool entry. */
 916     private Type typeForPool(Object o) {
 917         if (o instanceof Integer) return syms.intType;
 918         if (o instanceof Float) return syms.floatType;
 919         if (o instanceof String) return syms.stringType;
 920         if (o instanceof Long) return syms.longType;
 921         if (o instanceof Double) return syms.doubleType;
 922         if (o instanceof ClassSymbol) return syms.classType;
 923         if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
 924         if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type);
 925         if (o instanceof Type) {
 926             Type ty = (Type) o;
 927 
 928             if (ty instanceof Type.ArrayType) return syms.classType;
 929             if (ty instanceof Type.MethodType) return syms.methodTypeType;
 930         }
 931         throw new AssertionError("Invalid type of constant pool entry: " + o.getClass());
 932     }
 933 
 934     /** Emit an opcode with a one-byte operand field;
 935      *  widen if field does not fit in a byte.
 936      */
 937     public void emitop1w(int op, int od) {
 938         if (od > 0xFF) {
 939             emitop(wide);
 940             emitop(op);
 941             emit2(od);
 942         } else {
 943             emitop(op);
 944             emit1(od);
 945         }
 946         if (!alive) return;
 947         switch (op) {
 948         case iload:
 949             state.push(syms.intType);
 950             break;
 951         case lload:
 952             state.push(syms.longType);
 953             break;
 954         case fload:
 955             state.push(syms.floatType);
 956             break;
 957         case dload:
 958             state.push(syms.doubleType);
 959             break;
 960         case aload:
 961         case vload:
 962             state.push(lvar[od].sym.type);
 963             break;
 964         case lstore:
 965         case dstore:
 966             state.pop(2);
 967             break;
 968         case istore:
 969         case fstore:
 970         case astore:
 971         case vstore:
 972             state.pop(1);
 973             break;
 974         case ret:
 975             markDead();
 976             break;
 977         default:
 978             throw new AssertionError(mnem(op));
 979         }
 980         postop();
 981     }
 982 
 983     /** Emit an opcode with two one-byte operand fields;
 984      *  widen if either field does not fit in a byte.
 985      */
 986     public void emitop1w(int op, int od1, int od2) {
 987         if (od1 > 0xFF || od2 < -128 || od2 > 127) {
 988             emitop(wide);
 989             emitop(op);
 990             emit2(od1);
 991             emit2(od2);
 992         } else {
 993             emitop(op);
 994             emit1(od1);
 995             emit1(od2);
 996         }
 997         if (!alive) return;
 998         switch (op) {
 999         case iinc:
1000             break;
1001         default:
1002             throw new AssertionError(mnem(op));
1003         }
1004     }
1005 
1006     /** Emit a vnew opcode.
1007      */
1008     public void emitVnew(Type type, int od, int argsize) {
1009         emitop(vnew);
1010         if (!alive) return;
1011         emit2(od);
1012         state.pop(argsize);
1013         state.push(type);
1014     }
1015 
1016     /** Emit an opcode with a two-byte operand field.
1017      */
1018     public void emitop2(int op, int od) {
1019         emitop(op);
1020         if (!alive) return;
1021         emit2(od);
1022         switch (op) {
1023         case getstatic:
1024             state.push(((Symbol)(pool.pool[od])).erasure(types));
1025             break;
1026         case putstatic:
1027             state.pop(((Symbol)(pool.pool[od])).erasure(types));
1028             break;
1029         case vnew:
1030         case new_:
1031             Symbol sym;
1032             if (pool.pool[od] instanceof UniqueType) {
1033                 // Required by change in Gen.makeRef to allow
1034                 // annotated types.
1035                 // TODO: is this needed anywhere else?
1036                 sym = ((UniqueType)(pool.pool[od])).type.tsym;
1037             } else {
1038                 sym = (Symbol)(pool.pool[od]);
1039             }
1040             state.push(uninitializedObject(sym.erasure(types), cp-3));
1041             break;
1042         case vdefault:
1043             if (pool.pool[od] instanceof UniqueType) {
1044                 // Required by change in Gen.makeRef to allow
1045                 // annotated types.
1046                 // TODO: is this needed anywhere else?
1047                 sym = ((UniqueType)(pool.pool[od])).type.tsym;
1048             } else {
1049                 sym = (Symbol)(pool.pool[od]);
1050             }
1051             state.push(sym.erasure(types));
1052             break;
1053         case sipush:
1054             state.push(syms.intType);
1055             break;
1056         case if_acmp_null:
1057         case if_acmp_nonnull:
1058         case ifeq:
1059         case ifne:
1060         case iflt:
1061         case ifge:
1062         case ifgt:
1063         case ifle:
1064             state.pop(1);
1065             break;
1066         case if_icmpeq:
1067         case if_icmpne:
1068         case if_icmplt:
1069         case if_icmpge:
1070         case if_icmpgt:
1071         case if_icmple:
1072         case if_acmpeq:
1073         case if_acmpne:
1074             state.pop(2);
1075             break;
1076         case goto_:
1077             markDead();
1078             break;
1079         case vwithfield:
1080             state.pop(((Symbol)(pool.pool[od])).erasure(types));
1081             break;
1082         case putfield:
1083             state.pop(((Symbol)(pool.pool[od])).erasure(types));
1084             state.pop(1); // object ref
1085             break;
1086         case getfield:
1087             state.pop(1); // object ref
1088             state.push(((Symbol)(pool.pool[od])).erasure(types));
1089             break;
1090         case checkcast: {
1091             state.pop(1); // object ref
1092             Object o = pool.pool[od];
1093             Type t = (o instanceof Symbol)
1094                 ? ((Symbol)o).erasure(types)
1095                 : types.erasure((((UniqueType)o).type));
1096             state.push(t);
1097             break; }
1098         case ldc2w:
1099             state.push(typeForPool(pool.pool[od]));
1100             break;
1101         case instanceof_:
1102             state.pop(1);
1103             state.push(syms.intType);
1104             break;
1105         case ldc2:
1106             state.push(typeForPool(pool.pool[od]));
1107             break;
1108         case jsr:
1109             break;
1110         default:
1111             throw new AssertionError(mnem(op));
1112         }
1113         // postop();
1114     }
1115 
1116     /** Emit an opcode with a four-byte operand field.
1117      */
1118     public void emitop4(int op, int od) {
1119         emitop(op);
1120         if (!alive) return;
1121         emit4(od);
1122         switch (op) {
1123         case goto_w:
1124             markDead();
1125             break;
1126         case jsr_w:
1127             break;
1128         default:
1129             throw new AssertionError(mnem(op));
1130         }
1131         // postop();
1132     }
1133 
1134     /** Align code pointer to next `incr' boundary.
1135      */
1136     public void align(int incr) {
1137         if (alive)
1138             while (cp % incr != 0) emitop0(nop);
1139     }
1140 
1141     /** Place a byte into code at address pc.
1142      *  Pre: {@literal pc + 1 <= cp }.
1143      */
1144     private void put1(int pc, int op) {
1145         code[pc] = (byte)op;
1146     }
1147 
1148     /** Place two bytes into code at address pc.
1149      *  Pre: {@literal pc + 2 <= cp }.
1150      */
1151     private void put2(int pc, int od) {
1152         // pre: pc + 2 <= cp
1153         put1(pc, od >> 8);
1154         put1(pc+1, od);
1155     }
1156 
1157     /** Place four  bytes into code at address pc.
1158      *  Pre: {@literal pc + 4 <= cp }.
1159      */
1160     public void put4(int pc, int od) {
1161         // pre: pc + 4 <= cp
1162         put1(pc  , od >> 24);
1163         put1(pc+1, od >> 16);
1164         put1(pc+2, od >> 8);
1165         put1(pc+3, od);
1166     }
1167 
1168     /** Return code byte at position pc as an unsigned int.
1169      */
1170     private int get1(int pc) {
1171         return code[pc] & 0xFF;
1172     }
1173 
1174     /** Return two code bytes at position pc as an unsigned int.
1175      */
1176     private int get2(int pc) {
1177         return (get1(pc) << 8) | get1(pc+1);
1178     }
1179 
1180     /** Return four code bytes at position pc as an int.
1181      */
1182     public int get4(int pc) {
1183         // pre: pc + 4 <= cp
1184         return
1185             (get1(pc) << 24) |
1186             (get1(pc+1) << 16) |
1187             (get1(pc+2) << 8) |
1188             (get1(pc+3));
1189     }
1190 
1191     /** Is code generation currently enabled?
1192      */
1193     public boolean isAlive() {
1194         return alive || pendingJumps != null;
1195     }
1196 
1197     /** Switch code generation on/off.
1198      */
1199     public void markDead() {
1200         alive = false;
1201     }
1202 
1203     /** Declare an entry point; return current code pointer
1204      */
1205     public int entryPoint() {
1206         int pc = curCP();
1207         alive = true;
1208         pendingStackMap = needStackMap;
1209         return pc;
1210     }
1211 
1212     /** Declare an entry point with initial state;
1213      *  return current code pointer
1214      */
1215     public int entryPoint(State state) {
1216         int pc = curCP();
1217         alive = true;
1218         State newState = state.dup();
1219         setDefined(newState.defined);
1220         this.state = newState;
1221         Assert.check(state.stacksize <= max_stack);
1222         if (debugCode) System.err.println("entry point " + state);
1223         pendingStackMap = needStackMap;
1224         return pc;
1225     }
1226 
1227     /** Declare an entry point with initial state plus a pushed value;
1228      *  return current code pointer
1229      */
1230     public int entryPoint(State state, Type pushed) {
1231         int pc = curCP();
1232         alive = true;
1233         State newState = state.dup();
1234         setDefined(newState.defined);
1235         this.state = newState;
1236         Assert.check(state.stacksize <= max_stack);
1237         this.state.push(pushed);
1238         if (debugCode) System.err.println("entry point " + state);
1239         pendingStackMap = needStackMap;
1240         return pc;
1241     }
1242 
1243 
1244 /**************************************************************************
1245  * Stack map generation
1246  *************************************************************************/
1247 
1248     /** An entry in the stack map. */
1249     static class StackMapFrame {
1250         int pc;
1251         Type[] locals;
1252         Type[] stack;
1253     }
1254 
1255     /** A buffer of cldc stack map entries. */
1256     StackMapFrame[] stackMapBuffer = null;
1257 
1258     /** A buffer of compressed StackMapTable entries. */
1259     StackMapTableFrame[] stackMapTableBuffer = null;
1260     int stackMapBufferSize = 0;
1261 
1262     /** The last PC at which we generated a stack map. */
1263     int lastStackMapPC = -1;
1264 
1265     /** The last stack map frame in StackMapTable. */
1266     StackMapFrame lastFrame = null;
1267 
1268     /** The stack map frame before the last one. */
1269     StackMapFrame frameBeforeLast = null;
1270 
1271     /** Emit a stack map entry.  */
1272     public void emitStackMap() {
1273         int pc = curCP();
1274         if (!needStackMap) return;
1275 
1276 
1277 
1278         switch (stackMap) {
1279             case CLDC:
1280                 emitCLDCStackMap(pc, getLocalsSize());
1281                 break;
1282             case JSR202:
1283                 emitStackMapFrame(pc, getLocalsSize());
1284                 break;
1285             default:
1286                 throw new AssertionError("Should have chosen a stackmap format");
1287         }
1288         // DEBUG code follows
1289         if (debugCode) state.dump(pc);
1290     }
1291 
1292     private int getLocalsSize() {
1293         int nextLocal = 0;
1294         for (int i=max_locals-1; i>=0; i--) {
1295             if (state.defined.isMember(i) && lvar[i] != null) {
1296                 nextLocal = i + width(lvar[i].sym.erasure(types));
1297                 break;
1298             }
1299         }
1300         return nextLocal;
1301     }
1302 
1303     /** Emit a CLDC stack map frame. */
1304     void emitCLDCStackMap(int pc, int localsSize) {
1305         if (lastStackMapPC == pc) {
1306             // drop existing stackmap at this offset
1307             stackMapBuffer[--stackMapBufferSize] = null;
1308         }
1309         lastStackMapPC = pc;
1310 
1311         if (stackMapBuffer == null) {
1312             stackMapBuffer = new StackMapFrame[20];
1313         } else {
1314             stackMapBuffer = ArrayUtils.ensureCapacity(stackMapBuffer, stackMapBufferSize);
1315         }
1316         StackMapFrame frame =
1317             stackMapBuffer[stackMapBufferSize++] = new StackMapFrame();
1318         frame.pc = pc;
1319 
1320         frame.locals = new Type[localsSize];
1321         for (int i=0; i<localsSize; i++) {
1322             if (state.defined.isMember(i) && lvar[i] != null) {
1323                 Type vtype = lvar[i].sym.type;
1324                 if (!(vtype instanceof UninitializedType))
1325                     vtype = types.erasure(vtype);
1326                 frame.locals[i] = vtype;
1327             }
1328         }
1329         frame.stack = new Type[state.stacksize];
1330         for (int i=0; i<state.stacksize; i++)
1331             frame.stack[i] = state.stack[i];
1332     }
1333 
1334     void emitStackMapFrame(int pc, int localsSize) {
1335         if (lastFrame == null) {
1336             // first frame
1337             lastFrame = getInitialFrame();
1338         } else if (lastFrame.pc == pc) {
1339             // drop existing stackmap at this offset
1340             stackMapTableBuffer[--stackMapBufferSize] = null;
1341             lastFrame = frameBeforeLast;
1342             frameBeforeLast = null;
1343         }
1344 
1345         StackMapFrame frame = new StackMapFrame();
1346         frame.pc = pc;
1347 
1348         int localCount = 0;
1349         Type[] locals = new Type[localsSize];
1350         for (int i=0; i<localsSize; i++, localCount++) {
1351             if (state.defined.isMember(i) && lvar[i] != null) {
1352                 Type vtype = lvar[i].sym.type;
1353                 if (!(vtype instanceof UninitializedType))
1354                     vtype = types.erasure(vtype);
1355                 locals[i] = vtype;
1356                 if (width(vtype) > 1) i++;
1357             }
1358         }
1359         frame.locals = new Type[localCount];
1360         for (int i=0, j=0; i<localsSize; i++, j++) {
1361             Assert.check(j < localCount);
1362             frame.locals[j] = locals[i];
1363             if (width(locals[i]) > 1) i++;
1364         }
1365 
1366         int stackCount = 0;
1367         for (int i=0; i<state.stacksize; i++) {
1368             if (state.stack[i] != null) {
1369                 stackCount++;
1370             }
1371         }
1372         frame.stack = new Type[stackCount];
1373         stackCount = 0;
1374         for (int i=0; i<state.stacksize; i++) {
1375             if (state.stack[i] != null) {
1376                 frame.stack[stackCount++] = types.erasure(state.stack[i]);
1377             }
1378         }
1379 
1380         if (stackMapTableBuffer == null) {
1381             stackMapTableBuffer = new StackMapTableFrame[20];
1382         } else {
1383             stackMapTableBuffer = ArrayUtils.ensureCapacity(
1384                                     stackMapTableBuffer,
1385                                     stackMapBufferSize);
1386         }
1387         stackMapTableBuffer[stackMapBufferSize++] =
1388                 StackMapTableFrame.getInstance(frame, lastFrame.pc, lastFrame.locals, types);
1389 
1390         frameBeforeLast = lastFrame;
1391         lastFrame = frame;
1392     }
1393 
1394     StackMapFrame getInitialFrame() {
1395         StackMapFrame frame = new StackMapFrame();
1396         List<Type> arg_types = ((MethodType)meth.externalType(types)).argtypes;
1397         int len = arg_types.length();
1398         int count = 0;
1399         if (!meth.isStatic()) {
1400             Type thisType = meth.owner.type;
1401             frame.locals = new Type[len+1];
1402             if (meth.isConstructor() && thisType != syms.objectType) {
1403                 frame.locals[count++] = UninitializedType.uninitializedThis(thisType);
1404             } else {
1405                 frame.locals[count++] = types.erasure(thisType);
1406             }
1407         } else {
1408             frame.locals = new Type[len];
1409         }
1410         for (Type arg_type : arg_types) {
1411             frame.locals[count++] = types.erasure(arg_type);
1412         }
1413         frame.pc = -1;
1414         frame.stack = null;
1415         return frame;
1416     }
1417 
1418 
1419 /**************************************************************************
1420  * Operations having to do with jumps
1421  *************************************************************************/
1422 
1423     /** A chain represents a list of unresolved jumps. Jump locations
1424      *  are sorted in decreasing order.
1425      */
1426     public static class Chain {
1427 
1428         /** The position of the jump instruction.
1429          */
1430         public final int pc;
1431 
1432         /** The machine state after the jump instruction.
1433          *  Invariant: all elements of a chain list have the same stacksize
1434          *  and compatible stack and register contents.
1435          */
1436         Code.State state;
1437 
1438         /** The next jump in the list.
1439          */
1440         public final Chain next;
1441 
1442         /** Construct a chain from its jump position, stacksize, previous
1443          *  chain, and machine state.
1444          */
1445         public Chain(int pc, Chain next, Code.State state) {
1446             this.pc = pc;
1447             this.next = next;
1448             this.state = state;
1449         }
1450     }
1451 
1452     /** Negate a branch opcode.
1453      */
1454     public static int negate(int opcode) {
1455         if (opcode == if_acmp_null) return if_acmp_nonnull;
1456         else if (opcode == if_acmp_nonnull) return if_acmp_null;
1457         else return ((opcode + 1) ^ 1) - 1;
1458     }
1459 
1460     /** Emit a jump instruction.
1461      *  Return code pointer of instruction to be patched.
1462      */
1463     public int emitJump(int opcode) {
1464         if (fatcode) {
1465             if (opcode == goto_ || opcode == jsr) {
1466                 emitop4(opcode + goto_w - goto_, 0);
1467             } else {
1468                 emitop2(negate(opcode), 8);
1469                 emitop4(goto_w, 0);
1470                 alive = true;
1471                 pendingStackMap = needStackMap;
1472             }
1473             return cp - 5;
1474         } else {
1475             emitop2(opcode, 0);
1476             return cp - 3;
1477         }
1478     }
1479 
1480     /** Emit a branch with given opcode; return its chain.
1481      *  branch differs from jump in that jsr is treated as no-op.
1482      */
1483     public Chain branch(int opcode) {
1484         Chain result = null;
1485         if (opcode == goto_) {
1486             result = pendingJumps;
1487             pendingJumps = null;
1488         }
1489         if (opcode != dontgoto && isAlive()) {
1490             result = new Chain(emitJump(opcode),
1491                                result,
1492                                state.dup());
1493             fixedPc = fatcode;
1494             if (opcode == goto_) alive = false;
1495         }
1496         return result;
1497     }
1498 
1499     /** Resolve chain to point to given target.
1500      */
1501     public void resolve(Chain chain, int target) {
1502         boolean changed = false;
1503         State newState = state;
1504         for (; chain != null; chain = chain.next) {
1505             Assert.check(state != chain.state
1506                     && (target > chain.pc || state.stacksize == 0));
1507             if (target >= cp) {
1508                 target = cp;
1509             } else if (get1(target) == goto_) {
1510                 if (fatcode) target = target + get4(target + 1);
1511                 else target = target + get2(target + 1);
1512             }
1513             if (get1(chain.pc) == goto_ &&
1514                 chain.pc + 3 == target && target == cp && !fixedPc) {
1515                 // If goto the next instruction, the jump is not needed:
1516                 // compact the code.
1517                 if (varDebugInfo) {
1518                     adjustAliveRanges(cp, -3);
1519                 }
1520                 cp = cp - 3;
1521                 target = target - 3;
1522                 if (chain.next == null) {
1523                     // This is the only jump to the target. Exit the loop
1524                     // without setting new state. The code is reachable
1525                     // from the instruction before goto_.
1526                     alive = true;
1527                     break;
1528                 }
1529             } else {
1530                 if (fatcode)
1531                     put4(chain.pc + 1, target - chain.pc);
1532                 else if (target - chain.pc < Short.MIN_VALUE ||
1533                          target - chain.pc > Short.MAX_VALUE)
1534                     fatcode = true;
1535                 else
1536                     put2(chain.pc + 1, target - chain.pc);
1537                 Assert.check(!alive ||
1538                     chain.state.stacksize == newState.stacksize &&
1539                     chain.state.nlocks == newState.nlocks);
1540             }
1541             fixedPc = true;
1542             if (cp == target) {
1543                 changed = true;
1544                 if (debugCode)
1545                     System.err.println("resolving chain state=" + chain.state);
1546                 if (alive) {
1547                     newState = chain.state.join(newState);
1548                 } else {
1549                     newState = chain.state;
1550                     alive = true;
1551                 }
1552             }
1553         }
1554         Assert.check(!changed || state != newState);
1555         if (state != newState) {
1556             setDefined(newState.defined);
1557             state = newState;
1558             pendingStackMap = needStackMap;
1559         }
1560     }
1561 
1562     /** Resolve chain to point to current code pointer.
1563      */
1564     public void resolve(Chain chain) {
1565         Assert.check(
1566             !alive ||
1567             chain==null ||
1568             state.stacksize == chain.state.stacksize &&
1569             state.nlocks == chain.state.nlocks);
1570         pendingJumps = mergeChains(chain, pendingJumps);
1571     }
1572 
1573     /** Resolve any pending jumps.
1574      */
1575     public void resolvePending() {
1576         Chain x = pendingJumps;
1577         pendingJumps = null;
1578         resolve(x, cp);
1579     }
1580 
1581     /** Merge the jumps in of two chains into one.
1582      */
1583     public static Chain mergeChains(Chain chain1, Chain chain2) {
1584         // recursive merge sort
1585         if (chain2 == null) return chain1;
1586         if (chain1 == null) return chain2;
1587         Assert.check(
1588             chain1.state.stacksize == chain2.state.stacksize &&
1589             chain1.state.nlocks == chain2.state.nlocks);
1590         if (chain1.pc < chain2.pc)
1591             return new Chain(
1592                 chain2.pc,
1593                 mergeChains(chain1, chain2.next),
1594                 chain2.state);
1595         return new Chain(
1596                 chain1.pc,
1597                 mergeChains(chain1.next, chain2),
1598                 chain1.state);
1599     }
1600 
1601 
1602 /* **************************************************************************
1603  * Catch clauses
1604  ****************************************************************************/
1605 
1606     /** Add a catch clause to code.
1607      */
1608     public void addCatch(char startPc, char endPc,
1609                          char handlerPc, char catchType) {
1610             catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType});
1611         }
1612 
1613 
1614     public void compressCatchTable() {
1615         ListBuffer<char[]> compressedCatchInfo = new ListBuffer<>();
1616         List<Integer> handlerPcs = List.nil();
1617         for (char[] catchEntry : catchInfo) {
1618             handlerPcs = handlerPcs.prepend((int)catchEntry[2]);
1619         }
1620         for (char[] catchEntry : catchInfo) {
1621             int startpc = catchEntry[0];
1622             int endpc = catchEntry[1];
1623             if (startpc == endpc ||
1624                     (startpc == (endpc - 1) &&
1625                     handlerPcs.contains(startpc))) {
1626                 continue;
1627             } else {
1628                 compressedCatchInfo.append(catchEntry);
1629             }
1630         }
1631         catchInfo = compressedCatchInfo;
1632     }
1633 
1634 
1635 /* **************************************************************************
1636  * Line numbers
1637  ****************************************************************************/
1638 
1639     /** Add a line number entry.
1640      */
1641     public void addLineNumber(char startPc, char lineNumber) {
1642         if (lineDebugInfo) {
1643             if (lineInfo.nonEmpty() && lineInfo.head[0] == startPc)
1644                 lineInfo = lineInfo.tail;
1645             if (lineInfo.isEmpty() || lineInfo.head[1] != lineNumber)
1646                 lineInfo = lineInfo.prepend(new char[]{startPc, lineNumber});
1647         }
1648     }
1649 
1650     /** Mark beginning of statement.
1651      */
1652     public void statBegin(int pos) {
1653         if (pos != Position.NOPOS) {
1654             pendingStatPos = pos;
1655         }
1656     }
1657 
1658     /** Force stat begin eagerly
1659      */
1660     public void markStatBegin() {
1661         if (alive && lineDebugInfo) {
1662             int line = lineMap.getLineNumber(pendingStatPos);
1663             char cp1 = (char)cp;
1664             char line1 = (char)line;
1665             if (cp1 == cp && line1 == line)
1666                 addLineNumber(cp1, line1);
1667         }
1668         pendingStatPos = Position.NOPOS;
1669     }
1670 
1671 
1672 /* **************************************************************************
1673  * Simulated VM machine state
1674  ****************************************************************************/
1675 
1676     class State implements Cloneable {
1677         /** The set of registers containing values. */
1678         Bits defined;
1679 
1680         /** The (types of the) contents of the machine stack. */
1681         Type[] stack;
1682 
1683         /** The first stack position currently unused. */
1684         int stacksize;
1685 
1686         /** The numbers of registers containing locked monitors. */
1687         int[] locks;
1688         int nlocks;
1689 
1690         State() {
1691             defined = new Bits();
1692             stack = new Type[16];
1693         }
1694 
1695         State dup() {
1696             try {
1697                 State state = (State)super.clone();
1698                 state.defined = new Bits(defined);
1699                 state.stack = stack.clone();
1700                 if (locks != null) state.locks = locks.clone();
1701                 if (debugCode) {
1702                     System.err.println("duping state " + this);
1703                     dump();
1704                 }
1705                 return state;
1706             } catch (CloneNotSupportedException ex) {
1707                 throw new AssertionError(ex);
1708             }
1709         }
1710 
1711         void lock(int register) {
1712             if (locks == null) {
1713                 locks = new int[20];
1714             } else {
1715                 locks = ArrayUtils.ensureCapacity(locks, nlocks);
1716             }
1717             locks[nlocks] = register;
1718             nlocks++;
1719         }
1720 
1721         void unlock(int register) {
1722             nlocks--;
1723             Assert.check(locks[nlocks] == register);
1724             locks[nlocks] = -1;
1725         }
1726 
1727         void push(Type t) {
1728             if (debugCode) System.err.println("   pushing " + t);
1729             switch (t.getTag()) {
1730             case VOID:
1731                 return;
1732             case BYTE:
1733             case CHAR:
1734             case SHORT:
1735             case BOOLEAN:
1736                 t = syms.intType;
1737                 break;
1738             default:
1739                 break;
1740             }
1741             stack = ArrayUtils.ensureCapacity(stack, stacksize+2);
1742             stack[stacksize++] = t;
1743             switch (width(t)) {
1744             case 1:
1745                 break;
1746             case 2:
1747                 stack[stacksize++] = null;
1748                 break;
1749             default:
1750                 throw new AssertionError(t);
1751             }
1752             if (stacksize > max_stack)
1753                 max_stack = stacksize;
1754         }
1755 
1756         Type pop1() {
1757             if (debugCode) System.err.println("   popping " + 1);
1758             stacksize--;
1759             Type result = stack[stacksize];
1760             stack[stacksize] = null;
1761             Assert.check(result != null && width(result) == 1);
1762             return result;
1763         }
1764 
1765         Type peek() {
1766             return stack[stacksize-1];
1767         }
1768 
1769         Type pop2() {
1770             if (debugCode) System.err.println("   popping " + 2);
1771             stacksize -= 2;
1772             Type result = stack[stacksize];
1773             stack[stacksize] = null;
1774             Assert.check(stack[stacksize+1] == null
1775                     && result != null && width(result) == 2);
1776             return result;
1777         }
1778 
1779         void pop(int n) {
1780             if (debugCode) System.err.println("   popping " + n);
1781             while (n > 0) {
1782                 stack[--stacksize] = null;
1783                 n--;
1784             }
1785         }
1786 
1787         void pop(Type t) {
1788             pop(width(t));
1789         }
1790 
1791         /** Force the top of the stack to be treated as this supertype
1792          *  of its current type. */
1793         void forceStackTop(Type t) {
1794             if (!alive) return;
1795             switch (t.getTag()) {
1796             case CLASS:
1797             case ARRAY:
1798                 int width = width(t);
1799                 Type old = stack[stacksize-width];
1800                 Assert.check(types.isSubtype(types.erasure(old),
1801                                        types.erasure(t)));
1802                 stack[stacksize-width] = t;
1803                 break;
1804             default:
1805             }
1806         }
1807 
1808         void markInitialized(UninitializedType old) {
1809             Type newtype = old.initializedType();
1810             for (int i=0; i<stacksize; i++) {
1811                 if (stack[i] == old) stack[i] = newtype;
1812             }
1813             for (int i=0; i<lvar.length; i++) {
1814                 LocalVar lv = lvar[i];
1815                 if (lv != null && lv.sym.type == old) {
1816                     VarSymbol sym = lv.sym;
1817                     sym = sym.clone(sym.owner);
1818                     sym.type = newtype;
1819                     LocalVar newlv = lvar[i] = new LocalVar(sym);
1820                     newlv.aliveRanges = lv.aliveRanges;
1821                 }
1822             }
1823         }
1824 
1825         State join(State other) {
1826             defined.andSet(other.defined);
1827             Assert.check(stacksize == other.stacksize
1828                     && nlocks == other.nlocks);
1829             for (int i=0; i<stacksize; ) {
1830                 Type t = stack[i];
1831                 Type tother = other.stack[i];
1832                 Type result =
1833                     t==tother ? t :
1834                     types.isSubtype(t, tother) ? tother :
1835                     types.isSubtype(tother, t) ? t :
1836                     error();
1837                 int w = width(result);
1838                 stack[i] = result;
1839                 if (w == 2) Assert.checkNull(stack[i+1]);
1840                 i += w;
1841             }
1842             return this;
1843         }
1844 
1845         Type error() {
1846             throw new AssertionError("inconsistent stack types at join point");
1847         }
1848 
1849         void dump() {
1850             dump(-1);
1851         }
1852 
1853         void dump(int pc) {
1854             System.err.print("stackMap for " + meth.owner + "." + meth);
1855             if (pc == -1)
1856                 System.out.println();
1857             else
1858                 System.out.println(" at " + pc);
1859             System.err.println(" stack (from bottom):");
1860             for (int i=0; i<stacksize; i++)
1861                 System.err.println("  " + i + ": " + stack[i]);
1862 
1863             int lastLocal = 0;
1864             for (int i=max_locals-1; i>=0; i--) {
1865                 if (defined.isMember(i)) {
1866                     lastLocal = i;
1867                     break;
1868                 }
1869             }
1870             if (lastLocal >= 0)
1871                 System.err.println(" locals:");
1872             for (int i=0; i<=lastLocal; i++) {
1873                 System.err.print("  " + i + ": ");
1874                 if (defined.isMember(i)) {
1875                     LocalVar var = lvar[i];
1876                     if (var == null) {
1877                         System.err.println("(none)");
1878                     } else if (var.sym == null)
1879                         System.err.println("UNKNOWN!");
1880                     else
1881                         System.err.println("" + var.sym + " of type " +
1882                                            var.sym.erasure(types));
1883                 } else {
1884                     System.err.println("undefined");
1885                 }
1886             }
1887             if (nlocks != 0) {
1888                 System.err.print(" locks:");
1889                 for (int i=0; i<nlocks; i++) {
1890                     System.err.print(" " + locks[i]);
1891                 }
1892                 System.err.println();
1893             }
1894         }
1895     }
1896 
1897     static final Type jsrReturnValue = new JCPrimitiveType(INT, null);
1898 
1899 
1900 /* **************************************************************************
1901  * Local variables
1902  ****************************************************************************/
1903 
1904     /** A live range of a local variable. */
1905     static class LocalVar {
1906         final VarSymbol sym;
1907         final char reg;
1908 
1909         class Range {
1910             char start_pc = Character.MAX_VALUE;
1911             char length = Character.MAX_VALUE;
1912 
1913             Range() {}
1914 
1915             Range(char start) {
1916                 this.start_pc = start;
1917             }
1918 
1919             Range(char start, char length) {
1920                 this.start_pc = start;
1921                 this.length = length;
1922             }
1923 
1924             boolean closed() {
1925                 return start_pc != Character.MAX_VALUE && length != Character.MAX_VALUE;
1926             }
1927 
1928             @Override
1929             public String toString() {
1930                 int currentStartPC = start_pc;
1931                 int currentLength = length;
1932                 return "startpc = " + currentStartPC + " length " + currentLength;
1933             }
1934         }
1935 
1936         java.util.List<Range> aliveRanges = new java.util.ArrayList<>();
1937 
1938         LocalVar(VarSymbol v) {
1939             this.sym = v;
1940             this.reg = (char)v.adr;
1941         }
1942         public LocalVar dup() {
1943             return new LocalVar(sym);
1944         }
1945 
1946         Range firstRange() {
1947             return aliveRanges.isEmpty() ? null : aliveRanges.get(0);
1948         }
1949 
1950         Range lastRange() {
1951             return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1);
1952         }
1953 
1954         void removeLastRange() {
1955             Range lastRange = lastRange();
1956             if (lastRange != null) {
1957                 aliveRanges.remove(lastRange);
1958             }
1959         }
1960 
1961         @Override
1962         public String toString() {
1963             if (aliveRanges == null) {
1964                 return "empty local var";
1965             }
1966             StringBuilder sb = new StringBuilder().append(sym)
1967                     .append(" in register ").append((int)reg).append(" \n");
1968             for (Range r : aliveRanges) {
1969                 sb.append(" starts at pc=").append(Integer.toString(((int)r.start_pc)))
1970                     .append(" length=").append(Integer.toString(((int)r.length)))
1971                     .append("\n");
1972             }
1973             return sb.toString();
1974         }
1975 
1976         public void openRange(char start) {
1977             if (!hasOpenRange()) {
1978                 aliveRanges.add(new Range(start));
1979             }
1980         }
1981 
1982         public void closeRange(char length) {
1983             if (isLastRangeInitialized() && length > 0) {
1984                 Range range = lastRange();
1985                 if (range != null) {
1986                     if (range.length == Character.MAX_VALUE) {
1987                         range.length = length;
1988                     }
1989                 }
1990             } else {
1991                 removeLastRange();
1992             }
1993         }
1994 
1995         public boolean hasOpenRange() {
1996             if (aliveRanges.isEmpty()) {
1997                 return false;
1998             }
1999             return lastRange().length == Character.MAX_VALUE;
2000         }
2001 
2002         public boolean isLastRangeInitialized() {
2003             if (aliveRanges.isEmpty()) {
2004                 return false;
2005             }
2006             return lastRange().start_pc != Character.MAX_VALUE;
2007         }
2008 
2009         public Range getWidestRange() {
2010             if (aliveRanges.isEmpty()) {
2011                 return new Range();
2012             } else {
2013                 Range firstRange = firstRange();
2014                 Range lastRange = lastRange();
2015                 char length = (char)(lastRange.length + (lastRange.start_pc - firstRange.start_pc));
2016                 return new Range(firstRange.start_pc, length);
2017             }
2018          }
2019 
2020     }
2021 
2022     /** Local variables, indexed by register. */
2023     LocalVar[] lvar;
2024 
2025     /** Add a new local variable. */
2026     private void addLocalVar(VarSymbol v) {
2027         int adr = v.adr;
2028         lvar = ArrayUtils.ensureCapacity(lvar, adr+1);
2029         Assert.checkNull(lvar[adr]);
2030         if (pendingJumps != null) {
2031             resolvePending();
2032         }
2033         lvar[adr] = new LocalVar(v);
2034         state.defined.excl(adr);
2035     }
2036 
2037     void adjustAliveRanges(int oldCP, int delta) {
2038         for (LocalVar localVar: lvar) {
2039             if (localVar != null) {
2040                 for (LocalVar.Range range: localVar.aliveRanges) {
2041                     if (range.closed() && range.start_pc + range.length >= oldCP) {
2042                         range.length += delta;
2043                     }
2044                 }
2045             }
2046         }
2047     }
2048 
2049     /**
2050      * Calculates the size of the LocalVariableTable.
2051      */
2052     public int getLVTSize() {
2053         int result = varBufferSize;
2054         for (int i = 0; i < varBufferSize; i++) {
2055             LocalVar var = varBuffer[i];
2056             result += var.aliveRanges.size() - 1;
2057         }
2058         return result;
2059     }
2060 
2061     /** Set the current variable defined state. */
2062     public void setDefined(Bits newDefined) {
2063         if (alive && newDefined != state.defined) {
2064             Bits diff = new Bits(state.defined).xorSet(newDefined);
2065             for (int adr = diff.nextBit(0);
2066                  adr >= 0;
2067                  adr = diff.nextBit(adr+1)) {
2068                 if (adr >= nextreg)
2069                     state.defined.excl(adr);
2070                 else if (state.defined.isMember(adr))
2071                     setUndefined(adr);
2072                 else
2073                     setDefined(adr);
2074             }
2075         }
2076     }
2077 
2078     /** Mark a register as being (possibly) defined. */
2079     public void setDefined(int adr) {
2080         LocalVar v = lvar[adr];
2081         if (v == null) {
2082             state.defined.excl(adr);
2083         } else {
2084             state.defined.incl(adr);
2085             if (cp < Character.MAX_VALUE) {
2086                 v.openRange((char)cp);
2087             }
2088         }
2089     }
2090 
2091     /** Mark a register as being undefined. */
2092     public void setUndefined(int adr) {
2093         state.defined.excl(adr);
2094         if (adr < lvar.length &&
2095             lvar[adr] != null &&
2096             lvar[adr].isLastRangeInitialized()) {
2097             LocalVar v = lvar[adr];
2098             char length = (char)(curCP() - v.lastRange().start_pc);
2099             if (length < Character.MAX_VALUE) {
2100                 lvar[adr] = v.dup();
2101                 v.closeRange(length);
2102                 putVar(v);
2103             } else {
2104                 v.removeLastRange();
2105             }
2106         }
2107     }
2108 
2109     /** End the scope of a variable. */
2110     private void endScope(int adr) {
2111         LocalVar v = lvar[adr];
2112         if (v != null) {
2113             if (v.isLastRangeInitialized()) {
2114                 char length = (char)(curCP() - v.lastRange().start_pc);
2115                 if (length < Character.MAX_VALUE) {
2116                     v.closeRange(length);
2117                     putVar(v);
2118                     fillLocalVarPosition(v);
2119                 }
2120             }
2121             /** the call to curCP() can implicitly adjust the current cp, if so
2122              * the alive range of local variables may be modified. Thus we need
2123              * all of them. For this reason assigning null to the given address
2124              * should be the last action to do.
2125              */
2126             lvar[adr] = null;
2127         }
2128         state.defined.excl(adr);
2129     }
2130 
2131     private void fillLocalVarPosition(LocalVar lv) {
2132         if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations())
2133             return;
2134         for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
2135             TypeAnnotationPosition p = ta.position;
2136             LocalVar.Range widestRange = lv.getWidestRange();
2137             p.lvarOffset = new int[] { (int)widestRange.start_pc };
2138             p.lvarLength = new int[] { (int)widestRange.length };
2139             p.lvarIndex = new int[] { (int)lv.reg };
2140             p.isValidOffset = true;
2141         }
2142     }
2143 
2144     // Method to be called after compressCatchTable to
2145     // fill in the exception table index for type
2146     // annotations on exception parameters.
2147     public void fillExceptionParameterPositions() {
2148         for (int i = 0; i < varBufferSize; ++i) {
2149             LocalVar lv = varBuffer[i];
2150             if (lv == null || lv.sym == null
2151                     || !lv.sym.hasTypeAnnotations()
2152                     || !lv.sym.isExceptionParameter())
2153                 continue;
2154 
2155             for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
2156                 TypeAnnotationPosition p = ta.position;
2157                 if (p.hasCatchType()) {
2158                     final int idx = findExceptionIndex(p);
2159                     if (idx == -1)
2160                         Assert.error("Could not find exception index for type annotation " +
2161                                      ta + " on exception parameter");
2162                     p.setExceptionIndex(idx);
2163                 }
2164             }
2165         }
2166     }
2167 
2168     private int findExceptionIndex(TypeAnnotationPosition p) {
2169         final int catchType = p.getCatchType();
2170         final int startPos = p.getStartPos();
2171         final int len = catchInfo.length();
2172         List<char[]> iter = catchInfo.toList();
2173         for (int i = 0; i < len; ++i) {
2174             char[] catchEntry = iter.head;
2175             iter = iter.tail;
2176             int ct = catchEntry[3];
2177             int sp = catchEntry[0];
2178             if (catchType == ct && sp == startPos) {
2179                 return i;
2180             }
2181         }
2182         return -1;
2183     }
2184 
2185     /** Put a live variable range into the buffer to be output to the
2186      *  class file.
2187      */
2188     void putVar(LocalVar var) {
2189         // Keep local variables if
2190         // 1) we need them for debug information
2191         // 2) it is an exception type and it contains type annotations
2192         boolean keepLocalVariables = varDebugInfo ||
2193             (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
2194         if (!keepLocalVariables) return;
2195         //don't keep synthetic vars, unless they are lambda method parameters
2196         boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 &&
2197                 ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 ||
2198                  (var.sym.flags() & Flags.PARAMETER) == 0);
2199         if (ignoredSyntheticVar) return;
2200         if (varBuffer == null)
2201             varBuffer = new LocalVar[20];
2202         else
2203             varBuffer = ArrayUtils.ensureCapacity(varBuffer, varBufferSize);
2204         varBuffer[varBufferSize++] = var;
2205     }
2206 
2207     /** Previously live local variables, to be put into the variable table. */
2208     LocalVar[] varBuffer;
2209     int varBufferSize;
2210 
2211     /** Create a new local variable address and return it.
2212      */
2213     private int newLocal(int typecode) {
2214         int reg = nextreg;
2215         int w = width(typecode);
2216         nextreg = reg + w;
2217         if (nextreg > max_locals) max_locals = nextreg;
2218         return reg;
2219     }
2220 
2221     private int newLocal(Type type) {
2222         return newLocal(typecode(type));
2223     }
2224 
2225     public int newLocal(VarSymbol v) {
2226         int reg = v.adr = newLocal(v.erasure(types));
2227         addLocalVar(v);
2228         return reg;
2229     }
2230 
2231     /** Start a set of fresh registers.
2232      */
2233     public void newRegSegment() {
2234         nextreg = max_locals;
2235     }
2236 
2237     /** End scopes of all variables with registers &ge; first.
2238      */
2239     public void endScopes(int first) {
2240         int prevNextReg = nextreg;
2241         nextreg = first;
2242         for (int i = nextreg; i < prevNextReg; i++) endScope(i);
2243     }
2244 
2245 /**************************************************************************
2246  * static tables
2247  *************************************************************************/
2248 
2249     public static String mnem(int opcode) {
2250         return Mneumonics.mnem[opcode];
2251     }
2252 
2253     private static class Mneumonics {
2254         private final static String[] mnem = new String[ByteCodeCount];
2255         static {
2256             mnem[nop] = "nop";
2257             mnem[aconst_null] = "aconst_null";
2258             mnem[iconst_m1] = "iconst_m1";
2259             mnem[iconst_0] = "iconst_0";
2260             mnem[iconst_1] = "iconst_1";
2261             mnem[iconst_2] = "iconst_2";
2262             mnem[iconst_3] = "iconst_3";
2263             mnem[iconst_4] = "iconst_4";
2264             mnem[iconst_5] = "iconst_5";
2265             mnem[lconst_0] = "lconst_0";
2266             mnem[lconst_1] = "lconst_1";
2267             mnem[fconst_0] = "fconst_0";
2268             mnem[fconst_1] = "fconst_1";
2269             mnem[fconst_2] = "fconst_2";
2270             mnem[dconst_0] = "dconst_0";
2271             mnem[dconst_1] = "dconst_1";
2272             mnem[bipush] = "bipush";
2273             mnem[sipush] = "sipush";
2274             mnem[ldc1] = "ldc1";
2275             mnem[ldc2] = "ldc2";
2276             mnem[ldc2w] = "ldc2w";
2277             mnem[iload] = "iload";
2278             mnem[lload] = "lload";
2279             mnem[fload] = "fload";
2280             mnem[dload] = "dload";
2281             mnem[aload] = "aload";
2282             mnem[iload_0] = "iload_0";
2283             mnem[lload_0] = "lload_0";
2284             mnem[fload_0] = "fload_0";
2285             mnem[dload_0] = "dload_0";
2286             mnem[aload_0] = "aload_0";
2287             mnem[iload_1] = "iload_1";
2288             mnem[lload_1] = "lload_1";
2289             mnem[fload_1] = "fload_1";
2290             mnem[dload_1] = "dload_1";
2291             mnem[aload_1] = "aload_1";
2292             mnem[iload_2] = "iload_2";
2293             mnem[lload_2] = "lload_2";
2294             mnem[fload_2] = "fload_2";
2295             mnem[dload_2] = "dload_2";
2296             mnem[aload_2] = "aload_2";
2297             mnem[iload_3] = "iload_3";
2298             mnem[lload_3] = "lload_3";
2299             mnem[fload_3] = "fload_3";
2300             mnem[dload_3] = "dload_3";
2301             mnem[aload_3] = "aload_3";
2302             mnem[iaload] = "iaload";
2303             mnem[laload] = "laload";
2304             mnem[faload] = "faload";
2305             mnem[daload] = "daload";
2306             mnem[aaload] = "aaload";
2307             mnem[baload] = "baload";
2308             mnem[caload] = "caload";
2309             mnem[saload] = "saload";
2310             mnem[istore] = "istore";
2311             mnem[lstore] = "lstore";
2312             mnem[fstore] = "fstore";
2313             mnem[dstore] = "dstore";
2314             mnem[astore] = "astore";
2315             mnem[istore_0] = "istore_0";
2316             mnem[lstore_0] = "lstore_0";
2317             mnem[fstore_0] = "fstore_0";
2318             mnem[dstore_0] = "dstore_0";
2319             mnem[astore_0] = "astore_0";
2320             mnem[istore_1] = "istore_1";
2321             mnem[lstore_1] = "lstore_1";
2322             mnem[fstore_1] = "fstore_1";
2323             mnem[dstore_1] = "dstore_1";
2324             mnem[astore_1] = "astore_1";
2325             mnem[istore_2] = "istore_2";
2326             mnem[lstore_2] = "lstore_2";
2327             mnem[fstore_2] = "fstore_2";
2328             mnem[dstore_2] = "dstore_2";
2329             mnem[astore_2] = "astore_2";
2330             mnem[istore_3] = "istore_3";
2331             mnem[lstore_3] = "lstore_3";
2332             mnem[fstore_3] = "fstore_3";
2333             mnem[dstore_3] = "dstore_3";
2334             mnem[astore_3] = "astore_3";
2335             mnem[iastore] = "iastore";
2336             mnem[lastore] = "lastore";
2337             mnem[fastore] = "fastore";
2338             mnem[dastore] = "dastore";
2339             mnem[aastore] = "aastore";
2340             mnem[bastore] = "bastore";
2341             mnem[castore] = "castore";
2342             mnem[sastore] = "sastore";
2343             mnem[pop] = "pop";
2344             mnem[pop2] = "pop2";
2345             mnem[dup] = "dup";
2346             mnem[dup_x1] = "dup_x1";
2347             mnem[dup_x2] = "dup_x2";
2348             mnem[dup2] = "dup2";
2349             mnem[dup2_x1] = "dup2_x1";
2350             mnem[dup2_x2] = "dup2_x2";
2351             mnem[swap] = "swap";
2352             mnem[iadd] = "iadd";
2353             mnem[ladd] = "ladd";
2354             mnem[fadd] = "fadd";
2355             mnem[dadd] = "dadd";
2356             mnem[isub] = "isub";
2357             mnem[lsub] = "lsub";
2358             mnem[fsub] = "fsub";
2359             mnem[dsub] = "dsub";
2360             mnem[imul] = "imul";
2361             mnem[lmul] = "lmul";
2362             mnem[fmul] = "fmul";
2363             mnem[dmul] = "dmul";
2364             mnem[idiv] = "idiv";
2365             mnem[ldiv] = "ldiv";
2366             mnem[fdiv] = "fdiv";
2367             mnem[ddiv] = "ddiv";
2368             mnem[imod] = "imod";
2369             mnem[lmod] = "lmod";
2370             mnem[fmod] = "fmod";
2371             mnem[dmod] = "dmod";
2372             mnem[ineg] = "ineg";
2373             mnem[lneg] = "lneg";
2374             mnem[fneg] = "fneg";
2375             mnem[dneg] = "dneg";
2376             mnem[ishl] = "ishl";
2377             mnem[lshl] = "lshl";
2378             mnem[ishr] = "ishr";
2379             mnem[lshr] = "lshr";
2380             mnem[iushr] = "iushr";
2381             mnem[lushr] = "lushr";
2382             mnem[iand] = "iand";
2383             mnem[land] = "land";
2384             mnem[ior] = "ior";
2385             mnem[lor] = "lor";
2386             mnem[ixor] = "ixor";
2387             mnem[lxor] = "lxor";
2388             mnem[iinc] = "iinc";
2389             mnem[i2l] = "i2l";
2390             mnem[i2f] = "i2f";
2391             mnem[i2d] = "i2d";
2392             mnem[l2i] = "l2i";
2393             mnem[l2f] = "l2f";
2394             mnem[l2d] = "l2d";
2395             mnem[f2i] = "f2i";
2396             mnem[f2l] = "f2l";
2397             mnem[f2d] = "f2d";
2398             mnem[d2i] = "d2i";
2399             mnem[d2l] = "d2l";
2400             mnem[d2f] = "d2f";
2401             mnem[int2byte] = "int2byte";
2402             mnem[int2char] = "int2char";
2403             mnem[int2short] = "int2short";
2404             mnem[lcmp] = "lcmp";
2405             mnem[fcmpl] = "fcmpl";
2406             mnem[fcmpg] = "fcmpg";
2407             mnem[dcmpl] = "dcmpl";
2408             mnem[dcmpg] = "dcmpg";
2409             mnem[ifeq] = "ifeq";
2410             mnem[ifne] = "ifne";
2411             mnem[iflt] = "iflt";
2412             mnem[ifge] = "ifge";
2413             mnem[ifgt] = "ifgt";
2414             mnem[ifle] = "ifle";
2415             mnem[if_icmpeq] = "if_icmpeq";
2416             mnem[if_icmpne] = "if_icmpne";
2417             mnem[if_icmplt] = "if_icmplt";
2418             mnem[if_icmpge] = "if_icmpge";
2419             mnem[if_icmpgt] = "if_icmpgt";
2420             mnem[if_icmple] = "if_icmple";
2421             mnem[if_acmpeq] = "if_acmpeq";
2422             mnem[if_acmpne] = "if_acmpne";
2423             mnem[goto_] = "goto_";
2424             mnem[jsr] = "jsr";
2425             mnem[ret] = "ret";
2426             mnem[tableswitch] = "tableswitch";
2427             mnem[lookupswitch] = "lookupswitch";
2428             mnem[ireturn] = "ireturn";
2429             mnem[lreturn] = "lreturn";
2430             mnem[freturn] = "freturn";
2431             mnem[dreturn] = "dreturn";
2432             mnem[areturn] = "areturn";
2433             mnem[return_] = "return_";
2434             mnem[getstatic] = "getstatic";
2435             mnem[putstatic] = "putstatic";
2436             mnem[getfield] = "getfield";
2437             mnem[putfield] = "putfield";
2438             mnem[invokevirtual] = "invokevirtual";
2439             mnem[invokespecial] = "invokespecial";
2440             mnem[invokestatic] = "invokestatic";
2441             mnem[invokeinterface] = "invokeinterface";
2442             mnem[invokedynamic] = "invokedynamic";
2443             mnem[new_] = "new_";
2444             mnem[newarray] = "newarray";
2445             mnem[anewarray] = "anewarray";
2446             mnem[arraylength] = "arraylength";
2447             mnem[athrow] = "athrow";
2448             mnem[checkcast] = "checkcast";
2449             mnem[instanceof_] = "instanceof_";
2450             mnem[monitorenter] = "monitorenter";
2451             mnem[monitorexit] = "monitorexit";
2452             mnem[wide] = "wide";
2453             mnem[multianewarray] = "multianewarray";
2454             mnem[if_acmp_null] = "if_acmp_null";
2455             mnem[if_acmp_nonnull] = "if_acmp_nonnull";
2456             mnem[goto_w] = "goto_w";
2457             mnem[jsr_w] = "jsr_w";
2458             mnem[breakpoint] = "breakpoint";
2459             mnem[vload] = "vload";
2460             mnem[vstore] = "vstore";
2461             mnem[vaload] = "vaload";
2462             mnem[vastore] = "vastore";
2463             mnem[vreturn] = "vreturn";
2464             mnem[vdefault] = "vdefault";
2465             mnem[vwithfield] = "vwithfield";
2466         }
2467     }
2468 }