Commit 7d4486ff authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[compiler] Use Handles for source positions in concurrent-inlining

When we add safepointing, the source position address might change.
Then, we need to use the handlified version for both concurrent-inlining
and not.

The logic for retrieving the Handle can be encapsulated in the
BytecodeArrayRef, which can be reused in the other source_position_*
methods.

Bug: v8:7790
Change-Id: I3e5f937eb06153449cf6f720a2a4321cb338d903
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2316301Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69076}
parent 926094db
...@@ -966,6 +966,8 @@ BytecodeGraphBuilder::BytecodeGraphBuilder( ...@@ -966,6 +966,8 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(
FrameStateType::kInterpretedFunction, FrameStateType::kInterpretedFunction,
bytecode_array().parameter_count(), bytecode_array().register_count(), bytecode_array().parameter_count(), bytecode_array().register_count(),
shared_info.object())), shared_info.object())),
source_position_iterator_(std::make_unique<SourcePositionTableIterator>(
bytecode_array().source_positions())),
bytecode_iterator_( bytecode_iterator_(
std::make_unique<OffHeapBytecodeArray>(bytecode_array())), std::make_unique<OffHeapBytecodeArray>(bytecode_array())),
bytecode_analysis_(broker_->GetBytecodeAnalysis( bytecode_analysis_(broker_->GetBytecodeAnalysis(
...@@ -994,20 +996,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder( ...@@ -994,20 +996,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(
state_values_cache_(jsgraph), state_values_cache_(jsgraph),
source_positions_(source_positions), source_positions_(source_positions),
start_position_(shared_info.StartPosition(), inlining_id), start_position_(shared_info.StartPosition(), inlining_id),
tick_counter_(tick_counter) { tick_counter_(tick_counter) {}
if (should_disallow_heap_access()) {
// With concurrent inlining on, the source position address doesn't change
// because it's been copied from the heap.
source_position_iterator_ = std::make_unique<SourcePositionTableIterator>(
Vector<const byte>(bytecode_array().source_positions_address(),
bytecode_array().source_positions_size()));
} else {
// Otherwise, we need to access the table through a handle.
source_position_iterator_ = std::make_unique<SourcePositionTableIterator>(
handle(bytecode_array().object()->SourcePositionTableIfCollected(),
isolate()));
}
}
Node* BytecodeGraphBuilder::GetFunctionClosure() { Node* BytecodeGraphBuilder::GetFunctionClosure() {
if (!function_closure_.is_set()) { if (!function_closure_.is_set()) {
......
...@@ -723,8 +723,7 @@ class BytecodeArrayRef : public FixedArrayBaseRef { ...@@ -723,8 +723,7 @@ class BytecodeArrayRef : public FixedArrayBaseRef {
Address GetFirstBytecodeAddress() const; Address GetFirstBytecodeAddress() const;
// Source position table. // Source position table.
const byte* source_positions_address() const; Handle<ByteArray> source_positions() const;
int source_positions_size() const;
// Constant pool access. // Constant pool access.
Handle<Object> GetConstantAtIndex(int index) const; Handle<Object> GetConstantAtIndex(int index) const;
......
...@@ -1626,11 +1626,7 @@ class BytecodeArrayData : public FixedArrayBaseData { ...@@ -1626,11 +1626,7 @@ class BytecodeArrayData : public FixedArrayBaseData {
is_serialized_for_compilation_ = true; is_serialized_for_compilation_ = true;
} }
const byte* source_positions_address() const { Handle<ByteArray> source_positions() const { return source_positions_; }
return source_positions_->GetDataStartAddress();
}
int source_positions_size() const { return source_positions_->length(); }
Address handler_table_address() const { Address handler_table_address() const {
CHECK(is_serialized_for_compilation_); CHECK(is_serialized_for_compilation_);
...@@ -3285,24 +3281,15 @@ void BytecodeArrayRef::SerializeForCompilation() { ...@@ -3285,24 +3281,15 @@ void BytecodeArrayRef::SerializeForCompilation() {
data()->AsBytecodeArray()->SerializeForCompilation(broker()); data()->AsBytecodeArray()->SerializeForCompilation(broker());
} }
const byte* BytecodeArrayRef::source_positions_address() const { Handle<ByteArray> BytecodeArrayRef::source_positions() const {
if (data_->should_access_heap()) {
DCHECK(data_->kind() != ObjectDataKind::kUnserializedReadOnlyHeapObject);
AllowHandleDereferenceIf allow_handle_dereference(data()->kind(),
broker()->mode());
return object()->SourcePositionTableIfCollected().GetDataStartAddress();
}
return data()->AsBytecodeArray()->source_positions_address();
}
int BytecodeArrayRef::source_positions_size() const {
if (data_->should_access_heap()) { if (data_->should_access_heap()) {
DCHECK(data_->kind() != ObjectDataKind::kUnserializedReadOnlyHeapObject); DCHECK(data_->kind() != ObjectDataKind::kUnserializedReadOnlyHeapObject);
AllowHandleDereferenceIf allow_handle_dereference(data()->kind(), AllowHandleDereferenceIf allow_handle_dereference(data()->kind(),
broker()->mode()); broker()->mode());
return object()->SourcePositionTableIfCollected().length(); return handle(object()->SourcePositionTableIfCollected(),
broker()->isolate());
} }
return data()->AsBytecodeArray()->source_positions_size(); return data()->AsBytecodeArray()->source_positions();
} }
Address BytecodeArrayRef::handler_table_address() const { Address BytecodeArrayRef::handler_table_address() const {
......
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