41 bool SafepointEntry::HasRegisters()
const {
45 for (
int i = 0; i < num_reg_bytes; i++) {
46 if (bits_[i] != SafepointTable::kNoRegisters)
return true;
52 bool SafepointEntry::HasRegisterAt(
int reg_index)
const {
57 return (bits_[byte_index] & (1 << bit_index)) != 0;
61 SafepointTable::SafepointTable(Code*
code) {
62 ASSERT(code->is_crankshafted());
64 Address header = code->instruction_start() + code->safepoint_table_offset();
67 pc_and_deoptimization_indexes_ = header + kHeaderSize;
68 entries_ = pc_and_deoptimization_indexes_ +
69 (length_ * kPcAndDeoptimizationIndexSize);
71 STATIC_ASSERT(SafepointEntry::DeoptimizationIndexField::kMax ==
72 Safepoint::kNoDeoptimizationIndex);
76 SafepointEntry SafepointTable::FindEntry(
Address pc)
const {
77 unsigned pc_offset =
static_cast<unsigned>(pc - code_->instruction_start());
78 for (
unsigned i = 0; i < length(); i++) {
80 if (GetPcOffset(i) == pc_offset)
return GetEntry(i);
82 return SafepointEntry();
86 void SafepointTable::PrintEntry(
unsigned index, FILE* out)
const {
88 SafepointEntry entry = GetEntry(index);
89 uint8_t* bits = entry.bits();
92 if (entry_size_ > 0) {
95 int last = entry_size_ - 1;
96 for (
int i = first; i < last; i++) PrintBits(out, bits[i],
kBitsPerByte);
97 int last_bits = code_->stack_slots() - ((last - first) *
kBitsPerByte);
98 PrintBits(out, bits[last], last_bits);
101 if (!entry.HasRegisters())
return;
103 if (entry.HasRegisterAt(j)) {
111 void SafepointTable::PrintBits(FILE* out, uint8_t
byte,
int digits) {
113 for (
int i = 0; i < digits; i++) {
114 PrintF(out,
"%c", ((byte & (1 << i)) == 0) ?
'0' :
'1');
119 void Safepoint::DefinePointerRegister(Register reg, Zone* zone) {
120 registers_->Add(reg.code(), zone);
124 Safepoint SafepointTableBuilder::DefineSafepoint(
125 Assembler* assembler,
126 Safepoint::Kind kind,
128 Safepoint::DeoptMode deopt_mode) {
130 DeoptimizationInfo
info;
131 info.pc = assembler->pc_offset();
132 info.arguments = arguments;
133 info.has_doubles = (kind & Safepoint::kWithDoubles);
134 deoptimization_info_.Add(info, zone_);
135 deopt_index_list_.Add(Safepoint::kNoDeoptimizationIndex, zone_);
136 if (deopt_mode == Safepoint::kNoLazyDeopt) {
137 last_lazy_safepoint_ = deopt_index_list_.length();
139 indexes_.Add(
new(zone_) ZoneList<int>(8, zone_), zone_);
140 registers_.Add((kind & Safepoint::kWithRegisters)
141 ?
new(zone_) ZoneList<int>(4, zone_)
144 return Safepoint(indexes_.last(), registers_.last());
148 void SafepointTableBuilder::RecordLazyDeoptimizationIndex(
int index) {
149 while (last_lazy_safepoint_ < deopt_index_list_.length()) {
150 deopt_index_list_[last_lazy_safepoint_++] = index;
154 unsigned SafepointTableBuilder::GetCodeOffset()
const {
160 void SafepointTableBuilder::Emit(Assembler* assembler,
int bits_per_entry) {
163 assembler->RecordComment(
";;; Safepoint table.");
164 offset_ = assembler->pc_offset();
170 int bytes_per_entry =
174 int length = deoptimization_info_.length();
175 assembler->dd(length);
176 assembler->dd(bytes_per_entry);
179 for (
int i = 0; i < length; i++) {
180 assembler->dd(deoptimization_info_[i].pc);
181 assembler->dd(EncodeExceptPC(deoptimization_info_[i],
182 deopt_index_list_[i]));
186 ZoneList<uint8_t> bits(bytes_per_entry, zone_);
187 for (
int i = 0; i < length; i++) {
188 ZoneList<int>* indexes = indexes_[i];
189 ZoneList<int>* registers = registers_[i];
191 bits.AddBlock(0, bytes_per_entry, zone_);
195 if (registers == NULL) {
197 for (
int j = 0; j < num_reg_bytes; j++) {
198 bits[j] = SafepointTable::kNoRegisters;
201 for (
int j = 0; j < registers->length(); j++) {
202 int index = registers->at(j);
203 ASSERT(index >= 0 && index < kNumSafepointRegisters);
206 bits[byte_index] |= (1 << bit_index);
211 for (
int j = 0; j < indexes->length(); j++) {
212 int index = bits_per_entry - 1 - indexes->at(j);
215 bits[byte_index] |= (1
U << bit_index);
219 for (
int k = 0; k < bytes_per_entry; k++) {
220 assembler->db(bits[k]);
227 uint32_t SafepointTableBuilder::EncodeExceptPC(
const DeoptimizationInfo& info,
229 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index);
230 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments);
231 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles);
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void PrintF(const char *format,...)
const int kBitsPerByteLog2
#define ASSERT(condition)
virtual const char * NameOfCPURegister(int reg) const
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
bool IsAligned(T value, U alignment)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
T RoundUp(T x, intptr_t m)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
const int kNumSafepointRegisters
static uint32_t & uint32_at(Address addr)