5 #ifndef V8_SAFEPOINT_TABLE_H_ 6 #define V8_SAFEPOINT_TABLE_H_ 8 #include "src/allocation.h" 9 #include "src/assert-scope.h" 10 #include "src/utils.h" 11 #include "src/v8memory.h" 12 #include "src/zone/zone-chunk-list.h" 13 #include "src/zone/zone.h" 25 : info_(info), bits_(bits), trampoline_pc_(trampoline_pc) {
29 bool is_valid()
const {
return bits_ !=
nullptr; }
32 return info_ == other.info_ && bits_ == other.bits_;
40 int deoptimization_index()
const {
42 return DeoptimizationIndexField::decode(info_);
45 int trampoline_pc() {
return trampoline_pc_; }
47 void set_trampoline_pc(
int trampoline_pc) { trampoline_pc_ = trampoline_pc; }
49 static const int kArgumentsFieldBits = 3;
50 static const int kSaveDoublesFieldBits = 1;
51 static const int kDeoptIndexBits =
52 32 - kArgumentsFieldBits - kSaveDoublesFieldBits;
55 public BitField<int, 0, kDeoptIndexBits> {};
59 kArgumentsFieldBits> {};
62 kDeoptIndexBits + kArgumentsFieldBits,
63 kSaveDoublesFieldBits> { };
65 int argument_count()
const {
67 return ArgumentsField::decode(info_);
70 bool has_doubles()
const {
72 return SaveDoublesField::decode(info_);
80 bool HasRegisters()
const;
81 bool HasRegisterAt(
int reg_index)
const;
94 size_t safepoint_table_offset,
uint32_t stack_slots,
95 bool has_deopt =
false);
98 return kHeaderSize + (length_ * (kFixedEntrySize + entry_size_));
100 unsigned length()
const {
return length_; }
101 unsigned entry_size()
const {
return entry_size_; }
103 unsigned GetPcOffset(
unsigned index)
const {
104 DCHECK(index < length_);
105 return Memory<uint32_t>(GetPcOffsetLocation(index));
108 int GetTrampolinePcOffset(
unsigned index)
const {
109 DCHECK(index < length_);
110 return Memory<int>(GetTrampolineLocation(index));
113 unsigned find_return_pc(
unsigned pc_offset);
116 DCHECK(index < length_);
117 unsigned info = Memory<uint32_t>(GetInfoLocation(index));
118 uint8_t* bits = &Memory<uint8_t>(entries_ + (index * entry_size_));
120 has_deopt_ ? Memory<int>(GetTrampolineLocation(index)) : -1;
127 void PrintEntry(
unsigned index, std::ostream& os)
const;
130 static const uint8_t kNoRegisters = 0xFF;
133 static const int kLengthOffset = 0;
134 static const int kEntrySizeOffset = kLengthOffset + kIntSize;
135 static const int kHeaderSize = kEntrySizeOffset + kIntSize;
136 static const int kPcOffset = 0;
137 static const int kDeoptimizationIndexOffset = kPcOffset + kIntSize;
138 static const int kTrampolinePcOffset = kDeoptimizationIndexOffset + kIntSize;
139 static const int kFixedEntrySize = kTrampolinePcOffset + kIntSize;
141 Address GetPcOffsetLocation(
unsigned index)
const {
142 return pc_and_deoptimization_indexes_ + (index * kFixedEntrySize);
146 Address GetInfoLocation(
unsigned index)
const {
147 return GetPcOffsetLocation(index) + kDeoptimizationIndexOffset;
150 Address GetTrampolineLocation(
unsigned index)
const {
151 return GetPcOffsetLocation(index) + kTrampolinePcOffset;
154 static void PrintBits(std::ostream& os,
155 uint8_t byte,
int digits);
157 DISALLOW_HEAP_ALLOCATION(no_allocation_);
161 unsigned entry_size_;
163 Address pc_and_deoptimization_indexes_;
177 kWithRegisters = 1 << 0,
178 kWithDoubles = 1 << 1,
179 kWithRegistersAndDoubles = kWithRegisters | kWithDoubles
187 static const int kNoDeoptimizationIndex =
188 (1 << (SafepointEntry::kDeoptIndexBits)) - 1;
190 void DefinePointerSlot(
int index) { indexes_->push_back(index); }
191 void DefinePointerRegister(
Register reg);
195 : indexes_(indexes), registers_(registers) {}
205 : deoptimization_info_(zone),
207 last_lazy_safepoint_(0),
211 unsigned GetCodeOffset()
const;
215 Safepoint::Kind kind,
217 Safepoint::DeoptMode mode);
221 void RecordLazyDeoptimizationIndex(
int index);
222 void BumpLastLazySafepointIndex() {
223 last_lazy_safepoint_ = deoptimization_info_.size();
228 void Emit(
Assembler* assembler,
int bits_per_entry);
234 int UpdateDeoptimizationInfo(
int pc,
int trampoline,
int start);
237 struct DeoptimizationInfo {
244 unsigned deopt_index;
245 DeoptimizationInfo(
Zone* zone,
unsigned pc,
unsigned arguments,
246 Safepoint::Kind kind)
248 arguments(arguments),
249 has_doubles(kind & Safepoint::kWithDoubles),
253 registers(kind & Safepoint::kWithRegisters
257 deopt_index(Safepoint::kNoDeoptimizationIndex) {}
260 uint32_t EncodeExceptPC(
const DeoptimizationInfo&);
262 bool IsIdenticalExceptForPc(
const DeoptimizationInfo&,
263 const DeoptimizationInfo&)
const;
265 void RemoveDuplicates();
271 size_t last_lazy_safepoint_;
281 #endif // V8_SAFEPOINT_TABLE_H_