001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.compilers.baseline;
014
015import static org.jikesrvm.classloader.BytecodeConstants.*;
016import static org.jikesrvm.classloader.ClassLoaderConstants.CP_DOUBLE;
017import static org.jikesrvm.classloader.ClassLoaderConstants.CP_FLOAT;
018import static org.jikesrvm.classloader.ClassLoaderConstants.CP_INT;
019import static org.jikesrvm.classloader.ClassLoaderConstants.CP_LONG;
020
021import org.jikesrvm.VM;
022import org.jikesrvm.classloader.BytecodeStream;
023import org.jikesrvm.classloader.FieldReference;
024import org.jikesrvm.classloader.MethodReference;
025import org.jikesrvm.classloader.NormalMethod;
026import org.jikesrvm.classloader.RVMArray;
027import org.jikesrvm.classloader.RVMClass;
028import org.jikesrvm.classloader.RVMMethod;
029import org.jikesrvm.classloader.RVMType;
030import org.jikesrvm.classloader.TypeReference;
031import org.jikesrvm.compilers.common.CodeArray;
032import org.jikesrvm.compilers.common.CompiledMethod;
033import org.jikesrvm.compilers.common.CompiledMethods;
034import org.jikesrvm.compilers.common.assembler.AbstractAssembler;
035import org.jikesrvm.compilers.common.assembler.ForwardReference;
036import org.jikesrvm.osr.bytecodes.InvokeStatic;
037import org.jikesrvm.runtime.Statics;
038import org.jikesrvm.scheduler.RVMThread;
039import org.jikesrvm.util.Services;
040import org.vmmagic.pragma.Inline;
041import org.vmmagic.pragma.NoInline;
042import org.vmmagic.unboxed.Offset;
043
044/**
045 * Framework compiler - platform independent code.
046 * This compiler provides the structure for a very simple compiler --
047 * one that generates code as each bytecode in the class file is
048 * seen. It is the common base class of the base compiler.
049 */
050public abstract class TemplateCompilerFramework {
051
052  /**
053   * The method being compiled
054   */
055  protected final NormalMethod method;
056
057  /**
058   * The declaring class of the method being compiled
059   */
060  protected final RVMClass klass;
061
062  /**
063   * The bytecodes of the method being compiled
064   */
065  protected final BytecodeStream bcodes;
066
067  /**
068   * Mapping from bytecodes to machine code offsets
069   */
070  protected final int[] bytecodeMap;
071
072  /**
073   * bi at the start of a bytecode
074   */
075  protected int biStart;
076
077  /**
078   * The compiledMethod assigned to this compilation of method
079   */
080  protected final CompiledMethod compiledMethod;
081
082  /**
083   * The height of the expression stack at the start of each bytecode.
084   * Only saved for some architectures, on others this field will be null.
085   * See the BaselineCompilerImpl constructor.
086   */
087  protected int[] stackHeights;
088
089  /**
090   * machine code offset at which the lock is acquired in the prologue of a synchronized method.
091   */
092  protected int lockOffset;
093
094  /**
095   * Should we print the machine code we generate?
096   */
097  protected boolean shouldPrint = false;
098
099  /**
100   * Is the method currently being compiled interruptible?
101   */
102  protected final boolean isInterruptible;
103  /**
104   * Does this method do checkstore?
105   */
106  protected final boolean doesCheckStore;
107
108  /**
109   * Is the method currently being compiled uninterruptible?
110   */
111  protected final boolean isUninterruptible;
112
113  public static class MachineCode {
114    private final CodeArray instructions;
115    private int[] bcMap;
116    MachineCode(CodeArray i, int[] bcm) {
117      instructions = i;
118      bcMap = bcm;
119    }
120    public CodeArray getInstructions() {
121      return instructions;
122    }
123    public int[] getBytecodeMap() {
124      return bcMap;
125    }
126    public void setBytecodeMap(int[] newmap) {
127      bcMap = newmap;
128    }
129  }
130  /**
131   * Is the method currently being compiled unpreemptible?
132   */
133  protected final boolean isUnpreemptible;
134
135  public enum BranchCondition {
136    EQ, NE, LT, GE, GT, LE
137  }
138
139  protected TemplateCompilerFramework(CompiledMethod cm) {
140    compiledMethod = cm;
141    method = (NormalMethod) cm.getMethod();
142
143    klass = method.getDeclaringClass();
144
145    // new synthesized bytecodes for OSR
146    if (method.isForOsrSpecialization()) {
147      bcodes = method.getOsrSynthesizedBytecodes();
148    } else {
149      bcodes = method.getBytecodes();
150    }
151
152    bytecodeMap = new int[bcodes.length() + 1];
153    isInterruptible = method.isInterruptible();
154    if (isInterruptible) {
155      isUninterruptible = false;
156      isUnpreemptible = false;
157    } else {
158      isUninterruptible = method.isUninterruptible();
159      isUnpreemptible = method.isUnpreemptible();
160    }
161    doesCheckStore = !method.hasNoCheckStoreAnnotation();
162
163    // Double check logically uninterruptible methods have been annotated as
164    // uninterruptible
165    // TODO: remove logically uninterruptible annotations (see RVM-115).
166    if (VM.VerifyAssertions && method.hasLogicallyUninterruptibleAnnotation()) {
167      if (!isUninterruptible) {
168        String msg = "LogicallyUninterruptible but not Uninterruptible method: " +
169            method.toString();
170        VM._assert(VM.NOT_REACHED, msg);
171      }
172    }
173  }
174
175  /**
176   * @param method the method that contains the bytecode that produces an
177   *  empty basic block
178   * @return the stack height for a basic block with an empty stack. In a
179   *  basic with an empty stack, space for local variables still needs to
180   *  be reserved.
181   */
182  public static final int stackHeightForEmptyBasicBlock(NormalMethod method) {
183    return method.getLocalWords() - 1;   // -1 to locate the last "local" index
184  }
185
186  protected abstract AbstractAssembler getAssembler();
187
188  final int[] getBytecodeMap() {
189    return bytecodeMap;
190  }
191
192  /**
193   * Print a message to mark the start of machine code printing for a method
194   * @param method the method that will be compiled
195   */
196  protected final void printStartHeader(RVMMethod method) {
197    VM.sysWrite(getCompilerName());
198    VM.sysWrite(" Start: Final machine code for method ");
199    VM.sysWrite(method.getDeclaringClass().toString());
200    VM.sysWrite(" ");
201    VM.sysWrite(method.getName());
202    VM.sysWrite(" ");
203    VM.sysWrite(method.getDescriptor());
204    VM.sysWrite("\n");
205  }
206
207  /**
208   * Print a message to mark the end of machine code printing for a method
209   * @param method the method that was compiled
210   */
211  protected final void printEndHeader(RVMMethod method) {
212    VM.sysWrite(getCompilerName());
213    VM.sysWrite(" End: Final machine code for method ");
214    VM.sysWrite(method.getDeclaringClass().toString());
215    VM.sysWrite(" ");
216    VM.sysWrite(method.getName());
217    VM.sysWrite(" ");
218    VM.sysWrite(method.getDescriptor());
219    VM.sysWrite("\n");
220  }
221
222  /**
223   * Print a message of a method name
224   */
225  protected final void printMethodMessage() {
226    String compilerName = getCompilerName();
227
228    // It's tempting to use Character.toUpperCase here, but Character
229    // isn't fully initialized early in booting, so don't do it!
230    if (compilerName.equals("baseline")) {
231      VM.sysWrite("-methodBaseline ");
232    } else if (VM.VerifyAssertions) {
233      VM._assert(VM.NOT_REACHED, "Unknown compiler");
234    }
235    VM.sysWrite(method.getDeclaringClass().toString());
236    VM.sysWrite(" ");
237    VM.sysWrite(method.getName());
238    VM.sysWrite(" ");
239    VM.sysWrite(method.getDescriptor());
240    VM.sysWrite(" \n");
241  }
242
243  /**
244   * Main code generation loop.
245   *
246   * @return generated machine code
247   */
248  protected final MachineCode genCode() {
249    AbstractAssembler asm = getAssembler();
250
251    emit_prologue();
252    while (bcodes.hasMoreBytecodes()) {
253      biStart = bcodes.index();
254      bytecodeMap[biStart] = asm.getMachineCodeIndex();
255      asm.resolveForwardReferences(biStart);
256      starting_bytecode();
257      int code = bcodes.nextInstruction();
258      switch (code) {
259        case JBC_nop: {
260          if (shouldPrint) asm.noteBytecode(biStart, "nop");
261          break;
262        }
263
264        case JBC_aconst_null: {
265          if (shouldPrint) asm.noteBytecode(biStart, "aconst_null");
266          emit_aconst_null();
267          break;
268        }
269
270        case JBC_iconst_m1: {
271          if (shouldPrint) asm.noteBytecode(biStart, "iconst_m1");
272          emit_iconst(-1);
273          break;
274        }
275
276        case JBC_iconst_0: {
277          if (shouldPrint) asm.noteBytecode(biStart, "iconst_0");
278          emit_iconst(0);
279          break;
280        }
281
282        case JBC_iconst_1: {
283          if (shouldPrint) asm.noteBytecode(biStart, "iconst_1");
284          emit_iconst(1);
285          break;
286        }
287
288        case JBC_iconst_2: {
289          if (shouldPrint) asm.noteBytecode(biStart, "iconst_2");
290          emit_iconst(2);
291          break;
292        }
293
294        case JBC_iconst_3: {
295          if (shouldPrint) asm.noteBytecode(biStart, "iconst_3");
296          emit_iconst(3);
297          break;
298        }
299
300        case JBC_iconst_4: {
301          if (shouldPrint) asm.noteBytecode(biStart, "iconst_4");
302          emit_iconst(4);
303          break;
304        }
305
306        case JBC_iconst_5: {
307          if (shouldPrint) asm.noteBytecode(biStart, "iconst_5");
308          emit_iconst(5);
309          break;
310        }
311
312        case JBC_lconst_0: {
313          if (shouldPrint) asm.noteBytecode(biStart, "lconst_0");  // floating-point 0 is long 0
314          emit_lconst(0);
315          break;
316        }
317
318        case JBC_lconst_1: {
319          if (shouldPrint) asm.noteBytecode(biStart, "lconst_1");
320          emit_lconst(1);
321          break;
322        }
323
324        case JBC_fconst_0: {
325          if (shouldPrint) asm.noteBytecode(biStart, "fconst_0");
326          emit_fconst_0();
327          break;
328        }
329
330        case JBC_fconst_1: {
331          if (shouldPrint) asm.noteBytecode(biStart, "fconst_1");
332          emit_fconst_1();
333          break;
334        }
335
336        case JBC_fconst_2: {
337          if (shouldPrint) asm.noteBytecode(biStart, "fconst_2");
338          emit_fconst_2();
339          break;
340        }
341
342        case JBC_dconst_0: {
343          if (shouldPrint) asm.noteBytecode(biStart, "dconst_0");
344          emit_dconst_0();
345          break;
346        }
347
348        case JBC_dconst_1: {
349          if (shouldPrint) asm.noteBytecode(biStart, "dconst_1");
350          emit_dconst_1();
351          break;
352        }
353
354        case JBC_bipush: {
355          int val = bcodes.getByteValue();
356          if (shouldPrint) asm.noteBytecode(biStart, "bipush", val);
357          emit_iconst(val);
358          break;
359        }
360
361        case JBC_sipush: {
362          int val = bcodes.getShortValue();
363          if (shouldPrint) asm.noteBytecode(biStart, "sipush", val);
364          emit_iconst(val);
365          break;
366        }
367
368        case JBC_ldc: {
369          int index = bcodes.getConstantIndex();
370          if (shouldPrint) asm.noteBytecode(biStart, "ldc", index);
371          Offset offset = klass.getLiteralOffset(index);
372          byte type = klass.getLiteralDescription(index);
373          emit_ldc(offset, type);
374          break;
375        }
376
377        case JBC_ldc_w: {
378          int index = bcodes.getWideConstantIndex();
379          if (shouldPrint) asm.noteBytecode(biStart, "ldc_w", index);
380          Offset offset = klass.getLiteralOffset(index);
381          byte type = klass.getLiteralDescription(index);
382          emit_ldc(offset, type);
383          break;
384        }
385
386        case JBC_ldc2_w: {
387          int index = bcodes.getWideConstantIndex();
388          if (shouldPrint) asm.noteBytecode(biStart, "ldc2_w", index);
389          Offset offset = klass.getLiteralOffset(index);
390          byte type = klass.getLiteralDescription(index);
391          emit_ldc2(offset, type);
392          break;
393        }
394
395        case JBC_iload: {
396          int index = bcodes.getLocalNumber();
397          if (shouldPrint) asm.noteBytecode(biStart, "iload", index);
398          emit_iload(index);
399          break;
400        }
401
402        case JBC_lload: {
403          int index = bcodes.getLocalNumber();
404          if (shouldPrint) asm.noteBytecode(biStart, "lload", index);
405          emit_lload(index);
406          break;
407        }
408
409        case JBC_fload: {
410          int index = bcodes.getLocalNumber();
411          if (shouldPrint) asm.noteBytecode(biStart, "fload", index);
412          emit_fload(index);
413          break;
414        }
415
416        case JBC_dload: {
417          int index = bcodes.getLocalNumber();
418          if (shouldPrint) asm.noteBytecode(biStart, "dload", index);
419          emit_dload(index);
420          break;
421        }
422
423        case JBC_aload: {
424          int index = bcodes.getLocalNumber();
425          if (shouldPrint) asm.noteBytecode(biStart, "aload", index);
426          emit_aload(index);
427          break;
428        }
429
430        case JBC_iload_0: {
431          if (shouldPrint) asm.noteBytecode(biStart, "iload_0");
432          emit_iload(0);
433          break;
434        }
435
436        case JBC_iload_1: {
437          if (shouldPrint) asm.noteBytecode(biStart, "iload_1");
438          emit_iload(1);
439          break;
440        }
441
442        case JBC_iload_2: {
443          if (shouldPrint) asm.noteBytecode(biStart, "iload_2");
444          emit_iload(2);
445          break;
446        }
447
448        case JBC_iload_3: {
449          if (shouldPrint) asm.noteBytecode(biStart, "iload_3");
450          emit_iload(3);
451          break;
452        }
453
454        case JBC_lload_0: {
455          if (shouldPrint) asm.noteBytecode(biStart, "lload_0");
456          emit_lload(0);
457          break;
458        }
459
460        case JBC_lload_1: {
461          if (shouldPrint) asm.noteBytecode(biStart, "lload_1");
462          emit_lload(1);
463          break;
464        }
465
466        case JBC_lload_2: {
467          if (shouldPrint) asm.noteBytecode(biStart, "lload_2");
468          emit_lload(2);
469          break;
470        }
471
472        case JBC_lload_3: {
473          if (shouldPrint) asm.noteBytecode(biStart, "lload_3");
474          emit_lload(3);
475          break;
476        }
477
478        case JBC_fload_0: {
479          if (shouldPrint) asm.noteBytecode(biStart, "fload_0");
480          emit_fload(0);
481          break;
482        }
483
484        case JBC_fload_1: {
485          if (shouldPrint) asm.noteBytecode(biStart, "fload_1");
486          emit_fload(1);
487          break;
488        }
489
490        case JBC_fload_2: {
491          if (shouldPrint) asm.noteBytecode(biStart, "fload_2");
492          emit_fload(2);
493          break;
494        }
495
496        case JBC_fload_3: {
497          if (shouldPrint) asm.noteBytecode(biStart, "fload_3");
498          emit_fload(3);
499          break;
500        }
501
502        case JBC_dload_0: {
503          if (shouldPrint) asm.noteBytecode(biStart, "dload_0");
504          emit_dload(0);
505          break;
506        }
507
508        case JBC_dload_1: {
509          if (shouldPrint) asm.noteBytecode(biStart, "dload_1");
510          emit_dload(1);
511          break;
512        }
513
514        case JBC_dload_2: {
515          if (shouldPrint) asm.noteBytecode(biStart, "dload_2");
516          emit_dload(2);
517          break;
518        }
519
520        case JBC_dload_3: {
521          if (shouldPrint) asm.noteBytecode(biStart, "dload_3");
522          emit_dload(3);
523          break;
524        }
525
526        case JBC_aload_0: {
527          if (shouldPrint) asm.noteBytecode(biStart, "aload_0");
528          emit_aload(0);
529          break;
530        }
531
532        case JBC_aload_1: {
533          if (shouldPrint) asm.noteBytecode(biStart, "aload_1");
534          emit_aload(1);
535          break;
536        }
537
538        case JBC_aload_2: {
539          if (shouldPrint) asm.noteBytecode(biStart, "aload_2");
540          emit_aload(2);
541          break;
542        }
543
544        case JBC_aload_3: {
545          if (shouldPrint) asm.noteBytecode(biStart, "aload_3");
546          emit_aload(3);
547          break;
548        }
549
550        case JBC_iaload: {
551          if (shouldPrint) asm.noteBytecode(biStart, "iaload");
552          emit_iaload();
553          break;
554        }
555
556        case JBC_laload: {
557          if (shouldPrint) asm.noteBytecode(biStart, "laload");
558          emit_laload();
559          break;
560        }
561
562        case JBC_faload: {
563          if (shouldPrint) asm.noteBytecode(biStart, "faload");
564          emit_faload();
565          break;
566        }
567
568        case JBC_daload: {
569          if (shouldPrint) asm.noteBytecode(biStart, "daload");
570          emit_daload();
571          break;
572        }
573
574        case JBC_aaload: {
575          if (shouldPrint) asm.noteBytecode(biStart, "aaload");
576          emit_aaload();
577          break;
578        }
579
580        case JBC_baload: {
581          if (shouldPrint) asm.noteBytecode(biStart, "baload");
582          emit_baload();
583          break;
584        }
585
586        case JBC_caload: {
587          if (shouldPrint) asm.noteBytecode(biStart, "caload");
588          emit_caload();
589          break;
590        }
591
592        case JBC_saload: {
593          if (shouldPrint) asm.noteBytecode(biStart, "saload");
594          emit_saload();
595          break;
596        }
597
598        case JBC_istore: {
599          int index = bcodes.getLocalNumber();
600          if (shouldPrint) asm.noteBytecode(biStart, "istore", index);
601          emit_istore(index);
602          break;
603        }
604
605        case JBC_lstore: {
606          int index = bcodes.getLocalNumber();
607          if (shouldPrint) asm.noteBytecode(biStart, "lstore", index);
608          emit_lstore(index);
609          break;
610        }
611
612        case JBC_fstore: {
613          int index = bcodes.getLocalNumber();
614          if (shouldPrint) asm.noteBytecode(biStart, "fstore", index);
615          emit_fstore(index);
616          break;
617        }
618
619        case JBC_dstore: {
620          int index = bcodes.getLocalNumber();
621          if (shouldPrint) asm.noteBytecode(biStart, "dstore", index);
622          emit_dstore(index);
623          break;
624        }
625
626        case JBC_astore: {
627          int index = bcodes.getLocalNumber();
628          if (shouldPrint) asm.noteBytecode(biStart, "astore", index);
629          emit_astore(index);
630          break;
631        }
632
633        case JBC_istore_0: {
634          if (shouldPrint) asm.noteBytecode(biStart, "istore_0");
635          emit_istore(0);
636          break;
637        }
638
639        case JBC_istore_1: {
640          if (shouldPrint) asm.noteBytecode(biStart, "istore_1");
641          emit_istore(1);
642          break;
643        }
644
645        case JBC_istore_2: {
646          if (shouldPrint) asm.noteBytecode(biStart, "istore_2");
647          emit_istore(2);
648          break;
649        }
650
651        case JBC_istore_3: {
652          if (shouldPrint) asm.noteBytecode(biStart, "istore_3");
653          emit_istore(3);
654          break;
655        }
656
657        case JBC_lstore_0: {
658          if (shouldPrint) asm.noteBytecode(biStart, "lstore_0");
659          emit_lstore(0);
660          break;
661        }
662
663        case JBC_lstore_1: {
664          if (shouldPrint) asm.noteBytecode(biStart, "lstore_1");
665          emit_lstore(1);
666          break;
667        }
668
669        case JBC_lstore_2: {
670          if (shouldPrint) asm.noteBytecode(biStart, "lstore_2");
671          emit_lstore(2);
672          break;
673        }
674
675        case JBC_lstore_3: {
676          if (shouldPrint) asm.noteBytecode(biStart, "lstore_3");
677          emit_lstore(3);
678          break;
679        }
680
681        case JBC_fstore_0: {
682          if (shouldPrint) asm.noteBytecode(biStart, "fstore_0");
683          emit_fstore(0);
684          break;
685        }
686
687        case JBC_fstore_1: {
688          if (shouldPrint) asm.noteBytecode(biStart, "fstore_1");
689          emit_fstore(1);
690          break;
691        }
692
693        case JBC_fstore_2: {
694          if (shouldPrint) asm.noteBytecode(biStart, "fstore_2");
695          emit_fstore(2);
696          break;
697        }
698
699        case JBC_fstore_3: {
700          if (shouldPrint) asm.noteBytecode(biStart, "fstore_3");
701          emit_fstore(3);
702          break;
703        }
704
705        case JBC_dstore_0: {
706          if (shouldPrint) asm.noteBytecode(biStart, "dstore_0");
707          emit_dstore(0);
708          break;
709        }
710
711        case JBC_dstore_1: {
712          if (shouldPrint) asm.noteBytecode(biStart, "dstore_1");
713          emit_dstore(1);
714          break;
715        }
716
717        case JBC_dstore_2: {
718          if (shouldPrint) asm.noteBytecode(biStart, "dstore_2");
719          emit_dstore(2);
720          break;
721        }
722
723        case JBC_dstore_3: {
724          if (shouldPrint) asm.noteBytecode(biStart, "dstore_3");
725          emit_dstore(3);
726          break;
727        }
728
729        case JBC_astore_0: {
730          if (shouldPrint) asm.noteBytecode(biStart, "astore_0");
731          emit_astore(0);
732          break;
733        }
734
735        case JBC_astore_1: {
736          if (shouldPrint) asm.noteBytecode(biStart, "astore_1");
737          emit_astore(1);
738          break;
739        }
740
741        case JBC_astore_2: {
742          if (shouldPrint) asm.noteBytecode(biStart, "astore_2");
743          emit_astore(2);
744          break;
745        }
746
747        case JBC_astore_3: {
748          if (shouldPrint) asm.noteBytecode(biStart, "astore_3");
749          emit_astore(3);
750          break;
751        }
752
753        case JBC_iastore: {
754          if (shouldPrint) asm.noteBytecode(biStart, "iastore");
755          emit_iastore();
756          break;
757        }
758
759        case JBC_lastore: {
760          if (shouldPrint) asm.noteBytecode(biStart, "lastore");
761          emit_lastore();
762          break;
763        }
764
765        case JBC_fastore: {
766          if (shouldPrint) asm.noteBytecode(biStart, "fastore");
767          emit_fastore();
768          break;
769        }
770
771        case JBC_dastore: {
772          if (shouldPrint) asm.noteBytecode(biStart, "dastore");
773          emit_dastore();
774          break;
775        }
776
777        case JBC_aastore: {
778          if (shouldPrint) asm.noteBytecode(biStart, "aastore");
779          // Forbidden from uninterruptible code as may cause an {@link
780          // ArrayStoreException}
781          if (VM.VerifyUnint && isUninterruptible && doesCheckStore) forbiddenBytecode("aastore", bcodes.index());
782          emit_aastore();
783          break;
784        }
785
786        case JBC_bastore: {
787          if (shouldPrint) asm.noteBytecode(biStart, "bastore");
788          emit_bastore();
789          break;
790        }
791
792        case JBC_castore: {
793          if (shouldPrint) asm.noteBytecode(biStart, "castore");
794          emit_castore();
795          break;
796        }
797
798        case JBC_sastore: {
799          if (shouldPrint) asm.noteBytecode(biStart, "sastore");
800          emit_sastore();
801          break;
802        }
803
804        case JBC_pop: {
805          if (shouldPrint) asm.noteBytecode(biStart, "pop");
806          emit_pop();
807          break;
808        }
809
810        case JBC_pop2: {
811          if (shouldPrint) asm.noteBytecode(biStart, "pop2");
812          emit_pop2();
813          break;
814        }
815
816        case JBC_dup: {
817          if (shouldPrint) asm.noteBytecode(biStart, "dup");
818          emit_dup();
819          break;
820        }
821
822        case JBC_dup_x1: {
823          if (shouldPrint) asm.noteBytecode(biStart, "dup_x1");
824          emit_dup_x1();
825          break;
826        }
827
828        case JBC_dup_x2: {
829          if (shouldPrint) asm.noteBytecode(biStart, "dup_x2");
830          emit_dup_x2();
831          break;
832        }
833
834        case JBC_dup2: {
835          if (shouldPrint) asm.noteBytecode(biStart, "dup2");
836          emit_dup2();
837          break;
838        }
839
840        case JBC_dup2_x1: {
841          if (shouldPrint) asm.noteBytecode(biStart, "dup2_x1");
842          emit_dup2_x1();
843          break;
844        }
845
846        case JBC_dup2_x2: {
847          if (shouldPrint) asm.noteBytecode(biStart, "dup2_x2");
848          emit_dup2_x2();
849          break;
850        }
851
852        case JBC_swap: {
853          if (shouldPrint) asm.noteBytecode(biStart, "swap");
854          emit_swap();
855          break;
856        }
857
858        case JBC_iadd: {
859          if (shouldPrint) asm.noteBytecode(biStart, "iadd");
860          emit_iadd();
861          break;
862        }
863
864        case JBC_ladd: {
865          if (shouldPrint) asm.noteBytecode(biStart, "ladd");
866          emit_ladd();
867          break;
868        }
869
870        case JBC_fadd: {
871          if (shouldPrint) asm.noteBytecode(biStart, "fadd");
872          emit_fadd();
873          break;
874        }
875
876        case JBC_dadd: {
877          if (shouldPrint) asm.noteBytecode(biStart, "dadd");
878          emit_dadd();
879          break;
880        }
881
882        case JBC_isub: {
883          if (shouldPrint) asm.noteBytecode(biStart, "isub");
884          emit_isub();
885          break;
886        }
887
888        case JBC_lsub: {
889          if (shouldPrint) asm.noteBytecode(biStart, "lsub");
890          emit_lsub();
891          break;
892        }
893
894        case JBC_fsub: {
895          if (shouldPrint) asm.noteBytecode(biStart, "fsub");
896          emit_fsub();
897          break;
898        }
899
900        case JBC_dsub: {
901          if (shouldPrint) asm.noteBytecode(biStart, "dsub");
902          emit_dsub();
903          break;
904        }
905
906        case JBC_imul: {
907          if (shouldPrint) asm.noteBytecode(biStart, "imul");
908          emit_imul();
909          break;
910        }
911
912        case JBC_lmul: {
913          if (shouldPrint) asm.noteBytecode(biStart, "lmul");
914          emit_lmul();
915          break;
916        }
917
918        case JBC_fmul: {
919          if (shouldPrint) asm.noteBytecode(biStart, "fmul");
920          emit_fmul();
921          break;
922        }
923
924        case JBC_dmul: {
925          if (shouldPrint) asm.noteBytecode(biStart, "dmul");
926          emit_dmul();
927          break;
928        }
929
930        case JBC_idiv: {
931          if (shouldPrint) asm.noteBytecode(biStart, "idiv");
932          emit_idiv();
933          break;
934        }
935
936        case JBC_ldiv: {
937          if (shouldPrint) asm.noteBytecode(biStart, "ldiv");
938          emit_ldiv();
939          break;
940        }
941
942        case JBC_fdiv: {
943          if (shouldPrint) asm.noteBytecode(biStart, "fdiv");
944          emit_fdiv();
945          break;
946        }
947
948        case JBC_ddiv: {
949          if (shouldPrint) asm.noteBytecode(biStart, "ddiv");
950          emit_ddiv();
951          break;
952        }
953
954        case JBC_irem: {
955          if (shouldPrint) asm.noteBytecode(biStart, "irem");
956          emit_irem();
957          break;
958        }
959
960        case JBC_lrem: {
961          if (shouldPrint) asm.noteBytecode(biStart, "lrem");
962          emit_lrem();
963          break;
964        }
965
966        case JBC_frem: {
967          if (shouldPrint) asm.noteBytecode(biStart, "frem");
968          emit_frem();
969          break;
970        }
971
972        case JBC_drem: {
973          if (shouldPrint) asm.noteBytecode(biStart, "drem");
974          emit_drem();
975          break;
976        }
977
978        case JBC_ineg: {
979          if (shouldPrint) asm.noteBytecode(biStart, "ineg");
980          emit_ineg();
981          break;
982        }
983
984        case JBC_lneg: {
985          if (shouldPrint) asm.noteBytecode(biStart, "lneg");
986          emit_lneg();
987          break;
988        }
989
990        case JBC_fneg: {
991          if (shouldPrint) asm.noteBytecode(biStart, "fneg");
992          emit_fneg();
993          break;
994        }
995
996        case JBC_dneg: {
997          if (shouldPrint) asm.noteBytecode(biStart, "dneg");
998          emit_dneg();
999          break;
1000        }
1001
1002        case JBC_ishl: {
1003          if (shouldPrint) asm.noteBytecode(biStart, "ishl");
1004          emit_ishl();
1005          break;
1006        }
1007
1008        case JBC_lshl: {
1009          if (shouldPrint) asm.noteBytecode(biStart, "lshl");    // l >> n
1010          emit_lshl();
1011          break;
1012        }
1013
1014        case JBC_ishr: {
1015          if (shouldPrint) asm.noteBytecode(biStart, "ishr");
1016          emit_ishr();
1017          break;
1018        }
1019
1020        case JBC_lshr: {
1021          if (shouldPrint) asm.noteBytecode(biStart, "lshr");
1022          emit_lshr();
1023          break;
1024        }
1025
1026        case JBC_iushr: {
1027          if (shouldPrint) asm.noteBytecode(biStart, "iushr");
1028          emit_iushr();
1029          break;
1030        }
1031
1032        case JBC_lushr: {
1033          if (shouldPrint) asm.noteBytecode(biStart, "lushr");
1034          emit_lushr();
1035          break;
1036        }
1037
1038        case JBC_iand: {
1039          if (shouldPrint) asm.noteBytecode(biStart, "iand");
1040          emit_iand();
1041          break;
1042        }
1043
1044        case JBC_land: {
1045          if (shouldPrint) asm.noteBytecode(biStart, "land");
1046          emit_land();
1047          break;
1048        }
1049
1050        case JBC_ior: {
1051          if (shouldPrint) asm.noteBytecode(biStart, "ior");
1052          emit_ior();
1053          break;
1054        }
1055
1056        case JBC_lor: {
1057          if (shouldPrint) asm.noteBytecode(biStart, "lor");
1058          emit_lor();
1059          break;
1060        }
1061
1062        case JBC_ixor: {
1063          if (shouldPrint) asm.noteBytecode(biStart, "ixor");
1064          emit_ixor();
1065          break;
1066        }
1067
1068        case JBC_lxor: {
1069          if (shouldPrint) asm.noteBytecode(biStart, "lxor");
1070          emit_lxor();
1071          break;
1072        }
1073
1074        case JBC_iinc: {
1075          int index = bcodes.getLocalNumber();
1076          int val = bcodes.getIncrement();
1077          if (shouldPrint) asm.noteBytecode(biStart, "iinc", index, val);
1078          emit_iinc(index, val);
1079          break;
1080        }
1081
1082        case JBC_i2l: {
1083          if (shouldPrint) asm.noteBytecode(biStart, "i2l");
1084          emit_i2l();
1085          break;
1086        }
1087
1088        case JBC_i2f: {
1089          if (shouldPrint) asm.noteBytecode(biStart, "i2f");
1090          emit_i2f();
1091          break;
1092        }
1093
1094        case JBC_i2d: {
1095          if (shouldPrint) asm.noteBytecode(biStart, "i2d");
1096          emit_i2d();
1097          break;
1098        }
1099
1100        case JBC_l2i: {
1101          if (shouldPrint) asm.noteBytecode(biStart, "l2i");
1102          emit_l2i();
1103          break;
1104        }
1105
1106        case JBC_l2f: {
1107          if (shouldPrint) asm.noteBytecode(biStart, "l2f");
1108          emit_l2f();
1109          break;
1110        }
1111
1112        case JBC_l2d: {
1113          if (shouldPrint) asm.noteBytecode(biStart, "l2d");
1114          emit_l2d();
1115          break;
1116        }
1117
1118        case JBC_f2i: {
1119          if (shouldPrint) asm.noteBytecode(biStart, "f2i");
1120          emit_f2i();
1121          break;
1122        }
1123
1124        case JBC_f2l: {
1125          if (shouldPrint) asm.noteBytecode(biStart, "f2l");
1126          emit_f2l();
1127          break;
1128        }
1129
1130        case JBC_f2d: {
1131          if (shouldPrint) asm.noteBytecode(biStart, "f2d");
1132          emit_f2d();
1133          break;
1134        }
1135
1136        case JBC_d2i: {
1137          if (shouldPrint) asm.noteBytecode(biStart, "d2i");
1138          emit_d2i();
1139          break;
1140        }
1141
1142        case JBC_d2l: {
1143          if (shouldPrint) asm.noteBytecode(biStart, "d2l");
1144          emit_d2l();
1145          break;
1146        }
1147
1148        case JBC_d2f: {
1149          if (shouldPrint) asm.noteBytecode(biStart, "d2f");
1150          emit_d2f();
1151          break;
1152        }
1153
1154        case JBC_int2byte: {
1155          if (shouldPrint) asm.noteBytecode(biStart, "i2b");
1156          emit_i2b();
1157          break;
1158        }
1159
1160        case JBC_int2char: {
1161          if (shouldPrint) asm.noteBytecode(biStart, "i2c");
1162          emit_i2c();
1163          break;
1164        }
1165
1166        case JBC_int2short: {
1167          if (shouldPrint) asm.noteBytecode(biStart, "i2s");
1168          emit_i2s();
1169          break;
1170        }
1171
1172        case JBC_lcmp: {
1173          if (shouldPrint) asm.noteBytecode(biStart, "lcmp");  // a ? b
1174          emit_lcmp();
1175          break;
1176        }
1177
1178        case JBC_fcmpl: {
1179          if (shouldPrint) asm.noteBytecode(biStart, "fcmpl");
1180          emit_DFcmpGL(true, false);
1181          break;
1182        }
1183
1184        case JBC_fcmpg: {
1185          if (shouldPrint) asm.noteBytecode(biStart, "fcmpg");
1186          emit_DFcmpGL(true, true);
1187          break;
1188        }
1189
1190        case JBC_dcmpl: {
1191          if (shouldPrint) asm.noteBytecode(biStart, "dcmpl");
1192          emit_DFcmpGL(false, false);
1193          break;
1194        }
1195
1196        case JBC_dcmpg: {
1197          if (shouldPrint) asm.noteBytecode(biStart, "dcmpg");
1198          emit_DFcmpGL(false, true);
1199          break;
1200        }
1201
1202        case JBC_ifeq: {
1203          do_if(biStart, BranchCondition.EQ);
1204          break;
1205        }
1206
1207        case JBC_ifne: {
1208          do_if(biStart, BranchCondition.NE);
1209          break;
1210        }
1211
1212        case JBC_iflt: {
1213          do_if(biStart, BranchCondition.LT);
1214          break;
1215        }
1216
1217        case JBC_ifge: {
1218          do_if(biStart, BranchCondition.GE);
1219          break;
1220        }
1221
1222        case JBC_ifgt: {
1223          do_if(biStart, BranchCondition.GT);
1224          break;
1225        }
1226
1227        case JBC_ifle: {
1228          do_if(biStart, BranchCondition.LE);
1229          break;
1230        }
1231
1232        case JBC_if_icmpeq: {
1233          do_if_icmp(biStart, BranchCondition.EQ);
1234          break;
1235        }
1236
1237        case JBC_if_icmpne: {
1238          do_if_icmp(biStart, BranchCondition.NE);
1239          break;
1240        }
1241
1242        case JBC_if_icmplt: {
1243          do_if_icmp(biStart, BranchCondition.LT);
1244          break;
1245        }
1246
1247        case JBC_if_icmpge: {
1248          do_if_icmp(biStart, BranchCondition.GE);
1249          break;
1250        }
1251
1252        case JBC_if_icmpgt: {
1253          do_if_icmp(biStart, BranchCondition.GT);
1254          break;
1255        }
1256
1257        case JBC_if_icmple: {
1258          do_if_icmp(biStart, BranchCondition.LE);
1259          break;
1260        }
1261
1262        case JBC_if_acmpeq: {
1263          int offset = bcodes.getBranchOffset();
1264          int bTarget = biStart + offset;
1265          if (shouldPrint) asm.noteBranchBytecode(biStart, "if_acmpeq", offset, bTarget);
1266          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1267          emit_if_acmpeq(bTarget);
1268          break;
1269        }
1270
1271        case JBC_if_acmpne: {
1272          int offset = bcodes.getBranchOffset();
1273          int bTarget = biStart + offset;
1274          if (shouldPrint) asm.noteBranchBytecode(biStart, "if_acmpne", offset, bTarget);
1275          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1276          emit_if_acmpne(bTarget);
1277          break;
1278        }
1279
1280        case JBC_goto: {
1281          int offset = bcodes.getBranchOffset();
1282          int bTarget = biStart + offset; // bi has been bumped by 3 already
1283          if (shouldPrint) asm.noteBranchBytecode(biStart, "goto", offset, bTarget);
1284          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1285          emit_goto(bTarget);
1286          break;
1287        }
1288
1289        case JBC_jsr: {
1290          int offset = bcodes.getBranchOffset();
1291          int bTarget = biStart + offset;
1292          if (shouldPrint) asm.noteBranchBytecode(biStart, "jsr", offset, bTarget);
1293          emit_jsr(bTarget);
1294          break;
1295        }
1296
1297        case JBC_ret: {
1298          int index = bcodes.getLocalNumber();
1299          if (shouldPrint) asm.noteBytecode(biStart, "ret ", index);
1300          emit_ret(index);
1301          break;
1302        }
1303
1304        case JBC_tableswitch: {
1305          bcodes.alignSwitch();
1306          int defaultval = bcodes.getDefaultSwitchOffset();
1307          int low = bcodes.getLowSwitchValue();
1308          int high = bcodes.getHighSwitchValue();
1309          if (shouldPrint) asm.noteTableswitchBytecode(biStart, low, high, defaultval);
1310          emit_tableswitch(defaultval, low, high);
1311          break;
1312        }
1313
1314        case JBC_lookupswitch: {
1315          bcodes.alignSwitch();
1316          int defaultval = bcodes.getDefaultSwitchOffset();
1317          int npairs = bcodes.getSwitchLength();
1318          if (shouldPrint) asm.noteLookupswitchBytecode(biStart, npairs, defaultval);
1319          emit_lookupswitch(defaultval, npairs);
1320          break;
1321        }
1322
1323        case JBC_ireturn: {
1324          if (shouldPrint) asm.noteBytecode(biStart, "ireturn");
1325          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1326          emit_ireturn();
1327          break;
1328        }
1329
1330        case JBC_lreturn: {
1331          if (shouldPrint) asm.noteBytecode(biStart, "lreturn");
1332          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1333          emit_lreturn();
1334          break;
1335        }
1336
1337        case JBC_freturn: {
1338          if (shouldPrint) asm.noteBytecode(biStart, "freturn");
1339          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1340          emit_freturn();
1341          break;
1342        }
1343
1344        case JBC_dreturn: {
1345          if (shouldPrint) asm.noteBytecode(biStart, "dreturn");
1346          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1347          emit_dreturn();
1348          break;
1349        }
1350
1351        case JBC_areturn: {
1352          if (shouldPrint) asm.noteBytecode(biStart, "areturn");
1353          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1354          emit_areturn();
1355          break;
1356        }
1357
1358        case JBC_return: {
1359          if (shouldPrint) asm.noteBytecode(biStart, "return");
1360          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1361          emit_return();
1362          break;
1363        }
1364
1365        case JBC_getstatic: {
1366          FieldReference fieldRef = bcodes.getFieldReference();
1367          if (shouldPrint) asm.noteBytecode(biStart, "getstatic", fieldRef);
1368          if (fieldRef.needsDynamicLink(method)) {
1369            // Forbidden from uninterruptible code as dynamic linking can cause
1370            // interruptions
1371            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved getstatic ", fieldRef, bcodes.index());
1372            emit_unresolved_getstatic(fieldRef);
1373          } else {
1374            emit_resolved_getstatic(fieldRef);
1375          }
1376          break;
1377        }
1378
1379        case JBC_putstatic: {
1380          FieldReference fieldRef = bcodes.getFieldReference();
1381          if (shouldPrint) asm.noteBytecode(biStart, "putstatic", fieldRef);
1382          if (fieldRef.needsDynamicLink(method)) {
1383            // Forbidden from uninterruptible code as dynamic linking can cause
1384            // interruptions
1385            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved putstatic ", fieldRef, bcodes.index());
1386            emit_unresolved_putstatic(fieldRef);
1387          } else {
1388            emit_resolved_putstatic(fieldRef);
1389          }
1390          break;
1391        }
1392
1393        case JBC_getfield: {
1394          FieldReference fieldRef = bcodes.getFieldReference();
1395          if (shouldPrint) asm.noteBytecode(biStart, "getfield", fieldRef);
1396          if (fieldRef.needsDynamicLink(method)) {
1397            // Forbidden from uninterruptible code as dynamic linking can cause
1398            // interruptions
1399            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved getfield ", fieldRef, bcodes.index());
1400            emit_unresolved_getfield(fieldRef);
1401          } else {
1402            emit_resolved_getfield(fieldRef);
1403          }
1404          break;
1405        }
1406
1407        case JBC_putfield: {
1408          FieldReference fieldRef = bcodes.getFieldReference();
1409          if (shouldPrint) asm.noteBytecode(biStart, "putfield", fieldRef);
1410          if (fieldRef.needsDynamicLink(method)) {
1411            // Forbidden from uninterruptible code as dynamic linking can cause
1412            // interruptions
1413            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved putfield ", fieldRef, bcodes.index());
1414            emit_unresolved_putfield(fieldRef);
1415          } else {
1416            emit_resolved_putfield(fieldRef);
1417          }
1418          break;
1419        }
1420
1421        case JBC_invokevirtual: {
1422          ForwardReference xx = null;
1423          if (biStart == this.pendingIdx) {
1424            ForwardReference x = emit_pending_goto(0);  // goto X
1425            this.pendingRef.resolve(asm);          // pendingIdx:     (target of pending goto in prologue)
1426            CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
1427            if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
1428            emit_invoke_compiledmethod(cm);  //  invoke_cmid
1429            xx = emit_pending_goto(0);                     // goto XX
1430            x.resolve(asm);                       //  X:
1431          }
1432
1433          MethodReference methodRef = bcodes.getMethodReference();
1434          if (shouldPrint) asm.noteBytecode(biStart, "invokevirtual", methodRef);
1435          if (methodRef.getType().isMagicType()) {
1436            if (emit_Magic(methodRef)) {
1437              break;
1438            }
1439          }
1440
1441          if (methodRef.isMiranda()) {
1442            /* Special case of abstract interface method should generate
1443             * an invokeinterface, despite the compiler claiming it should
1444             * be invokevirtual.
1445             */
1446            if (shouldPrint) asm.noteBytecode(biStart, "invokeinterface", methodRef);
1447            // Forbidden from uninterruptible code as interface invocation
1448            // causes runtime checks that can be interrupted
1449            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("invokeinterface ", methodRef, bcodes.index());
1450            emit_invokeinterface(methodRef);
1451          } else {
1452            if (methodRef.needsDynamicLink(method)) {
1453              // Forbidden from uninterruptible code as dynamic linking can
1454              // cause interruptions
1455              if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved invokevirtual ", methodRef, bcodes.index());
1456              emit_unresolved_invokevirtual(methodRef);
1457            } else {
1458              if (VM.VerifyUnint && !isInterruptible) checkTarget(methodRef.peekResolvedMethod(), bcodes.index());
1459              emit_resolved_invokevirtual(methodRef);
1460            }
1461          }
1462
1463          if (xx != null) {
1464            xx.resolve(asm);                     // XX:
1465          }
1466          break;
1467        }
1468
1469        case JBC_invokespecial: {
1470          ForwardReference xx = null;
1471          if (biStart == this.pendingIdx) {
1472            ForwardReference x = emit_pending_goto(0);  // goto X
1473            this.pendingRef.resolve(asm);          // pendingIdx:     (target of pending goto in prologue)
1474            CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
1475            if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
1476            emit_invoke_compiledmethod(cm);  //  invoke_cmid
1477            xx = emit_pending_goto(0);                     // goto XX
1478            x.resolve(asm);                       //  X:
1479          }
1480          MethodReference methodRef = bcodes.getMethodReference();
1481          if (shouldPrint) asm.noteBytecode(biStart, "invokespecial", methodRef);
1482          RVMMethod target = methodRef.resolveInvokeSpecial();
1483          if (target != null) {
1484            if (VM.VerifyUnint && !isInterruptible) checkTarget(target, bcodes.index());
1485            emit_resolved_invokespecial(methodRef, target);
1486          } else {
1487            emit_unresolved_invokespecial(methodRef);
1488          }
1489
1490          if (xx != null) {
1491            xx.resolve(asm);                     // XX:
1492          }
1493
1494          break;
1495        }
1496
1497        case JBC_invokestatic: {
1498          ForwardReference xx = null;
1499          if (biStart == this.pendingIdx) {
1500            ForwardReference x = emit_pending_goto(0);  // goto X
1501            this.pendingRef.resolve(asm);          // pendingIdx:     (target of pending goto in prologue)
1502            CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
1503            if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
1504            emit_invoke_compiledmethod(cm);  //  invoke_cmid
1505            xx = emit_pending_goto(0);                     // goto XX
1506            x.resolve(asm);                       //  X:
1507          }
1508
1509          MethodReference methodRef = bcodes.getMethodReference();
1510          if (shouldPrint) asm.noteBytecode(biStart, "invokestatic", methodRef);
1511          if (methodRef.isMagic()) {
1512            if (emit_Magic(methodRef)) {
1513              break;
1514            }
1515          }
1516          if (methodRef.needsDynamicLink(method)) {
1517            // Forbidden from uninterruptible code as dynamic linking can
1518            // cause interruptions
1519            if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("unresolved invokestatic ", methodRef, bcodes.index());
1520            emit_unresolved_invokestatic(methodRef);
1521          } else {
1522            if (VM.VerifyUnint && !isInterruptible) checkTarget(methodRef.peekResolvedMethod(), bcodes.index());
1523            emit_resolved_invokestatic(methodRef);
1524          }
1525
1526          if (xx != null) {
1527            xx.resolve(asm);                     // XX:
1528          }
1529
1530          break;
1531        }
1532
1533        case JBC_invokeinterface: {
1534          ForwardReference xx = null;
1535          if (biStart == this.pendingIdx) {
1536            ForwardReference x = emit_pending_goto(0);  // goto X
1537            this.pendingRef.resolve(asm);          // pendingIdx:     (target of pending goto in prologue)
1538            CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
1539            if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
1540            emit_invoke_compiledmethod(cm);  //  invoke_cmid
1541            xx = emit_pending_goto(0);                     // goto XX
1542            x.resolve(asm);                       //  X:
1543          }
1544
1545          MethodReference methodRef = bcodes.getMethodReference();
1546          bcodes.alignInvokeInterface();
1547          if (shouldPrint) asm.noteBytecode(biStart, "invokeinterface", methodRef);
1548          // Forbidden from uninterruptible code as interface invocation
1549          // causes runtime checks that can be interrupted
1550          if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("invokeinterface ", methodRef, bcodes.index());
1551          emit_invokeinterface(methodRef);
1552
1553          if (xx != null) {
1554            xx.resolve(asm);                     // XX:
1555          }
1556
1557          break;
1558        }
1559
1560        case JBC_invokedynamic: {
1561          if (shouldPrint) asm.noteBytecode(biStart, "unused");
1562          if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
1563          break;
1564        }
1565
1566        case JBC_new: {
1567          TypeReference typeRef = bcodes.getTypeReference();
1568          if (shouldPrint) asm.noteBytecode(biStart, "new", typeRef);
1569          // Forbidden from uninterruptible code as new causes calls into MMTk
1570          // that are interruptible
1571          if (VM.VerifyUnint && isUninterruptible) forbiddenBytecode("new ", typeRef, bcodes.index());
1572          RVMType type = typeRef.peekType();
1573          if (type != null && (type.isInitialized() || type.isInBootImage())) {
1574            emit_resolved_new(type.asClass());
1575          } else {
1576            if (VM.VerifyUnint && isUnpreemptible) forbiddenBytecode("unresolved new ", typeRef, bcodes.index());
1577            emit_unresolved_new(typeRef);
1578          }
1579          break;
1580        }
1581
1582        case JBC_newarray: {
1583          int atype = bcodes.getArrayElementType();
1584          RVMArray array = RVMArray.getPrimitiveArrayType(atype);
1585          if (VM.VerifyAssertions) VM._assert(array.isResolved());
1586          // Forbidden from uninterruptible code as new causes calls into MMTk
1587          // that are interruptible
1588          if (shouldPrint) asm.noteBytecode(biStart, "newarray", array.getTypeRef());
1589          if (VM.VerifyUnint && isUninterruptible) forbiddenBytecode("newarray ", array, bcodes.index());
1590          emit_resolved_newarray(array);
1591          break;
1592        }
1593
1594        case JBC_anewarray: {
1595          TypeReference elementTypeRef = bcodes.getTypeReference();
1596          TypeReference arrayRef = elementTypeRef.getArrayTypeForElementType();
1597
1598          if (shouldPrint) asm.noteBytecode(biStart, "anewarray new", arrayRef);
1599          // Forbidden from uninterruptible code as new causes calls into MMTk
1600          // that are interruptible
1601          if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("anewarray ", arrayRef, bcodes.index());
1602
1603          if (VM.VerifyAssertions && elementTypeRef.isUnboxedType()) {
1604            String msg = "During compilation of " + method + " found an anewarray of " +
1605             elementTypeRef + "\n" + "You must use the 'create' function to create an array of this type";
1606            VM._assert(VM.NOT_REACHED, msg);
1607          }
1608
1609          RVMArray array = (RVMArray) arrayRef.peekType();
1610          if (RVMType.JavaLangObjectType.isInstantiated()) {
1611            // If we've already instantiated java.lang.Object, then we can
1612            // forcibly fully instantiate the array type as long as the element type is
1613            // either already initialized or is in the bootimage.
1614            // Note: The test against java.lang.Object is required only for the baseline compiler
1615            //       and is not present in the opt compiler version of anewarray (BC2IR) because of the way
1616            //       we handle recursive invocations of the compiler (can be caused by instantiate()).
1617            //       We need Object to be instantiated because we are going to mine it's TIB to get entries for array methods...
1618            if (array == null || !(array.isInitialized() || array.isInBootImage())) {
1619              RVMType elementType = elementTypeRef.peekType();
1620              if (elementType != null && (elementType.isInitialized() || elementType.isInBootImage())) {
1621                if (array == null) {
1622                  array = (RVMArray)arrayRef.resolve();
1623                }
1624                array.resolve();
1625                array.instantiate();
1626              }
1627            }
1628          }
1629          if (array != null && (array.isInitialized() || array.isInBootImage())) {
1630            emit_resolved_newarray(array);
1631          } else {
1632            emit_unresolved_newarray(arrayRef);
1633          }
1634          break;
1635        }
1636
1637        case JBC_arraylength: {
1638          if (shouldPrint) asm.noteBytecode(biStart, "arraylength");
1639          emit_arraylength();
1640          break;
1641        }
1642
1643        case JBC_athrow: {
1644          if (shouldPrint) asm.noteBytecode(biStart, "athrow");
1645          if (VM.UseEpilogueYieldPoints) emit_threadSwitchTest(RVMThread.EPILOGUE);
1646          // Forbidden from uninterruptible code as athrow causes calls into runtime
1647          // that are interruptible
1648          if (VM.VerifyUnint && isUninterruptible) forbiddenBytecode("athrow", bcodes.index());
1649          emit_athrow();
1650          break;
1651        }
1652
1653        case JBC_checkcast: {
1654          TypeReference typeRef = bcodes.getTypeReference();
1655          if (shouldPrint) asm.noteBytecode(biStart, "checkcast", typeRef);
1656          RVMType type = typeRef.peekType();
1657          if (type != null) {
1658            if (type.isClassType()) {
1659              RVMClass cType = type.asClass();
1660              if (cType.isFinal()) {
1661                emit_checkcast_final(cType);
1662                break;
1663              } else if (cType.isResolved()) {
1664                if (cType.isInterface()) {
1665                  emit_checkcast_resolvedInterface(cType);
1666                } else {
1667                  emit_checkcast_resolvedClass(cType);
1668                }
1669                break;
1670              } // else fall through to emit_checkcast
1671            } else if (type.isArrayType()) {
1672              RVMType elemType = type.asArray().getElementType();
1673              if (elemType.isPrimitiveType() || elemType.isUnboxedType() ||
1674                  (elemType.isClassType() && elemType.asClass().isFinal())) {
1675                emit_checkcast_final(type);
1676                break;
1677              } // else fall through to emit_checkcast
1678            } else {
1679              // checkcast to a primitive. Must be a word type.
1680              if (VM.VerifyAssertions) VM._assert(type.getTypeRef().isUnboxedType());
1681              break;
1682            }
1683          }
1684          // Forbidden from uninterruptible code as it may throw an exception
1685          // that executes via interruptible code
1686          if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("checkcast ", typeRef, bcodes.index());
1687          emit_checkcast(typeRef);
1688          break;
1689        }
1690
1691        case JBC_instanceof: {
1692          TypeReference typeRef = bcodes.getTypeReference();
1693          if (shouldPrint) asm.noteBytecode(biStart, "instanceof", typeRef);
1694          RVMType type = typeRef.peekType();
1695          if (type != null) {
1696            if (type.isClassType()) {
1697              RVMClass cType = type.asClass();
1698              if (cType.isFinal()) {
1699                emit_instanceof_final(type);
1700                break;
1701              } else if (cType.isResolved()) {
1702                if (cType.isInterface()) {
1703                  emit_instanceof_resolvedInterface(cType);
1704                } else {
1705                  emit_instanceof_resolvedClass(cType);
1706                }
1707                break;
1708              }
1709            } else if (type.isArrayType()) {
1710              RVMType elemType = type.asArray().getElementType();
1711              if (elemType.isPrimitiveType() || elemType.isUnboxedType() ||
1712                  (elemType.isClassType() && elemType.asClass().isFinal())) {
1713                emit_instanceof_final(type);
1714                break;
1715              }
1716            }
1717          }
1718          // Forbidden from uninterruptible code as calls interruptible runtime
1719          // for its implementation
1720          if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("instanceof ", typeRef, bcodes.index());
1721          emit_instanceof(typeRef);
1722          break;
1723        }
1724
1725        case JBC_monitorenter: {
1726          if (shouldPrint) asm.noteBytecode(biStart, "monitorenter");
1727          // Forbidden from uninterruptible code as calls interruptible object model
1728          // for its implementation
1729          if (VM.VerifyUnint && isUninterruptible) forbiddenBytecode("monitorenter", bcodes.index());
1730          emit_monitorenter();
1731          break;
1732        }
1733
1734        case JBC_monitorexit: {
1735          if (shouldPrint) asm.noteBytecode(biStart, "monitorexit");
1736          // Forbidden from uninterruptible code as calls interruptible object model
1737          // for its implementation
1738          if (VM.VerifyUnint && isUninterruptible) forbiddenBytecode("monitorexit", bcodes.index());
1739          emit_monitorexit();
1740          break;
1741        }
1742
1743        case JBC_wide: {
1744          int widecode = bcodes.getWideOpcode();
1745          int index = bcodes.getWideLocalNumber();
1746          switch (widecode) {
1747            case JBC_iload: {
1748              if (shouldPrint) asm.noteBytecode(biStart, "wide iload", index);
1749              emit_iload(index);
1750              break;
1751            }
1752            case JBC_lload: {
1753              if (shouldPrint) asm.noteBytecode(biStart, "wide lload", index);
1754              emit_lload(index);
1755              break;
1756            }
1757            case JBC_fload: {
1758              if (shouldPrint) asm.noteBytecode(biStart, "wide fload", index);
1759              emit_fload(index);
1760              break;
1761            }
1762            case JBC_dload: {
1763              if (shouldPrint) asm.noteBytecode(biStart, "wide dload", index);
1764              emit_dload(index);
1765              break;
1766            }
1767            case JBC_aload: {
1768              if (shouldPrint) asm.noteBytecode(biStart, "wide aload", index);
1769              emit_aload(index);
1770              break;
1771            }
1772            case JBC_istore: {
1773              if (shouldPrint) asm.noteBytecode(biStart, "wide istore", index);
1774              emit_istore(index);
1775              break;
1776            }
1777            case JBC_lstore: {
1778              if (shouldPrint) asm.noteBytecode(biStart, "wide lstore", index);
1779              emit_lstore(index);
1780              break;
1781            }
1782            case JBC_fstore: {
1783              if (shouldPrint) asm.noteBytecode(biStart, "wide fstore", index);
1784              emit_fstore(index);
1785              break;
1786            }
1787            case JBC_dstore: {
1788              if (shouldPrint) asm.noteBytecode(biStart, "wide dstore", index);
1789              emit_dstore(index);
1790              break;
1791            }
1792            case JBC_astore: {
1793              if (shouldPrint) asm.noteBytecode(biStart, "wide astore", index);
1794              emit_astore(index);
1795              break;
1796            }
1797            case JBC_iinc: {
1798              int val = bcodes.getWideIncrement();
1799              if (shouldPrint) asm.noteBytecode(biStart, "wide inc", index, val);
1800              emit_iinc(index, val);
1801              break;
1802            }
1803            case JBC_ret: {
1804              if (shouldPrint) asm.noteBytecode(biStart, "wide ret", index);
1805              emit_ret(index);
1806              break;
1807            }
1808            default:
1809              if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
1810          }
1811          break;
1812        }
1813
1814        case JBC_multianewarray: {
1815          TypeReference typeRef = bcodes.getTypeReference();
1816          int dimensions = bcodes.getArrayDimension();
1817          if (shouldPrint) asm.noteBytecode(biStart, "multianewarray", typeRef);
1818          // Forbidden from uninterruptible code as new causes calls into MMTk
1819          // that are interruptible
1820          if (VM.VerifyUnint && !isInterruptible) forbiddenBytecode("multianewarray", bcodes.index());
1821          emit_multianewarray(typeRef, dimensions);
1822          break;
1823        }
1824
1825        case JBC_ifnull: {
1826          int offset = bcodes.getBranchOffset();
1827          int bTarget = biStart + offset;
1828          if (shouldPrint) asm.noteBranchBytecode(biStart, "ifnull", offset, bTarget);
1829          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1830          emit_ifnull(bTarget);
1831          break;
1832        }
1833
1834        case JBC_ifnonnull: {
1835          int offset = bcodes.getBranchOffset();
1836          int bTarget = biStart + offset;
1837          if (shouldPrint) asm.noteBranchBytecode(biStart, "ifnonnull", offset, bTarget);
1838          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1839          emit_ifnonnull(bTarget);
1840          break;
1841        }
1842
1843        case JBC_goto_w: {
1844          int offset = bcodes.getWideBranchOffset();
1845          int bTarget = biStart + offset;
1846          if (shouldPrint) asm.noteBranchBytecode(biStart, "goto_w", offset, bTarget);
1847          if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
1848          emit_goto(bTarget);
1849          break;
1850        }
1851
1852        case JBC_jsr_w: {
1853          int offset = bcodes.getWideBranchOffset();
1854          int bTarget = biStart + offset;
1855          if (shouldPrint) asm.noteBranchBytecode(biStart, "jsr_w", offset, bTarget);
1856          emit_jsr(bTarget);
1857          break;
1858        }
1859
1860        /* CAUTION: cannot use JBC_impdep1, which is 0xfffffffe (signed),
1861         * this is not consistent with OPT compiler.
1862         */
1863        case JBC_impdep1: /* --- pseudo bytecode --- */ {
1864          if (VM.BuildForAdaptiveSystem) {
1865            int pseudo_opcode = bcodes.nextPseudoInstruction();
1866            // pseudo instruction
1867            switch (pseudo_opcode) {
1868              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadIntConst: {
1869                int value = bcodes.readIntConst();
1870
1871                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_int", value);
1872
1873                Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(value));
1874                emit_ldc(offset, CP_INT);
1875
1876                break;
1877              }
1878              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadLongConst: {
1879                long value = bcodes.readLongConst();  // fetch8BytesUnsigned();
1880
1881                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_long", value);
1882
1883                Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(value));
1884                emit_ldc2(offset, CP_LONG);
1885
1886                break;
1887              }
1888              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadWordConst: {
1889                if (VM.BuildFor32Addr) {
1890                  int value = bcodes.readIntConst();
1891
1892                  if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_word " + Integer.toHexString(value));
1893
1894                  Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(value));
1895                  emit_ldc(offset, CP_INT);
1896                } else {
1897                  long value = bcodes.readLongConst();
1898
1899                  if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_word " + Long.toHexString(value));
1900
1901                  Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(value));
1902                  emit_ldc2(offset, CP_LONG);
1903                  emit_l2i(); //dirty hack
1904                }
1905                break;
1906              }
1907              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadFloatConst: {
1908                int ibits = bcodes.readIntConst(); // fetch4BytesSigned();
1909
1910                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_float", ibits);
1911
1912                Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(ibits));
1913                emit_ldc(offset, CP_FLOAT);
1914
1915                break;
1916              }
1917              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadDoubleConst: {
1918                long lbits = bcodes.readLongConst(); // fetch8BytesUnsigned();
1919
1920                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_double", lbits);
1921
1922                Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(lbits));
1923                emit_ldc2(offset, CP_DOUBLE);
1924
1925                break;
1926              }
1927              case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadRetAddrConst: {
1928                int bcIndex = bcodes.readIntConst(); // fetch4BytesSigned();
1929
1930                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_load_retaddr", bcIndex);
1931                // for bytecode to get future bytecode's address
1932                // we register it and patch it later.
1933                emit_loadretaddrconst(bcIndex);
1934
1935                break;
1936              }
1937              case org.jikesrvm.osr.OSRConstants.PSEUDO_InvokeStatic: {
1938                int targetidx = bcodes.readIntConst(); // fetch4BytesSigned();
1939                RVMMethod methodRef = InvokeStatic.targetMethod(targetidx);
1940                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_invokestatic", methodRef);
1941                emit_resolved_invokestatic(methodRef.getMemberRef().asMethodReference());
1942                break;
1943              }
1944              /*
1945                case org.jikesrvm.osr.OSRConstants.PSEUDO_CheckCast: {
1946
1947                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_checkcast");
1948
1949                // fetch 4 byte type id
1950                int tid = bcodes.readIntConst(); // fetch4BytesSigned();
1951                // do nothing now
1952                break;
1953                }
1954              */
1955              case org.jikesrvm.osr.OSRConstants.PSEUDO_InvokeCompiledMethod: {
1956                int cmid = bcodes.readIntConst(); // fetch4BytesSigned();    // callee's cmid
1957                int origIdx =
1958                    bcodes.readIntConst(); // fetch4BytesSigned(); // orginal bytecode index of this call (for build gc map)
1959
1960                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_invoke_cmid", cmid);
1961
1962                this.pendingCMID = cmid;
1963                this.pendingIdx = origIdx + this.method.getOsrPrologueLength();
1964                this.pendingRef = emit_pending_goto(this.pendingIdx);
1965                /*
1966                  CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
1967                  if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
1968                  emit_invoke_compiledmethod(cm);
1969                */
1970                break;
1971              }
1972              case org.jikesrvm.osr.OSRConstants.PSEUDO_ParamInitEnd: {
1973                if (shouldPrint) asm.noteBytecode(biStart, "pseudo_paraminitend");
1974                // now we can inserted stack overflow check,
1975                emit_deferred_prologue();
1976                break;
1977              }
1978              default:
1979                if (VM.TraceOnStackReplacement) {
1980                  VM.sysWrite("Unexpected PSEUDO code " + Services.intAsHexString(pseudo_opcode) + "\n");
1981                }
1982                if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
1983                break;
1984            }
1985          } else {
1986            if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
1987          }
1988          break;
1989        }
1990
1991        default:
1992          VM.sysWrite("BaselineCompilerImpl: unexpected bytecode: " + Services.getHexString(code, false) + "\n");
1993          if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
1994      }
1995      ending_bytecode();
1996    }
1997    bytecodeMap[bcodes.length()] = asm.getMachineCodeIndex();
1998    return new MachineCode(getAssembler().getMachineCodes(),bytecodeMap);
1999  }
2000
2001  /**
2002   * Handle if.. bytecodes
2003   * @param biStart offset of bytecode
2004   * @param bc branch condition
2005   */
2006  @Inline
2007  private void do_if(int biStart, BranchCondition bc) {
2008    final boolean shouldPrint = this.shouldPrint;
2009    int offset = bcodes.getBranchOffset();
2010    int bTarget = biStart + offset;
2011    if (shouldPrint) getAssembler().noteBranchBytecode(biStart, "if" + bc, offset, bTarget);
2012    if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
2013    emit_if(bTarget, bc);
2014  }
2015
2016  /**
2017   * Handle if_icmp.. bytecodes
2018   * @param biStart offset of bytecode
2019   * @param bc branch condition
2020   */
2021  @Inline
2022  private void do_if_icmp(int biStart, BranchCondition bc) {
2023    final boolean shouldPrint = this.shouldPrint;
2024    int offset = bcodes.getBranchOffset();
2025    int bTarget = biStart + offset;
2026    if (shouldPrint) getAssembler().noteBranchBytecode(biStart, "if_icmp" + bc, offset, bTarget);
2027    if (offset <= 0) emit_threadSwitchTest(RVMThread.BACKEDGE);
2028    emit_if_icmp(bTarget, bc);
2029  }
2030
2031
2032  /* for invoke compiled method, we have to fool GC map,
2033  * InvokeCompiledMethod has two parameters compiledMethodID
2034  * and originalBytecodeIndex of that call site
2035  *
2036  * we make the InvokeCompiledMethod pending until generating code
2037  * for the original call.
2038  * it looks like following instruction sequence:
2039  *    invokeCompiledMethod cmid, bc
2040  *
2041  *  ==>  forward (x)
2042  *
2043  *          bc:  forward(x')
2044  *             resolve (x):
2045  *               invoke cmid
2046  *               forward(x")
2047  *             resolve (x'):
2048  *               invoke xxxx
2049  *             resolve (x");
2050  * in this way, the instruction for invokeCompiledMethod is right before
2051  * the original call, and it uses the original call's GC map
2052  */
2053  private int pendingCMID = -1;
2054  private int pendingIdx = -1;
2055  private ForwardReference pendingRef = null;
2056
2057  /**
2058   * Print a warning message whan we compile a bytecode that is forbidden in
2059   * Uninterruptible code.
2060   *
2061   * @param msg description of bytecode that is violating the invariant
2062   * @param obj object that provides further information
2063   * @param bci the index of the current bytecode
2064   */
2065  @NoInline
2066  protected final void forbiddenBytecode(String msg, Object obj, int bci) {
2067    forbiddenBytecode(msg + obj, bci);
2068  }
2069
2070  /**
2071   * Print a warning message whan we compile a bytecode that is forbidden in
2072   * Uninterruptible code.
2073   *
2074   * @param msg description of bytecode that is violating the invariant
2075   * @param bci the index of the current bytecode
2076   */
2077  @NoInline
2078  protected final void forbiddenBytecode(String msg, int bci) {
2079    if (!VM.ParanoidVerifyUnint) {
2080      // Respect programmer overrides of uninterruptibility checking
2081      if (method.hasLogicallyUninterruptibleAnnotation()) return;
2082      if (method.hasUninterruptibleNoWarnAnnotation()) return;
2083      if (method.hasUnpreemptibleNoWarnAnnotation()) return;
2084    }
2085    // NB generate as a single string to avoid threads splitting output
2086    VM.sysWriteln("WARNING: UNINTERRUPTIBLE VIOLATION. " + method + " at line " + method.getLineNumberForBCIndex(bci) +
2087    ". Uninterruptible methods may not contain the following forbidden bytecode: " + msg);
2088  }
2089
2090  /**
2091   * Ensure that the callee method is safe to invoke from uninterruptible code
2092   *
2093   * @param target the target methodRef
2094   * @param bci the index of the current bytecode
2095   */
2096  protected final void checkTarget(RVMMethod target, int bci) {
2097    if (!VM.ParanoidVerifyUnint) {
2098      // Respect programmer overrides of uninterruptibility checking
2099      if (method.hasLogicallyUninterruptibleAnnotation()) return;
2100      if (method.hasUninterruptibleNoWarnAnnotation()) return;
2101      if (method.hasUnpreemptibleNoWarnAnnotation()) return;
2102    }
2103    if (isUninterruptible && !target.isUninterruptible()) {
2104      // NB generate as a single string to avoid threads splitting output
2105      VM.sysWrite("WARNING: UNINTERRUPTIBLE VIOLATION. " + method + " at line " + method.getLineNumberForBCIndex(bci) +
2106      ". Uninterruptible method calls non-uninterruptible method " + target + "\n");
2107    }
2108    if (isUnpreemptible && target.isInterruptible()) {
2109      // NB generate as a single string to avoid threads splitting output
2110      VM.sysWrite("WARNING: UNPREEMPTIBLE VIOLATION. " + method + " at line " + method.getLineNumberForBCIndex(bci) +
2111          ". Unpreemptible method calls interruptible method " + target + "\n");
2112    }
2113  }
2114
2115  /*
2116   * The target-specific BaselineCompilerImpl class must implement the
2117   * following (lengthy) list of abstract methods.  Porting this
2118   * compiler to a new platform mainly entails implementing all of
2119   * these methods.
2120   */
2121
2122  /*
2123  * Misc routines not directly tied to a particular bytecode
2124  */
2125
2126  /**
2127   * Notify BaselineCompilerImpl that we are starting code gen for the bytecode biStart
2128   */
2129  protected abstract void starting_bytecode();
2130
2131  /**
2132   * Notify BaselineCompilerImpl that we are ending code gen for the bytecode biStart
2133   */
2134  protected void ending_bytecode() {}
2135
2136  /**
2137   * Emit the prologue for the method
2138   */
2139  protected abstract void emit_prologue();
2140
2141  /**
2142   * Emit the code for a threadswitch tests (aka a yieldpoint).
2143   * @param whereFrom is this thread switch from a PROLOGUE, BACKEDGE, or EPILOGUE?
2144   */
2145  protected abstract void emit_threadSwitchTest(int whereFrom);
2146
2147  protected abstract void emit_deferred_prologue();
2148
2149  /**
2150   * Emits the code to implement the spcified magic.
2151   * @param magicMethod desired magic
2152   *
2153   * @return {@code true} if code was emitted
2154   */
2155  protected abstract boolean emit_Magic(MethodReference magicMethod);
2156
2157  /*
2158  * Loading constants
2159  */
2160
2161  /**
2162   * Emit code to load the null constant.
2163   */
2164  protected abstract void emit_aconst_null();
2165
2166  /**
2167   * Emit code to load an int constant.
2168   * @param val the int constant to load
2169   */
2170  protected abstract void emit_iconst(int val);
2171
2172  /**
2173   * Emit code to load a long constant
2174   * @param val the lower 32 bits of long constant (upper32 are 0).
2175   */
2176  protected abstract void emit_lconst(int val);
2177
2178  /**
2179   * Emit code to load 0.0f
2180   */
2181  protected abstract void emit_fconst_0();
2182
2183  /**
2184   * Emit code to load 1.0f
2185   */
2186  protected abstract void emit_fconst_1();
2187
2188  /**
2189   * Emit code to load 2.0f
2190   */
2191  protected abstract void emit_fconst_2();
2192
2193  /**
2194   * Emit code to load 0.0d
2195   */
2196  protected abstract void emit_dconst_0();
2197
2198  /**
2199   * Emit code to load 1.0d
2200   */
2201  protected abstract void emit_dconst_1();
2202
2203  /**
2204   * Emit code to load a 32 bit constant
2205   * @param offset JTOC offset of the constant
2206   * @param type the type of the constant
2207   */
2208  protected abstract void emit_ldc(Offset offset, byte type);
2209
2210  /**
2211   * Emit code to load a 64 bit constant
2212   * @param offset JTOC offset of the constant
2213   * @param type the type of the constant
2214   */
2215  protected abstract void emit_ldc2(Offset offset, byte type);
2216
2217  /*
2218  * loading local variables
2219  */
2220
2221  /**
2222   * Emit code to load an int local variable
2223   * @param index the local index to load
2224   */
2225  protected abstract void emit_iload(int index);
2226
2227  /**
2228   * Emit code to load a long local variable
2229   * @param index the local index to load
2230   */
2231  protected abstract void emit_lload(int index);
2232
2233  /**
2234   * Emit code to local a float local variable
2235   * @param index the local index to load
2236   */
2237  protected abstract void emit_fload(int index);
2238
2239  /**
2240   * Emit code to load a double local variable
2241   * @param index the local index to load
2242   */
2243  protected abstract void emit_dload(int index);
2244
2245  /**
2246   * Emit code to load a reference local variable
2247   * @param index the local index to load
2248   */
2249  protected abstract void emit_aload(int index);
2250
2251  /*
2252  * storing local variables
2253  */
2254
2255  /**
2256   * Emit code to store an int to a local variable
2257   * @param index the local index to load
2258   */
2259  protected abstract void emit_istore(int index);
2260
2261  /**
2262   * Emit code to store a long to a local variable
2263   * @param index the local index to load
2264   */
2265  protected abstract void emit_lstore(int index);
2266
2267  /**
2268   * Emit code to store a float to a local variable
2269   * @param index the local index to load
2270   */
2271  protected abstract void emit_fstore(int index);
2272
2273  /**
2274   * Emit code to store an double  to a local variable
2275   * @param index the local index to load
2276   */
2277  protected abstract void emit_dstore(int index);
2278
2279  /**
2280   * Emit code to store a reference to a local variable
2281   * @param index the local index to load
2282   */
2283  protected abstract void emit_astore(int index);
2284
2285  /*
2286  * array loads
2287  */
2288
2289  /**
2290   * Emit code to load from an int array
2291   */
2292  protected abstract void emit_iaload();
2293
2294  /**
2295   * Emit code to load from a long array
2296   */
2297  protected abstract void emit_laload();
2298
2299  /**
2300   * Emit code to load from a float array
2301   */
2302  protected abstract void emit_faload();
2303
2304  /**
2305   * Emit code to load from a double array
2306   */
2307  protected abstract void emit_daload();
2308
2309  /**
2310   * Emit code to load from a reference array
2311   */
2312  protected abstract void emit_aaload();
2313
2314  /**
2315   * Emit code to load from a byte/boolean array
2316   */
2317  protected abstract void emit_baload();
2318
2319  /**
2320   * Emit code to load from a char array
2321   */
2322  protected abstract void emit_caload();
2323
2324  /**
2325   * Emit code to load from a short array
2326   */
2327  protected abstract void emit_saload();
2328
2329  /*
2330  * array stores
2331  */
2332
2333  /**
2334   * Emit code to store to an int array
2335   */
2336  protected abstract void emit_iastore();
2337
2338  /**
2339   * Emit code to store to a long array
2340   */
2341  protected abstract void emit_lastore();
2342
2343  /**
2344   * Emit code to store to a float array
2345   */
2346  protected abstract void emit_fastore();
2347
2348  /**
2349   * Emit code to store to a double array
2350   */
2351  protected abstract void emit_dastore();
2352
2353  /**
2354   * Emit code to store to a reference array
2355   */
2356  protected abstract void emit_aastore();
2357
2358  /**
2359   * Emit code to store to a byte/boolean array
2360   */
2361  protected abstract void emit_bastore();
2362
2363  /**
2364   * Emit code to store to a char array
2365   */
2366  protected abstract void emit_castore();
2367
2368  /**
2369   * Emit code to store to a short array
2370   */
2371  protected abstract void emit_sastore();
2372
2373  /*
2374  * expression stack manipulation
2375  */
2376
2377  /**
2378   * Emit code to implement the pop bytecode
2379   */
2380  protected abstract void emit_pop();
2381
2382  /**
2383   * Emit code to implement the pop2 bytecode
2384   */
2385  protected abstract void emit_pop2();
2386
2387  /**
2388   * Emit code to implement the dup bytecode
2389   */
2390  protected abstract void emit_dup();
2391
2392  /**
2393   * Emit code to implement the dup_x1 bytecode
2394   */
2395  protected abstract void emit_dup_x1();
2396
2397  /**
2398   * Emit code to implement the dup_x2 bytecode
2399   */
2400  protected abstract void emit_dup_x2();
2401
2402  /**
2403   * Emit code to implement the dup2 bytecode
2404   */
2405  protected abstract void emit_dup2();
2406
2407  /**
2408   * Emit code to implement the dup2_x1 bytecode
2409   */
2410  protected abstract void emit_dup2_x1();
2411
2412  /**
2413   * Emit code to implement the dup2_x2 bytecode
2414   */
2415  protected abstract void emit_dup2_x2();
2416
2417  /**
2418   * Emit code to implement the swap bytecode
2419   */
2420  protected abstract void emit_swap();
2421
2422  /*
2423  * int ALU
2424  */
2425
2426  /**
2427   * Emit code to implement the iadd bytecode
2428   */
2429  protected abstract void emit_iadd();
2430
2431  /**
2432   * Emit code to implement the isub bytecode
2433   */
2434  protected abstract void emit_isub();
2435
2436  /**
2437   * Emit code to implement the imul bytecode
2438   */
2439  protected abstract void emit_imul();
2440
2441  /**
2442   * Emit code to implement the idiv bytecode
2443   */
2444  protected abstract void emit_idiv();
2445
2446  /**
2447   * Emit code to implement the irem bytecode
2448   */
2449  protected abstract void emit_irem();
2450
2451  /**
2452   * Emit code to implement the ineg bytecode
2453   */
2454  protected abstract void emit_ineg();
2455
2456  /**
2457   * Emit code to implement the ishl bytecode
2458   */
2459  protected abstract void emit_ishl();
2460
2461  /**
2462   * Emit code to implement the ishr bytecode
2463   */
2464  protected abstract void emit_ishr();
2465
2466  /**
2467   * Emit code to implement the iushr bytecode
2468   */
2469  protected abstract void emit_iushr();
2470
2471  /**
2472   * Emit code to implement the iand bytecode
2473   */
2474  protected abstract void emit_iand();
2475
2476  /**
2477   * Emit code to implement the ior bytecode
2478   */
2479  protected abstract void emit_ior();
2480
2481  /**
2482   * Emit code to implement the ixor bytecode
2483   */
2484  protected abstract void emit_ixor();
2485
2486  /**
2487   * Emit code to implement the iinc bytecode
2488   * @param index index of local
2489   * @param val value to increment it by
2490   */
2491  protected abstract void emit_iinc(int index, int val);
2492
2493  /*
2494  * long ALU
2495  */
2496
2497  /**
2498   * Emit code to implement the ladd bytecode
2499   */
2500  protected abstract void emit_ladd();
2501
2502  /**
2503   * Emit code to implement the lsub bytecode
2504   */
2505  protected abstract void emit_lsub();
2506
2507  /**
2508   * Emit code to implement the lmul bytecode
2509   */
2510  protected abstract void emit_lmul();
2511
2512  /**
2513   * Emit code to implement the ldiv bytecode
2514   */
2515  protected abstract void emit_ldiv();
2516
2517  /**
2518   * Emit code to implement the lrem bytecode
2519   */
2520  protected abstract void emit_lrem();
2521
2522  /**
2523   * Emit code to implement the lneg bytecode
2524   */
2525  protected abstract void emit_lneg();
2526
2527  /**
2528   * Emit code to implement the lshsl bytecode
2529   */
2530  protected abstract void emit_lshl();
2531
2532  /**
2533   * Emit code to implement the lshr bytecode
2534   */
2535  protected abstract void emit_lshr();
2536
2537  /**
2538   * Emit code to implement the lushr bytecode
2539   */
2540  protected abstract void emit_lushr();
2541
2542  /**
2543   * Emit code to implement the land bytecode
2544   */
2545  protected abstract void emit_land();
2546
2547  /**
2548   * Emit code to implement the lor bytecode
2549   */
2550  protected abstract void emit_lor();
2551
2552  /**
2553   * Emit code to implement the lxor bytecode
2554   */
2555  protected abstract void emit_lxor();
2556
2557  /*
2558  * float ALU
2559  */
2560
2561  /**
2562   * Emit code to implement the fadd bytecode
2563   */
2564  protected abstract void emit_fadd();
2565
2566  /**
2567   * Emit code to implement the fsub bytecode
2568   */
2569  protected abstract void emit_fsub();
2570
2571  /**
2572   * Emit code to implement the fmul bytecode
2573   */
2574  protected abstract void emit_fmul();
2575
2576  /**
2577   * Emit code to implement the fdiv bytecode
2578   */
2579  protected abstract void emit_fdiv();
2580
2581  /**
2582   * Emit code to implement the frem bytecode
2583   */
2584  protected abstract void emit_frem();
2585
2586  /**
2587   * Emit code to implement the fneg bytecode
2588   */
2589  protected abstract void emit_fneg();
2590
2591  /*
2592  * double ALU
2593  */
2594
2595  /**
2596   * Emit code to implement the dadd bytecode
2597   */
2598  protected abstract void emit_dadd();
2599
2600  /**
2601   * Emit code to implement the dsub bytecode
2602   */
2603  protected abstract void emit_dsub();
2604
2605  /**
2606   * Emit code to implement the dmul bytecode
2607   */
2608  protected abstract void emit_dmul();
2609
2610  /**
2611   * Emit code to implement the ddiv bytecode
2612   */
2613  protected abstract void emit_ddiv();
2614
2615  /**
2616   * Emit code to implement the drem bytecode
2617   */
2618  protected abstract void emit_drem();
2619
2620  /**
2621   * Emit code to implement the dneg bytecode
2622   */
2623  protected abstract void emit_dneg();
2624
2625  /*
2626  * conversion ops
2627  */
2628
2629  /**
2630   * Emit code to implement the i2l bytecode
2631   */
2632  protected abstract void emit_i2l();
2633
2634  /**
2635   * Emit code to implement the i2f bytecode
2636   */
2637  protected abstract void emit_i2f();
2638
2639  /**
2640   * Emit code to implement the i2d bytecode
2641   */
2642  protected abstract void emit_i2d();
2643
2644  /**
2645   * Emit code to implement the l2i bytecode
2646   */
2647  protected abstract void emit_l2i();
2648
2649  /**
2650   * Emit code to implement the l2f bytecode
2651   */
2652  protected abstract void emit_l2f();
2653
2654  /**
2655   * Emit code to implement the l2d bytecode
2656   */
2657  protected abstract void emit_l2d();
2658
2659  /**
2660   * Emit code to implement the f2i bytecode
2661   */
2662  protected abstract void emit_f2i();
2663
2664  /**
2665   * Emit code to implement the f2l bytecode
2666   */
2667  protected abstract void emit_f2l();
2668
2669  /**
2670   * Emit code to implement the f2d bytecode
2671   */
2672  protected abstract void emit_f2d();
2673
2674  /**
2675   * Emit code to implement the d2i bytecode
2676   */
2677  protected abstract void emit_d2i();
2678
2679  /**
2680   * Emit code to implement the d2l bytecode
2681   */
2682  protected abstract void emit_d2l();
2683
2684  /**
2685   * Emit code to implement the d2f bytecode
2686   */
2687  protected abstract void emit_d2f();
2688
2689  /**
2690   * Emit code to implement the i2b bytecode
2691   */
2692  protected abstract void emit_i2b();
2693
2694  /**
2695   * Emit code to implement the i2c bytecode
2696   */
2697  protected abstract void emit_i2c();
2698
2699  /**
2700   * Emit code to implement the i2s bytecode
2701   */
2702  protected abstract void emit_i2s();
2703
2704  /*
2705  * comparision ops
2706  */
2707
2708  /**
2709   * Emit code to implement the lcmp bytecode
2710   */
2711  protected abstract void emit_lcmp();
2712
2713  /**
2714   * Emits code to handle all [df]cmp[gl] cases
2715   *
2716   * @param single {@code true} for float [f], {@code false} for double [d]
2717   * @param unorderedGT {@code true} for [g], {@code false} for [l]
2718   */
2719  protected abstract void emit_DFcmpGL(boolean single, boolean unorderedGT);
2720
2721  /*
2722  * branching
2723  */
2724
2725  /**
2726   * Emits code to implement the if.. bytecode
2727   * @param bTarget target bytecode of the branch
2728   * @param bc branch condition
2729   */
2730  protected abstract void emit_if(int bTarget, BranchCondition bc);
2731
2732  /**
2733   * Emits code to implement the if_icmp.. bytecode
2734   * @param bTarget target bytecode of the branch
2735   * @param bc branch condition
2736   */
2737  protected abstract void emit_if_icmp(int bTarget, BranchCondition bc);
2738
2739  /**
2740   * Emit code to implement the if_acmpeq bytecode
2741   * @param bTarget target bytecode of the branch
2742   */
2743  protected abstract void emit_if_acmpeq(int bTarget);
2744
2745  /**
2746   * Emit code to implement the if_acmpne bytecode
2747   * @param bTarget target bytecode of the branch
2748   */
2749  protected abstract void emit_if_acmpne(int bTarget);
2750
2751  /**
2752   * Emit code to implement the ifnull bytecode
2753   * @param bTarget target bytecode of the branch
2754   */
2755  protected abstract void emit_ifnull(int bTarget);
2756
2757  /**
2758   * Emit code to implement the ifnonnull bytecode
2759   * @param bTarget target bytecode of the branch
2760   */
2761  protected abstract void emit_ifnonnull(int bTarget);
2762
2763  /**
2764   * Emit code to implement the goto and gotow bytecodes
2765   * @param bTarget target bytecode of the branch
2766   */
2767  protected abstract void emit_goto(int bTarget);
2768
2769  /**
2770   * Emit code to implement the jsr and jsrw bytecode
2771   * @param bTarget target bytecode of the jsr
2772   */
2773  protected abstract void emit_jsr(int bTarget);
2774
2775  /**
2776   * Emit code to implement the ret bytecode
2777   * @param index local variable containing the return address
2778   */
2779  protected abstract void emit_ret(int index);
2780
2781  /**
2782   * Emit code to implement the tableswitch bytecode
2783   * @param defaultval bcIndex of the default target
2784   * @param low low value of switch
2785   * @param high high value of switch
2786   */
2787  protected abstract void emit_tableswitch(int defaultval, int low, int high);
2788
2789  /**
2790   * Emit code to implement the lookupswitch bytecode
2791   * @param defaultval bcIndex of the default target
2792   * @param npairs number of pairs in the lookup switch
2793   */
2794  protected abstract void emit_lookupswitch(int defaultval, int npairs);
2795
2796  /*
2797  * returns (from function; NOT ret)
2798  */
2799
2800  /**
2801   * Emit code to implement the ireturn bytecode
2802   */
2803  protected abstract void emit_ireturn();
2804
2805  /**
2806   * Emit code to implement the lreturn bytecode
2807   */
2808  protected abstract void emit_lreturn();
2809
2810  /**
2811   * Emit code to implement the freturn bytecode
2812   */
2813  protected abstract void emit_freturn();
2814
2815  /**
2816   * Emit code to implement the dreturn bytecode
2817   */
2818  protected abstract void emit_dreturn();
2819
2820  /**
2821   * Emit code to implement the areturn bytecode
2822   */
2823  protected abstract void emit_areturn();
2824
2825  /**
2826   * Emit code to implement the return bytecode
2827   */
2828  protected abstract void emit_return();
2829
2830  /*
2831  * field access
2832  */
2833
2834  /**
2835   * Emit code to implement a dynamically linked getstatic
2836   * @param fieldRef the referenced field
2837   */
2838  protected abstract void emit_unresolved_getstatic(FieldReference fieldRef);
2839
2840  /**
2841   * Emit code to implement a getstatic
2842   * @param fieldRef the referenced field
2843   */
2844  protected abstract void emit_resolved_getstatic(FieldReference fieldRef);
2845
2846  /**
2847   * Emit code to implement a dynamically linked putstatic
2848   * @param fieldRef the referenced field
2849   */
2850  protected abstract void emit_unresolved_putstatic(FieldReference fieldRef);
2851
2852  /**
2853   * Emit code to implement a putstatic
2854   * @param fieldRef the referenced field
2855   */
2856  protected abstract void emit_resolved_putstatic(FieldReference fieldRef);
2857
2858  /**
2859   * Emit code to implement a dynamically linked getfield
2860   * @param fieldRef the referenced field
2861   */
2862  protected abstract void emit_unresolved_getfield(FieldReference fieldRef);
2863
2864  /**
2865   * Emit code to implement a getfield
2866   * @param fieldRef the referenced field
2867   */
2868  protected abstract void emit_resolved_getfield(FieldReference fieldRef);
2869
2870  /**
2871   * Emit code to implement a dynamically linked putfield
2872   * @param fieldRef the referenced field
2873   */
2874  protected abstract void emit_unresolved_putfield(FieldReference fieldRef);
2875
2876  /**
2877   * Emit code to implement a putfield
2878   * @param fieldRef the referenced field
2879   */
2880  protected abstract void emit_resolved_putfield(FieldReference fieldRef);
2881
2882  /*
2883  * method invocation
2884  */
2885
2886  /**
2887   * Emit code to implement a dynamically linked invokevirtual
2888   * @param methodRef the referenced method
2889   */
2890  protected abstract void emit_unresolved_invokevirtual(MethodReference methodRef);
2891
2892  /**
2893   * Emit code to implement invokevirtual
2894   * @param methodRef the referenced method
2895   */
2896  protected abstract void emit_resolved_invokevirtual(MethodReference methodRef);
2897
2898  /**
2899   * Emit code to implement a dynamically linked invokespecial
2900   * @param methodRef the referenced method
2901   * @param target the method to invoke
2902   */
2903  protected abstract void emit_resolved_invokespecial(MethodReference methodRef, RVMMethod target);
2904
2905  /**
2906   * Emit code to implement invokespecial
2907   * @param methodRef the referenced method
2908   */
2909  protected abstract void emit_unresolved_invokespecial(MethodReference methodRef);
2910
2911  /**
2912   * Emit code to implement a dynamically linked invokestatic
2913   * @param methodRef the referenced method
2914   */
2915  protected abstract void emit_unresolved_invokestatic(MethodReference methodRef);
2916
2917  /**
2918   * Emit code to implement invokestatic
2919   * @param methodRef the referenced method
2920   */
2921  protected abstract void emit_resolved_invokestatic(MethodReference methodRef);
2922
2923  // OSR only
2924  protected abstract void emit_invoke_compiledmethod(CompiledMethod cm);
2925
2926  // OSR only
2927  protected abstract ForwardReference emit_pending_goto(int origidx);
2928
2929  /**
2930   * Emit code to implement the invokeinterface bytecode
2931   * @param methodRef the referenced method
2932   */
2933  protected abstract void emit_invokeinterface(MethodReference methodRef);
2934
2935  /*
2936  * other object model functions
2937  */
2938
2939  /**
2940   * Emit code to allocate a scalar object
2941   *
2942   * @param typeRef  The {@link RVMClass} to instantiate
2943   */
2944  protected abstract void emit_resolved_new(RVMClass typeRef);
2945
2946  /**
2947   * Emit code to dynamically link and allocate a scalar object
2948   * @param typeRef   {@link TypeReference} to dynamically link &amp; instantiate
2949   */
2950  protected abstract void emit_unresolved_new(TypeReference typeRef);
2951
2952  /**
2953   * Emit code to allocate an array
2954   * @param array the {@link RVMArray} to instantiate
2955   */
2956  protected abstract void emit_resolved_newarray(RVMArray array);
2957
2958  /**
2959   * Emit code to dynamically link the element class and allocate an array
2960   * @param typeRef typeReference to dynamically link &amp; instantiate
2961   */
2962  protected abstract void emit_unresolved_newarray(TypeReference typeRef);
2963
2964  /**
2965   * Emit code to allocate a multi-dimensional array
2966   * @param typeRef typeReference to dynamically link &amp; instantiate
2967   * @param dimensions the number of dimensions
2968   */
2969  protected abstract void emit_multianewarray(TypeReference typeRef, int dimensions);
2970
2971  /**
2972   * Emit code to implement the arraylength bytecode
2973   */
2974  protected abstract void emit_arraylength();
2975
2976  /**
2977   * Emit code to implement the athrow bytecode
2978   */
2979  protected abstract void emit_athrow();
2980
2981  /**
2982   * Emit code to implement the checkcast bytecode
2983   * @param typeRef the LHS type
2984   */
2985  protected abstract void emit_checkcast(TypeReference typeRef);
2986
2987  /**
2988   * Emit code to implement the checkcast bytecode
2989   * @param type the LHS type
2990   */
2991  protected abstract void emit_checkcast_resolvedInterface(RVMClass type);
2992  /**
2993   * Emit code to implement the checkcast bytecode
2994   * @param type the LHS type
2995   */
2996  protected abstract void emit_checkcast_resolvedClass(RVMClass type);
2997
2998  /**
2999   * Emit code to implement the checkcast bytecode
3000   * @param type the LHS type
3001   */
3002  protected abstract void emit_checkcast_final(RVMType type);
3003
3004  /**
3005   * Emit code to implement the instanceof bytecode
3006   * @param typeRef the LHS type
3007   */
3008  protected abstract void emit_instanceof(TypeReference typeRef);
3009
3010  /**
3011   * Emit code to implement the instanceof bytecode
3012   * @param type the LHS type
3013   */
3014  protected abstract void emit_instanceof_resolvedInterface(RVMClass type);
3015
3016  /**
3017   * Emit code to implement the instanceof bytecode
3018   * @param type the LHS type
3019   */
3020  protected abstract void emit_instanceof_resolvedClass(RVMClass type);
3021
3022  /**
3023   * Emit code to implement the instanceof bytecode
3024   * @param type the LHS type
3025   */
3026  protected abstract void emit_instanceof_final(RVMType type);
3027
3028  /**
3029   * Emit code to implement the monitorenter bytecode
3030   */
3031  protected abstract void emit_monitorenter();
3032
3033  /**
3034   * Emit code to implement the monitorexit bytecode
3035   */
3036  protected abstract void emit_monitorexit();
3037
3038  // OSR only
3039  protected abstract void emit_loadretaddrconst(int bcIndex);
3040
3041  protected abstract String getCompilerName();
3042}