[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/+/3289159
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77979}
This commit is contained in:
Clemens Backes 2021-11-17 14:25:24 +01:00 committed by V8 LUCI CQ
parent e8b76952a4
commit 7814343b75
4 changed files with 16 additions and 18 deletions

View File

@ -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);

View File

@ -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) {}

View File

@ -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();

View File

@ -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(),