[vm] Preserve ThreadLocal value if dart::Thread is reclaimed
dart::Thread object representing Isolate's mutator can be reclaimed when thread is suspended, so we need to preserve thread_locals on Isolate itself. TEST=vm/dart/thread_local_test Fixes https://github.com/dart-lang/sdk/issues/63408 Change-Id: I7502b9bc67a07fb2e82479d3052740516a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504921 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
cbb94bc140
commit
bc16ca4d51
@@ -279,6 +279,9 @@ void Thread::set_default_tag(const UserTag& tag) {
|
||||
}
|
||||
|
||||
void Thread::set_thread_locals(const Array& thread_locals) {
|
||||
if (isolate_ != nullptr) {
|
||||
isolate_->isolate_object_store()->set_thread_locals(thread_locals);
|
||||
}
|
||||
thread_locals_ = thread_locals.ptr();
|
||||
}
|
||||
|
||||
@@ -436,10 +439,6 @@ void Thread::EnterIsolate(Isolate* isolate) {
|
||||
/*bypass_safepoint=*/false);
|
||||
thread->SetupMutatorState();
|
||||
thread->SetupDartMutatorState(isolate);
|
||||
|
||||
if (Array::empty_array().ptr() != nullptr) {
|
||||
thread->set_thread_locals(Array::empty_array());
|
||||
}
|
||||
}
|
||||
|
||||
isolate->scheduled_mutator_thread_ = thread;
|
||||
@@ -1643,6 +1642,7 @@ void Thread::ResetMutatorState() {
|
||||
|
||||
void Thread::SetupDartMutatorState(Isolate* isolate) {
|
||||
field_table_values_ = isolate->field_table_->table();
|
||||
thread_locals_ = isolate->isolate_object_store()->thread_locals();
|
||||
|
||||
SetupDartMutatorStateDependingOnSnapshot(isolate->group());
|
||||
}
|
||||
@@ -1682,6 +1682,7 @@ void Thread::ResetDartMutatorState() {
|
||||
|
||||
field_table_values_ = nullptr;
|
||||
shared_field_table_values_ = nullptr;
|
||||
thread_locals_ = Array::null();
|
||||
ONLY_IN_PRECOMPILED(global_object_pool_ = ObjectPool::null());
|
||||
ONLY_IN_PRECOMPILED(dispatch_table_array_ = nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user