Skip to content

Commit 6cceaac

Browse files
Merge branch 'oracle:master' into master
2 parents c5f315d + 7a66c26 commit 6cceaac

File tree

46 files changed

+1371
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1371
-409
lines changed

common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "7.61.0",
7+
"mx_version": "7.62.0",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {

sdk/mx.sdk/mx_sdk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
200200

201201
def mx_post_parse_cmd_line(args):
202202
mx_sdk_vm_impl.mx_post_parse_cmd_line(args)
203+
mx_sdk_benchmark.register_graalvm_vms()
203204

204205

205206
mx.update_commands(_suite, {

sdk/mx.sdk/mx_sdk_benchmark.py

Lines changed: 88 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def post_process_command_line_args(self, args):
157157
return [arg if not callable(arg) else arg() for arg in self.extra_args] + args
158158

159159
def get_jdk(self):
160+
if self.run_on_java_home():
161+
# forcing the use of the default JAVA_HOME VM as runtime instead of the one pointed at by the tag
162+
return mx.get_jdk()
160163
tag = mx.get_jdk_option().tag
161164
if tag and tag != JVMCI_JDK_TAG:
162165
mx.abort("The '{0}/{1}' VM requires '--jdk={2}'".format(
@@ -254,7 +257,7 @@ def post_process_launcher_command_line_args(self, args):
254257
args
255258

256259
def home(self):
257-
if self.name() == 'native-image-java-home':
260+
if self.run_on_java_home() or self.name() == 'native-image-java-home':
258261
return mx.get_jdk().home
259262
return mx_sdk_vm_impl.graalvm_home(fatalIfMissing=True)
260263

@@ -341,18 +344,24 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
341344
self.skip_agent_assertions = bm_suite.skip_agent_assertions(self.benchmark_name, args)
342345
current_stage = vm.stages_info.current_stage
343346
is_shared_library = current_stage is not None and current_stage.is_layered() and current_stage.layer_info.is_shared_library
347+
# base image name (used for auxiliary output files)
348+
base_image_name = self.bm_suite.get_base_image_name(shared_library_layer_index=current_stage.layer_info.index if is_shared_library else None)
349+
# full image name qualified with vm suffix (passed as -o argument to native-image)
350+
self.final_image_name = self.bm_suite.get_full_image_name(base_image_name, vm.config_name())
351+
# root directory for all output. can be overridden with -Dnative-image.benchmark.benchmark-output-dir
344352
self.benchmark_output_dir = self.bm_suite.benchmark_output_dir(self.benchmark_name, args)
345-
executable_name, output_dir = self.get_executable_name_and_output_dir_for_stage(current_stage, vm)
346-
self.executable_name: str = executable_name
347-
self.output_dir: Path = output_dir
348-
self.final_image_name = self.executable_name + '-' + vm.config_name()
349-
self.profile_path: Path = self.output_dir / f"{self.executable_name}.iprof"
350-
self.source_mappings_path: Path = self.output_dir / f"{self.executable_name}.sourceMappings.json"
351-
self.perf_script_path: Path = self.output_dir / f"{self.executable_name}.perf.script.out"
352-
self.perf_data_path: Path = self.output_dir / f"{self.executable_name}.perf.data"
353+
# specific directory with output for this image build.
354+
self.output_dir: Path = self.bm_suite.get_image_output_dir(self.benchmark_output_dir, self.final_image_name)
355+
# path of the final executable.
356+
self.image_path: Path = self.output_dir / self.bm_suite.get_image_file_name(self.final_image_name, shared_library=is_shared_library)
357+
self.instrumented_image_path = self.output_dir / self.bm_suite.get_image_file_name(f"{base_image_name}-instrument")
358+
self.profile_path: Path = self.output_dir / f"{base_image_name}.iprof"
359+
self.source_mappings_path: Path = self.output_dir / f"{base_image_name}.sourceMappings.json"
360+
self.perf_script_path: Path = self.output_dir / f"{base_image_name}.perf.script.out"
361+
self.perf_data_path: Path = self.output_dir / f"{base_image_name}.perf.data"
353362
self.config_dir: Path = self.output_dir / "config"
354363
self.log_dir: Path = self.output_dir
355-
self.ml_log_dump_path: Path = self.output_dir / f"{self.executable_name}.ml.log.csv"
364+
self.ml_log_dump_path: Path = self.output_dir / f"{base_image_name}.ml.log.csv"
356365
base_image_build_args = ['--no-fallback']
357366
if not vm.pgo_use_perf:
358367
# Can only have debug info when not using perf, [GR-66850]
@@ -405,13 +414,6 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc
405414

406415
self.image_build_reports_directory: Path = self.output_dir / "reports"
407416

408-
# Path of the final executable
409-
self.image_path = self.output_dir / self.final_image_name
410-
self.instrumented_image_path = self.output_dir / f"{self.executable_name}-instrument"
411-
if is_shared_library:
412-
self.image_path = self.image_path.parent / f"{self.image_path.name}.so"
413-
self.instrumented_image_path = self.instrumented_image_path.parent / f"{self.instrumented_image_path.name}.so"
414-
415417
if vm.is_quickbuild:
416418
base_image_build_args += ['-Ob']
417419
if vm.graalos or vm.graalhost_graalos:
@@ -465,33 +467,6 @@ def build_report_args(self, is_gate: bool, graalvm_edition: str):
465467
# Generate Build Report only when the benchmark is a part of EE gate.
466468
return ['--emit=build-report'] if is_gate and graalvm_edition == "ee" else []
467469

468-
def get_executable_name_and_output_dir_for_stage(self, stage: Stage, vm: NativeImageVM) -> Tuple[str, Path]:
469-
executable_name = self.compute_executable_name()
470-
is_shared_library = stage is not None and stage.is_layered() and stage.layer_info.is_shared_library
471-
if is_shared_library:
472-
# Shared library layers have to start with 'lib' and are differentiated with the layer index
473-
executable_name = f"lib-layer{stage.layer_info.index}-{executable_name}"
474-
475-
# Form output directory
476-
root_dir = Path(
477-
self.benchmark_output_dir if self.benchmark_output_dir else mx.suite('sdk').get_output_root(platformDependent=False,
478-
jdkDependent=False)).absolute()
479-
output_dir = root_dir / "native-image-benchmarks" / f"{executable_name}-{vm.config_name()}"
480-
481-
return executable_name, output_dir
482-
483-
def compute_executable_name(self) -> str:
484-
result = self.bm_suite.executable_name()
485-
if result is not None:
486-
return result
487-
488-
parts = [self.bm_suite.benchSuiteName()]
489-
if self.bm_suite.version() != "unknown":
490-
parts.append(self.bm_suite.version().replace(".", "-"))
491-
if self.benchmark_name:
492-
parts.append(self.benchmark_name.replace(os.sep, "_"))
493-
return "-".join(parts).lower()
494-
495470
def get_build_output_json_file(self, stage: StageName) -> Path:
496471
"""
497472
Path to the build output statistics JSON file (see also ``-H:BuildOutputJSONFile``).
@@ -1638,7 +1613,10 @@ def get_layer_aware_build_args(self) -> List[str]:
16381613
mx.abort("Failed to find any shared library layer image stages!")
16391614
layer_output_dirs = []
16401615
for stage in shared_library_stages:
1641-
_, stage_output_dir = self.config.get_executable_name_and_output_dir_for_stage(stage, self)
1616+
assert isinstance(self.bmSuite, NativeImageBenchmarkMixin)
1617+
layer_base_image_name = self.bmSuite.get_base_image_name(shared_library_layer_index=stage.layer_info.index)
1618+
layer_full_image_name = self.bmSuite.get_full_image_name(layer_base_image_name, self.config_name())
1619+
stage_output_dir = self.bmSuite.get_image_output_dir(self.config.benchmark_output_dir, layer_full_image_name)
16421620
layer_output_dirs.append(stage_output_dir.absolute().as_posix())
16431621
linker_r_path = ",".join(layer_output_dirs)
16441622
app_layer_build_args = [f"-H:LinkerRPath={linker_r_path}"]
@@ -1845,9 +1823,29 @@ def _layerize_stages(self, bm_suite, bm_suite_args, stages: List[Stage]) -> List
18451823
return layered_stages
18461824

18471825

1848-
# Adds JAVA_HOME VMs so benchmarks can run on GraalVM binaries without building them first.
1849-
for java_home_config in ['default', 'pgo', 'g1gc', 'g1gc-pgo', 'upx', 'upx-g1gc', 'quickbuild', 'quickbuild-g1gc']:
1850-
mx_benchmark.add_java_vm(NativeImageVM('native-image-java-home', java_home_config), _suite, 5)
1826+
def register_graalvm_vms():
1827+
# a simple JVM config that runs without any custom flag
1828+
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'vanilla', []), _suite, 2)
1829+
1830+
for java_home_config in ['default', 'pgo', 'g1gc', 'g1gc-pgo', 'upx', 'upx-g1gc', 'quickbuild', 'quickbuild-g1gc']:
1831+
mx_benchmark.add_java_vm(NativeImageVM('native-image-java-home', java_home_config), _suite)
1832+
1833+
optimization_levels = ['O0', 'O1', 'O2', 'O3', 'Os']
1834+
analysis_context_sensitivity = ['insens', 'allocsens', '1obj', '2obj1h', '3obj2h', '4obj3h']
1835+
1836+
for short_name, config_suffix in [(None, ''), ('niee', '-ee'), ('ni', '-ce')]:
1837+
if short_name is None or any(component.short_name == short_name for component in mx_sdk_vm_impl.registered_graalvm_components(stage1=False)):
1838+
config_names = list()
1839+
for main_config in ['default', 'gate', 'llvm', 'native-architecture', 'future-defaults-all', 'preserve-all', 'preserve-classpath'] + analysis_context_sensitivity + (['g1gc', 'pgo', 'g1gc-pgo'] if config_suffix != '-ce' else []):
1840+
config_names.append(f'{main_config}{config_suffix}')
1841+
1842+
for optimization_level in optimization_levels:
1843+
config_names.append(f'{optimization_level}{config_suffix}')
1844+
for main_config in ['llvm', 'native-architecture', 'g1gc', 'native-architecture-g1gc', 'preserve-all', 'preserve-classpath'] + analysis_context_sensitivity:
1845+
config_names.append(f'{main_config}-{optimization_level}{config_suffix}')
1846+
1847+
for config_name in config_names:
1848+
mx_benchmark.add_java_vm(NativeImageVM('native-image', config_name, ['--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED']), _suite, 10)
18511849

18521850

18531851
class ObjdumpSectionRule(mx_benchmark.StdOutRule):
@@ -4196,7 +4194,7 @@ def benchmark_output_dir(self, _, args):
41964194
if parsed_args:
41974195
return parsed_args[0]
41984196
else:
4199-
return None
4197+
return mx.suite('sdk').get_output_root(platformDependent=False, jdkDependent=False)
42004198

42014199
def filter_stages_with_cli_requested_stages(self, bm_suite_args: List[str], stages: List[Stage]) -> List[Stage]:
42024200
"""
@@ -4252,9 +4250,47 @@ def get_stage_env(self) -> Optional[dict]:
42524250
"""Return the environment to be used when executing a stage."""
42534251
return None
42544252

4255-
def executable_name(self) -> Optional[str]:
4256-
"""Override to allow suites to control the executable name used in image builds."""
4257-
return None
4253+
def _base_image_name(self: BenchmarkSuite | NativeImageBenchmarkMixin) -> str:
4254+
"""
4255+
Returns the name to use in image builds. May be overridden.
4256+
Note that this name is not necessarily the full image name (there may be prefixes/suffixes added).
4257+
Use `get_image_path` to obtain the final image path.
4258+
"""
4259+
parts = [self.benchSuiteName()]
4260+
if self.version() != "unknown":
4261+
parts.append(self.version().replace(".", "-"))
4262+
parts.append(self.benchmarkName())
4263+
return "-".join(parts).lower()
4264+
4265+
def get_base_image_name(self, shared_library_layer_index: Optional[int] = None) -> str:
4266+
"""
4267+
Returns the base image name to use for auxiliary build files (e.g., iprof files).
4268+
"""
4269+
base_image_name = self._base_image_name()
4270+
if shared_library_layer_index is not None:
4271+
# Shared library layers have to start with 'lib' and are differentiated with the layer index
4272+
base_image_name = f"lib-layer{shared_library_layer_index}-{base_image_name}"
4273+
return base_image_name
4274+
4275+
def get_full_image_name(self, base_image_name: str, vm_config: str) -> str:
4276+
"""
4277+
Returns the base image name qualified by the vm suffix. This name is passed as the -o argument to native-image.
4278+
"""
4279+
return f"{base_image_name}-{vm_config}"
4280+
4281+
def get_image_file_name(self, full_image_name: str, shared_library: bool = False) -> str:
4282+
"""
4283+
Returns the file name of the generated image.
4284+
"""
4285+
if shared_library:
4286+
return f"{full_image_name}.so"
4287+
return full_image_name
4288+
4289+
def get_image_output_dir(self, benchmark_output_dir: str, full_image_name: str) -> Path:
4290+
"""
4291+
Returns the output directory for the given image name, as a subdirectory of the root output directory.
4292+
"""
4293+
return Path(benchmark_output_dir).absolute() / "native-image-benchmarks" / full_image_name
42584294

42594295

42604296
def measureTimeToFirstResponse(bmSuite):

sdk/src/org.graalvm.nativebridge.launcher/src/launcher.cc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,18 @@
5151

5252
#if defined(__linux__)
5353
#include<dlfcn.h>
54+
#include<sys/stat.h>
55+
#include<unistd.h>
5456
#elif defined(__APPLE__)
5557
#include<dlfcn.h>
5658
#include<pthread.h>
59+
#include<sys/stat.h>
60+
#include<unistd.h>
5761
#include<Cocoa/Cocoa.h>
5862
#include<objc/objc-runtime.h>
5963
#include<objc/objc-auto.h>
6064
#elif defined(_WIN32)
65+
#include <io.h>
6166
#include<windows.h>
6267
#include<libloaderapi.h>
6368
#include<process.h>
@@ -105,6 +110,20 @@ static CreateJavaVM loadIsolateLibrary(const std::string library_path) {
105110
const char* err = dlerror();
106111
std::stringstream builder {};
107112
builder << "Failed to load isolate library " << library_path;
113+
struct stat sb;
114+
if (stat(library_path.c_str(), &sb) == -1) {
115+
builder << " (file does not exist)";
116+
} else {
117+
if (!S_ISREG(sb.st_mode)) {
118+
builder << " (not a regular file)";
119+
} else {
120+
bool readable = (access(library_path.c_str(), R_OK) == 0);
121+
bool executable = (access(library_path.c_str(), X_OK) == 0);
122+
builder << " (regular file, "
123+
<< (readable ? "readable" : "not readable") << ", "
124+
<< (executable ? "executable" : "not executable") << ")";
125+
}
126+
}
108127
if (err) {
109128
builder << " due to: " << err;
110129
}
@@ -115,8 +134,39 @@ static CreateJavaVM loadIsolateLibrary(const std::string library_path) {
115134
if (handle) {
116135
return reinterpret_cast<CreateJavaVM>(GetProcAddress(handle, "JNI_CreateJavaVM"));
117136
} else {
137+
DWORD errorMessageID = GetLastError();
138+
std::string err;
139+
if (errorMessageID != 0) {
140+
LPSTR messageBuffer = nullptr;
141+
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
142+
nullptr,
143+
errorMessageID,
144+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
145+
(LPSTR)&messageBuffer,
146+
0,
147+
nullptr);
148+
err = std::string {messageBuffer, size};
149+
LocalFree(messageBuffer);
150+
};
118151
std::stringstream builder {};
119152
builder << "Failed to load isolate library " << library_path;
153+
DWORD attrs = GetFileAttributesA(library_path.c_str());
154+
if (attrs == INVALID_FILE_ATTRIBUTES) {
155+
builder << " (file does not exist)";
156+
} else {
157+
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
158+
builder << " (is a directory)";
159+
} else {
160+
bool readable = (_access(library_path.c_str(), 4) == 0);
161+
bool executable = (_access(library_path.c_str(), 1) == 0);
162+
builder << " (regular file, "
163+
<< (readable ? "readable" : "not readable") << ", "
164+
<< (executable ? "executable" : "not executable") << ")";
165+
}
166+
}
167+
if (!err.empty()) {
168+
builder << " due to: " << err;
169+
}
120170
ABORT(builder.str().c_str())
121171
}
122172
#else

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import jdk.graal.compiler.nodes.calc.IntegerEqualsNode;
6161
import jdk.graal.compiler.nodes.calc.IntegerLowerThanNode;
6262
import jdk.graal.compiler.nodes.calc.IsNullNode;
63+
import jdk.graal.compiler.nodes.extended.BranchProbabilityNode;
6364
import jdk.graal.compiler.nodes.extended.ValueAnchorNode;
6465
import jdk.graal.compiler.nodes.java.InstanceOfNode;
6566
import jdk.graal.compiler.nodes.java.LoadFieldNode;
@@ -322,7 +323,8 @@ protected JavaTypeProfile makeTypeProfile(TypeState typeState, boolean injectNot
322323
}
323324

324325
private JavaTypeProfile createTypeProfile(TypeState typeState, boolean injectNotRecordedProbability) {
325-
double probability = 1d / (typeState.typesCount() + (injectNotRecordedProbability ? 1 : 0));
326+
final double notRecordedProb = injectNotRecordedProbability ? BranchProbabilityNode.EXTREMELY_SLOW_PATH_PROBABILITY : 0.0d;
327+
final double probability = (1.0 - notRecordedProb) / typeState.typesCount();
326328

327329
Stream<? extends ResolvedJavaType> stream = typeState.typesStream(bb);
328330
if (converter != null) {
@@ -332,7 +334,7 @@ private JavaTypeProfile createTypeProfile(TypeState typeState, boolean injectNot
332334
.map(type -> new JavaTypeProfile.ProfiledType(type, probability))
333335
.toArray(JavaTypeProfile.ProfiledType[]::new);
334336

335-
return new JavaTypeProfile(TriState.get(typeState.canBeNull()), injectNotRecordedProbability ? probability : 0, pitems);
337+
return new JavaTypeProfile(TriState.get(typeState.canBeNull()), notRecordedProb, pitems);
336338
}
337339

338340
protected JavaMethodProfile makeMethodProfile(Collection<AnalysisMethod> callees, boolean injectNotRecordedProbability) {
@@ -347,15 +349,16 @@ protected JavaMethodProfile makeMethodProfile(Collection<AnalysisMethod> callees
347349
private CachedJavaMethodProfile createMethodProfile(Collection<AnalysisMethod> callees, boolean injectNotRecordedProbability) {
348350
JavaMethodProfile.ProfiledMethod[] pitems = new JavaMethodProfile.ProfiledMethod[callees.size()];
349351
int hashCode = 0;
350-
double probability = 1d / (pitems.length + (injectNotRecordedProbability ? 1 : 0));
352+
final double notRecordedProb = injectNotRecordedProbability ? BranchProbabilityNode.EXTREMELY_SLOW_PATH_PROBABILITY : 0.0d;
353+
final double probability = (1.0 - notRecordedProb) / pitems.length;
351354

352355
int idx = 0;
353356
for (AnalysisMethod aMethod : callees) {
354357
ResolvedJavaMethod convertedMethod = converter == null ? aMethod : converter.lookup(aMethod);
355358
pitems[idx++] = new JavaMethodProfile.ProfiledMethod(convertedMethod, probability);
356359
hashCode = hashCode * 31 + convertedMethod.hashCode();
357360
}
358-
return new CachedJavaMethodProfile(new JavaMethodProfile(injectNotRecordedProbability ? probability : 0, pitems), hashCode);
361+
return new CachedJavaMethodProfile(new JavaMethodProfile(notRecordedProb, pitems), hashCode);
359362
}
360363
}
361364

0 commit comments

Comments
 (0)