8271128: InlineIntrinsics support for 32-bit ARM

Reviewed-by: shade
This commit is contained in:
Christoph Göttschkes 2021-08-06 10:23:18 +00:00 committed by Aleksey Shipilev
parent c2b7facea4
commit b6a19f173b
4 changed files with 110 additions and 6 deletions

View file

@ -35,7 +35,7 @@
#ifndef COMPILER2 // avoid duplicated definitions, favoring C2 version #ifndef COMPILER2 // avoid duplicated definitions, favoring C2 version
define_pd_global(bool, BackgroundCompilation, true ); 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, PreferInterpreterNativeStubs, false);
define_pd_global(bool, ProfileTraps, false); define_pd_global(bool, ProfileTraps, false);
define_pd_global(bool, UseOnStackReplacement, true ); define_pd_global(bool, UseOnStackReplacement, true );

View file

@ -34,7 +34,7 @@
define_pd_global(bool, BackgroundCompilation, true); define_pd_global(bool, BackgroundCompilation, true);
define_pd_global(bool, CICompileOSR, 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, PreferInterpreterNativeStubs, false);
define_pd_global(bool, ProfileTraps, true); define_pd_global(bool, ProfileTraps, true);
define_pd_global(bool, UseOnStackReplacement, true); define_pd_global(bool, UseOnStackReplacement, true);

View file

@ -124,14 +124,114 @@ address TemplateInterpreterGenerator::generate_abstract_entry(void) {
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
if (!InlineIntrinsics) return NULL; // Generate a vanilla entry if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
// TODO: ARM address entry_point = NULL;
return NULL; Register continuation = LR;
bool use_runtime_call = false;
switch (kind) {
case Interpreter::java_lang_math_abs:
entry_point = __ pc();
#ifdef __SOFTFP__
use_runtime_call = 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__
use_runtime_call = 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();
use_runtime_call = 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();
use_runtime_call = 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(); if (entry_point != NULL) {
STOP("generate_math_entry"); __ mov(SP, Rsender_sp);
if (use_runtime_call) {
__ mov(Rtmp_save0, LR);
continuation = Rtmp_save0;
generate_math_runtime_call(kind);
}
__ ret(continuation);
}
return entry_point; return entry_point;
} }
void TemplateInterpreterGenerator::generate_math_runtime_call(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 TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
address entry = __ pc(); address entry = __ pc();

View file

@ -114,6 +114,10 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator {
void generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs); void generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs);
#endif // AARCH64 #endif // AARCH64
#ifdef ARM32
void generate_math_runtime_call(AbstractInterpreter::MethodKind kind);
#endif // ARM32
#ifdef PPC #ifdef PPC
void lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded=false); 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); void generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals);