108 make = TreeMaker.instance(context); 109 target = Target.instance(context); 110 types = Types.instance(context); 111 concat = StringConcat.instance(context); 112 113 methodType = new MethodType(null, null, null, syms.methodClass); 114 accessDollar = names. 115 fromString("access" + target.syntheticNameChar()); 116 lower = Lower.instance(context); 117 118 Options options = Options.instance(context); 119 lineDebugInfo = 120 options.isUnset(G_CUSTOM) || 121 options.isSet(G_CUSTOM, "lines"); 122 varDebugInfo = 123 options.isUnset(G_CUSTOM) 124 ? options.isSet(G) 125 : options.isSet(G_CUSTOM, "vars"); 126 genCrt = options.isSet(XJCOV); 127 debugCode = options.isSet("debug.code"); 128 allowBetterNullChecks = target.hasObjects(); 129 disableVirtualizedPrivateInvoke = options.isSet("disableVirtualizedPrivateInvoke"); 130 pool = new Pool(types); 131 132 // ignore cldc because we cannot have both stackmap formats 133 this.stackMap = StackMapFormat.JSR202; 134 annotate = Annotate.instance(context); 135 } 136 137 /** Switches 138 */ 139 private final boolean lineDebugInfo; 140 private final boolean varDebugInfo; 141 private final boolean genCrt; 142 private final boolean debugCode; 143 private final boolean allowBetterNullChecks; 144 private boolean disableVirtualizedPrivateInvoke; 145 146 /** Code buffer, set by genMethod. 147 */ 148 private Code code; 149 150 /** Items structure, set by genMethod. 151 */ 152 private Items items; 153 154 /** Environment for symbol lookup, set by genClass 155 */ 156 private Env<AttrContext> attrEnv; 157 158 /** The top level tree. 159 */ 160 private JCCompilationUnit toplevel; 161 162 /** The number of code-gen errors in this class. 163 */ 1902 Code.truncate(od.typecode) == INTcode) 1903 code.emitop0(int2byte + od.typecode - BYTEcode); 1904 od.store(); 1905 result = res; 1906 } 1907 break; 1908 case NULLCHK: 1909 result = od.load(); 1910 code.emitop0(dup); 1911 genNullCheck(tree); 1912 break; 1913 default: 1914 Assert.error(); 1915 } 1916 } 1917 } 1918 1919 /** Generate a null check from the object value at stack top. */ 1920 private void genNullCheck(JCTree tree) { 1921 code.statBegin(tree.pos); 1922 if (allowBetterNullChecks) { 1923 callMethod(tree.pos(), syms.objectsType, names.requireNonNull, 1924 List.of(syms.objectType), true); 1925 } else { 1926 callMethod(tree.pos(), syms.objectType, names.getClass, 1927 List.nil(), false); 1928 } 1929 code.emitop0(pop); 1930 } 1931 1932 public void visitBinary(JCBinary tree) { 1933 OperatorSymbol operator = tree.operator; 1934 if (operator.opcode == string_add) { 1935 result = concat.makeConcat(tree); 1936 } else if (tree.hasTag(AND)) { 1937 CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER); 1938 if (!lcond.isFalse()) { 1939 Chain falseJumps = lcond.jumpFalse(); 1940 code.resolve(lcond.trueJumps); 1941 CondItem rcond = genCond(tree.rhs, CRT_FLOW_TARGET); 1942 result = items. 1943 makeCondItem(rcond.opcode, 1944 rcond.trueJumps, 1945 Code.mergeChains(falseJumps, 1946 rcond.falseJumps)); 1947 } else { 1948 result = lcond; | 108 make = TreeMaker.instance(context); 109 target = Target.instance(context); 110 types = Types.instance(context); 111 concat = StringConcat.instance(context); 112 113 methodType = new MethodType(null, null, null, syms.methodClass); 114 accessDollar = names. 115 fromString("access" + target.syntheticNameChar()); 116 lower = Lower.instance(context); 117 118 Options options = Options.instance(context); 119 lineDebugInfo = 120 options.isUnset(G_CUSTOM) || 121 options.isSet(G_CUSTOM, "lines"); 122 varDebugInfo = 123 options.isUnset(G_CUSTOM) 124 ? options.isSet(G) 125 : options.isSet(G_CUSTOM, "vars"); 126 genCrt = options.isSet(XJCOV); 127 debugCode = options.isSet("debug.code"); 128 disableVirtualizedPrivateInvoke = options.isSet("disableVirtualizedPrivateInvoke"); 129 pool = new Pool(types); 130 131 // ignore cldc because we cannot have both stackmap formats 132 this.stackMap = StackMapFormat.JSR202; 133 annotate = Annotate.instance(context); 134 } 135 136 /** Switches 137 */ 138 private final boolean lineDebugInfo; 139 private final boolean varDebugInfo; 140 private final boolean genCrt; 141 private final boolean debugCode; 142 private boolean disableVirtualizedPrivateInvoke; 143 144 /** Code buffer, set by genMethod. 145 */ 146 private Code code; 147 148 /** Items structure, set by genMethod. 149 */ 150 private Items items; 151 152 /** Environment for symbol lookup, set by genClass 153 */ 154 private Env<AttrContext> attrEnv; 155 156 /** The top level tree. 157 */ 158 private JCCompilationUnit toplevel; 159 160 /** The number of code-gen errors in this class. 161 */ 1900 Code.truncate(od.typecode) == INTcode) 1901 code.emitop0(int2byte + od.typecode - BYTEcode); 1902 od.store(); 1903 result = res; 1904 } 1905 break; 1906 case NULLCHK: 1907 result = od.load(); 1908 code.emitop0(dup); 1909 genNullCheck(tree); 1910 break; 1911 default: 1912 Assert.error(); 1913 } 1914 } 1915 } 1916 1917 /** Generate a null check from the object value at stack top. */ 1918 private void genNullCheck(JCTree tree) { 1919 code.statBegin(tree.pos); 1920 callMethod(tree.pos(), syms.objectsType, names.requireNonNull, 1921 List.of(syms.objectType), true); 1922 code.emitop0(pop); 1923 } 1924 1925 public void visitBinary(JCBinary tree) { 1926 OperatorSymbol operator = tree.operator; 1927 if (operator.opcode == string_add) { 1928 result = concat.makeConcat(tree); 1929 } else if (tree.hasTag(AND)) { 1930 CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER); 1931 if (!lcond.isFalse()) { 1932 Chain falseJumps = lcond.jumpFalse(); 1933 code.resolve(lcond.trueJumps); 1934 CondItem rcond = genCond(tree.rhs, CRT_FLOW_TARGET); 1935 result = items. 1936 makeCondItem(rcond.opcode, 1937 rcond.trueJumps, 1938 Code.mergeChains(falseJumps, 1939 rcond.falseJumps)); 1940 } else { 1941 result = lcond; |