Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/hotspot/share/jvmci/jvmciCompiler.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)",
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/jvmci/jvmciCompiler.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -136,6 +136,8 @@ class JVMCICompiler : public AbstractCompiler {
// 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; }
Expand Down
27 changes: 26 additions & 1 deletion src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/jvmci/jvmciEnv.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -359,6 +359,8 @@ class JVMCIEnv : public ResourceObj {

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
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jvmci/jvmciJavaClasses.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) \
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/jvmci/jvmciRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jvmci/vmSymbols_jvmci.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;") \
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -987,6 +987,12 @@ private boolean isGCSupported(int gcIdentifier) {
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.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -82,6 +82,27 @@ public List<VMIntrinsicMethod> getIntrinsics() {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}
}