summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-05-06 11:34:34 +0100
committerNicolas Geoffray <ngeoffray@google.com>2015-05-11 15:23:25 +0100
commit8e5bd18fc665d7ec5461ea068e98740a65da754c (patch)
tree83441cdfdab06709b573aad2ab731cc65c10b9f1
parentcdeb0b5fede4c06488f43a212591e661d946bc78 (diff)
downloadandroid_art-8e5bd18fc665d7ec5461ea068e98740a65da754c.tar.gz
android_art-8e5bd18fc665d7ec5461ea068e98740a65da754c.tar.bz2
android_art-8e5bd18fc665d7ec5461ea068e98740a65da754c.zip
Add a flag to StackVisitor for inlining.
The flag tells whether the stack walk needs to include inlined Java frames. This does not do anything just yet, as we're not inlining anyways. Change-Id: I716e25094fe56fa335ca1f9a398c1bcdba478e73
-rw-r--r--runtime/check_reference_map_visitor.h2
-rw-r--r--runtime/debugger.cc36
-rw-r--r--runtime/instrumentation.cc14
-rw-r--r--runtime/native/dalvik_system_VMStack.cc3
-rw-r--r--runtime/nth_caller_visitor.h7
-rw-r--r--runtime/profiler.cc6
-rw-r--r--runtime/quick_exception_handler.cc17
-rw-r--r--runtime/stack.cc49
-rw-r--r--runtime/stack.h23
-rw-r--r--runtime/thread.cc32
-rw-r--r--runtime/trace.cc5
-rw-r--r--test/454-get-vreg/get_vreg_jni.cc4
-rw-r--r--test/455-set-vreg/set_vreg_jni.cc3
-rw-r--r--test/457-regs/regs_jni.cc2
-rw-r--r--test/461-get-reference-vreg/get_reference_vreg_jni.cc4
-rw-r--r--test/466-get-live-vreg/get_live_vreg_jni.cc2
16 files changed, 145 insertions, 64 deletions
diff --git a/runtime/check_reference_map_visitor.h b/runtime/check_reference_map_visitor.h
index 5d9cd35c83..d87a563d73 100644
--- a/runtime/check_reference_map_visitor.h
+++ b/runtime/check_reference_map_visitor.h
@@ -29,7 +29,7 @@ namespace art {
class CheckReferenceMapVisitor : public StackVisitor {
public:
explicit CheckReferenceMapVisitor(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr) {}
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 9b33e50881..811d15ad97 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -890,8 +890,10 @@ JDWP::JdwpError Dbg::GetOwnedMonitors(JDWP::ObjectId thread_id,
std::vector<JDWP::ObjectId>* monitor_vector,
std::vector<uint32_t>* stack_depth_vector)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), current_stack_depth(0),
- monitors(monitor_vector), stack_depths(stack_depth_vector) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ current_stack_depth(0),
+ monitors(monitor_vector),
+ stack_depths(stack_depth_vector) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
@@ -2252,7 +2254,8 @@ void Dbg::GetThreads(mirror::Object* thread_group, std::vector<JDWP::ObjectId>*
static int GetStackDepth(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
struct CountStackDepthVisitor : public StackVisitor {
explicit CountStackDepthVisitor(Thread* thread_in)
- : StackVisitor(thread_in, nullptr), depth(0) {}
+ : StackVisitor(thread_in, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ depth(0) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
@@ -2292,8 +2295,11 @@ JDWP::JdwpError Dbg::GetThreadFrames(JDWP::ObjectId thread_id, size_t start_fram
GetFrameVisitor(Thread* thread, size_t start_frame_in, size_t frame_count_in,
JDWP::ExpandBuf* buf_in)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr), depth_(0),
- start_frame_(start_frame_in), frame_count_(frame_count_in), buf_(buf_in) {
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ depth_(0),
+ start_frame_(start_frame_in),
+ frame_count_(frame_count_in),
+ buf_(buf_in) {
expandBufAdd4BE(buf_, frame_count_);
}
@@ -2410,7 +2416,9 @@ void Dbg::SuspendSelf() {
struct GetThisVisitor : public StackVisitor {
GetThisVisitor(Thread* thread, Context* context, JDWP::FrameId frame_id_in)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), this_object(nullptr), frame_id(frame_id_in) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_object(nullptr),
+ frame_id(frame_id_in) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
@@ -2450,7 +2458,9 @@ class FindFrameVisitor FINAL : public StackVisitor {
public:
FindFrameVisitor(Thread* thread, Context* context, JDWP::FrameId frame_id)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), frame_id_(frame_id), error_(JDWP::ERR_INVALID_FRAMEID) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ frame_id_(frame_id),
+ error_(JDWP::ERR_INVALID_FRAMEID) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
@@ -2834,7 +2844,7 @@ class CatchLocationFinder : public StackVisitor {
public:
CatchLocationFinder(Thread* self, const Handle<mirror::Throwable>& exception, Context* context)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(self, context),
+ : StackVisitor(self, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
self_(self),
exception_(exception),
handle_scope_(self),
@@ -3582,8 +3592,10 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize
// is for step-out.
struct SingleStepStackVisitor : public StackVisitor {
explicit SingleStepStackVisitor(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr), stack_depth(0), method(nullptr), line_number(-1) {
- }
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ stack_depth(0),
+ method(nullptr),
+ line_number(-1) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
@@ -4696,7 +4708,9 @@ void Dbg::SetAllocTrackingEnabled(bool enable) {
struct AllocRecordStackVisitor : public StackVisitor {
AllocRecordStackVisitor(Thread* thread, AllocRecord* record_in)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr), record(record_in), depth(0) {}
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ record(record_in),
+ depth(0) {}
// TODO: Enable annotalysis. We know lock is held in constructor, but abstraction confuses
// annotalysis.
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index f810bc8289..98e6200bcb 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -44,6 +44,11 @@ namespace instrumentation {
constexpr bool kVerboseInstrumentation = false;
+// Instrumentation works on non-inlined frames by updating returned PCs
+// of compiled frames.
+static constexpr StackVisitor::StackWalkKind kInstrumentationStackWalk =
+ StackVisitor::StackWalkKind::kSkipInlinedFrames;
+
static bool InstallStubsClassVisitor(mirror::Class* klass, void* arg)
EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_) {
Instrumentation* instrumentation = reinterpret_cast<Instrumentation*>(arg);
@@ -162,7 +167,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
struct InstallStackVisitor FINAL : public StackVisitor {
InstallStackVisitor(Thread* thread_in, Context* context, uintptr_t instrumentation_exit_pc)
- : StackVisitor(thread_in, context),
+ : StackVisitor(thread_in, context, kInstrumentationStackWalk),
instrumentation_stack_(thread_in->GetInstrumentationStack()),
instrumentation_exit_pc_(instrumentation_exit_pc),
reached_existing_instrumentation_frames_(false), instrumentation_stack_depth_(0),
@@ -303,7 +308,8 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg)
struct RestoreStackVisitor FINAL : public StackVisitor {
RestoreStackVisitor(Thread* thread_in, uintptr_t instrumentation_exit_pc,
Instrumentation* instrumentation)
- : StackVisitor(thread_in, nullptr), thread_(thread_in),
+ : StackVisitor(thread_in, nullptr, kInstrumentationStackWalk),
+ thread_(thread_in),
instrumentation_exit_pc_(instrumentation_exit_pc),
instrumentation_(instrumentation),
instrumentation_stack_(thread_in->GetInstrumentationStack()),
@@ -964,7 +970,7 @@ void Instrumentation::ExceptionCaughtEvent(Thread* thread,
static void CheckStackDepth(Thread* self, const InstrumentationStackFrame& instrumentation_frame,
int delta)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- size_t frame_id = StackVisitor::ComputeNumFrames(self) + delta;
+ size_t frame_id = StackVisitor::ComputeNumFrames(self, kInstrumentationStackWalk) + delta;
if (frame_id != instrumentation_frame.frame_id_) {
LOG(ERROR) << "Expected frame_id=" << frame_id << " but found "
<< instrumentation_frame.frame_id_;
@@ -977,7 +983,7 @@ void Instrumentation::PushInstrumentationStackFrame(Thread* self, mirror::Object
mirror::ArtMethod* method,
uintptr_t lr, bool interpreter_entry) {
// We have a callee-save frame meaning this value is guaranteed to never be 0.
- size_t frame_id = StackVisitor::ComputeNumFrames(self);
+ size_t frame_id = StackVisitor::ComputeNumFrames(self, kInstrumentationStackWalk);
std::deque<instrumentation::InstrumentationStackFrame>* stack = self->GetInstrumentationStack();
if (kVerboseInstrumentation) {
LOG(INFO) << "Entering " << PrettyMethod(method) << " from PC " << reinterpret_cast<void*>(lr);
diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc
index 17fbc4f85d..1d7d853431 100644
--- a/runtime/native/dalvik_system_VMStack.cc
+++ b/runtime/native/dalvik_system_VMStack.cc
@@ -84,7 +84,8 @@ static jobject VMStack_getCallingClassLoader(JNIEnv* env, jclass) {
static jobject VMStack_getClosestUserClassLoader(JNIEnv* env, jclass) {
struct ClosestUserClassLoaderVisitor : public StackVisitor {
explicit ClosestUserClassLoaderVisitor(Thread* thread)
- : StackVisitor(thread, nullptr), class_loader(nullptr) {}
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ class_loader(nullptr) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
DCHECK(class_loader == nullptr);
diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h
index 632ccdedc0..d2d7fa8a21 100644
--- a/runtime/nth_caller_visitor.h
+++ b/runtime/nth_caller_visitor.h
@@ -27,8 +27,11 @@ class Thread;
// Walks up the stack 'n' callers, when used with Thread::WalkStack.
struct NthCallerVisitor : public StackVisitor {
NthCallerVisitor(Thread* thread, size_t n_in, bool include_runtime_and_upcalls = false)
- : StackVisitor(thread, nullptr), n(n_in),
- include_runtime_and_upcalls_(include_runtime_and_upcalls), count(0), caller(nullptr) {}
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ n(n_in),
+ include_runtime_and_upcalls_(include_runtime_and_upcalls),
+ count(0),
+ caller(nullptr) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/runtime/profiler.cc b/runtime/profiler.cc
index 90a47b38c2..5354fd8486 100644
--- a/runtime/profiler.cc
+++ b/runtime/profiler.cc
@@ -58,8 +58,10 @@ class BoundedStackVisitor : public StackVisitor {
BoundedStackVisitor(std::vector<std::pair<mirror::ArtMethod*, uint32_t>>* stack,
Thread* thread, uint32_t max_depth)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr), stack_(stack), max_depth_(max_depth), depth_(0) {
- }
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ stack_(stack),
+ max_depth_(max_depth),
+ depth_(0) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 9e79bd20cb..730759a71b 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -46,7 +46,9 @@ class CatchBlockStackVisitor FINAL : public StackVisitor {
CatchBlockStackVisitor(Thread* self, Context* context, Handle<mirror::Throwable>* exception,
QuickExceptionHandler* exception_handler)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(self, context), self_(self), exception_(exception),
+ : StackVisitor(self, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ self_(self),
+ exception_(exception),
exception_handler_(exception_handler) {
}
@@ -160,7 +162,9 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor {
public:
DeoptimizeStackVisitor(Thread* self, Context* context, QuickExceptionHandler* exception_handler)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(self, context), self_(self), exception_handler_(exception_handler),
+ : StackVisitor(self, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ self_(self),
+ exception_handler_(exception_handler),
prev_shadow_frame_(nullptr) {
CHECK(!self_->HasDeoptimizationShadowFrame());
}
@@ -338,7 +342,7 @@ class InstrumentationStackVisitor : public StackVisitor {
public:
InstrumentationStackVisitor(Thread* self, size_t frame_depth)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(self, nullptr),
+ : StackVisitor(self, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
frame_depth_(frame_depth),
instrumentation_frames_to_pop_(0) {
CHECK_NE(frame_depth_, kInvalidFrameDepth);
@@ -349,7 +353,12 @@ class InstrumentationStackVisitor : public StackVisitor {
if (current_frame_depth < frame_depth_) {
CHECK(GetMethod() != nullptr);
if (UNLIKELY(reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == GetReturnPc())) {
- ++instrumentation_frames_to_pop_;
+ if (!IsInInlinedFrame()) {
+ // We do not count inlined frames, because we do not instrument them. The reason we
+ // include them in the stack walking is the check against `frame_depth_`, which is
+ // given to us by a visitor that visits inlined frames.
+ ++instrumentation_frames_to_pop_;
+ }
}
return true;
} else {
diff --git a/runtime/stack.cc b/runtime/stack.cc
index a566886d73..800acaa320 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -85,16 +85,20 @@ bool ManagedStack::ShadowFramesContain(StackReference<mirror::Object>* shadow_fr
return false;
}
-StackVisitor::StackVisitor(Thread* thread, Context* context)
- : thread_(thread), cur_shadow_frame_(nullptr),
- cur_quick_frame_(nullptr), cur_quick_frame_pc_(0), num_frames_(0), cur_depth_(0),
- context_(context) {
- DCHECK(thread == Thread::Current() || thread->IsSuspended()) << *thread;
-}
-
-StackVisitor::StackVisitor(Thread* thread, Context* context, size_t num_frames)
- : thread_(thread), cur_shadow_frame_(nullptr),
- cur_quick_frame_(nullptr), cur_quick_frame_pc_(0), num_frames_(num_frames), cur_depth_(0),
+StackVisitor::StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind)
+ : StackVisitor(thread, context, walk_kind, 0) {}
+
+StackVisitor::StackVisitor(Thread* thread,
+ Context* context,
+ StackWalkKind walk_kind,
+ size_t num_frames)
+ : thread_(thread),
+ walk_kind_(walk_kind),
+ cur_shadow_frame_(nullptr),
+ cur_quick_frame_(nullptr),
+ cur_quick_frame_pc_(0),
+ num_frames_(num_frames),
+ cur_depth_(0),
context_(context) {
DCHECK(thread == Thread::Current() || thread->IsSuspended()) << *thread;
}
@@ -565,10 +569,10 @@ void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) {
*reinterpret_cast<uintptr_t*>(pc_addr) = new_ret_pc;
}
-size_t StackVisitor::ComputeNumFrames(Thread* thread) {
+size_t StackVisitor::ComputeNumFrames(Thread* thread, StackWalkKind walk_kind) {
struct NumFramesVisitor : public StackVisitor {
- explicit NumFramesVisitor(Thread* thread_in)
- : StackVisitor(thread_in, nullptr), frames(0) {}
+ NumFramesVisitor(Thread* thread_in, StackWalkKind walk_kind_in)
+ : StackVisitor(thread_in, nullptr, walk_kind_in), frames(0) {}
bool VisitFrame() OVERRIDE {
frames++;
@@ -577,16 +581,23 @@ size_t StackVisitor::ComputeNumFrames(Thread* thread) {
size_t frames;
};
- NumFramesVisitor visitor(thread);
+ NumFramesVisitor visitor(thread, walk_kind);
visitor.WalkStack(true);
return visitor.frames;
}
bool StackVisitor::GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32_t* next_dex_pc) {
struct HasMoreFramesVisitor : public StackVisitor {
- explicit HasMoreFramesVisitor(Thread* thread, size_t num_frames, size_t frame_height)
- : StackVisitor(thread, nullptr, num_frames), frame_height_(frame_height),
- found_frame_(false), has_more_frames_(false), next_method_(nullptr), next_dex_pc_(0) {
+ HasMoreFramesVisitor(Thread* thread,
+ StackWalkKind walk_kind,
+ size_t num_frames,
+ size_t frame_height)
+ : StackVisitor(thread, nullptr, walk_kind, num_frames),
+ frame_height_(frame_height),
+ found_frame_(false),
+ has_more_frames_(false),
+ next_method_(nullptr),
+ next_dex_pc_(0) {
}
bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -610,7 +621,7 @@ bool StackVisitor::GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32
mirror::ArtMethod* next_method_;
uint32_t next_dex_pc_;
};
- HasMoreFramesVisitor visitor(thread_, GetNumFrames(), GetFrameHeight());
+ HasMoreFramesVisitor visitor(thread_, walk_kind_, GetNumFrames(), GetFrameHeight());
visitor.WalkStack(true);
*next_method = visitor.next_method_;
*next_dex_pc = visitor.next_dex_pc_;
@@ -620,7 +631,7 @@ bool StackVisitor::GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32
void StackVisitor::DescribeStack(Thread* thread) {
struct DescribeStackVisitor : public StackVisitor {
explicit DescribeStackVisitor(Thread* thread_in)
- : StackVisitor(thread_in, nullptr) {}
+ : StackVisitor(thread_in, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames) {}
bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
LOG(INFO) << "Frame Id=" << GetFrameId() << " " << DescribeLocation();
diff --git a/runtime/stack.h b/runtime/stack.h
index ab8641b4d5..bf6101619d 100644
--- a/runtime/stack.h
+++ b/runtime/stack.h
@@ -409,8 +409,17 @@ class PACKED(4) ManagedStack {
};
class StackVisitor {
+ public:
+ // This enum defines a flag to control whether inlined frames are included
+ // when walking the stack.
+ enum class StackWalkKind {
+ kIncludeInlinedFrames,
+ kSkipInlinedFrames,
+ };
+
protected:
- StackVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
public:
virtual ~StackVisitor() {}
@@ -465,7 +474,7 @@ class StackVisitor {
size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (num_frames_ == 0) {
- num_frames_ = ComputeNumFrames(thread_);
+ num_frames_ = ComputeNumFrames(thread_, walk_kind_);
}
return num_frames_;
}
@@ -601,6 +610,10 @@ class StackVisitor {
return sizeof(StackReference<mirror::ArtMethod>) + (out_num * sizeof(uint32_t));
}
+ bool IsInInlinedFrame() const {
+ return false;
+ }
+
uintptr_t GetCurrentQuickFramePc() const {
return cur_quick_frame_pc_;
}
@@ -621,13 +634,14 @@ class StackVisitor {
std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- static size_t ComputeNumFrames(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ static size_t ComputeNumFrames(Thread* thread, StackWalkKind walk_kind)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
private:
// Private constructor known in the case that num_frames_ has already been computed.
- StackVisitor(Thread* thread, Context* context, size_t num_frames)
+ StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind, size_t num_frames)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool IsAccessibleRegister(uint32_t reg, bool is_float) const {
@@ -690,6 +704,7 @@ class StackVisitor {
void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Thread* const thread_;
+ const StackWalkKind walk_kind_;
ShadowFrame* cur_shadow_frame_;
StackReference<mirror::ArtMethod>* cur_quick_frame_;
uintptr_t cur_quick_frame_pc_;
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 605a1b5419..b7cfc7299d 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -940,10 +940,14 @@ void Thread::DumpState(std::ostream& os) const {
struct StackDumpVisitor : public StackVisitor {
StackDumpVisitor(std::ostream& os_in, Thread* thread_in, Context* context, bool can_allocate_in)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread_in, context), os(os_in), thread(thread_in),
- can_allocate(can_allocate_in), last_method(nullptr), last_line_number(0),
- repetition_count(0), frame_count(0) {
- }
+ : StackVisitor(thread_in, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ os(os_in),
+ thread(thread_in),
+ can_allocate(can_allocate_in),
+ last_method(nullptr),
+ last_line_number(0),
+ repetition_count(0),
+ frame_count(0) {}
virtual ~StackDumpVisitor() {
if (frame_count == 0) {
@@ -1528,7 +1532,7 @@ class CountStackDepthVisitor : public StackVisitor {
public:
explicit CountStackDepthVisitor(Thread* thread)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, nullptr),
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
depth_(0), skip_depth_(0), skipping_(true) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -1568,8 +1572,12 @@ template<bool kTransactionActive>
class BuildInternalStackTraceVisitor : public StackVisitor {
public:
explicit BuildInternalStackTraceVisitor(Thread* self, Thread* thread, int skip_depth)
- : StackVisitor(thread, nullptr), self_(self),
- skip_depth_(skip_depth), count_(0), dex_pc_trace_(nullptr), method_trace_(nullptr) {}
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ self_(self),
+ skip_depth_(skip_depth),
+ count_(0),
+ dex_pc_trace_(nullptr),
+ method_trace_(nullptr) {}
bool Init(int depth)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -2111,7 +2119,10 @@ Context* Thread::GetLongJumpContext() {
struct CurrentMethodVisitor FINAL : public StackVisitor {
CurrentMethodVisitor(Thread* thread, Context* context, bool abort_on_error)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), this_object_(nullptr), method_(nullptr), dex_pc_(0),
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_object_(nullptr),
+ method_(nullptr),
+ dex_pc_(0),
abort_on_error_(abort_on_error) {}
bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
@@ -2154,7 +2165,10 @@ class ReferenceMapVisitor : public StackVisitor {
public:
ReferenceMapVisitor(Thread* thread, Context* context, RootVisitor& visitor)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), visitor_(visitor) {}
+ // We are visiting the references in compiled frames, so we do not need
+ // to know the inlined frames.
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kSkipInlinedFrames),
+ visitor_(visitor) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (false) {
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 3b8feda2cd..76367923c0 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -91,8 +91,9 @@ static constexpr uint8_t kOpNewThread = 2U;
class BuildStackTraceVisitor : public StackVisitor {
public:
- explicit BuildStackTraceVisitor(Thread* thread) : StackVisitor(thread, nullptr),
- method_trace_(Trace::AllocStackTrace()) {}
+ explicit BuildStackTraceVisitor(Thread* thread)
+ : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ method_trace_(Trace::AllocStackTrace()) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/test/454-get-vreg/get_vreg_jni.cc b/test/454-get-vreg/get_vreg_jni.cc
index 6b4bc11086..0ef2964e35 100644
--- a/test/454-get-vreg/get_vreg_jni.cc
+++ b/test/454-get-vreg/get_vreg_jni.cc
@@ -29,7 +29,9 @@ class TestVisitor : public StackVisitor {
public:
TestVisitor(Thread* thread, Context* context, mirror::Object* this_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), this_value_(this_value), found_method_index_(0) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_value_(this_value),
+ found_method_index_(0) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/test/455-set-vreg/set_vreg_jni.cc b/test/455-set-vreg/set_vreg_jni.cc
index 0a83ac0738..dffbfa47d8 100644
--- a/test/455-set-vreg/set_vreg_jni.cc
+++ b/test/455-set-vreg/set_vreg_jni.cc
@@ -29,7 +29,8 @@ class TestVisitor : public StackVisitor {
public:
TestVisitor(Thread* thread, Context* context, mirror::Object* this_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), this_value_(this_value) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_value_(this_value) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/test/457-regs/regs_jni.cc b/test/457-regs/regs_jni.cc
index 1b32348e25..193ab9dc4e 100644
--- a/test/457-regs/regs_jni.cc
+++ b/test/457-regs/regs_jni.cc
@@ -29,7 +29,7 @@ class TestVisitor : public StackVisitor {
public:
TestVisitor(Thread* thread, Context* context)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/test/461-get-reference-vreg/get_reference_vreg_jni.cc b/test/461-get-reference-vreg/get_reference_vreg_jni.cc
index f0b78e1f5e..a8ef684e93 100644
--- a/test/461-get-reference-vreg/get_reference_vreg_jni.cc
+++ b/test/461-get-reference-vreg/get_reference_vreg_jni.cc
@@ -29,7 +29,9 @@ class TestVisitor : public StackVisitor {
public:
TestVisitor(Thread* thread, Context* context, mirror::Object* this_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context), this_value_(this_value), found_method_index_(0) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_value_(this_value),
+ found_method_index_(0) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();
diff --git a/test/466-get-live-vreg/get_live_vreg_jni.cc b/test/466-get-live-vreg/get_live_vreg_jni.cc
index 6715ba17e6..4724e8ebe4 100644
--- a/test/466-get-live-vreg/get_live_vreg_jni.cc
+++ b/test/466-get-live-vreg/get_live_vreg_jni.cc
@@ -28,7 +28,7 @@ namespace {
class TestVisitor : public StackVisitor {
public:
TestVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : StackVisitor(thread, context) {}
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames) {}
bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* m = GetMethod();