Skip to content

Commit f8794dc

Browse files
Dominik InführCommit Bot
authored andcommitted
[debug, execution, heap] Iterate debug roots for archived threads
When a thread gets archived, we still need to scan and update debug roots on GCs for it. Otherwise we restore stale references when the thread becomes active again. Bug: v8:11145 Change-Id: I88f4c1534e826aed222e7fb67bd82bb0a4758fab Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2537691 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/master@{#71221}
1 parent ba681fd commit f8794dc

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/debug/debug.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,23 @@ char* Debug::RestoreDebug(char* storage) {
393393

394394
int Debug::ArchiveSpacePerThread() { return sizeof(ThreadLocal); }
395395

396-
void Debug::Iterate(RootVisitor* v) {
396+
void Debug::Iterate(RootVisitor* v) { Iterate(v, &thread_local_); }
397+
398+
char* Debug::Iterate(RootVisitor* v, char* thread_storage) {
399+
ThreadLocal* thread_local_data =
400+
reinterpret_cast<ThreadLocal*>(thread_storage);
401+
Iterate(v, thread_local_data);
402+
return thread_storage + ArchiveSpacePerThread();
403+
}
404+
405+
void Debug::Iterate(RootVisitor* v, ThreadLocal* thread_local_data) {
397406
v->VisitRootPointer(Root::kDebug, nullptr,
398-
FullObjectSlot(&thread_local_.return_value_));
407+
FullObjectSlot(&thread_local_data->return_value_));
399408
v->VisitRootPointer(Root::kDebug, nullptr,
400-
FullObjectSlot(&thread_local_.suspended_generator_));
409+
FullObjectSlot(&thread_local_data->suspended_generator_));
401410
v->VisitRootPointer(
402411
Root::kDebug, nullptr,
403-
FullObjectSlot(&thread_local_.ignore_step_into_function_));
412+
FullObjectSlot(&thread_local_data->ignore_step_into_function_));
404413
}
405414

406415
DebugInfoListNode::DebugInfoListNode(Isolate* isolate, DebugInfo debug_info)

src/debug/debug.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ class V8_EXPORT_PRIVATE Debug {
392392

393393
void RemoveBreakInfoAndMaybeFree(Handle<DebugInfo> debug_info);
394394

395+
static char* Iterate(RootVisitor* v, char* thread_storage);
396+
395397
private:
396398
explicit Debug(Isolate* isolate);
397399
~Debug();
@@ -546,6 +548,8 @@ class V8_EXPORT_PRIVATE Debug {
546548
bool break_on_next_function_call_;
547549
};
548550

551+
static void Iterate(RootVisitor* v, ThreadLocal* thread_local_data);
552+
549553
// Storage location for registers when handling debug break calls
550554
ThreadLocal thread_local_;
551555

src/execution/stack-guard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ExecutionAccess;
1616
class InterruptsScope;
1717
class Isolate;
1818
class Object;
19+
class RootVisitor;
1920

2021
// StackGuard contains the handling of the limits that are used to limit the
2122
// number of nested invocations of JavaScript and the stack size used in each
@@ -88,6 +89,10 @@ class V8_EXPORT_PRIVATE StackGuard final {
8889

8990
static constexpr int kSizeInBytes = 7 * kSystemPointerSize;
9091

92+
static char* Iterate(RootVisitor* v, char* thread_storage) {
93+
return thread_storage + ArchiveSpacePerThread();
94+
}
95+
9196
private:
9297
bool CheckInterrupt(InterruptFlag flag);
9398
void RequestInterrupt(InterruptFlag flag);

src/execution/v8threads.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "src/debug/debug.h"
99
#include "src/execution/execution.h"
1010
#include "src/execution/isolate-inl.h"
11+
#include "src/execution/stack-guard.h"
1112
#include "src/init/bootstrapper.h"
1213
#include "src/objects/visitors.h"
1314
#include "src/regexp/regexp-stack.h"
@@ -298,6 +299,8 @@ void ThreadManager::Iterate(RootVisitor* v) {
298299
data = HandleScopeImplementer::Iterate(v, data);
299300
data = isolate_->Iterate(v, data);
300301
data = Relocatable::Iterate(v, data);
302+
data = StackGuard::Iterate(v, data);
303+
data = Debug::Iterate(v, data);
301304
}
302305
}
303306

0 commit comments

Comments
 (0)