|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. Oracle designates this |
| 8 | + * particular file as subject to the "Classpath" exception as provided |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. |
| 10 | + * |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | + * accompanied this code). |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License version |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | + * |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | + * or visit www.oracle.com if you need additional information or have any |
| 23 | + * questions. |
| 24 | + */ |
| 25 | +package com.oracle.svm.core.imagelayer; |
| 26 | + |
| 27 | +import org.graalvm.collections.EconomicMap; |
| 28 | + |
| 29 | +import com.oracle.svm.core.SubstrateOptions; |
| 30 | +import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue; |
| 31 | +import com.oracle.svm.core.option.BundleMember; |
| 32 | +import com.oracle.svm.core.option.HostedOptionKey; |
| 33 | +import com.oracle.svm.core.util.UserError; |
| 34 | + |
| 35 | +import jdk.graal.compiler.options.Option; |
| 36 | +import jdk.graal.compiler.options.OptionKey; |
| 37 | +import jdk.graal.compiler.options.OptionType; |
| 38 | + |
| 39 | +public class LayeredImageOptions { |
| 40 | + public static final String LAYER_OPTION_PREFIX = "-H:Layer"; // "--layer" |
| 41 | + public static final String LAYER_CREATE_OPTION = LAYER_OPTION_PREFIX + "Create"; // "-create" |
| 42 | + |
| 43 | + // @APIOption(name = LAYER_CREATE_OPTION) // use when non-experimental |
| 44 | + @Option(help = "Build a Native Image layer. See NativeImageLayers.md for more info.")// |
| 45 | + public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> LayerCreate = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); |
| 46 | + |
| 47 | + // public static final String LAYER_USE_OPTION = LAYER_OPTION_PREFIX + "-use"; |
| 48 | + // @APIOption(name = LAYER_USE_OPTION) // use when non-experimental |
| 49 | + @Option(help = "Build an image based on a Native Image layer.")// |
| 50 | + @BundleMember(role = BundleMember.Role.Input) // |
| 51 | + public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Paths> LayerUse = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Paths.build()); |
| 52 | + |
| 53 | + @Option(help = "Mark singleton as application layer only")// |
| 54 | + public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> ApplicationLayerOnlySingletons = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); |
| 55 | + |
| 56 | + @Option(help = "Register class as being initialized in the app layer.")// |
| 57 | + public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> ApplicationLayerInitializedClasses = new HostedOptionKey<>( |
| 58 | + AccumulatingLocatableMultiOptionValue.Strings.build()); |
| 59 | + @Option(help = "Persist and reload all graphs across layers. If false, graphs defined in the base layer can be reparsed by the current layer and inlined before analysis, " + |
| 60 | + "but will not be inlined after analysis has completed via our other inlining infrastructure")// |
| 61 | + public static final HostedOptionKey<Boolean> UseSharedLayerGraphs = new HostedOptionKey<>(true) { |
| 62 | + @Override |
| 63 | + protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) { |
| 64 | + if (!newValue) { |
| 65 | + UseSharedLayerStrengthenedGraphs.update(values, false); |
| 66 | + } |
| 67 | + } |
| 68 | + }; |
| 69 | + |
| 70 | + @Option(help = "Persist and reload strengthened graphs across layers. If false, inlining after analysis will be disabled")// |
| 71 | + public static final HostedOptionKey<Boolean> UseSharedLayerStrengthenedGraphs = new HostedOptionKey<>(false) { |
| 72 | + @Override |
| 73 | + protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) { |
| 74 | + if (newValue) { |
| 75 | + UserError.guarantee(UseSharedLayerStrengthenedGraphs.getValueOrDefault(values), |
| 76 | + "UseSharedLayerStrengthenedGraph is a subset of UseSharedLayerGraphs, so the former cannot be enabled alone."); |
| 77 | + } else { |
| 78 | + SubstrateOptions.NeverInline.update(values, "SubstrateStringConcatHelper.simpleConcat"); |
| 79 | + } |
| 80 | + } |
| 81 | + }; |
| 82 | + |
| 83 | + public static class LayeredImageDiagnosticOptions { |
| 84 | + @Option(help = "Log discrepancies between layered open world type information. This is an experimental option which will be removed.")// |
| 85 | + public static final HostedOptionKey<Boolean> LogLayeredDispatchTableDiscrepancies = new HostedOptionKey<>(false); |
| 86 | + |
| 87 | + @Option(help = "Throw an error when there are discrepancies between layered open world type information. This is an experimental option which will be removed.")// |
| 88 | + public static final HostedOptionKey<Boolean> AbortOnLayeredDispatchTableDiscrepancies = new HostedOptionKey<>(false); |
| 89 | + |
| 90 | + @Option(help = "Log unique names which do not match across layers. This is an experimental option which will be removed.") // |
| 91 | + public static final HostedOptionKey<Boolean> LogUniqueNameInconsistencies = new HostedOptionKey<>(false); |
| 92 | + |
| 93 | + @Option(help = "Enables logging of failed hash code injection", type = OptionType.Debug) // |
| 94 | + public static final HostedOptionKey<Boolean> LogHashCodeInjectionFailure = new HostedOptionKey<>(false); |
| 95 | + |
| 96 | + @Option(help = "Enables logging on various loading failures", type = OptionType.Debug) // |
| 97 | + public static final HostedOptionKey<Boolean> LogLoadingFailures = new HostedOptionKey<>(false); |
| 98 | + |
| 99 | + @Option(help = "Throws an exception on potential type conflict during heap persisting if enabled", type = OptionType.Debug) // |
| 100 | + public static final HostedOptionKey<Boolean> AbortOnNameConflict = new HostedOptionKey<>(false); |
| 101 | + |
| 102 | + @Option(help = "Logs potential type conflict during heap persisting if enabled", type = OptionType.Debug) // |
| 103 | + public static final HostedOptionKey<Boolean> LogOnNameConflict = new HostedOptionKey<>(false); |
| 104 | + |
| 105 | + @Option(help = "Enables logging of layered archiving")// |
| 106 | + public static final HostedOptionKey<Boolean> LogLayeredArchiving = new HostedOptionKey<>(false); |
| 107 | + |
| 108 | + @Option(help = "Perform strict checking of options used for layered image build.")// |
| 109 | + public static final HostedOptionKey<Boolean> LayerOptionVerification = new HostedOptionKey<>(true); |
| 110 | + |
| 111 | + @Option(help = "Provide verbose output of difference in builder options between layers.")// |
| 112 | + public static final HostedOptionKey<Boolean> LayerOptionVerificationVerbose = new HostedOptionKey<>(false); |
| 113 | + } |
| 114 | +} |
0 commit comments