summaryrefslogtreecommitdiff
path: root/runtime/stack.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2020-02-10 16:56:54 +0000
committer Vladimir Marko <vmarko@google.com> 2020-02-12 13:21:28 +0000
commit6e043bbc1d9abd1d1d3247040f6cdc82a79f47be (patch)
tree02470465a0426e02d15525e171c6b3bbef3d60a6 /runtime/stack.cc
parentac5ae3cf5dc4c5f87293c45a1d6999f8d1515b39 (diff)
Rewrite GenericJNI frame setup.
Move the handle scope out of the managed frame, move the register values to load to the bottom of the reserved area and pass the hidden argument to @CriticalNative methods to prepare for implementing late lookup. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --interp-ac Test: aosp_taimen-userdebug boots. Test: run-gtests.sh Test: testrunner.py --target --optimizing --interp-ac Bug: 112189621 Change-Id: I4672176f9627bcbebafebb3dda0d02b8108e1329
Diffstat (limited to 'runtime/stack.cc')
-rw-r--r--runtime/stack.cc44
1 files changed, 15 insertions, 29 deletions
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 336b253d1c..04590910fa 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -149,8 +149,18 @@ ObjPtr<mirror::Object> StackVisitor::GetThisObject() const {
return nullptr;
} else if (m->IsNative()) {
if (cur_quick_frame_ != nullptr) {
- HandleScope* hs = reinterpret_cast<HandleScope*>(
- reinterpret_cast<char*>(cur_quick_frame_) + sizeof(ArtMethod*));
+ HandleScope* hs;
+ if (cur_oat_quick_method_header_ != nullptr) {
+ hs = reinterpret_cast<HandleScope*>(
+ reinterpret_cast<char*>(cur_quick_frame_) + sizeof(ArtMethod*));
+ } else {
+ // GenericJNI frames have the HandleScope under the managed frame.
+ uint32_t shorty_len;
+ const char* shorty = m->GetShorty(&shorty_len);
+ const size_t num_handle_scope_references =
+ /* this */ 1u + std::count(shorty + 1, shorty + shorty_len, 'L');
+ hs = GetGenericJniHandleScope(cur_quick_frame_, num_handle_scope_references);
+ }
return hs->GetReference(0);
} else {
return cur_shadow_frame_->GetVRegReference(0);
@@ -772,21 +782,6 @@ void StackVisitor::SanityCheckFrame() const {
}
}
-// Counts the number of references in the parameter list of the corresponding method.
-// Note: Thus does _not_ include "this" for non-static methods.
-static uint32_t GetNumberOfReferenceArgsWithoutReceiver(ArtMethod* method)
- REQUIRES_SHARED(Locks::mutator_lock_) {
- uint32_t shorty_len;
- const char* shorty = method->GetShorty(&shorty_len);
- uint32_t refs = 0;
- for (uint32_t i = 1; i < shorty_len ; ++i) {
- if (shorty[i] == 'L') {
- refs++;
- }
- }
- return refs;
-}
-
QuickMethodFrameInfo StackVisitor::GetCurrentQuickFrameInfo() const {
if (cur_oat_quick_method_header_ != nullptr) {
if (cur_oat_quick_method_header_->IsOptimized()) {
@@ -831,18 +826,9 @@ QuickMethodFrameInfo StackVisitor::GetCurrentQuickFrameInfo() const {
(runtime->GetJit() != nullptr &&
runtime->GetJit()->GetCodeCache()->ContainsPc(entry_point))) << method->PrettyMethod();
}
- // Generic JNI frame.
- uint32_t handle_refs = GetNumberOfReferenceArgsWithoutReceiver(method) + 1;
- size_t scope_size = HandleScope::SizeOf(handle_refs);
- constexpr QuickMethodFrameInfo callee_info =
- RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs);
-
- // Callee saves + handle scope + method ref + alignment
- // Note: -sizeof(void*) since callee-save frame stores a whole method pointer.
- size_t frame_size = RoundUp(
- callee_info.FrameSizeInBytes() - sizeof(void*) + sizeof(ArtMethod*) + scope_size,
- kStackAlignment);
- return QuickMethodFrameInfo(frame_size, callee_info.CoreSpillMask(), callee_info.FpSpillMask());
+ // Generic JNI frame is just like the SaveRefsAndArgs frame.
+ // Note that HandleScope, if any, is below the frame.
+ return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs);
}
template <StackVisitor::CountTransitions kCount>