Commit e2f0b1ad authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[cleanup] Unify the LocalIsolate/Isolate calls on js-heap-broker

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/+/2718609Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73048}
parent 9a31804b
......@@ -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);
}
}
......@@ -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());
}
......@@ -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());
}
......
......@@ -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
......@@ -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.
......
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