Commit 4113b70d authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[cleanup] Add named constant SafepointEntry::kNoTrampolinePC

.. instead of implicitly using -1 as a marker in a few spots.

Bug: chromium:1161357
Change-Id: Icfb9a2b81dbda844c8405c57454d63ae89dfe4f9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2606336
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72037}
parent ec598bbe
......@@ -21,7 +21,8 @@ class WasmCode;
class SafepointEntry {
public:
SafepointEntry() : deopt_index_(0), bits_(nullptr), trampoline_pc_(-1) {}
SafepointEntry()
: deopt_index_(0), bits_(nullptr), trampoline_pc_(kNoTrampolinePC) {}
SafepointEntry(unsigned deopt_index, uint8_t* bits, int trampoline_pc)
: deopt_index_(deopt_index), bits_(bits), trampoline_pc_(trampoline_pc) {
......@@ -42,6 +43,7 @@ class SafepointEntry {
int trampoline_pc() { return trampoline_pc_; }
static const unsigned kNoDeoptIndex = kMaxUInt32;
static constexpr int kNoTrampolinePC = -1;
int deoptimization_index() const {
DCHECK(is_valid() && has_deoptimization_index());
......@@ -96,8 +98,9 @@ class SafepointTable {
unsigned deopt_index =
base::Memory<uint32_t>(GetEncodedInfoLocation(index));
uint8_t* bits = &base::Memory<uint8_t>(entries() + (index * entry_size_));
int trampoline_pc =
has_deopt_ ? base::Memory<int>(GetTrampolineLocation(index)) : -1;
int trampoline_pc = has_deopt_
? base::Memory<int>(GetTrampolineLocation(index))
: SafepointEntry::kNoTrampolinePC;
return SafepointEntry(deopt_index, bits, trampoline_pc);
}
......
......@@ -267,6 +267,7 @@ class ActivationsFinder : public ThreadVisitor {
SafepointEntry safepoint = code.GetSafepointEntry(it.frame()->pc());
int trampoline_pc = safepoint.trampoline_pc();
DCHECK_IMPLIES(code == topmost_, safe_to_deopt_);
STATIC_ASSERT(SafepointEntry::kNoTrampolinePC == -1);
CHECK_GE(trampoline_pc, 0);
// Replace the current pc on the stack with the trampoline.
// TODO(v8:10026): avoid replacing a signed pointer.
......
......@@ -413,7 +413,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
table.PrintEntry(i, os);
os << " (sp -> fp)";
SafepointEntry entry = table.GetEntry(i);
if (entry.trampoline_pc() != -1) {
if (entry.trampoline_pc() != SafepointEntry::kNoTrampolinePC) {
os << " trampoline: " << std::hex << entry.trampoline_pc() << std::dec;
}
if (entry.has_deoptimization_index()) {
......
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