Skip to content

Commit 4164693

Browse files
Yudi ZhengDoug Simon
authored andcommitted
8313372: [JVMCI] Export vmIntrinsics::is_intrinsic_available results to JVMCI compilers.
Reviewed-by: dnsimon, kvn
1 parent 049b55f commit 4164693

File tree

10 files changed

+74
-17
lines changed

10 files changed

+74
-17
lines changed

src/hotspot/share/c1/c1_Compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
104104
// C1 does not support intrinsification of synchronized methods.
105105
return false;
106106
}
107+
return Compiler::is_intrinsic_supported(id);
108+
}
107109

110+
bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) {
108111
switch (id) {
109112
case vmIntrinsics::_compareAndSetLong:
110113
if (!VM_Version::supports_cx8()) return false;

src/hotspot/share/c1/c1_Compiler.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class Compiler: public AbstractCompiler {
5656
// Check if the C1 compiler supports an intrinsic for 'method'.
5757
virtual bool is_intrinsic_supported(const methodHandle& method);
5858

59+
// Return true if the intrinsic `id` is supported by C1
60+
static bool is_intrinsic_supported(vmIntrinsics::ID id);
61+
5962
// Size of the code buffer
6063
static int code_buffer_size();
6164
};

src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
// no precompiled headers
25+
#include "c1/c1_Compiler.hpp"
2526
#include "ci/ciUtilities.hpp"
2627
#include "compiler/compiler_globals.hpp"
2728
#include "compiler/oopMap.hpp"
@@ -42,6 +43,7 @@
4243
#include "memory/universe.hpp"
4344
#include "oops/compressedOops.hpp"
4445
#include "oops/klass.inline.hpp"
46+
#include "opto/c2compiler.hpp"
4547
#include "runtime/flags/jvmFlag.hpp"
4648
#include "runtime/sharedRuntime.hpp"
4749
#include "runtime/stubRoutines.hpp"
@@ -239,7 +241,10 @@ JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) {
239241
} \
240242
JVMCIObject name_str = VM_SYMBOL_TO_STRING(name); \
241243
JVMCIObject sig_str = VM_SYMBOL_TO_STRING(sig); \
242-
JVMCIObject vmIntrinsicMethod = JVMCIENV->new_VMIntrinsicMethod(kls_str, name_str, sig_str, (jint) vmIntrinsics::id, JVMCI_CHECK_NULL); \
244+
JVMCIObject vmIntrinsicMethod = JVMCIENV->new_VMIntrinsicMethod(kls_str, name_str, sig_str, (jint) vmIntrinsics::id, \
245+
(jboolean) vmIntrinsics::is_intrinsic_available(vmIntrinsics::id), \
246+
(jboolean) Compiler::is_intrinsic_supported(vmIntrinsics::id), \
247+
(jboolean) C2Compiler::is_intrinsic_supported(vmIntrinsics::id), JVMCI_CHECK_NULL); \
243248
JVMCIENV->put_object_at(vmIntrinsics, index++, vmIntrinsicMethod); \
244249
}
245250

@@ -286,7 +291,7 @@ JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) {
286291
do_uintx_flag(TLABWasteIncrement) \
287292
do_intx_flag(TypeProfileWidth) \
288293
do_bool_flag(UseAESIntrinsics) \
289-
X86_ONLY(do_int_flag(UseAVX)) \
294+
X86_ONLY(do_int_flag(UseAVX)) \
290295
do_bool_flag(UseCRC32Intrinsics) \
291296
do_bool_flag(UseAdler32Intrinsics) \
292297
do_bool_flag(UseCompressedClassPointers) \
@@ -306,7 +311,7 @@ JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) {
306311
do_bool_flag(UseSHA1Intrinsics) \
307312
do_bool_flag(UseSHA256Intrinsics) \
308313
do_bool_flag(UseSHA512Intrinsics) \
309-
X86_ONLY(do_int_flag(UseSSE)) \
314+
X86_ONLY(do_int_flag(UseSSE)) \
310315
COMPILER2_PRESENT(do_bool_flag(UseSquareToLenIntrinsic)) \
311316
do_bool_flag(UseTLAB) \
312317
do_bool_flag(VerifyOops) \

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ JVMCIObject JVMCIEnv::new_VMFlag(JVMCIObject name, JVMCIObject type, JVMCIObject
14591459
}
14601460
}
14611461

