Skip to content

Commit de33ea0

Browse files
committed
[JIT] Introduce AI-Extension
Summary: AI-Extension is designed for Java AI workloads and AIOps, enhances traditional JVM with AI capabilities, enabling higher performance and better maintainability Testing: test/hotspot/jtreg/compiler/alibaba/TestAIExtension.java Reviewers: kuaiwei, JoshuaZhuwj Issue: #970
1 parent 14674c4 commit de33ea0

27 files changed

Lines changed: 2716 additions & 3 deletions

make/autoconf/hotspot.m4

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# All valid JVM features, regardless of platform
2727
VALID_JVM_FEATURES="compiler1 compiler2 zero minimal dtrace jvmti jvmci \
2828
graal vm-structs jni-check services management cmsgc epsilongc g1gc parallelgc serialgc shenandoahgc zgc nmt cds \
29-
static-build link-time-opt aot jfr"
29+
static-build link-time-opt aot jfr aiext"
3030

3131
# Deprecated JVM features (these are ignored, but with a warning)
3232
DEPRECATED_JVM_FEATURES="trace"
@@ -357,6 +357,10 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
357357
AC_MSG_ERROR([Specified JVM feature 'cmsgc' requires feature 'serialgc'])
358358
fi
359359
360+
if HOTSPOT_CHECK_JVM_FEATURE(aiext) && ! HOTSPOT_CHECK_JVM_FEATURE(compiler2); then
361+
AC_MSG_ERROR([Specified JVM feature 'aiext' requires feature 'compiler2'])
362+
fi
363+
360364
# Enable JFR by default, except for Zero, linux-sparcv9 and on minimal.
361365
if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
362366
if test "x$OPENJDK_TARGET_OS" != xaix; then
@@ -518,6 +522,26 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
518522
519523
AC_SUBST(ENABLE_AOT)
520524
525+
AC_MSG_CHECKING([if aiext should be built])
526+
if HOTSPOT_IS_JVM_FEATURE_DISABLED(aiext); then
527+
AC_MSG_RESULT([no, forced])
528+
JVM_FEATURES_aiext=""
529+
else
530+
# Only enable aiext on x86_64/aarch64 linux
531+
if test "x$OPENJDK_TARGET_OS" = xlinux && \
532+
(test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \
533+
test "x$OPENJDK_TARGET_CPU" = "xaarch64"); then
534+
AC_MSG_RESULT([yes])
535+
JVM_FEATURES_aiext="aiext"
536+
else
537+
AC_MSG_RESULT([no])
538+
JVM_FEATURES_aiext=""
539+
if HOTSPOT_CHECK_JVM_FEATURE(aiext); then
540+
AC_MSG_ERROR([aiext is currently not supported on this platform])
541+
fi
542+
fi
543+
fi
544+
521545
if test "x$OPENJDK_TARGET_CPU" = xarm ; then
522546
# Default to use link time optimizations on minimal on arm
523547
JVM_FEATURES_link_time_opt="link-time-opt"
@@ -545,7 +569,7 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
545569
fi
546570
547571
# Enable features depending on variant.
548-
JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal"
572+
JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal $JVM_FEATURES_aiext"
549573
JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES"
550574
JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
551575
JVM_FEATURES_minimal="compiler1 minimal serialgc $JVM_FEATURES $JVM_FEATURES_link_time_opt"

make/hotspot/lib/JvmFeatures.gmk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ ifneq ($(call check-jvm-feature, jfr), true)
176176
JVM_EXCLUDE_PATTERNS += jfr
177177
endif
178178

179+
ifeq ($(call check-jvm-feature, aiext), true)
180+
JVM_CFLAGS_FEATURES += -DINCLUDE_AIEXT=1
181+
else
182+
JVM_CFLAGS_FEATURES += -DINCLUDE_AIEXT=0
183+
JVM_EXCLUDE_FILES += aiext.cpp aiExtension.cpp
184+
endif
185+
179186
################################################################################
180187

181188
ifeq ($(call check-jvm-feature, link-time-opt), true)

src/hotspot/share/ci/ciMethod.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
#include "ci/ciTypeFlow.hpp"
5454
#include "oops/method.hpp"
5555
#endif
56+
#if INCLUDE_AIEXT
57+
#include "opto/aiExtension.hpp"
58+
#endif
5659

5760
// ciMethod
5861
//
@@ -100,6 +103,11 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
100103
_bcea = NULL;
101104
#endif // COMPILER2
102105

106+
#if INCLUDE_AIEXT
107+
// Get entry of accelerated call.
108+
_accel_call_entry = AIExt::find(h_m->klass_name(), h_m->name(), h_m->signature());
109+
#endif // INCLUDE_AIEXT
110+
103111
ciEnv *env = CURRENT_ENV;
104112
if (env->jvmti_can_hotswap_or_post_breakpoint()) {
105113
// 6328518 check hotswap conditions under the right lock.
@@ -169,6 +177,9 @@ ciMethod::ciMethod(ciInstanceKlass* holder,
169177
_holder( holder),
170178
_intrinsic_id( vmIntrinsics::_none),
171179
_liveness( NULL),
180+
#if INCLUDE_AIEXT
181+
_accel_call_entry( NULL),
182+
#endif // INCLUDE_AIEXT
172183
_can_be_statically_bound(false),
173184
_method_blocks( NULL),
174185
_method_data( NULL)

src/hotspot/share/ci/ciMethod.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class MethodLiveness;
3838
class Arena;
3939
class BCEscapeAnalyzer;
4040
class InlineTree;
41+
#if INCLUDE_AIEXT
42+
class AccelCallEntry;
43+
#endif // INCLUDE_AIEXT
4144

4245
// Whether profiling found an oop to be always, never or sometimes
4346
// null
@@ -82,6 +85,11 @@ class ciMethod : public ciMetadata {
8285
int _instructions_size;
8386
int _size_of_parameters;
8487

88+
#if INCLUDE_AIEXT
89+
// Native acceleration.
90+
const AccelCallEntry* _accel_call_entry;
91+
#endif // INCLUDE_AIEXT
92+
8593
bool _uses_monitors;
8694
bool _balanced_monitors;
8795
bool _is_c1_compilable;
@@ -188,6 +196,11 @@ class ciMethod : public ciMetadata {
188196
// Should the method be compiled with an age counter?
189197
bool profile_aging() const;
190198

199+
#if INCLUDE_AIEXT
200+
// Native acceleration.
201+
const AccelCallEntry* accel_call_entry() const { check_is_loaded(); return _accel_call_entry; }
202+
#endif // INCLUDE_AIEXT
203+
191204
// Code size for inlining decisions.
192205
int code_size_for_inlining();
193206

src/hotspot/share/logging/logTag.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define LOG_TAG_LIST \
3535
LOG_TAG(add) \
3636
LOG_TAG(age) \
37+
AIEXT_ONLY(LOG_TAG(aiext)) \
3738
LOG_TAG(alloc) \
3839
LOG_TAG(aot) \
3940
LOG_TAG(annotation) \

0 commit comments

Comments
 (0)