Commit f09e3064 authored by palfia@homejinni.com's avatar palfia@homejinni.com

MIPS: Ensure that soft-deopts don't count against opt_count

Port r14658 (12c49bd)

This makes sure that Crankshaft doesn't disable optimization to early on hot functions that still contain unexecuted code without type information.

BUG=

Review URL: https://codereview.chromium.org/15005008
Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14672 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 85f4ae36
......@@ -1378,6 +1378,11 @@ void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) {
}
void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) {
Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
}
void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) {
Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
}
......
......@@ -531,9 +531,14 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
// Set the continuation for the topmost frame.
if (is_topmost && bailout_type_ != DEBUGGER) {
Builtins* builtins = isolate_->builtins();
Code* continuation = (bailout_type_ == EAGER)
? builtins->builtin(Builtins::kNotifyDeoptimized)
: builtins->builtin(Builtins::kNotifyLazyDeoptimized);
Code* continuation = builtins->builtin(Builtins::kNotifyDeoptimized);
if (bailout_type_ == LAZY) {
continuation = builtins->builtin(Builtins::kNotifyLazyDeoptimized);
} else if (bailout_type_ == SOFT) {
continuation = builtins->builtin(Builtins::kNotifySoftDeoptimized);
} else {
ASSERT(bailout_type_ == EAGER);
}
output_frame->SetContinuation(
reinterpret_cast<uint32_t>(continuation->entry()));
}
......@@ -627,7 +632,7 @@ void Deoptimizer::EntryGenerator::Generate() {
// Get the address of the location in the code object if possible (a3) (return
// address for lazy deoptimization) and compute the fp-to-sp delta in
// register t0.
if (type() == EAGER) {
if (type() == EAGER || type() == SOFT) {
__ mov(a3, zero_reg);
// Correct one word for bailout id.
__ Addu(t0, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize)));
......@@ -690,7 +695,7 @@ void Deoptimizer::EntryGenerator::Generate() {
// Remove the bailout id, eventually return address, and the saved registers
// from the stack.
if (type() == EAGER || type() == OSR) {
if (type() == EAGER || type() == SOFT || type() == OSR) {
__ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize)));
} else {
__ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize)));
......@@ -807,7 +812,7 @@ void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
for (int i = 0; i < count(); i++) {
Label start;
__ bind(&start);
if (type() != EAGER) {
if (type() != EAGER && type() != SOFT) {
// Emulate ia32 like call by pushing return address to stack.
__ addiu(sp, sp, -2 * kPointerSize);
__ sw(ra, MemOperand(sp, 1 * kPointerSize));
......
......@@ -350,9 +350,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
for (int i = 0; i < deopt_jump_table_.length(); i++) {
__ bind(&deopt_jump_table_[i].label);
Address entry = deopt_jump_table_[i].address;
bool is_lazy_deopt = deopt_jump_table_[i].is_lazy_deopt;
Deoptimizer::BailoutType type =
is_lazy_deopt ? Deoptimizer::LAZY : Deoptimizer::EAGER;
Deoptimizer::BailoutType type = deopt_jump_table_[i].bailout_type;
int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
if (id == Deoptimizer::kNotDeoptimizationEntry) {
Comment(";;; jump table entry %d.", i);
......@@ -361,7 +359,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
}
__ li(t9, Operand(ExternalReference::ForDeoptEntry(entry)));
if (deopt_jump_table_[i].needs_frame) {
if (is_lazy_deopt) {
if (type == Deoptimizer::LAZY) {
if (needs_frame_is_call.is_bound()) {
__ Branch(&needs_frame_is_call);
} else {
......@@ -393,7 +391,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
}
}
} else {
if (is_lazy_deopt) {
if (type == Deoptimizer::LAZY) {
__ Call(t9);
} else {
__ Jump(t9);
......@@ -805,15 +803,13 @@ void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment,
void LCodeGen::DeoptimizeIf(Condition cc,
LEnvironment* environment,
Deoptimizer::BailoutType bailout_type,
Register src1,
const Operand& src2) {
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
ASSERT(environment->HasBeenRegistered());
int id = environment->deoptimization_index();
ASSERT(info()->IsOptimizing() || info()->IsStub());
Deoptimizer::BailoutType bailout_type = info()->IsStub()
? Deoptimizer::LAZY
: Deoptimizer::EAGER;
Address entry =
Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type);
if (entry == NULL) {
......@@ -851,9 +847,11 @@ void LCodeGen::DeoptimizeIf(Condition cc,
// jump entry if this is the case.
if (deopt_jump_table_.is_empty() ||
(deopt_jump_table_.last().address != entry) ||
(deopt_jump_table_.last().is_lazy_deopt != needs_lazy_deopt) ||
(deopt_jump_table_.last().bailout_type != bailout_type) ||
(deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
JumpTableEntry table_entry(entry, !frame_is_built_, needs_lazy_deopt);
Deoptimizer::JumpTableEntry table_entry(entry,
bailout_type,
!frame_is_built_);
deopt_jump_table_.Add(table_entry, zone());
}
__ Branch(&deopt_jump_table_.last().label, cc, src1, src2);
......@@ -861,6 +859,25 @@ void LCodeGen::DeoptimizeIf(Condition cc,
}
void LCodeGen::DeoptimizeIf(Condition cc,
LEnvironment* environment,
Register src1,
const Operand& src2) {
Deoptimizer::BailoutType bailout_type = info()->IsStub()
? Deoptimizer::LAZY
: Deoptimizer::EAGER;
DeoptimizeIf(cc, environment, bailout_type, src1, src2);
}
void LCodeGen::SoftDeoptimize(LEnvironment* environment,
Register src1,
const Operand& src2) {
ASSERT(!info()->IsStub());
DeoptimizeIf(al, environment, Deoptimizer::SOFT, src1, src2);
}
void LCodeGen::RegisterDependentCodeForEmbeddedMaps(Handle<Code> code) {
ZoneList<Handle<Map> > maps(1, zone());
int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
......@@ -5435,7 +5452,11 @@ void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
void LCodeGen::DoDeoptimize(LDeoptimize* instr) {
DeoptimizeIf(al, instr->environment(), zero_reg, Operand(zero_reg));
if (instr->hydrogen_value()->IsSoftDeoptimize()) {
SoftDeoptimize(instr->environment(), zero_reg, Operand(zero_reg));
} else {
DeoptimizeIf(al, instr->environment(), zero_reg, Operand(zero_reg));
}
}
......
......@@ -283,8 +283,16 @@ class LCodeGen BASE_EMBEDDED {
Safepoint::DeoptMode mode);
void DeoptimizeIf(Condition cc,
LEnvironment* environment,
Deoptimizer::BailoutType bailout_type,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void DeoptimizeIf(Condition cc,
LEnvironment* environment,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void SoftDeoptimize(LEnvironment* environment,
Register src1 = zero_reg,
const Operand& src2 = Operand(zero_reg));
void AddToTranslation(Translation* translation,
LOperand* op,
......@@ -385,18 +393,6 @@ class LCodeGen BASE_EMBEDDED {
int* offset,
AllocationSiteMode mode);
struct JumpTableEntry {
inline JumpTableEntry(Address entry, bool frame, bool is_lazy)
: label(),
address(entry),
needs_frame(frame),
is_lazy_deopt(is_lazy) { }
Label label;
Address address;
bool needs_frame;
bool is_lazy_deopt;
};
void EnsureSpaceForLazyDeopt();
void DoLoadKeyedExternalArray(LLoadKeyed* instr);
void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr);
......@@ -414,7 +410,7 @@ class LCodeGen BASE_EMBEDDED {
int current_instruction_;
const ZoneList<LInstruction*>* instructions_;
ZoneList<LEnvironment*> deoptimizations_;
ZoneList<JumpTableEntry> deopt_jump_table_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_;
ZoneList<Handle<Map> > prototype_maps_;
ZoneList<Handle<Map> > transition_maps_;
......
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