8305753: Allow JIT compilation for -Xshare:dump
Reviewed-by: dholmes, matsaave, ccheung
This commit is contained in:
parent
728b858c78
commit
08f79148c6
@ -131,6 +131,9 @@ char* Arguments::_ext_dirs = nullptr;
|
|||||||
// True if -Xshare:auto option was specified.
|
// True if -Xshare:auto option was specified.
|
||||||
static bool xshare_auto_cmd_line = false;
|
static bool xshare_auto_cmd_line = false;
|
||||||
|
|
||||||
|
// True if -Xint/-Xmixed/-Xcomp were specified
|
||||||
|
static bool mode_flag_cmd_line = false;
|
||||||
|
|
||||||
bool PathString::set_value(const char *value, AllocFailType alloc_failmode) {
|
bool PathString::set_value(const char *value, AllocFailType alloc_failmode) {
|
||||||
char* new_value = AllocateHeap(strlen(value)+1, mtArguments, alloc_failmode);
|
char* new_value = AllocateHeap(strlen(value)+1, mtArguments, alloc_failmode);
|
||||||
if (new_value == nullptr) {
|
if (new_value == nullptr) {
|
||||||
@ -2600,13 +2603,16 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
|||||||
// -Xint
|
// -Xint
|
||||||
} else if (match_option(option, "-Xint")) {
|
} else if (match_option(option, "-Xint")) {
|
||||||
set_mode_flags(_int);
|
set_mode_flags(_int);
|
||||||
|
mode_flag_cmd_line = true;
|
||||||
// -Xmixed
|
// -Xmixed
|
||||||
} else if (match_option(option, "-Xmixed")) {
|
} else if (match_option(option, "-Xmixed")) {
|
||||||
set_mode_flags(_mixed);
|
set_mode_flags(_mixed);
|
||||||
|
mode_flag_cmd_line = true;
|
||||||
// -Xcomp
|
// -Xcomp
|
||||||
} else if (match_option(option, "-Xcomp")) {
|
} else if (match_option(option, "-Xcomp")) {
|
||||||
// for testing the compiler; turn off all flags that inhibit compilation
|
// for testing the compiler; turn off all flags that inhibit compilation
|
||||||
set_mode_flags(_comp);
|
set_mode_flags(_comp);
|
||||||
|
mode_flag_cmd_line = true;
|
||||||
// -Xshare:dump
|
// -Xshare:dump
|
||||||
} else if (match_option(option, "-Xshare:dump")) {
|
} else if (match_option(option, "-Xshare:dump")) {
|
||||||
DumpSharedSpaces = true;
|
DumpSharedSpaces = true;
|
||||||
@ -3031,14 +3037,18 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
|
|||||||
|
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
if (DumpSharedSpaces) {
|
if (DumpSharedSpaces) {
|
||||||
// Compiler threads may concurrently update the class metadata (such as method entries), so it's
|
if (!mode_flag_cmd_line) {
|
||||||
// unsafe with -Xshare:dump (which modifies the class metadata in place). Let's disable
|
// By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
|
||||||
// compiler just to be safe.
|
|
||||||
//
|
//
|
||||||
// Note: this is not a concern for dynamically dumping shared spaces, which makes a copy of the
|
// If your classlist is large and you don't care about deterministic dumping, you can use
|
||||||
// class metadata instead of modifying them in place. The copy is inaccessible to the compiler.
|
// -Xshare:dump -Xmixed to improve dumping speed.
|
||||||
// TODO: revisit the following for the static archive case.
|
|
||||||
set_mode_flags(_int);
|
set_mode_flags(_int);
|
||||||
|
} else if (_mode == _comp) {
|
||||||
|
// -Xcomp may use excessive CPU for the test tiers. Also, -Xshare:dump runs a small and fixed set of
|
||||||
|
// Java code, so there's not much benefit in running -Xcomp.
|
||||||
|
log_info(cds)("reduced -Xcomp to -Xmixed for static dumping");
|
||||||
|
set_mode_flags(_mixed);
|
||||||
|
}
|
||||||
|
|
||||||
// String deduplication may cause CDS to iterate the strings in different order from one
|
// String deduplication may cause CDS to iterate the strings in different order from one
|
||||||
// run to another which resulting in non-determinstic CDS archives.
|
// run to another which resulting in non-determinstic CDS archives.
|
||||||
|
@ -5069,6 +5069,18 @@ The output of this command should contain the following text:
|
|||||||
\f[V][info][class,load] test.Hello source: shared objects file\f[R]
|
\f[V][info][class,load] test.Hello source: shared objects file\f[R]
|
||||||
.RE
|
.RE
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
By default, when the \f[V]-Xshare:dump\f[R] option is used, the JVM runs
|
||||||
|
in interpreter-only mode (as if the \f[V]-Xint\f[R] option were
|
||||||
|
specified).
|
||||||
|
This is required for generating deterministic output in the shared
|
||||||
|
archive file.
|
||||||
|
I.e., the exact same archive will be generated, bit-for-bit, every time
|
||||||
|
you dump it.
|
||||||
|
However, if deterministic output is not needed, and you have a large
|
||||||
|
classlist, you can explicitly add \f[V]-Xmixed\f[R] to the command-line
|
||||||
|
to enable the JIT compiler.
|
||||||
|
This will speed up the archive creation.
|
||||||
.SS Creating a Dynamic CDS Archive File with -XX:ArchiveClassesAtExit
|
.SS Creating a Dynamic CDS Archive File with -XX:ArchiveClassesAtExit
|
||||||
.PP
|
.PP
|
||||||
Advantages of dynamic CDS archives are:
|
Advantages of dynamic CDS archives are:
|
||||||
|
@ -79,6 +79,7 @@ public class DeterministicDump {
|
|||||||
String archiveName = logName + ".jsa";
|
String archiveName = logName + ".jsa";
|
||||||
String mapName = logName + ".map";
|
String mapName = logName + ".map";
|
||||||
CDSOptions opts = (new CDSOptions())
|
CDSOptions opts = (new CDSOptions())
|
||||||
|
.addPrefix("-Xint") // Override any -Xmixed/-Xcomp flags from jtreg -vmoptions
|
||||||
.addPrefix("-Xlog:cds=debug")
|
.addPrefix("-Xlog:cds=debug")
|
||||||
.addPrefix("-Xlog:cds+map*=trace:file=" + mapName + ":none:filesize=0")
|
.addPrefix("-Xlog:cds+map*=trace:file=" + mapName + ":none:filesize=0")
|
||||||
.setArchiveName(archiveName)
|
.setArchiveName(archiveName)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -59,7 +59,10 @@ public class CommandLineFlagCombo {
|
|||||||
"-XX:+UseCompressedOops",
|
"-XX:+UseCompressedOops",
|
||||||
"-XX:ObjectAlignmentInBytes=16",
|
"-XX:ObjectAlignmentInBytes=16",
|
||||||
"-XX:ObjectAlignmentInBytes=32",
|
"-XX:ObjectAlignmentInBytes=32",
|
||||||
"-XX:ObjectAlignmentInBytes=64"
|
"-XX:ObjectAlignmentInBytes=64",
|
||||||
|
"-Xint",
|
||||||
|
"-Xmixed",
|
||||||
|
"-Xcomp",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user