Commit 7814343b authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[codegen] Use kNoDeoptIndex consistently

This removes the redundant {Safepoint::kNoDeoptimizationIndex}
definition, and uses {SafepointEntry::kNoDeoptIndex} consistently.

R=jkummerow@chromium.org

Bug: v8:12401
Change-Id: I4e12862d96a2b97245f8dde62243013425e53ff1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3289159Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77979}
parent e8b76952
......@@ -143,7 +143,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
if (info.register_indexes) {
// We emit the register indexes in the same bits as the deopt_index.
// Register indexes and deopt_index should not exist at the same time.
DCHECK_EQ(info.deopt_index, Safepoint::kNoDeoptimizationIndex);
DCHECK_EQ(info.deopt_index, SafepointEntry::kNoDeoptIndex);
assembler->dd(info.register_indexes);
} else {
assembler->dd(info.deopt_index);
......
......@@ -22,6 +22,9 @@ class WasmCode;
class SafepointEntry {
public:
static constexpr int kNoDeoptIndex = -1;
static constexpr int kNoTrampolinePC = -1;
SafepointEntry() = default;
SafepointEntry(int deopt_index, uint8_t* bits, uint8_t* bits_end,
......@@ -40,16 +43,13 @@ class SafepointEntry {
}
void Reset() {
deopt_index_ = 0;
deopt_index_ = kNoDeoptIndex;
bits_ = nullptr;
bits_end_ = nullptr;
}
int trampoline_pc() { return trampoline_pc_; }
static constexpr int kNoDeoptIndex = -1;
static constexpr int kNoTrampolinePC = -1;
int deoptimization_index() const {
DCHECK(is_valid() && has_deoptimization_index());
return deopt_index_;
......@@ -84,7 +84,7 @@ class SafepointEntry {
size_t entry_size() const { return bits_end_ - bits_; }
private:
int deopt_index_ = 0;
int deopt_index_ = kNoDeoptIndex;
uint8_t* bits_ = nullptr;
uint8_t* bits_end_ = nullptr;
int trampoline_pc_ = kNoTrampolinePC;
......@@ -191,13 +191,11 @@ class SafepointTable {
class Safepoint {
public:
static const int kNoDeoptimizationIndex = SafepointEntry::kNoDeoptIndex;
void DefinePointerSlot(int index) { stack_indexes_->push_back(index); }
void DefineRegister(int reg_code) {
// Make sure the recorded index is always less than 31, so that we don't
// generate {kNoDeoptimizationIndex} by accident.
// generate {kNoDeoptIndex} by accident.
DCHECK_LT(reg_code, 31);
*register_indexes_ |= 1u << reg_code;
}
......@@ -247,8 +245,8 @@ class SafepointTableBuilder {
uint32_t register_indexes;
DeoptimizationInfo(Zone* zone, int pc)
: pc(pc),
deopt_index(Safepoint::kNoDeoptimizationIndex),
trampoline(-1),
deopt_index(SafepointEntry::kNoDeoptIndex),
trampoline(SafepointEntry::kNoTrampolinePC),
stack_indexes(zone->New<ZoneChunkList<int>>(
zone, ZoneChunkList<int>::StartMode::kSmall)),
register_indexes(0) {}
......
......@@ -1279,11 +1279,11 @@ Address TranslatedState::DecompressIfNeeded(intptr_t value) {
TranslatedState::TranslatedState(const JavaScriptFrame* frame)
: purpose_(kFrameInspection) {
int deopt_index = Safepoint::kNoDeoptimizationIndex;
int deopt_index = SafepointEntry::kNoDeoptIndex;
DeoptimizationData data =
static_cast<const OptimizedFrame*>(frame)->GetDeoptimizationData(
&deopt_index);
DCHECK(!data.is_null() && deopt_index != Safepoint::kNoDeoptimizationIndex);
DCHECK(!data.is_null() && deopt_index != SafepointEntry::kNoDeoptIndex);
TranslationArrayIterator it(data.TranslationByteArray(),
data.TranslationIndex(deopt_index).value());
int actual_argc = frame->GetActualArgumentCount();
......
......@@ -1642,9 +1642,9 @@ void OptimizedFrame::Summarize(std::vector<FrameSummary>* frames) const {
return JavaScriptFrame::Summarize(frames);
}
int deopt_index = Safepoint::kNoDeoptimizationIndex;
int deopt_index = SafepointEntry::kNoDeoptIndex;
DeoptimizationData const data = GetDeoptimizationData(&deopt_index);
if (deopt_index == Safepoint::kNoDeoptimizationIndex) {
if (deopt_index == SafepointEntry::kNoDeoptIndex) {
CHECK(data.is_null());
FATAL("Missing deoptimization information for OptimizedFrame::Summarize.");
}
......@@ -1754,7 +1754,7 @@ DeoptimizationData OptimizedFrame::GetDeoptimizationData(
*deopt_index = safepoint_entry.deoptimization_index();
return DeoptimizationData::cast(code.deoptimization_data());
}
*deopt_index = Safepoint::kNoDeoptimizationIndex;
*deopt_index = SafepointEntry::kNoDeoptIndex;
return DeoptimizationData();
}
......@@ -1771,10 +1771,10 @@ void OptimizedFrame::GetFunctions(
}
DisallowGarbageCollection no_gc;
int deopt_index = Safepoint::kNoDeoptimizationIndex;
int deopt_index = SafepointEntry::kNoDeoptIndex;
DeoptimizationData const data = GetDeoptimizationData(&deopt_index);
DCHECK(!data.is_null());
DCHECK_NE(Safepoint::kNoDeoptimizationIndex, deopt_index);
DCHECK_NE(SafepointEntry::kNoDeoptIndex, deopt_index);
DeoptimizationLiteralArray const literal_array = data.LiteralArray();
TranslationArrayIterator it(data.TranslationByteArray(),
......
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