src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderConfiguration.java
changeset 58877 aec7bf35d6f5
parent 58299 6df94ce3ab2f
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
   201     private final List<ResolvedJavaType> skippedExceptionTypes;
   201     private final List<ResolvedJavaType> skippedExceptionTypes;
   202     private final boolean insertFullInfopoints;
   202     private final boolean insertFullInfopoints;
   203     private final boolean trackNodeSourcePosition;
   203     private final boolean trackNodeSourcePosition;
   204     private final boolean retainLocalVariables;
   204     private final boolean retainLocalVariables;
   205     private final Plugins plugins;
   205     private final Plugins plugins;
       
   206     private final boolean replaceLocalsWithConstants;
   206 
   207 
   207     public enum BytecodeExceptionMode {
   208     public enum BytecodeExceptionMode {
   208         /**
   209         /**
   209          * This mode always explicitly checks for exceptions.
   210          * This mode always explicitly checks for exceptions.
   210          */
   211          */
   229                     BytecodeExceptionMode bytecodeExceptionMode,
   230                     BytecodeExceptionMode bytecodeExceptionMode,
   230                     boolean omitAssertions,
   231                     boolean omitAssertions,
   231                     boolean insertFullInfopoints,
   232                     boolean insertFullInfopoints,
   232                     boolean trackNodeSourcePosition,
   233                     boolean trackNodeSourcePosition,
   233                     boolean retainLocalVariables,
   234                     boolean retainLocalVariables,
       
   235                     boolean replaceLocalsWithConstants,
   234                     List<ResolvedJavaType> skippedExceptionTypes,
   236                     List<ResolvedJavaType> skippedExceptionTypes,
   235                     Plugins plugins) {
   237                     Plugins plugins) {
   236         this.eagerResolving = eagerResolving;
   238         this.eagerResolving = eagerResolving;
   237         this.unresolvedIsError = unresolvedIsError;
   239         this.unresolvedIsError = unresolvedIsError;
   238         this.bytecodeExceptionMode = bytecodeExceptionMode;
   240         this.bytecodeExceptionMode = bytecodeExceptionMode;
   239         this.omitAssertions = omitAssertions;
   241         this.omitAssertions = omitAssertions;
   240         this.insertFullInfopoints = insertFullInfopoints;
   242         this.insertFullInfopoints = insertFullInfopoints;
   241         this.trackNodeSourcePosition = trackNodeSourcePosition;
   243         this.trackNodeSourcePosition = trackNodeSourcePosition;
   242         this.retainLocalVariables = retainLocalVariables;
   244         this.retainLocalVariables = retainLocalVariables;
       
   245         this.replaceLocalsWithConstants = replaceLocalsWithConstants;
   243         this.skippedExceptionTypes = skippedExceptionTypes;
   246         this.skippedExceptionTypes = skippedExceptionTypes;
   244         this.plugins = plugins;
   247         this.plugins = plugins;
   245     }
   248     }
   246 
   249 
   247     /**
   250     /**
   257                         bytecodeExceptionMode,
   260                         bytecodeExceptionMode,
   258                         omitAssertions,
   261                         omitAssertions,
   259                         insertFullInfopoints,
   262                         insertFullInfopoints,
   260                         trackNodeSourcePosition,
   263                         trackNodeSourcePosition,
   261                         retainLocalVariables,
   264                         retainLocalVariables,
       
   265                         replaceLocalsWithConstants,
   262                         skippedExceptionTypes,
   266                         skippedExceptionTypes,
   263                         newPlugins);
   267                         newPlugins);
   264         return result;
   268         return result;
   265     }
   269     }
   266 
   270 
   277                         bytecodeExceptionMode,
   281                         bytecodeExceptionMode,
   278                         omitAssertions,
   282                         omitAssertions,
   279                         insertFullInfopoints,
   283                         insertFullInfopoints,
   280                         trackNodeSourcePosition,
   284                         trackNodeSourcePosition,
   281                         retainLocalVariables,
   285                         retainLocalVariables,
       
   286                         replaceLocalsWithConstants,
   282                         skippedExceptionTypes,
   287                         skippedExceptionTypes,
   283                         plugins);
   288                         plugins);
   284     }
   289     }
   285 
   290 
   286     public GraphBuilderConfiguration withEagerResolving(boolean newEagerResolving) {
   291     public GraphBuilderConfiguration withEagerResolving(boolean newEagerResolving) {
   290                         bytecodeExceptionMode,
   295                         bytecodeExceptionMode,
   291                         omitAssertions,
   296                         omitAssertions,
   292                         insertFullInfopoints,
   297                         insertFullInfopoints,
   293                         trackNodeSourcePosition,
   298                         trackNodeSourcePosition,
   294                         retainLocalVariables,
   299                         retainLocalVariables,
       
   300                         replaceLocalsWithConstants,
   295                         skippedExceptionTypes,
   301                         skippedExceptionTypes,
   296                         plugins);
   302                         plugins);
   297     }
   303     }
   298 
   304 
   299     public GraphBuilderConfiguration withSkippedExceptionTypes(ResolvedJavaType[] newSkippedExceptionTypes) {
   305     public GraphBuilderConfiguration withSkippedExceptionTypes(ResolvedJavaType[] newSkippedExceptionTypes) {
   303                         bytecodeExceptionMode,
   309                         bytecodeExceptionMode,
   304                         omitAssertions,
   310                         omitAssertions,
   305                         insertFullInfopoints,
   311                         insertFullInfopoints,
   306                         trackNodeSourcePosition,
   312                         trackNodeSourcePosition,
   307                         retainLocalVariables,
   313                         retainLocalVariables,
       
   314                         replaceLocalsWithConstants,
   308                         Collections.unmodifiableList(Arrays.asList(newSkippedExceptionTypes)),
   315                         Collections.unmodifiableList(Arrays.asList(newSkippedExceptionTypes)),
   309                         plugins);
   316                         plugins);
   310     }
   317     }
   311 
   318 
   312     public GraphBuilderConfiguration withBytecodeExceptionMode(BytecodeExceptionMode newBytecodeExceptionMode) {
   319     public GraphBuilderConfiguration withBytecodeExceptionMode(BytecodeExceptionMode newBytecodeExceptionMode) {
   315                         newBytecodeExceptionMode,
   322                         newBytecodeExceptionMode,
   316                         omitAssertions,
   323                         omitAssertions,
   317                         insertFullInfopoints,
   324                         insertFullInfopoints,
   318                         trackNodeSourcePosition,
   325                         trackNodeSourcePosition,
   319                         retainLocalVariables,
   326                         retainLocalVariables,
       
   327                         replaceLocalsWithConstants,
   320                         skippedExceptionTypes,
   328                         skippedExceptionTypes,
   321                         plugins);
   329                         plugins);
   322     }
   330     }
   323 
   331 
   324     public GraphBuilderConfiguration withOmitAssertions(boolean newOmitAssertions) {
   332     public GraphBuilderConfiguration withOmitAssertions(boolean newOmitAssertions) {
   328                         bytecodeExceptionMode,
   336                         bytecodeExceptionMode,
   329                         newOmitAssertions,
   337                         newOmitAssertions,
   330                         insertFullInfopoints,
   338                         insertFullInfopoints,
   331                         trackNodeSourcePosition,
   339                         trackNodeSourcePosition,
   332                         retainLocalVariables,
   340                         retainLocalVariables,
       
   341                         replaceLocalsWithConstants,
   333                         skippedExceptionTypes,
   342                         skippedExceptionTypes,
   334                         plugins);
   343                         plugins);
   335     }
   344     }
   336 
   345 
   337     public GraphBuilderConfiguration withFullInfopoints(boolean newInsertFullInfopoints) {
   346     public GraphBuilderConfiguration withFullInfopoints(boolean newInsertFullInfopoints) {
   341                         bytecodeExceptionMode,
   350                         bytecodeExceptionMode,
   342                         omitAssertions,
   351                         omitAssertions,
   343                         newInsertFullInfopoints,
   352                         newInsertFullInfopoints,
   344                         trackNodeSourcePosition,
   353                         trackNodeSourcePosition,
   345                         retainLocalVariables,
   354                         retainLocalVariables,
       
   355                         replaceLocalsWithConstants,
   346                         skippedExceptionTypes,
   356                         skippedExceptionTypes,
   347                         plugins);
   357                         plugins);
   348     }
   358     }
   349 
   359 
   350     public GraphBuilderConfiguration withNodeSourcePosition(boolean newTrackNodeSourcePosition) {
   360     public GraphBuilderConfiguration withNodeSourcePosition(boolean newTrackNodeSourcePosition) {
   354                         bytecodeExceptionMode,
   364                         bytecodeExceptionMode,
   355                         omitAssertions,
   365                         omitAssertions,
   356                         insertFullInfopoints,
   366                         insertFullInfopoints,
   357                         newTrackNodeSourcePosition,
   367                         newTrackNodeSourcePosition,
   358                         retainLocalVariables,
   368                         retainLocalVariables,
       
   369                         replaceLocalsWithConstants,
   359                         skippedExceptionTypes,
   370                         skippedExceptionTypes,
   360                         plugins);
   371                         plugins);
   361     }
   372     }
   362 
   373 
   363     public GraphBuilderConfiguration withRetainLocalVariables(boolean newRetainLocalVariables) {
   374     public GraphBuilderConfiguration withRetainLocalVariables(boolean newRetainLocalVariables) {
   367                         bytecodeExceptionMode,
   378                         bytecodeExceptionMode,
   368                         omitAssertions,
   379                         omitAssertions,
   369                         insertFullInfopoints,
   380                         insertFullInfopoints,
   370                         trackNodeSourcePosition,
   381                         trackNodeSourcePosition,
   371                         newRetainLocalVariables,
   382                         newRetainLocalVariables,
       
   383                         replaceLocalsWithConstants,
       
   384                         skippedExceptionTypes,
       
   385                         plugins);
       
   386     }
       
   387 
       
   388     public GraphBuilderConfiguration withReplaceLocalsWithConstants(boolean newReplaceLocalsWithConstants) {
       
   389         return new GraphBuilderConfiguration(
       
   390                         eagerResolving,
       
   391                         unresolvedIsError,
       
   392                         bytecodeExceptionMode,
       
   393                         omitAssertions,
       
   394                         insertFullInfopoints,
       
   395                         trackNodeSourcePosition,
       
   396                         retainLocalVariables,
       
   397                         newReplaceLocalsWithConstants,
   372                         skippedExceptionTypes,
   398                         skippedExceptionTypes,
   373                         plugins);
   399                         plugins);
   374     }
   400     }
   375 
   401 
   376     public List<ResolvedJavaType> getSkippedExceptionTypes() {
   402     public List<ResolvedJavaType> getSkippedExceptionTypes() {
   397         return retainLocalVariables;
   423         return retainLocalVariables;
   398     }
   424     }
   399 
   425 
   400     public boolean insertFullInfopoints() {
   426     public boolean insertFullInfopoints() {
   401         return insertFullInfopoints;
   427         return insertFullInfopoints;
       
   428     }
       
   429 
       
   430     public boolean replaceLocalsWithConstants() {
       
   431         return this.replaceLocalsWithConstants;
   402     }
   432     }
   403 
   433 
   404     public static GraphBuilderConfiguration getDefault(Plugins plugins) {
   434     public static GraphBuilderConfiguration getDefault(Plugins plugins) {
   405         return new GraphBuilderConfiguration(
   435         return new GraphBuilderConfiguration(
   406                         /* eagerResolving: */ false,
   436                         /* eagerResolving: */ false,
   408                         BytecodeExceptionMode.Profile,
   438                         BytecodeExceptionMode.Profile,
   409                         /* omitAssertions: */ false,
   439                         /* omitAssertions: */ false,
   410                         /* insertFullInfopoints: */ false,
   440                         /* insertFullInfopoints: */ false,
   411                         /* trackNodeSourcePosition: */ false,
   441                         /* trackNodeSourcePosition: */ false,
   412                         /* retainLocalVariables */ false,
   442                         /* retainLocalVariables */ false,
       
   443                         /* replaceLocalsWithConstants */ false,
   413                         Collections.emptyList(),
   444                         Collections.emptyList(),
   414                         plugins);
   445                         plugins);
   415     }
   446     }
   416 
   447 
   417     public static GraphBuilderConfiguration getSnippetDefault(Plugins plugins) {
   448     public static GraphBuilderConfiguration getSnippetDefault(Plugins plugins) {
   421                         BytecodeExceptionMode.OmitAll,
   452                         BytecodeExceptionMode.OmitAll,
   422                         /* omitAssertions: */ false,
   453                         /* omitAssertions: */ false,
   423                         /* insertFullInfopoints: */ false,
   454                         /* insertFullInfopoints: */ false,
   424                         /* trackNodeSourcePosition: */ false,
   455                         /* trackNodeSourcePosition: */ false,
   425                         /* retainLocalVariables */ false,
   456                         /* retainLocalVariables */ false,
       
   457                         /* replaceLocalsWithConstants */ false,
   426                         Collections.emptyList(),
   458                         Collections.emptyList(),
   427                         plugins);
   459                         plugins);
   428     }
   460     }
   429 
   461 
   430     /** Returns {@code true} if it is an error for a class/field/method resolution to fail. */
   462     /** Returns {@code true} if it is an error for a class/field/method resolution to fail. */