Skip to content

Commit

Permalink
[cleanup] Unify the LocalIsolate/Isolate calls on js-heap-broker
Browse files Browse the repository at this point in the history
We have several ways of doing the Isolate or LocalIsolate calls. Let's
unify it to have one consistent way of doing it.

Bug: v8:7790
Change-Id: I7d860e918406b07e3b8ab2d46e775a2beb5a4397
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2718609
Reviewed-by: Nico Hartmann <[email protected]>
Commit-Queue: Santiago Aboy Solanes <[email protected]>
Cr-Commit-Position: refs/heads/master@{#73048}
  • Loading branch information
santiaboy authored and Commit Bot committed Feb 25, 2021
1 parent 9a31804 commit e2f0b1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 7 additions & 8 deletions src/compiler/js-heap-broker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3271,11 +3271,11 @@ base::Optional<uint16_t> StringRef::GetFirstChar() {
return base::nullopt;
}

if (broker()->local_isolate()) {
if (!broker()->IsMainThread()) {
return object()->Get(0, broker()->local_isolate());
} else {
// TODO(solanes, v8:7790): Remove this case once we always have a local
// isolate, i.e. the inlining phase is done concurrently all the time.
// TODO(solanes, v8:7790): Remove this case once the inlining phase is
// done concurrently all the time.
return object()->Get(0);
}
}
Expand Down Expand Up @@ -3584,9 +3584,8 @@ BIMODAL_ACCESSOR_C(SharedFunctionInfo, int, builtin_id)
BytecodeArrayRef SharedFunctionInfoRef::GetBytecodeArray() const {
if (data_->should_access_heap() || FLAG_turbo_direct_heap_access) {
BytecodeArray bytecode_array;
LocalIsolate* local_isolate = broker()->local_isolate();
if (local_isolate && !local_isolate->is_main_thread()) {
bytecode_array = object()->GetBytecodeArray(local_isolate);
if (!broker()->IsMainThread()) {
bytecode_array = object()->GetBytecodeArray(broker()->local_isolate());
} else {
bytecode_array = object()->GetBytecodeArray(broker()->isolate());
}
Expand All @@ -3603,8 +3602,8 @@ BROKER_SFI_FIELDS(DEF_SFI_ACCESSOR)
SharedFunctionInfo::Inlineability SharedFunctionInfoRef::GetInlineability()
const {
if (data_->should_access_heap()) {
if (LocalIsolate* local_isolate = broker()->local_isolate()) {
return object()->GetInlineability(local_isolate);
if (!broker()->IsMainThread()) {
return object()->GetInlineability(broker()->local_isolate());
} else {
return object()->GetInlineability(broker()->isolate());
}
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/js-heap-broker.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
bool IsSerializedForCompilation(const SharedFunctionInfoRef& shared,
const FeedbackVectorRef& feedback) const;

bool IsMainThread() const {
return local_isolate() == nullptr || local_isolate()->is_main_thread();
}

LocalIsolate* local_isolate() const { return local_isolate_; }

// Return the corresponding canonical persistent handle for {object}. Create
Expand Down Expand Up @@ -315,10 +319,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
friend class ObjectData;
friend class PropertyCellData;

bool IsMainThread() const {
return local_isolate() == nullptr || local_isolate()->is_main_thread();
}

// If this returns false, the object is guaranteed to be fully initialized and
// thus safe to read from a memory safety perspective. The converse does not
// necessarily hold.
Expand Down

0 comments on commit e2f0b1a

Please sign in to comment.