[objects] Use global safepoint in OptimizedCodeIterator if needed

MakeHeapIterable() in a shared heap isolate requires a global
safepoint. OptimizedCodeIterator uses MakeHeapIterable() but always
entered a local safepoint.

This CL changes OptimizedCodeIterator to request a global safepoint
for shared heap isolates.

Bug: v8:13267
Change-Id: I642a7731f4294cc1558de92d4daf5a1e3603f6cc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4110854
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Auto-Submit: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Nikolaos Papaspyrou <nikolaos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84967}
This commit is contained in:
Dominik Inführ 2022-12-21 09:43:41 +01:00 committed by V8 LUCI CQ
parent ab957d40bd
commit 72f041654d
2 changed files with 6 additions and 4 deletions

View File

@ -420,8 +420,10 @@ bool Code::Inlines(SharedFunctionInfo sfi) {
Code::OptimizedCodeIterator::OptimizedCodeIterator(Isolate* isolate)
: isolate_(isolate),
safepoint_scope_(
std::make_unique<IsolateSafepointScope>(isolate->heap())),
safepoint_scope_(std::make_unique<SafepointScope>(
isolate, isolate->is_shared_heap_isolate()
? SafepointKind::kGlobal
: SafepointKind::kIsolate)),
object_iterator_(
isolate->heap()->code_space()->GetObjectIterator(isolate->heap())),
state_(kIteratingCodeSpace) {}

View File

@ -29,7 +29,7 @@ class BytecodeArray;
class CodeDataContainer;
class CodeDesc;
class ObjectIterator;
class IsolateSafepointScope;
class SafepointScope;
class LocalFactory;
template <typename Impl>
@ -993,7 +993,7 @@ class Code::OptimizedCodeIterator {
private:
Isolate* isolate_;
std::unique_ptr<IsolateSafepointScope> safepoint_scope_;
std::unique_ptr<SafepointScope> safepoint_scope_;
std::unique_ptr<ObjectIterator> object_iterator_;
enum { kIteratingCodeSpace, kIteratingCodeLOSpace, kDone } state_;