changeset 49710:747d35c1b820 condy-folding

force constant folding to be active in the build
author vromero
date Fri, 06 Apr 2018 13:40:51 -0400
parents bec646ff7f36
children 16d2d89ce2ec
files make/BuildNashorn.gmk make/CompileJavaModules.gmk src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstablesVisitor.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
diffstat 6 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/make/BuildNashorn.gmk	Thu Apr 05 12:07:54 2018 -0400
+++ b/make/BuildNashorn.gmk	Fri Apr 06 13:40:51 2018 -0400
@@ -42,7 +42,7 @@
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
     FLAGS := -g -source 11 -target 11 --upgrade-module-path "$(JDK_OUTPUTDIR)/modules/" \
-         --system none --module-source-path $(call GetModuleSrcPath), \
+         --system none --module-source-path $(call GetModuleSrcPath) -XDfolding=false, \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
 
--- a/make/CompileJavaModules.gmk	Thu Apr 05 12:07:54 2018 -0400
+++ b/make/CompileJavaModules.gmk	Fri Apr 06 13:40:51 2018 -0400
@@ -38,7 +38,7 @@
 ################################################################################
 # Module specific build settings
 
-java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline
+java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline -XDfolding=false
 java.base_COPY += .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
 java.base_CLEAN += intrinsic.properties
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Thu Apr 05 12:07:54 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Fri Apr 06 13:40:51 2018 -0400
@@ -182,7 +182,8 @@
         UNDERSCORE_IDENTIFIER(MIN, JDK8),
         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
         LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
-        CONDY_FOR_LAMBDA(JDK11);
+        CONDY_FOR_LAMBDA(JDK11),
+        CONSTABLES(JDK11);
 
         enum DiagKind {
             NORMAL,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Apr 05 12:07:54 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Fri Apr 06 13:40:51 2018 -0400
@@ -127,7 +127,10 @@
         functionDescriptorLookupError = new FunctionDescriptorLookupError();
         noWarnings = new Warner(null);
         Options options = Options.instance(context);
-        doConstantFold = options.isSet("doConstantFold");
+        String foldingOp = options.get("folding");
+        doConstantFold = foldingOp != null ?
+                foldingOp.equals("true") :
+                Feature.CONSTABLES.allowedInSource(source);
         constables = Constables.instance(context);
     }
     // </editor-fold>
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstablesVisitor.java	Thu Apr 05 12:07:54 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstablesVisitor.java	Fri Apr 06 13:40:51 2018 -0400
@@ -31,6 +31,8 @@
 import java.util.Optional;
 import java.util.Set;
 
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.code.Source.Feature;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.DynamicVarSymbol;
 import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol;
@@ -42,6 +44,7 @@
 import com.sun.tools.javac.code.Type.MethodType;
 import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.jvm.Pool;
+import com.sun.tools.javac.jvm.Target;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCBinary;
@@ -98,7 +101,12 @@
     protected ConstablesVisitor(Context context) {
         context.put(constablesVisitorKey, this);
         Options options = Options.instance(context);
-        doConstantFold = options.isSet("doConstantFold");
+        // format: -XDfolding=true, which is the default, or -XDfolding=false
+        String foldingOp = options.get("folding");
+        Source source = Source.instance(context);
+        doConstantFold = foldingOp != null ?
+                foldingOp.equals("true") :
+                Feature.CONSTABLES.allowedInSource(source);
         syms = Symtab.instance(context);
         names = Names.instance(context);
         types = Types.instance(context);
@@ -240,7 +248,7 @@
             return;
         }
         Symbol sym = TreeInfo.symbol(tree);
-        if (sym.kind == VAR) {
+        if (sym != null && sym.kind == VAR) {
             VarSymbol v = (VarSymbol)sym;
             Object constant = v.getConstValue();
             if (constant != null && tree.type.constValue() == null) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Apr 05 12:07:54 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Apr 06 13:40:51 2018 -0400
@@ -34,6 +34,7 @@
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.code.Source.Feature;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
@@ -131,7 +132,12 @@
             : options.isSet(G_CUSTOM, "vars");
         genCrt = options.isSet(XJCOV);
         debugCode = options.isSet("debug.code");
-        doConstantFold = options.isSet("doConstantFold");
+        // format: -XDfolding=true, which is the default, or -XDfolding=false
+        String foldingOp = options.get("folding");
+        Source source = Source.instance(context);
+        doConstantFold = foldingOp != null ?
+                foldingOp.equals("true") :
+                Feature.CONSTABLES.allowedInSource(source);
         allowBetterNullChecks = target.hasObjects();
         pool = new Pool(types);
         // ignore cldc because we cannot have both stackmap formats