Commit 03bb3389 authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

Move stack walking to shared directory

This allows the implementation of different stack scanning mechanisms in
V8 (e.g. conservative scanning) while re-using the stack walking API.

Change-Id: I9b9c3b8ffe5d527ca3f7105776821776b509b187
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2238194
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68457}
parent d4d3f3fa
......@@ -4111,6 +4111,45 @@ v8_source_set("fuzzer_support") {
]
}
v8_source_set("v8_cppgc_shared") {
sources = [
"src/heap/base/stack.cc",
"src/heap/base/stack.h",
]
if (is_clang || !is_win) {
if (current_cpu == "x64") {
sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ]
} else if (current_cpu == "x86") {
sources += [ "src/heap/base/asm/ia32/push_registers_asm.cc" ]
} else if (current_cpu == "arm") {
sources += [ "src/heap/base/asm/arm/push_registers_asm.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "src/heap/base/asm/arm64/push_registers_asm.cc" ]
} else if (current_cpu == "ppc64") {
sources += [ "src/heap/base/asm/ppc/push_registers_asm.cc" ]
} else if (current_cpu == "s390x") {
sources += [ "src/heap/base/asm/s390/push_registers_asm.cc" ]
} else if (current_cpu == "mipsel") {
sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ]
} else if (current_cpu == "mips64el") {
sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ]
}
} else if (is_win) {
if (current_cpu == "x64") {
sources += [ "src/heap/base/asm/x64/push_registers_masm.S" ]
} else if (current_cpu == "x86") {
sources += [ "src/heap/base/asm/ia32/push_registers_masm.S" ]
} else if (current_cpu == "arm64") {
sources += [ "src/heap/base/asm/arm64/push_registers_masm.S" ]
}
}
configs = [ ":internal_config" ]
public_deps = [ ":v8_libbase" ]
}
v8_source_set("cppgc_base") {
visibility = [ ":*" ]
......@@ -4190,8 +4229,6 @@ v8_source_set("cppgc_base") {
"src/heap/cppgc/raw-heap.h",
"src/heap/cppgc/sanitizers.h",
"src/heap/cppgc/source-location.cc",
"src/heap/cppgc/stack.cc",
"src/heap/cppgc/stack.h",
"src/heap/cppgc/stats-collector.cc",
"src/heap/cppgc/stats-collector.h",
"src/heap/cppgc/sweeper.cc",
......@@ -4213,40 +4250,15 @@ v8_source_set("cppgc_base") {
]
}
if (is_clang || !is_win) {
if (current_cpu == "x64") {
sources += [ "src/heap/cppgc/asm/x64/push_registers_asm.cc" ]
} else if (current_cpu == "x86") {
sources += [ "src/heap/cppgc/asm/ia32/push_registers_asm.cc" ]
} else if (current_cpu == "arm") {
sources += [ "src/heap/cppgc/asm/arm/push_registers_asm.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "src/heap/cppgc/asm/arm64/push_registers_asm.cc" ]
} else if (current_cpu == "ppc64") {
sources += [ "src/heap/cppgc/asm/ppc/push_registers_asm.cc" ]
} else if (current_cpu == "s390x") {
sources += [ "src/heap/cppgc/asm/s390/push_registers_asm.cc" ]
} else if (current_cpu == "mipsel") {
sources += [ "src/heap/cppgc/asm/mips/push_registers_asm.cc" ]
} else if (current_cpu == "mips64el") {
sources += [ "src/heap/cppgc/asm/mips64/push_registers_asm.cc" ]
}
} else if (is_win) {
if (current_cpu == "x64") {
sources += [ "src/heap/cppgc/asm/x64/push_registers_masm.S" ]
} else if (current_cpu == "x86") {
sources += [ "src/heap/cppgc/asm/ia32/push_registers_masm.S" ]
} else if (current_cpu == "arm64") {
sources += [ "src/heap/cppgc/asm/arm64/push_registers_masm.S" ]
}
}
configs = [
":internal_config",
":cppgc_base_config",
]
public_deps = [ ":v8_libbase" ]
public_deps = [
":v8_cppgc_shared",
":v8_libbase",
]
}
###############################################################################
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/heap/cppgc/stack.h"
#include "src/heap/base/stack.h"
#include <limits>
......@@ -10,8 +10,8 @@
#include "src/heap/cppgc/globals.h"
#include "src/heap/cppgc/sanitizers.h"
namespace cppgc {
namespace internal {
namespace heap {
namespace base {
using IterateStackCallback = void (*)(const Stack*, StackVisitor*, intptr_t*);
extern "C" void PushAllRegistersAndIterateStack(const Stack*, StackVisitor*,
......@@ -125,5 +125,5 @@ void Stack::IteratePointers(StackVisitor* visitor) const {
IterateSafeStackIfNecessary(visitor);
}
} // namespace internal
} // namespace cppgc
} // namespace base
} // namespace heap
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_CPPGC_STACK_H_
#define V8_HEAP_CPPGC_STACK_H_
#ifndef V8_HEAP_BASE_STACK_H_
#define V8_HEAP_BASE_STACK_H_
#include "src/base/macros.h"
namespace cppgc {
namespace internal {
namespace heap {
namespace base {
class StackVisitor {
public:
......@@ -37,7 +37,7 @@ class V8_EXPORT_PRIVATE Stack final {
const void* stack_start_;
};
} // namespace internal
} // namespace cppgc
} // namespace base
} // namespace heap
#endif // V8_HEAP_CPPGC_STACK_H_
#endif // V8_HEAP_BASE_STACK_H_
......@@ -6,6 +6,7 @@
#include "src/base/bounded-page-allocator.h"
#include "src/base/platform/platform.h"
#include "src/heap/base/stack.h"
#include "src/heap/cppgc/globals.h"
#include "src/heap/cppgc/heap-object-header-inl.h"
#include "src/heap/cppgc/heap-page-inl.h"
......@@ -13,7 +14,6 @@
#include "src/heap/cppgc/marker.h"
#include "src/heap/cppgc/page-memory.h"
#include "src/heap/cppgc/prefinalizer-handler.h"
#include "src/heap/cppgc/stack.h"
#include "src/heap/cppgc/stats-collector.h"
namespace cppgc {
......@@ -64,7 +64,8 @@ HeapBase::HeapBase(std::shared_ptr<cppgc::Platform> platform,
std::make_unique<PageBackend>(platform_->GetPageAllocator())),
#endif
stats_collector_(std::make_unique<StatsCollector>()),
stack_(std::make_unique<Stack>(v8::base::Stack::GetStackStart())),
stack_(std::make_unique<heap::base::Stack>(
v8::base::Stack::GetStackStart())),
prefinalizer_handler_(std::make_unique<PreFinalizerHandler>()),
object_allocator_(&raw_heap_, page_backend_.get(),
stats_collector_.get()),
......
......@@ -19,6 +19,12 @@
#include "src/heap/cppgc/caged-heap.h"
#endif
namespace heap {
namespace base {
class Stack;
} // namespace base
} // namespace heap
namespace cppgc {
class Platform;
......@@ -32,7 +38,6 @@ class TestWithHeap;
class Marker;
class PageBackend;
class PreFinalizerHandler;
class Stack;
class StatsCollector;
// Base class for heap implementations.
......@@ -79,7 +84,7 @@ class V8_EXPORT_PRIVATE HeapBase {
const CagedHeap& caged_heap() const { return caged_heap_; }
#endif
Stack* stack() { return stack_.get(); }
heap::base::Stack* stack() { return stack_.get(); }
PreFinalizerHandler* prefinalizer_handler() {
return prefinalizer_handler_.get();
......@@ -121,7 +126,7 @@ class V8_EXPORT_PRIVATE HeapBase {
std::unique_ptr<PageBackend> page_backend_;
std::unique_ptr<StatsCollector> stats_collector_;
std::unique_ptr<Stack> stack_;
std::unique_ptr<heap::base::Stack> stack_;
std::unique_ptr<PreFinalizerHandler> prefinalizer_handler_;
std::unique_ptr<Marker> marker_;
......
......@@ -4,13 +4,13 @@
#include "src/heap/cppgc/heap.h"
#include "src/heap/base/stack.h"
#include "src/heap/cppgc/garbage-collector.h"
#include "src/heap/cppgc/gc-invoker.h"
#include "src/heap/cppgc/heap-object-header-inl.h"
#include "src/heap/cppgc/heap-visitor.h"
#include "src/heap/cppgc/marker.h"
#include "src/heap/cppgc/prefinalizer-handler.h"
#include "src/heap/cppgc/stack.h"
namespace cppgc {
......
......@@ -9,10 +9,10 @@
#include "include/cppgc/trace-trait.h"
#include "include/v8config.h"
#include "src/base/macros.h"
#include "src/heap/base/stack.h"
#include "src/heap/cppgc/globals.h"
#include "src/heap/cppgc/heap.h"
#include "src/heap/cppgc/marker.h"
#include "src/heap/cppgc/stack.h"
#include "src/heap/cppgc/visitor.h"
namespace cppgc {
......@@ -21,7 +21,8 @@ namespace internal {
class BasePage;
class HeapObjectHeader;
class MarkingVisitor : public ConservativeTracingVisitor, public StackVisitor {
class MarkingVisitor : public ConservativeTracingVisitor,
public heap::base::StackVisitor {
public:
MarkingVisitor(HeapBase&, Marker::MarkingWorklist*,
Marker::NotFullyConstructedWorklist*,
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/heap/cppgc/stack.h"
#include "src/heap/base/stack.h"
#include <memory>
#include <ostream>
......@@ -18,6 +18,9 @@
namespace cppgc {
namespace internal {
using heap::base::Stack;
using heap::base::StackVisitor;
namespace {
class GCStackTest : public ::testing::Test {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment