summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2020-05-11 16:55:55 +0100
committerVladimir Marko <vmarko@google.com>2020-06-19 08:26:46 +0000
commit86c8752f64629325026945cd4eabd1dcea224acb (patch)
tree9dc2be978f9e784a3ce16fa29d46941a94ac1c94 /compiler/optimizing/code_generator.h
parentf97a859e85f703644d897f0e3e1bc54315557aaa (diff)
Direct calls to @CriticalNative methods.
Emit direct calls from compiled managed code to the native code registered with the method, avoiding the JNI stub. Golem results: art-opt-cc x86 x86-64 arm arm64 NativeDowncallStaticCritical +12.5% +62.5% +75.9% +41.7% NativeDowncallStaticCritical6 +55.6% +87.5% +72.1% +35.3% art-opt x86 x86-64 arm arm64 NativeDowncallStaticCritical +28.6% +85.6% +76.4% +38.4% NativeDowncallStaticCritical6 +44.6% +44.6% +74.6% +32.2% Test: Covered by 178-app-image-native-method. Test: m test-art-host-gtest Test: testrunner.py --host --debuggable --ndebuggable \ --optimizing --jit --jit-on-first-use Test: run-gtests.sh Test: testrunner.py --target --optimizing Test: testrunner.py --target --debuggable --ndebuggable \ --optimizing --jit --jit-on-first-use -t 178 Test: aosp_cf_x86_phone-userdebug boots. Test: aosp_cf_x86_phone-userdebug/jitzygote boots. Bug: 112189621 Change-Id: I8b37da51e8fe0b7bc513bb81b127fe0416068866
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r--compiler/optimizing/code_generator.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index ff2be4740d..4bfc14a12b 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -570,6 +570,28 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
static void CreateCommonInvokeLocationSummary(
HInvoke* invoke, InvokeDexCallingConventionVisitor* visitor);
+ template <typename CriticalNativeCallingConventionVisitor,
+ size_t kNativeStackAlignment,
+ size_t GetCriticalNativeDirectCallFrameSize(const char* shorty, uint32_t shorty_len)>
+ static size_t PrepareCriticalNativeCall(HInvokeStaticOrDirect* invoke,
+ /*out*/HParallelMove* parallel_move) {
+ DCHECK(!invoke->GetLocations()->Intrinsified());
+ CriticalNativeCallingConventionVisitor calling_convention_visitor(
+ /*for_register_allocation=*/ false);
+ PrepareCriticalNativeArgumentMoves(invoke, &calling_convention_visitor, parallel_move);
+ size_t out_frame_size =
+ RoundUp(calling_convention_visitor.GetStackOffset(), kNativeStackAlignment);
+ if (kIsDebugBuild) {
+ uint32_t shorty_len;
+ const char* shorty = GetCriticalNativeShorty(invoke, &shorty_len);
+ DCHECK_EQ(GetCriticalNativeDirectCallFrameSize(shorty, shorty_len), out_frame_size);
+ }
+ if (out_frame_size != 0u) {
+ AdjustCriticalNativeArgumentMoves(out_frame_size, parallel_move);
+ }
+ return out_frame_size;
+ }
+
void GenerateInvokeStaticOrDirectRuntimeCall(
HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path);
@@ -799,6 +821,16 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
bool needs_vreg_info = true);
void EmitVRegInfo(HEnvironment* environment, SlowPathCode* slow_path);
+ static void PrepareCriticalNativeArgumentMoves(
+ HInvokeStaticOrDirect* invoke,
+ /*inout*/InvokeDexCallingConventionVisitor* visitor,
+ /*out*/HParallelMove* parallel_move);
+
+ static void AdjustCriticalNativeArgumentMoves(size_t out_frame_size,
+ /*inout*/HParallelMove* parallel_move);
+
+ static const char* GetCriticalNativeShorty(HInvokeStaticOrDirect* invoke, uint32_t* shorty_len);
+
OptimizingCompilerStats* stats_;
HGraph* const graph_;