langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
changeset 29295 5a367770a074
parent 28800 35f9042d53b3
child 29777 95a89a2efd89
equal deleted inserted replaced
29294:376a915b4ff0 29295:5a367770a074
   122             ? options.isSet(G)
   122             ? options.isSet(G)
   123             : options.isSet(G_CUSTOM, "vars");
   123             : options.isSet(G_CUSTOM, "vars");
   124         genCrt = options.isSet(XJCOV);
   124         genCrt = options.isSet(XJCOV);
   125         debugCode = options.isSet("debugcode");
   125         debugCode = options.isSet("debugcode");
   126         allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
   126         allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
       
   127         allowBetterNullChecks = target.hasObjects();
   127         pool = new Pool(types);
   128         pool = new Pool(types);
   128 
   129 
   129         // ignore cldc because we cannot have both stackmap formats
   130         // ignore cldc because we cannot have both stackmap formats
   130         this.stackMap = StackMapFormat.JSR202;
   131         this.stackMap = StackMapFormat.JSR202;
   131 
   132 
   148     private final boolean lineDebugInfo;
   149     private final boolean lineDebugInfo;
   149     private final boolean varDebugInfo;
   150     private final boolean varDebugInfo;
   150     private final boolean genCrt;
   151     private final boolean genCrt;
   151     private final boolean debugCode;
   152     private final boolean debugCode;
   152     private final boolean allowInvokedynamic;
   153     private final boolean allowInvokedynamic;
       
   154     private final boolean allowBetterNullChecks;
   153 
   155 
   154     /** Default limit of (approximate) size of finalizer to inline.
   156     /** Default limit of (approximate) size of finalizer to inline.
   155      *  Zero means always use jsr.  100 or greater means never use
   157      *  Zero means always use jsr.  100 or greater means never use
   156      *  jsr.
   158      *  jsr.
   157      */
   159      */
  1981         }
  1983         }
  1982     }
  1984     }
  1983 
  1985 
  1984     /** Generate a null check from the object value at stack top. */
  1986     /** Generate a null check from the object value at stack top. */
  1985     private void genNullCheck(DiagnosticPosition pos) {
  1987     private void genNullCheck(DiagnosticPosition pos) {
  1986         callMethod(pos, syms.objectType, names.getClass,
  1988         if (allowBetterNullChecks) {
  1987                    List.<Type>nil(), false);
  1989             callMethod(pos, syms.objectsType, names.requireNonNull,
       
  1990                     List.of(syms.objectType), true);
       
  1991         } else {
       
  1992             callMethod(pos, syms.objectType, names.getClass,
       
  1993                     List.<Type>nil(), false);
       
  1994         }
  1988         code.emitop0(pop);
  1995         code.emitop0(pop);
  1989     }
  1996     }
  1990 
  1997 
  1991     public void visitBinary(JCBinary tree) {
  1998     public void visitBinary(JCBinary tree) {
  1992         OperatorSymbol operator = (OperatorSymbol)tree.operator;
  1999         OperatorSymbol operator = (OperatorSymbol)tree.operator;