8334399: [JVMCI] Implement JVMCICompiler::is_intrinsic_supported
Reviewed-by: dnsimon
This commit is contained in:
parent
48621ae193
commit
2165a053e8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -200,6 +200,15 @@ void JVMCICompiler::print_timers() {
|
||||
_hosted_code_installs.print_on(tty, " Install Code: ");
|
||||
}
|
||||
|
||||
bool JVMCICompiler::is_intrinsic_supported(const methodHandle& method) {
|
||||
vmIntrinsics::ID id = method->intrinsic_id();
|
||||
assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
|
||||
JavaThread* thread = JavaThread::current();
|
||||
JVMCIEnv jvmciEnv(thread, __FILE__, __LINE__);
|
||||
JVMCIRuntime* runtime = JVMCI::compiler_runtime(thread, false);
|
||||
return runtime->is_intrinsic_supported(&jvmciEnv, (jint) id);
|
||||
}
|
||||
|
||||
void JVMCICompiler::CodeInstallStats::print_on(outputStream* st, const char* prefix) const {
|
||||
double time = _timer.seconds();
|
||||
st->print_cr("%s%7.3f s (installs: %d, CodeBlob total size: %d, CodeBlob code size: %d)",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -136,6 +136,8 @@ public:
|
||||
// Print compilation timers and statistics
|
||||
virtual void print_timers();
|
||||
|
||||
virtual bool is_intrinsic_supported(const methodHandle& method);
|
||||
|
||||
// Gets the number of methods that have been successfully compiled by
|
||||
// a call to JVMCICompiler::compile_method().
|
||||
int methods_compiled() { return _methods_compiled; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -967,6 +967,31 @@ jboolean JVMCIEnv::call_HotSpotJVMCIRuntime_isGCSupported (JVMCIObject runtime,
|
||||
}
|
||||
}
|
||||
|
||||
jboolean JVMCIEnv::call_HotSpotJVMCIRuntime_isIntrinsicSupported (JVMCIObject runtime, jint intrinsicIdentifier) {
|
||||
JavaThread* THREAD = JavaThread::current(); // For exception macros.
|
||||
if (is_hotspot()) {
|
||||
JavaCallArguments jargs;
|
||||
jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime)));
|
||||
jargs.push_int(intrinsicIdentifier);
|
||||
JavaValue result(T_BOOLEAN);
|
||||
JavaCalls::call_special(&result,
|
||||
HotSpotJVMCI::HotSpotJVMCIRuntime::klass(),
|
||||
vmSymbols::isIntrinsicSupported_name(),
|
||||
vmSymbols::int_bool_signature(), &jargs, CHECK_0);
|
||||
return result.get_jboolean();
|
||||
} else {
|
||||
JNIAccessMark jni(this, THREAD);
|
||||
jboolean result = jni()->CallNonvirtualBooleanMethod(runtime.as_jobject(),
|
||||
JNIJVMCI::HotSpotJVMCIRuntime::clazz(),
|
||||
JNIJVMCI::HotSpotJVMCIRuntime::isIntrinsicSupported_method(),
|
||||
intrinsicIdentifier);
|
||||
if (jni()->ExceptionCheck()) {
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
JVMCIObject JVMCIEnv::call_HotSpotJVMCIRuntime_compileMethod (JVMCIObject runtime, JVMCIObject method, int entry_bci,
|
||||
jlong compile_state, int id) {
|
||||
JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -359,6 +359,8 @@ public:
|
||||
|
||||
jboolean call_HotSpotJVMCIRuntime_isGCSupported(JVMCIObject runtime, jint gcIdentifier);
|
||||
|
||||
jboolean call_HotSpotJVMCIRuntime_isIntrinsicSupported(JVMCIObject runtime, jint intrinsicIdentifier);
|
||||
|
||||
void call_HotSpotJVMCIRuntime_postTranslation(JVMCIObject object, JVMCI_TRAPS);
|
||||
|
||||
// Converts the JavaKind.typeChar value in `ch` to a BasicType
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -202,6 +202,7 @@
|
||||
objectarray_field(HotSpotJVMCIRuntime, excludeFromJVMCICompilation, "[Ljava/lang/Module;") \
|
||||
jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, compileMethod, compileMethod_signature) \
|
||||
jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, isGCSupported, int_bool_signature) \
|
||||
jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, isIntrinsicSupported, int_bool_signature) \
|
||||
jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, bootstrapFinished, void_method_signature) \
|
||||
jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, shutdown, void_method_signature) \
|
||||
jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, runtime, runtime_signature) \
|
||||
|
@ -2050,6 +2050,16 @@ bool JVMCIRuntime::is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name)
|
||||
return JVMCIENV->call_HotSpotJVMCIRuntime_isGCSupported(receiver, (int) name);
|
||||
}
|
||||
|
||||
bool JVMCIRuntime::is_intrinsic_supported(JVMCIEnv* JVMCIENV, jint id) {
|
||||
JVMCI_EXCEPTION_CONTEXT
|
||||
|
||||
JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
|
||||
if (JVMCIENV->has_pending_exception()) {
|
||||
fatal_exception(JVMCIENV, "Exception during HotSpotJVMCIRuntime initialization");
|
||||
}
|
||||
return JVMCIENV->call_HotSpotJVMCIRuntime_isIntrinsicSupported(receiver, id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
|
||||
const methodHandle& method,
|
||||
|
@ -431,6 +431,9 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
|
||||
// Determines if the GC identified by `name` is supported by the JVMCI compiler.
|
||||
bool is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name);
|
||||
|
||||
// Determines if the intrinsic identified by `id` is supported by the JVMCI compiler.
|
||||
bool is_intrinsic_supported(JVMCIEnv* JVMCIENV, jint id);
|
||||
|
||||
// Register the result of a compilation.
|
||||
JVMCI::CodeInstallResult register_method(JVMCIEnv* JVMCIENV,
|
||||
const methodHandle& target,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -81,6 +81,7 @@
|
||||
template(compileMethod_name, "compileMethod") \
|
||||
template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/hotspot/HotSpotCompilationRequestResult;") \
|
||||
template(isGCSupported_name, "isGCSupported") \
|
||||
template(isIntrinsicSupported_name, "isIntrinsicSupported") \
|
||||
template(fromMetaspace_name, "fromMetaspace") \
|
||||
template(method_fromMetaspace_signature, "(JLjdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \
|
||||
template(constantPool_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;") \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -987,6 +987,12 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
|
||||
return getCompiler().isGCSupported(gcIdentifier);
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@VMEntryPoint
|
||||
private boolean isIntrinsicSupported(int intrinsicIdentifier) {
|
||||
return getCompiler().isIntrinsicSupported(intrinsicIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guard to ensure shut down actions are performed by at most one thread.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -82,6 +82,27 @@ public final class HotSpotVMConfigStore {
|
||||
return Collections.unmodifiableList(vmIntrinsics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the VM intrinsic description by its ID.
|
||||
*/
|
||||
public VMIntrinsicMethod getIntrinsic(int intrinsicID) {
|
||||
if (intrinsicID >= 1 && intrinsicID <= vmIntrinsics.size()) {
|
||||
// valid intrinsicID starts from 1
|
||||
VMIntrinsicMethod intrinsic = vmIntrinsics.get(intrinsicID - 1);
|
||||
// We speculate that vmIntrinsics are sorted by ID
|
||||
if (intrinsic.id == intrinsicID) {
|
||||
return intrinsic;
|
||||
}
|
||||
}
|
||||
// Assumption failed, fall back to iteration
|
||||
for (VMIntrinsicMethod intrinsic : vmIntrinsics) {
|
||||
if (intrinsic.id == intrinsicID) {
|
||||
return intrinsic;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final HashMap<String, VMField> vmFields;
|
||||
final HashMap<String, Long> vmConstants;
|
||||
final HashMap<String, Long> vmAddresses;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,4 +44,15 @@ public interface JVMCICompiler {
|
||||
default boolean isGCSupported(int gcIdentifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this compiler supports the {@code intrinsicIdentifier} intrinsic. The default
|
||||
* implementation of this method returns false as that is the effective answer given by a
|
||||
* {@link JVMCICompiler} before this method was added.
|
||||
*
|
||||
* @param intrinsicIdentifier intrinsic identifier defined in vmIntrinsics.hpp.
|
||||
*/
|
||||
default boolean isIntrinsicSupported(int intrinsicIdentifier) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user