1462-
JVMCIObject JVMCIEnv::new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, JVMCI_TRAPS) {
1462+
JVMCIObject JVMCIEnv::new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, jboolean isAvailable, jboolean c1Supported, jboolean c2Supported, JVMCI_TRAPS) {
14631463
JavaThread* THREAD = JavaThread::current(); // For exception macros.
14641464
if (is_hotspot()) {
14651465
HotSpotJVMCI::VMIntrinsicMethod::klass()->initialize(CHECK_(JVMCIObject()));
@@ -1468,12 +1468,15 @@ JVMCIObject JVMCIEnv::new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObj
14681468
HotSpotJVMCI::VMIntrinsicMethod::set_name(this, obj, HotSpotJVMCI::resolve(name));
14691469
HotSpotJVMCI::VMIntrinsicMethod::set_descriptor(this, obj, HotSpotJVMCI::resolve(descriptor));
14701470
HotSpotJVMCI::VMIntrinsicMethod::set_id(this, obj, id);
1471+
HotSpotJVMCI::VMIntrinsicMethod::set_isAvailable(this, obj, isAvailable);
1472+
HotSpotJVMCI::VMIntrinsicMethod::set_c1Supported(this, obj, c1Supported);
1473+
HotSpotJVMCI::VMIntrinsicMethod::set_c2Supported(this, obj, c2Supported);
14711474
return wrap(obj);
14721475
} else {
14731476
JNIAccessMark jni(this, THREAD);
14741477
jobject result = jni()->NewObject(JNIJVMCI::VMIntrinsicMethod::clazz(),
14751478
JNIJVMCI::VMIntrinsicMethod::constructor(),
1476-
get_jobject(declaringClass), get_jobject(name), get_jobject(descriptor), id);
1479+
get_jobject(declaringClass), get_jobject(name), get_jobject(descriptor), id, isAvailable, c1Supported, c2Supported);
14771480
return wrap(result);
14781481
}
14791482
}

src/hotspot/share/jvmci/jvmciEnv.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class JVMCIEnv : public ResourceObj {
406406
JVMCIObject new_HotSpotNmethod(const methodHandle& method, const char* name, jboolean isDefault, jlong compileId, JVMCI_TRAPS);
407407
JVMCIObject new_VMField(JVMCIObject name, JVMCIObject type, jlong offset, jlong address, JVMCIObject value, JVMCI_TRAPS);
408408
JVMCIObject new_VMFlag(JVMCIObject name, JVMCIObject type, JVMCIObject value, JVMCI_TRAPS);
409-
JVMCIObject new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, JVMCI_TRAPS);
409+
JVMCIObject new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, jboolean isAvailable, jboolean c1Supported, jboolean c2Supported, JVMCI_TRAPS);
410410
JVMCIObject new_HotSpotStackFrameReference(JVMCI_TRAPS);
411411
JVMCIObject new_JVMCIError(JVMCI_TRAPS);
412412
JVMCIObject new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS);

