Further improve deopt reason output.

* Make the detailed deopt reason mandatory on x64, other platforms
  will follow in separate CLs.

* Extracted and improved jump table entry sharing logic: When
  --trace-deopt is on, we get separate entries for different deopt
  reasons. This enables us to distinguish the several reasons single
  instructions can have.

* Don't emit superfluous jump table comments: The bailout ID is still
  visible, and the jump table entry number is not interesting (but
  easy to determine if really needed).

* Unify the internal name of the jump table member across platforms.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/595513002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24123 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1adad897
......@@ -319,29 +319,25 @@ bool LCodeGen::GenerateJumpTable() {
// Each entry in the jump table generates one instruction and inlines one
// 32bit data after it.
if (!is_int24((masm()->pc_offset() / Assembler::kInstrSize) +
deopt_jump_table_.length() * 7)) {
jump_table_.length() * 7)) {
Abort(kGeneratedCodeIsTooLarge);
}
if (deopt_jump_table_.length() > 0) {
if (jump_table_.length() > 0) {
Label needs_frame, call_deopt_entry;
Comment(";;; -------------------- Jump table --------------------");
Address base = deopt_jump_table_[0].address;
Address base = jump_table_[0].address;
Register entry_offset = scratch0();
int length = deopt_jump_table_.length();
int length = jump_table_.length();
for (int i = 0; i < length; i++) {
Deoptimizer::JumpTableEntry* table_entry = &deopt_jump_table_[i];
Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
__ bind(&table_entry->label);
Deoptimizer::BailoutType type = table_entry->bailout_type;
DCHECK(type == deopt_jump_table_[0].bailout_type);
DCHECK_EQ(jump_table_[0].bailout_type, table_entry->bailout_type);
Address entry = table_entry->address;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
DeoptComment(table_entry->reason);
// Second-level deopt table entries are contiguous and small, so instead
......@@ -909,17 +905,15 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
DeoptComment(reason);
__ Call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (deopt_jump_table_.is_empty() ||
(deopt_jump_table_.last().address != entry) ||
(deopt_jump_table_.last().bailout_type != bailout_type) ||
(deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
deopt_jump_table_.Add(table_entry, zone());
if (jump_table_.is_empty() ||
!table_entry.IsEquivalentTo(jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
__ b(condition, &deopt_jump_table_.last().label);
__ b(condition, &jump_table_.last().label);
}
}
......
......@@ -26,7 +26,7 @@ class LCodeGen: public LCodeGenBase {
LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
: LCodeGenBase(chunk, assembler, info),
deoptimizations_(4, info->zone()),
deopt_jump_table_(4, info->zone()),
jump_table_(4, info->zone()),
deoptimization_literals_(8, info->zone()),
inlined_function_count_(0),
scope_(info->scope()),
......@@ -332,7 +332,7 @@ class LCodeGen: public LCodeGenBase {
void EmitVectorLoadICRegisters(T* instr);
ZoneList<LEnvironment*> deoptimizations_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_;
int inlined_function_count_;
Scope* const scope_;
......
......@@ -839,11 +839,7 @@ bool LCodeGen::GenerateJumpTable() {
Deoptimizer::JumpTableEntry* table_entry = jump_table_[i];
__ Bind(&table_entry->label);
Deoptimizer::BailoutType type = table_entry->bailout_type;
Address entry = table_entry->address;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
DeoptComment(table_entry->reason);
// Second-level deopt table entries are contiguous and small, so instead
......@@ -1053,14 +1049,13 @@ void LCodeGen::DeoptimizeBranch(
DeoptComment(reason);
__ Call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
Deoptimizer::JumpTableEntry* table_entry =
new (zone()) Deoptimizer::JumpTableEntry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (jump_table_.is_empty() || (jump_table_.last()->address != entry) ||
(jump_table_.last()->bailout_type != bailout_type) ||
(jump_table_.last()->needs_frame != !frame_is_built_)) {
Deoptimizer::JumpTableEntry* table_entry =
new (zone()) Deoptimizer::JumpTableEntry(entry, reason, bailout_type,
!frame_is_built_);
if (jump_table_.is_empty() ||
!table_entry->IsEquivalentTo(*jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
__ B(&jump_table_.last()->label, branch_type, reg, bit);
......
......@@ -104,6 +104,15 @@ class Deoptimizer : public Malloced {
struct Reason {
Reason(int r, const char* m, const char* d)
: raw_position(r), mnemonic(m), detail(d) {}
bool operator==(const Reason& other) const {
return raw_position == other.raw_position &&
CStringEquals(mnemonic, other.mnemonic) &&
CStringEquals(detail, other.detail);
}
bool operator!=(const Reason& other) const { return !(*this == other); }
int raw_position;
const char* mnemonic;
const char* detail;
......@@ -117,6 +126,13 @@ class Deoptimizer : public Malloced {
reason(the_reason),
bailout_type(type),
needs_frame(frame) {}
bool IsEquivalentTo(const JumpTableEntry& other) const {
return address == other.address && bailout_type == other.bailout_type &&
needs_frame == other.needs_frame &&
(!FLAG_trace_deopt || reason == other.reason);
}
Label label;
Address address;
Reason reason;
......
......@@ -386,10 +386,6 @@ bool LCodeGen::GenerateJumpTable() {
Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
__ bind(&table_entry->label);
Address entry = table_entry->address;
Deoptimizer::BailoutType type = table_entry->bailout_type;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
DeoptComment(table_entry->reason);
if (table_entry->needs_frame) {
DCHECK(!info()->saves_caller_doubles());
......@@ -874,14 +870,12 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
DeoptComment(reason);
__ call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (jump_table_.is_empty() ||
jump_table_.last().address != entry ||
jump_table_.last().needs_frame != !frame_is_built_ ||
jump_table_.last().bailout_type != bailout_type) {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
!table_entry.IsEquivalentTo(jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
if (cc == no_condition) {
......
......@@ -324,25 +324,21 @@ bool LCodeGen::GenerateDeferredCode() {
bool LCodeGen::GenerateJumpTable() {
if (deopt_jump_table_.length() > 0) {
if (jump_table_.length() > 0) {
Label needs_frame, call_deopt_entry;
Comment(";;; -------------------- Jump table --------------------");
Address base = deopt_jump_table_[0].address;
Address base = jump_table_[0].address;
Register entry_offset = t9;
int length = deopt_jump_table_.length();
int length = jump_table_.length();
for (int i = 0; i < length; i++) {
Deoptimizer::JumpTableEntry* table_entry = &deopt_jump_table_[i];
Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
__ bind(&table_entry->label);
Deoptimizer::BailoutType type = table_entry->bailout_type;
DCHECK(type == deopt_jump_table_[0].bailout_type);
DCHECK(table_entry->bailout_type == jump_table_[0].bailout_type);
Address entry = table_entry->address;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
DeoptComment(table_entry->reason);
// Second-level deopt table entries are contiguous and small, so instead
......@@ -872,17 +868,15 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
DeoptComment(reason);
__ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (deopt_jump_table_.is_empty() ||
(deopt_jump_table_.last().address != entry) ||
(deopt_jump_table_.last().bailout_type != bailout_type) ||
(deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
deopt_jump_table_.Add(table_entry, zone());
if (jump_table_.is_empty() ||
!table_entry.IsEquivalentTo(jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
__ Branch(&deopt_jump_table_.last().label, condition, src1, src2);
__ Branch(&jump_table_.last().label, condition, src1, src2);
}
}
......
......@@ -25,7 +25,7 @@ class LCodeGen: public LCodeGenBase {
LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
: LCodeGenBase(chunk, assembler, info),
deoptimizations_(4, info->zone()),
deopt_jump_table_(4, info->zone()),
jump_table_(4, info->zone()),
deoptimization_literals_(8, info->zone()),
inlined_function_count_(0),
scope_(info->scope()),
......@@ -364,7 +364,7 @@ class LCodeGen: public LCodeGenBase {
void EmitVectorLoadICRegisters(T* instr);
ZoneList<LEnvironment*> deoptimizations_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_;
int inlined_function_count_;
Scope* const scope_;
......
......@@ -300,21 +300,17 @@ bool LCodeGen::GenerateDeferredCode() {
bool LCodeGen::GenerateJumpTable() {
if (deopt_jump_table_.length() > 0) {
if (jump_table_.length() > 0) {
Comment(";;; -------------------- Jump table --------------------");
}
Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_);
Label table_start;
__ bind(&table_start);
Label needs_frame;
for (int i = 0; i < deopt_jump_table_.length(); i++) {
Deoptimizer::JumpTableEntry* table_entry = &deopt_jump_table_[i];
for (int i = 0; i < jump_table_.length(); i++) {
Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
__ bind(&table_entry->label);
Address entry = table_entry->address;
Deoptimizer::BailoutType type = table_entry->bailout_type;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
DeoptComment(table_entry->reason);
__ li(t9, Operand(ExternalReference::ForDeoptEntry(entry)));
if (table_entry->needs_frame) {
......@@ -822,17 +818,15 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
DeoptComment(reason);
__ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (deopt_jump_table_.is_empty() ||
(deopt_jump_table_.last().address != entry) ||
(deopt_jump_table_.last().bailout_type != bailout_type) ||
(deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
deopt_jump_table_.Add(table_entry, zone());
if (jump_table_.is_empty() ||
!table_entry.IsEquivalentTo(jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
__ Branch(&deopt_jump_table_.last().label, condition, src1, src2);
__ Branch(&jump_table_.last().label, condition, src1, src2);
}
}
......
......@@ -25,7 +25,7 @@ class LCodeGen: public LCodeGenBase {
LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
: LCodeGenBase(chunk, assembler, info),
deoptimizations_(4, info->zone()),
deopt_jump_table_(4, info->zone()),
jump_table_(4, info->zone()),
deoptimization_literals_(8, info->zone()),
inlined_function_count_(0),
scope_(info->scope()),
......@@ -365,7 +365,7 @@ class LCodeGen: public LCodeGenBase {
void EmitVectorLoadICRegisters(T* instr);
ZoneList<LEnvironment*> deoptimizations_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_;
int inlined_function_count_;
Scope* const scope_;
......
......@@ -26,6 +26,13 @@ namespace internal {
// ----------------------------------------------------------------------------
// General helper functions
// Same as strcmp, but can handle NULL arguments.
inline bool CStringEquals(const char* s1, const char* s2) {
return (s1 == s2) || (s1 != NULL && s2 != NULL && strcmp(s1, s2) == 0);
}
// X must be a power of 2. Returns the number of trailing zeros.
inline int WhichPowerOf2(uint32_t x) {
DCHECK(base::bits::IsPowerOfTwo32(x));
......
This diff is collapsed.
......@@ -208,8 +208,7 @@ class LCodeGen: public LCodeGenBase {
Safepoint::DeoptMode mode);
void DeoptimizeIf(Condition cc, LInstruction* instr, const char* detail,
Deoptimizer::BailoutType bailout_type);
void DeoptimizeIf(Condition cc, LInstruction* instr,
const char* detail = NULL);
void DeoptimizeIf(Condition cc, LInstruction* instr, const char* detail);
bool DeoptEveryNTimes() {
return FLAG_deopt_every_n_times != 0 && !info()->IsStub();
......
......@@ -1155,14 +1155,12 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
DeoptComment(reason);
__ call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
// We often have several deopts to the same entry, reuse the last
// jump entry if this is the case.
if (jump_table_.is_empty() ||
jump_table_.last().address != entry ||
jump_table_.last().needs_frame != !frame_is_built_ ||
jump_table_.last().bailout_type != bailout_type) {
Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type,
!frame_is_built_);
!table_entry.IsEquivalentTo(jump_table_.last())) {
jump_table_.Add(table_entry, zone());
}
if (cc == no_condition) {
......
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