Commit 7aad1d2e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Revert "Remove deprecated ShouldSelfOptimize machinery."

This reverts commit 9da92c1a because of performance regressions.

R=danno@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25467}
parent 4f1cc515
......@@ -424,9 +424,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ b(pl, &ok);
......
......@@ -413,9 +413,14 @@ void FullCodeGenerator::EmitReturnSequence() {
DCHECK(x0.Is(result_register()));
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset() + kCodeSizeMultiplier / 2;
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset() + kCodeSizeMultiplier / 2;
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ B(pl, &ok);
......
......@@ -45,6 +45,7 @@ class AstNumberingVisitor FINAL : public AstVisitor {
void IncrementNodeCount() { properties_.add_node_count(1); }
void DisableCrankshaft(BailoutReason reason) {
dont_crankshaft_reason_ = reason;
properties_.flags()->Add(kDontSelfOptimize);
}
// TODO(turbofan): Remove the dont_turbofan_reason once no nodes are
// DontTurbofanNode. That set of nodes must be kept in sync with
......@@ -52,9 +53,14 @@ class AstNumberingVisitor FINAL : public AstVisitor {
void DisableTurbofan(BailoutReason reason) {
dont_crankshaft_reason_ = reason;
dont_turbofan_reason_ = reason;
DisableSelfOptimization();
}
void DisableSelfOptimization() {
properties_.flags()->Add(kDontSelfOptimize);
}
void DisableCaching(BailoutReason reason) {
dont_crankshaft_reason_ = reason;
DisableSelfOptimization();
properties_.flags()->Add(kDontCache);
}
......@@ -297,6 +303,7 @@ void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) {
IncrementNodeCount();
DisableSelfOptimization();
node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids()));
Visit(node->body());
Visit(node->cond());
......@@ -305,6 +312,7 @@ void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) {
void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) {
IncrementNodeCount();
DisableSelfOptimization();
node->set_base_id(ReserveIdRange(WhileStatement::num_ids()));
Visit(node->cond());
Visit(node->body());
......@@ -363,6 +371,7 @@ void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) {
void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
IncrementNodeCount();
DisableSelfOptimization();
ReserveFeedbackSlots(node);
node->set_base_id(ReserveIdRange(ForInStatement::num_ids()));
Visit(node->each());
......@@ -424,6 +433,7 @@ void AstNumberingVisitor::VisitCaseClause(CaseClause* node) {
void AstNumberingVisitor::VisitForStatement(ForStatement* node) {
IncrementNodeCount();
DisableSelfOptimization();
node->set_base_id(ReserveIdRange(ForStatement::num_ids()));
if (node->init() != NULL) Visit(node->init());
if (node->cond() != NULL) Visit(node->cond());
......
......@@ -150,6 +150,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
enum AstPropertiesFlag {
kDontSelfOptimize,
kDontSoftInline,
kDontCache
};
......
......@@ -276,6 +276,18 @@ Code::Flags CompilationInfo::flags() const {
}
// Primitive functions are unlikely to be picked up by the stack-walking
// profiler, so they trigger their own optimization when they're called
// for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time.
bool CompilationInfo::ShouldSelfOptimize() {
return FLAG_crankshaft &&
!function()->flags()->Contains(kDontSelfOptimize) &&
!function()->dont_optimize() &&
function()->scope()->AllowsLazyCompilation() &&
(shared_info().is_null() || !shared_info()->optimization_disabled());
}
void CompilationInfo::PrepareForCompilation(Scope* scope) {
DCHECK(scope_ == NULL);
scope_ = scope;
......
......@@ -301,6 +301,9 @@ class CompilationInfo {
SetFlag(kDeoptimizationSupport);
}
// Determines whether or not to insert a self-optimization header.
bool ShouldSelfOptimize();
void set_deferred_handles(DeferredHandles* deferred_handles) {
DCHECK(deferred_handles_ == NULL);
deferred_handles_ = deferred_handles;
......
......@@ -406,6 +406,7 @@ DEFINE_INT(type_info_threshold, 25,
"percentage of ICs that must have type info to allow optimization")
DEFINE_INT(generic_ic_threshold, 30,
"max percentage of megamorphic/generic ICs to allow optimization")
DEFINE_INT(self_opt_count, 130, "call count before self-optimization")
DEFINE_BOOL(trace_opt_verbose, false, "extra verbose compilation tracing")
DEFINE_IMPLICATION(trace_opt_verbose, trace_opt)
......
......@@ -383,9 +383,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ j(positive, &ok, Label::kNear);
......
......@@ -411,9 +411,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ Branch(&ok, ge, a3, Operand(zero_reg));
......
......@@ -407,9 +407,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ Branch(&ok, ge, a3, Operand(zero_reg));
......
......@@ -386,9 +386,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ j(positive, &ok, Label::kNear);
......
......@@ -380,9 +380,14 @@ void FullCodeGenerator::EmitReturnSequence() {
__ CallRuntime(Runtime::kTraceExit, 1);
}
// Pretend that the exit is a backwards jump to the entry.
int distance = masm_->pc_offset();
int weight =
Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
int weight = 1;
if (info_->ShouldSelfOptimize()) {
weight = FLAG_interrupt_budget / FLAG_self_opt_count;
} else {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kCodeSizeMultiplier));
}
EmitProfilingCounterDecrement(weight);
Label ok;
__ j(positive, &ok, Label::kNear);
......
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