Commit 07d7fd32 authored by Patrick Thier's avatar Patrick Thier Committed by Commit Bot

[sparkplug] Fix GetBytecodeOffsetForBaselinePC() in prologue

When GetBytecodeOffsetForBaselinePC() is called with a PC that is inside
the baseline prologue, correctly return kFunctionEntryOffset now.

Bug: v8:11420
Change-Id: I39cb96a04e7d92d0ba5dfcbcaeebd23144c9df05
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2773050
Auto-Submit: Patrick Thier <pthier@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73601}
parent be3c0126
......@@ -47,8 +47,11 @@ BytecodeOffsetIterator::~BytecodeOffsetIterator() {
}
void BytecodeOffsetIterator::Initialize() {
current_pc_start_offset_ = ReadPosition();
current_pc_end_offset_ = current_pc_start_offset_ + ReadPosition();
// Initialize values for the prologue.
// The first recorded position is at the start of the first bytecode.
current_pc_start_offset_ = 0;
current_pc_end_offset_ = ReadPosition();
current_bytecode_offset_ = kFunctionEntryBytecodeOffset;
}
void BytecodeOffsetIterator::UpdatePointers() {
......
......@@ -31,6 +31,7 @@ class V8_EXPORT_PRIVATE BytecodeOffsetIterator {
DCHECK(!done());
current_pc_start_offset_ = current_pc_end_offset_;
current_pc_end_offset_ += ReadPosition();
current_bytecode_offset_ = bytecode_iterator_.current_offset();
bytecode_iterator_.Advance();
}
......@@ -38,20 +39,14 @@ class V8_EXPORT_PRIVATE BytecodeOffsetIterator {
while (current_bytecode_offset() < bytecode_offset) {
Advance();
}
DCHECK(bytecode_offset == current_bytecode_offset() ||
// If kFunctionEntryBytecodeOffset is passed as bytecode_ofset, we
// want to return the PC for the first real bytecode.
bytecode_offset == kFunctionEntryBytecodeOffset);
DCHECK_EQ(bytecode_offset, current_bytecode_offset());
}
inline void AdvanceToPCOffset(Address pc_offset) {
while (current_pc_end_offset() < pc_offset) {
Advance();
}
// pc could be inside the baseline prologue, wich means we didn't record any
// position for it.
DCHECK(pc_offset > current_pc_start_offset() ||
current_bytecode_offset() == 0);
DCHECK_GT(pc_offset, current_pc_start_offset());
DCHECK_LE(pc_offset, current_pc_end_offset());
}
......@@ -68,7 +63,7 @@ class V8_EXPORT_PRIVATE BytecodeOffsetIterator {
}
inline int current_bytecode_offset() const {
return bytecode_iterator_.current_offset();
return current_bytecode_offset_;
}
static void UpdatePointersCallback(void* iterator) {
......@@ -89,6 +84,7 @@ class V8_EXPORT_PRIVATE BytecodeOffsetIterator {
int current_index_;
Address current_pc_start_offset_;
Address current_pc_end_offset_;
int current_bytecode_offset_;
BytecodeArray bytecode_handle_storage_;
interpreter::BytecodeArrayIterator bytecode_iterator_;
LocalHeap* local_heap_;
......
......@@ -1851,6 +1851,11 @@ void Shell::TestVerifySourcePositions(
i_isolate);
offset_iterator = std::make_unique<i::baseline::BytecodeOffsetIterator>(
bytecode_offsets, bytecodes);
// A freshly initiated BytecodeOffsetIterator points to the prologue.
DCHECK_EQ(offset_iterator->current_pc_start_offset(), 0);
DCHECK_EQ(offset_iterator->current_bytecode_offset(),
i::kFunctionEntryBytecodeOffset);
offset_iterator->Advance();
}
while (!bytecode_iterator.done()) {
if (has_baseline) {
......
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