src/hotspot/share/jvmci/jvmciJavaClasses.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@
131131
object_field(VMIntrinsicMethod, name, "Ljava/lang/String;") \
132132
object_field(VMIntrinsicMethod, descriptor, "Ljava/lang/String;") \
133133
int_field(VMIntrinsicMethod, id) \
134-
jvmci_constructor(VMIntrinsicMethod, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V") \
134+
boolean_field(VMIntrinsicMethod, isAvailable) \
135+
boolean_field(VMIntrinsicMethod, c1Supported) \
136+
boolean_field(VMIntrinsicMethod, c2Supported) \
137+
jvmci_constructor(VMIntrinsicMethod, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZZ)V") \
135138
end_class \
136139
start_class(HotSpotCompilationRequestResult, jdk_vm_ci_hotspot_HotSpotCompilationRequestResult) \
137140
object_field(HotSpotCompilationRequestResult, failureMessage, "Ljava/lang/String;") \

src/hotspot/share/opto/c2compiler.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ void C2Compiler::print_timers() {
190190

191191
bool C2Compiler::is_intrinsic_supported(const methodHandle& method) {
192192
vmIntrinsics::ID id = method->intrinsic_id();
193+
return C2Compiler::is_intrinsic_supported(id);
194+
}
195+
196+
bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) {
193197
assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
194198

195199
if (id < vmIntrinsics::FIRST_ID || id > vmIntrinsics::LAST_COMPILER_INLINE) {
@@ -225,6 +229,21 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method) {
225229
case vmIntrinsics::_copyMemory:
226230
if (StubRoutines::unsafe_arraycopy() == nullptr) return false;
227231
break;
232+
case vmIntrinsics::_electronicCodeBook_encryptAESCrypt:
233+
if (StubRoutines::electronicCodeBook_encryptAESCrypt() == nullptr) return false;
234+
break;
235+
case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
236+
if (StubRoutines::electronicCodeBook_decryptAESCrypt() == nullptr) return false;
237+
break;
238+
case vmIntrinsics::_galoisCounterMode_AESCrypt:
239+
if (StubRoutines::galoisCounterMode_AESCrypt() == nullptr) return false;
240+
break;
241+
case vmIntrinsics::_bigIntegerRightShiftWorker:
242+
if (StubRoutines::bigIntegerRightShift() == nullptr) return false;
243+
break;
244+
case vmIntrinsics::_bigIntegerLeftShiftWorker:
245+
if (StubRoutines::bigIntegerLeftShift() == nullptr) return false;
246+
break;
228247
case vmIntrinsics::_encodeAsciiArray:
229248
if (!Matcher::match_rule_supported(Op_EncodeISOArray) || !Matcher::supports_encode_ascii_array) return false;
230249
break;
@@ -716,10 +735,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method) {
716735
case vmIntrinsics::_aescrypt_decryptBlock:
717736
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
718737
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
719-
case vmIntrinsics::_electronicCodeBook_encryptAESCrypt:
720-
case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
721738
case vmIntrinsics::_counterMode_AESCrypt:
722-
case vmIntrinsics::_galoisCounterMode_AESCrypt:
723739
case vmIntrinsics::_md5_implCompress:
724740
case vmIntrinsics::_sha_implCompress:
725741
case vmIntrinsics::_sha2_implCompress:
@@ -731,8 +747,6 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method) {
731747
case vmIntrinsics::_mulAdd:
732748
case vmIntrinsics::_montgomeryMultiply:
733749
case vmIntrinsics::_montgomerySquare:
734-
case vmIntrinsics::_bigIntegerRightShiftWorker:
735-
case vmIntrinsics::_bigIntegerLeftShiftWorker:
736750
case vmIntrinsics::_vectorizedMismatch:
737751
case vmIntrinsics::_ghash_processBlocks:
738752
case vmIntrinsics::_chacha20Block:
@@ -752,7 +766,6 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method) {
752766
case vmIntrinsics::_Preconditions_checkLongIndex:
753767
case vmIntrinsics::_getObjectSize:
754768
break;
755-
756769
case vmIntrinsics::_VectorCompressExpand:
757770
case vmIntrinsics::_VectorUnaryOp:
758771
case vmIntrinsics::_VectorBinaryOp:

src/hotspot/share/opto/c2compiler.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class C2Compiler : public AbstractCompiler {
6363
// Return false otherwise.
6464
virtual bool is_intrinsic_supported(const methodHandle& method);
6565

66+
// Return true if the intrinsic `id` is supported by C2
67+
static bool is_intrinsic_supported(vmIntrinsics::ID id);
6668
// Initial size of the code buffer (may be increased at runtime)
6769
static int initial_code_buffer_size(int const_size = initial_const_capacity);
6870
};

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ void printConfig(HotSpotJVMCIRuntime runtime) {
184184
printConfigLine(runtime, "[vmconfig:constant] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue());
185185
}
186186
for (VMIntrinsicMethod e : getIntrinsics()) {
187-
printConfigLine(runtime, "[vmconfig:intrinsic] %d = %s.%s %s%n", e.id, e.declaringClass, e.name, e.descriptor);
187+
printConfigLine(runtime, "[vmconfig:intrinsic] %d = (available:%b c1Supported:%b c2Supported:%b) %s.%s %s%n",
188+
e.id, e.isAvailable, e.c1Supported, e.c2Supported, e.declaringClass, e.name, e.descriptor);
188189
}
189190
}
190191

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMIntrinsicMethod.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,32 @@ public final class VMIntrinsicMethod {
5454
*/
5555
public final int id;
5656

57+
/**
58+
* This value reflects the `ControlIntrinsic`, `DisableIntrinsic` and `UseXXXIntrinsic` VM flags
59+
* as well as other factors such as the current CPU.
60+
*/
61+
public final boolean isAvailable;
62+
63+
/**
64+
* True if this intrinsic is supported by C1.
65+
*/
66+
public final boolean c1Supported;
67+
68+
/**
69+
* True if this intrinsic is supported by C2.
70+
*/
71+
public final boolean c2Supported;
72+
5773
@VMEntryPoint
58-
VMIntrinsicMethod(String declaringClass, String name, String descriptor, int id) {
74+
VMIntrinsicMethod(String declaringClass, String name, String descriptor, int id,
75+
boolean isAvailable, boolean c1Supported, boolean c2Supported) {
5976
this.declaringClass = declaringClass;
6077
this.name = name;
6178
this.descriptor = descriptor;
6279
this.id = id;
80+
this.isAvailable = isAvailable;
81+
this.c1Supported = c1Supported;
82+
this.c2Supported = c2Supported;
6383
}
6484

6585
@Override
@@ -69,7 +89,10 @@ public boolean equals(Object obj) {
6989
if (that.id == this.id) {
7090
assert that.name.equals(this.name) &&
7191
that.declaringClass.equals(this.declaringClass) &&
72-
that.descriptor.equals(this.descriptor);
92+
that.descriptor.equals(this.descriptor) &&
93+
that.isAvailable == this.isAvailable &&
94+
that.c1Supported == this.c1Supported &&
95+
that.c2Supported == this.c2Supported;
7396
return true;
7497
}
7598
}
@@ -83,6 +106,7 @@ public int hashCode() {
83106

84107
@Override
85108
public String toString() {
86-
return String.format("IntrinsicMethod[declaringClass=%s, name=%s, descriptor=%s, id=%d]", declaringClass, name, descriptor, id);
109+
return String.format("IntrinsicMethod[declaringClass=%s, name=%s, descriptor=%s, id=%d, isAvailable=%b, c1Supported=%b, c2Supported=%b]",
110+
declaringClass, name, descriptor, id, isAvailable, c1Supported, c2Supported);
87111
}
88112
}

0 commit comments

Comments
 (0)