From d8926dfe48adef421ec2cda2d5c3793f21878ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20G=C3=B6ttschkes?= Date: Thu, 22 Jul 2021 10:56:19 +0200 Subject: [PATCH 1/4] 8271128: InlineIntrinsics support for 32-bit ARM --- src/hotspot/cpu/arm/c1_globals_arm.hpp | 2 +- src/hotspot/cpu/arm/c2_globals_arm.hpp | 2 +- .../arm/templateInterpreterGenerator_arm.cpp | 108 +++++++++++++++++- .../templateInterpreterGenerator.hpp | 4 + 4 files changed, 110 insertions(+), 6 deletions(-) diff --git a/src/hotspot/cpu/arm/c1_globals_arm.hpp b/src/hotspot/cpu/arm/c1_globals_arm.hpp index 8f196bc5e6abb..55917decc30ca 100644 --- a/src/hotspot/cpu/arm/c1_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c1_globals_arm.hpp @@ -35,7 +35,7 @@ #ifndef COMPILER2 // avoid duplicated definitions, favoring C2 version define_pd_global(bool, BackgroundCompilation, true ); -define_pd_global(bool, InlineIntrinsics, false); // TODO: ARM +define_pd_global(bool, InlineIntrinsics, true ); define_pd_global(bool, PreferInterpreterNativeStubs, false); define_pd_global(bool, ProfileTraps, false); define_pd_global(bool, UseOnStackReplacement, true ); diff --git a/src/hotspot/cpu/arm/c2_globals_arm.hpp b/src/hotspot/cpu/arm/c2_globals_arm.hpp index 1d666357b3095..57ed8f11c08b1 100644 --- a/src/hotspot/cpu/arm/c2_globals_arm.hpp +++ b/src/hotspot/cpu/arm/c2_globals_arm.hpp @@ -34,7 +34,7 @@ define_pd_global(bool, BackgroundCompilation, true); define_pd_global(bool, CICompileOSR, true); -define_pd_global(bool, InlineIntrinsics, false); +define_pd_global(bool, InlineIntrinsics, true); define_pd_global(bool, PreferInterpreterNativeStubs, false); define_pd_global(bool, ProfileTraps, true); define_pd_global(bool, UseOnStackReplacement, true); diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index 2891532d9bb3e..37a8c9cdfd8e1 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -124,14 +124,114 @@ address TemplateInterpreterGenerator::generate_abstract_entry(void) { address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { if (!InlineIntrinsics) return NULL; // Generate a vanilla entry - // TODO: ARM - return NULL; + address entry_point = NULL; + Register continuation = LR; + bool transcendental_entry = false; + switch (kind) { + case Interpreter::java_lang_math_abs: + entry_point = __ pc(); +#ifdef __SOFTFP__ + transcendental_entry = true; + __ ldrd(R0, Address(SP)); +#else // !__SOFTFP__ + __ ldr_double(D0, Address(SP)); + __ abs_double(D0, D0); +#endif // __SOFTFP__ + break; + case Interpreter::java_lang_math_sqrt: + entry_point = __ pc(); +#ifdef __SOFTFP__ + transcendental_entry = true; + __ ldrd(R0, Address(SP)); +#else // !__SOFTFP__ + __ ldr_double(D0, Address(SP)); + __ sqrt_double(D0, D0); +#endif // __SOFTFP__ + break; + case Interpreter::java_lang_math_sin: + case Interpreter::java_lang_math_cos: + case Interpreter::java_lang_math_tan: + case Interpreter::java_lang_math_log: + case Interpreter::java_lang_math_log10: + case Interpreter::java_lang_math_exp: + entry_point = __ pc(); + transcendental_entry = true; +#ifdef __SOFTFP__ + __ ldrd(R0, Address(SP)); +#else // !__SOFTFP__ + __ ldr_double(D0, Address(SP)); +#endif // __SOFTFP__ + break; + case Interpreter::java_lang_math_pow: + entry_point = __ pc(); + transcendental_entry = true; +#ifdef __SOFTFP__ + __ ldrd(R0, Address(SP, 2 * Interpreter::stackElementSize)); + __ ldrd(R2, Address(SP)); +#else // !__SOFTFP__ + __ ldr_double(D0, Address(SP, 2 * Interpreter::stackElementSize)); + __ ldr_double(D1, Address(SP)); +#endif // __SOFTFP__ + break; + case Interpreter::java_lang_math_fmaD: + case Interpreter::java_lang_math_fmaF: + // TODO: Implement intrinsic + break; + default: + ShouldNotReachHere(); + } - address entry_point = __ pc(); - STOP("generate_math_entry"); + if (entry_point != NULL) { + __ mov(SP, Rsender_sp); + if (transcendental_entry) { + __ mov(Rtmp_save0, LR); + continuation = Rtmp_save0; + generate_transcendental_entry(kind); + } + __ ret(continuation); + } return entry_point; } +void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind) { + address fn; + switch (kind) { +#ifdef __SOFTFP__ + case Interpreter::java_lang_math_abs: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dabs); + break; + case Interpreter::java_lang_math_sqrt: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt); + break; +#endif // __SOFTFP__ + case Interpreter::java_lang_math_sin: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsin); + break; + case Interpreter::java_lang_math_cos: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dcos); + break; + case Interpreter::java_lang_math_tan: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dtan); + break; + case Interpreter::java_lang_math_log: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog); + break; + case Interpreter::java_lang_math_log10: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10); + break; + case Interpreter::java_lang_math_exp: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dexp); + break; + case Interpreter::java_lang_math_pow: + fn = CAST_FROM_FN_PTR(address, SharedRuntime::dpow); + break; + default: + ShouldNotReachHere(); + fn = NULL; // silence "maybe uninitialized" compiler warnings + } + __ call_VM_leaf(fn); +} + address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { address entry = __ pc(); diff --git a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp index 4e167ff451ab4..ea06c30963762 100644 --- a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp +++ b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp @@ -114,6 +114,10 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator { void generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs); #endif // AARCH64 +#ifdef ARM32 + void generate_transcendental_entry(AbstractInterpreter::MethodKind kind); +#endif // ARM32 + #ifdef PPC void lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded=false); void generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals); From faadc2d58ea7c71b6af85e7c4966902e11565442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20G=C3=B6ttschkes?= Date: Thu, 5 Aug 2021 13:38:03 +0200 Subject: [PATCH 2/4] Rename generate_transcendental_entry -> generate_math_runtime_call --- src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp | 4 ++-- .../share/interpreter/templateInterpreterGenerator.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index 37a8c9cdfd8e1..b6cf935b2311f 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -186,14 +186,14 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M if (transcendental_entry) { __ mov(Rtmp_save0, LR); continuation = Rtmp_save0; - generate_transcendental_entry(kind); + generate_math_runtime_call(kind); } __ ret(continuation); } return entry_point; } -void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind) { +void TemplateInterpreterGenerator::generate_math_runtime_call(AbstractInterpreter::MethodKind kind) { address fn; switch (kind) { #ifdef __SOFTFP__ diff --git a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp index ea06c30963762..fcb50cfbe01a6 100644 --- a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp +++ b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp @@ -115,7 +115,7 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator { #endif // AARCH64 #ifdef ARM32 - void generate_transcendental_entry(AbstractInterpreter::MethodKind kind); + void generate_math_runtime_call(AbstractInterpreter::MethodKind kind); #endif // ARM32 #ifdef PPC From 3c20c980b870e94ac4958159ec0faae90c4fbc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20G=C3=B6ttschkes?= Date: Fri, 6 Aug 2021 09:39:48 +0200 Subject: [PATCH 3/4] Rename transcendental_entry -> use_runtime_function --- .../cpu/arm/templateInterpreterGenerator_arm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index b6cf935b2311f..05d4166506467 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -126,12 +126,12 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M address entry_point = NULL; Register continuation = LR; - bool transcendental_entry = false; + bool use_runtime_function = false; switch (kind) { case Interpreter::java_lang_math_abs: entry_point = __ pc(); #ifdef __SOFTFP__ - transcendental_entry = true; + use_runtime_function = true; __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ __ ldr_double(D0, Address(SP)); @@ -141,7 +141,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_sqrt: entry_point = __ pc(); #ifdef __SOFTFP__ - transcendental_entry = true; + use_runtime_function = true; __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ __ ldr_double(D0, Address(SP)); @@ -155,7 +155,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_log10: case Interpreter::java_lang_math_exp: entry_point = __ pc(); - transcendental_entry = true; + use_runtime_function = true; #ifdef __SOFTFP__ __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ @@ -164,7 +164,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M break; case Interpreter::java_lang_math_pow: entry_point = __ pc(); - transcendental_entry = true; + use_runtime_function = true; #ifdef __SOFTFP__ __ ldrd(R0, Address(SP, 2 * Interpreter::stackElementSize)); __ ldrd(R2, Address(SP)); @@ -183,7 +183,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M if (entry_point != NULL) { __ mov(SP, Rsender_sp); - if (transcendental_entry) { + if (use_runtime_function) { __ mov(Rtmp_save0, LR); continuation = Rtmp_save0; generate_math_runtime_call(kind); From 6de922f8b37f9acb1b454856333c62df8f08c531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20G=C3=B6ttschkes?= Date: Fri, 6 Aug 2021 10:23:18 +0200 Subject: [PATCH 4/4] Rename use_runtime_function -> use_runtime_call --- .../cpu/arm/templateInterpreterGenerator_arm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index 05d4166506467..fa8d9e7fb587d 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -126,12 +126,12 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M address entry_point = NULL; Register continuation = LR; - bool use_runtime_function = false; + bool use_runtime_call = false; switch (kind) { case Interpreter::java_lang_math_abs: entry_point = __ pc(); #ifdef __SOFTFP__ - use_runtime_function = true; + use_runtime_call = true; __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ __ ldr_double(D0, Address(SP)); @@ -141,7 +141,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_sqrt: entry_point = __ pc(); #ifdef __SOFTFP__ - use_runtime_function = true; + use_runtime_call = true; __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ __ ldr_double(D0, Address(SP)); @@ -155,7 +155,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_log10: case Interpreter::java_lang_math_exp: entry_point = __ pc(); - use_runtime_function = true; + use_runtime_call = true; #ifdef __SOFTFP__ __ ldrd(R0, Address(SP)); #else // !__SOFTFP__ @@ -164,7 +164,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M break; case Interpreter::java_lang_math_pow: entry_point = __ pc(); - use_runtime_function = true; + use_runtime_call = true; #ifdef __SOFTFP__ __ ldrd(R0, Address(SP, 2 * Interpreter::stackElementSize)); __ ldrd(R2, Address(SP)); @@ -183,7 +183,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M if (entry_point != NULL) { __ mov(SP, Rsender_sp); - if (use_runtime_function) { + if (use_runtime_call) { __ mov(Rtmp_save0, LR); continuation = Rtmp_save0; generate_math_runtime_call(kind);