Skip to content

Commit fb43193

Browse files
[GR-63018] Increase code alignment on AMD64 to 32 bytes.
PullRequest: graal/20347
2 parents f563cff + c78bb38 commit fb43193

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

+16-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import com.oracle.svm.core.c.libc.LibCBase;
5050
import com.oracle.svm.core.c.libc.MuslLibC;
51+
import com.oracle.svm.core.config.ConfigurationValues;
5152
import com.oracle.svm.core.heap.ReferenceHandler;
5253
import com.oracle.svm.core.option.APIOption;
5354
import com.oracle.svm.core.option.APIOptionGroup;
@@ -76,6 +77,7 @@
7677
import jdk.graal.compiler.options.OptionValues;
7778
import jdk.graal.compiler.phases.common.DeadCodeEliminationPhase;
7879
import jdk.internal.misc.Unsafe;
80+
import jdk.vm.ci.amd64.AMD64;
7981

8082
public class SubstrateOptions {
8183

@@ -679,9 +681,6 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
679681
"After the library path, a comma-separated list of options specific to the library can be used.", type = OptionType.User)//
680682
public static final RuntimeOptionKey<String> JVMTIAgentPath = new RuntimeOptionKey<>(null);
681683

682-
@Option(help = "Alignment of AOT and JIT compiled code in bytes.")//
683-
public static final HostedOptionKey<Integer> CodeAlignment = new HostedOptionKey<>(16);
684-
685684
public static final String BUILD_ARTIFACTS_FILE_NAME = "build-artifacts.json";
686685
@Option(help = "Create a " + BUILD_ARTIFACTS_FILE_NAME + " file in the build directory. The output conforms to the JSON schema located at: " +
687686
"docs/reference-manual/native-image/assets/build-artifacts-schema-v0.9.0.json", type = OptionType.User)//
@@ -972,7 +971,15 @@ public static boolean useLIRBackend() {
972971
*/
973972
@Fold
974973
public static int codeAlignment() {
975-
return CodeAlignment.getValue();
974+
int value = ConcealedOptions.CodeAlignment.getValue();
975+
if (value > 0) {
976+
return value;
977+
}
978+
979+
if (ConfigurationValues.getTarget().arch instanceof AMD64 && optimizationLevel() != OptimizationLevel.SIZE) {
980+
return 32;
981+
}
982+
return 16;
976983
}
977984

978985
@Option(help = "Determines if VM internal threads (e.g., a dedicated VM operation or reference handling thread) are allowed in this image.", type = OptionType.Expert) //
@@ -1121,11 +1128,13 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Integer o
11211128
@Option(help = "Physical memory size (in bytes). By default, the value is queried from the OS/container during VM startup.", type = OptionType.Expert)//
11221129
public static final RuntimeOptionKey<Long> MaxRAM = new RuntimeOptionKey<>(0L, IsolateCreationOnly);
11231130

1124-
/**
1125-
* Use {@link SubstrateOptions#getAllocatePrefetchStyle()} instead.
1126-
*/
1131+
/** Use {@link SubstrateOptions#getAllocatePrefetchStyle()} instead. */
11271132
@Option(help = "Generated code style for prefetch instructions: for 0 or less no prefetch instructions are generated and for 1 or more prefetch instructions are introduced after each allocation.")//
11281133
public static final HostedOptionKey<Integer> AllocatePrefetchStyle = new HostedOptionKey<>(null);
1134+
1135+
/** Use {@link SubstrateOptions#codeAlignment()} instead. */
1136+
@Option(help = "Alignment of AOT and JIT compiled code in bytes. The default of 0 automatically selects a suitable value.")//
1137+
public static final HostedOptionKey<Integer> CodeAlignment = new HostedOptionKey<>(0);
11291138
}
11301139

11311140
@Fold

0 commit comments

Comments
 (0)