Revert^4 "ART: Add StackVisitor accepting a lambda"
This reverts commit ec43a01e0ac948c59d5b1f9c3812f2901b48942a.
Reason for revert: Added missing code.
Bug: 115837065
Test: m test-art-host
Change-Id: Id30ccdf9aa9a6e56a914254793e399f2712c882d
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 1701ca8..7729838 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -18,7 +18,8 @@
#include <sstream>
-#include "android-base/unique_fd.h"
+#include <android-base/logging.h>
+#include <android-base/unique_fd.h>
#include "arch/context.h"
#include "art_method-inl.h"
@@ -1272,31 +1273,6 @@
}
}
-class MarkCodeVisitor final : public StackVisitor {
- public:
- MarkCodeVisitor(Thread* thread_in, JitCodeCache* code_cache_in, CodeCacheBitmap* bitmap)
- : StackVisitor(thread_in, nullptr, StackVisitor::StackWalkKind::kSkipInlinedFrames),
- code_cache_(code_cache_in),
- bitmap_(bitmap) {}
-
- bool VisitFrame() override REQUIRES_SHARED(Locks::mutator_lock_) {
- const OatQuickMethodHeader* method_header = GetCurrentOatQuickMethodHeader();
- if (method_header == nullptr) {
- return true;
- }
- const void* code = method_header->GetCode();
- if (code_cache_->ContainsPc(code)) {
- // Use the atomic set version, as multiple threads are executing this code.
- bitmap_->AtomicTestAndSet(FromCodeToAllocation(code));
- }
- return true;
- }
-
- private:
- JitCodeCache* const code_cache_;
- CodeCacheBitmap* const bitmap_;
-};
-
class MarkCodeClosure final : public Closure {
public:
MarkCodeClosure(JitCodeCache* code_cache, CodeCacheBitmap* bitmap, Barrier* barrier)
@@ -1305,8 +1281,24 @@
void Run(Thread* thread) override REQUIRES_SHARED(Locks::mutator_lock_) {
ScopedTrace trace(__PRETTY_FUNCTION__);
DCHECK(thread == Thread::Current() || thread->IsSuspended());
- MarkCodeVisitor visitor(thread, code_cache_, bitmap_);
- visitor.WalkStack();
+ StackVisitor::WalkStack(
+ [&](const art::StackVisitor* stack_visitor) {
+ const OatQuickMethodHeader* method_header =
+ stack_visitor->GetCurrentOatQuickMethodHeader();
+ if (method_header == nullptr) {
+ return true;
+ }
+ const void* code = method_header->GetCode();
+ if (code_cache_->ContainsPc(code)) {
+ // Use the atomic set version, as multiple threads are executing this code.
+ bitmap_->AtomicTestAndSet(FromCodeToAllocation(code));
+ }
+ return true;
+ },
+ thread,
+ /* context= */ nullptr,
+ art::StackVisitor::StackWalkKind::kSkipInlinedFrames);
+
if (kIsDebugBuild) {
// The stack walking code queries the side instrumentation stack if it
// sees an instrumentation exit pc, so the JIT code of methods in that stack