@@ -359,7 +359,9 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
359359 * precision of implicit stack traces. But for optimized release builds, including pgo
360360 * builds, it is a valuable image size reduction.
361361 */
362- SubstrateOptions .ReduceImplicitExceptionStackTraceInformation .update (values , newLevel == OptimizationLevel .O3 );
362+ if (!values .containsKey (SubstrateOptions .ReduceImplicitExceptionStackTraceInformation )) {
363+ SubstrateOptions .ReduceImplicitExceptionStackTraceInformation .update (values , newLevel == OptimizationLevel .O3 );
364+ }
363365
364366 GraalOptions .OptimizeLongJumps .update (values , !newLevel .isOneOf (OptimizationLevel .O0 , OptimizationLevel .BUILD_TIME ));
365367
@@ -375,18 +377,18 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
375377 };
376378
377379 public static void configureOs (EconomicMap <OptionKey <?>, Object > values ) {
378- enable (GraalOptions .ReduceCodeSize , values );
379- enable (ReduceImplicitExceptionStackTraceInformation , values );
380- enable (GraalOptions .OptimizeLongJumps , values );
380+ enableForOs (GraalOptions .ReduceCodeSize , values );
381+ enableForOs (ReduceImplicitExceptionStackTraceInformation , values );
382+ enableForOs (GraalOptions .OptimizeLongJumps , values );
381383
382384 /*
383385 * Remove all loop optimizations that can increase code size, i.e., duplicate a loop body
384386 * somehow.
385387 */
386- disable (GraalOptions .LoopPeeling , values );
387- disable (GraalOptions .LoopUnswitch , values );
388- disable (GraalOptions .FullUnroll , values );
389- disable (GraalOptions .PartialUnroll , values );
388+ disableForOs (GraalOptions .LoopPeeling , values );
389+ disableForOs (GraalOptions .LoopUnswitch , values );
390+ disableForOs (GraalOptions .FullUnroll , values );
391+ disableForOs (GraalOptions .PartialUnroll , values );
390392
391393 /*
392394 * Do not align code to further reduce code size.
@@ -396,17 +398,17 @@ public static void configureOs(EconomicMap<OptionKey<?>, Object> values) {
396398 GraalOptions .IsolatedLoopHeaderAlignment .update (values , 0 );
397399 // We cannot check for architecture at the moment because ImageSingletons has not been
398400 // initialized yet
399- disable (AMD64Assembler .Options .UseBranchesWithin32ByteBoundary , values );
401+ disableForOs (AMD64Assembler .Options .UseBranchesWithin32ByteBoundary , values );
400402
401403 /*
402404 * Do not run PEA - it can fan out allocations too much.
403405 */
404- disable (GraalOptions .PartialEscapeAnalysis , values );
406+ disableForOs (GraalOptions .PartialEscapeAnalysis , values );
405407
406408 /*
407409 * Do not fan out division.
408410 */
409- disable (GraalOptions .OptimizeDiv , values );
411+ disableForOs (GraalOptions .OptimizeDiv , values );
410412
411413 /*
412414 * Do more conditional elimination.
@@ -416,14 +418,22 @@ public static void configureOs(EconomicMap<OptionKey<?>, Object> values) {
416418 /*
417419 * Every dead code elimination should be non-optional
418420 */
419- disable (DeadCodeEliminationPhase .Options .ReduceDCE , values );
421+ disableForOs (DeadCodeEliminationPhase .Options .ReduceDCE , values );
420422 }
421423
422- public static void disable (OptionKey <Boolean > key , EconomicMap <OptionKey <?>, Object > values ) {
424+ /**
425+ * Sets {@code key} to false in {@code values} as a consequence of {@code -Os} having been
426+ * specified. This silently overrides any existing value for {@code key} in {@code values}.
427+ */
428+ public static void disableForOs (OptionKey <Boolean > key , EconomicMap <OptionKey <?>, Object > values ) {
423429 key .update (values , false );
424430 }
425431
426- public static void enable (OptionKey <Boolean > key , EconomicMap <OptionKey <?>, Object > values ) {
432+ /**
433+ * Sets {@code key} to true in {@code values} as a consequence of {@code -Os} having been
434+ * specified. This silently overrides any existing value for {@code key} in {@code values}.
435+ */
436+ public static void enableForOs (OptionKey <Boolean > key , EconomicMap <OptionKey <?>, Object > values ) {
427437 key .update (values , true );
428438 }
429439
0 commit comments