Classify small functions platform-dependently.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10829009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12186 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2012-07-25 13:51:29 +00:00
parent 52a7149efb
commit 2c9c94bd32
6 changed files with 23 additions and 20 deletions

View File

@ -338,8 +338,8 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
}
static const int kMaxBackEdgeWeight = 127;
static const int kBackEdgeDistanceDivisor = 142;
const int FullCodeGenerator::kMaxBackEdgeWeight = 127;
const int FullCodeGenerator::kBackEdgeDistanceUnit = 142;
void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
@ -355,7 +355,7 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
ASSERT(back_edge_target->is_bound());
int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
__ b(pl, &ok);
@ -407,7 +407,7 @@ void FullCodeGenerator::EmitReturnSequence() {
} else if (FLAG_weighted_back_edges) {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
Label ok;

View File

@ -113,6 +113,9 @@ class FullCodeGenerator: public AstVisitor {
Zone* zone() const { return zone_; }
static const int kMaxBackEdgeWeight;
static const int kBackEdgeDistanceUnit;
private:
class Breakable;
class Iteration;

View File

@ -325,8 +325,8 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
}
static const int kMaxBackEdgeWeight = 127;
static const int kBackEdgeDistanceDivisor = 100;
const int FullCodeGenerator::kMaxBackEdgeWeight = 127;
const int FullCodeGenerator::kBackEdgeDistanceUnit = 100;
void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
@ -340,7 +340,7 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
ASSERT(back_edge_target->is_bound());
int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
__ j(positive, &ok, Label::kNear);
@ -402,7 +402,7 @@ void FullCodeGenerator::EmitReturnSequence() {
} else if (FLAG_weighted_back_edges) {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
Label ok;

View File

@ -340,8 +340,8 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
}
static const int kMaxBackEdgeWeight = 127;
static const int kBackEdgeDistanceDivisor = 142;
const int FullCodeGenerator::kMaxBackEdgeWeight = 127;
const int FullCodeGenerator::kBackEdgeDistanceUnit = 142;
void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
@ -360,7 +360,7 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
ASSERT(back_edge_target->is_bound());
int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
__ slt(at, a3, zero_reg);
@ -413,7 +413,7 @@ void FullCodeGenerator::EmitReturnSequence() {
} else if (FLAG_weighted_back_edges) {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
Label ok;

View File

@ -34,6 +34,7 @@
#include "compilation-cache.h"
#include "deoptimizer.h"
#include "execution.h"
#include "full-codegen.h"
#include "global-handles.h"
#include "isolate-inl.h"
#include "mark-compact.h"
@ -81,7 +82,8 @@ STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256);
// Maximum size in bytes of generated code for a function to be optimized
// the very first time it is seen on the stack.
static const int kMaxSizeEarlyOpt = 500;
static const int kMaxSizeEarlyOpt =
5 * FullCodeGenerator::kBackEdgeDistanceUnit;
Atomic32 RuntimeProfiler::state_ = 0;
@ -317,8 +319,6 @@ void RuntimeProfiler::OptimizeNow() {
}
if (!function->IsOptimizable()) continue;
if (FLAG_watch_ic_patching) {
int ticks = shared_code->profiler_ticks();
@ -341,7 +341,7 @@ void RuntimeProfiler::OptimizeNow() {
}
}
} else if (!any_ic_changed_ &&
shared_code->instruction_size() < kMaxSizeEarlyOpt) {
shared_code->instruction_size() < kMaxSizeEarlyOpt) {
// If no IC was patched since the last tick and this function is very
// small, optimistically optimize it now.
Optimize(function, "small function");

View File

@ -321,8 +321,8 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
}
static const int kMaxBackEdgeWeight = 127;
static const int kBackEdgeDistanceDivisor = 162;
const int FullCodeGenerator::kMaxBackEdgeWeight = 127;
const int FullCodeGenerator::kBackEdgeDistanceUnit = 162;
void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
@ -336,7 +336,7 @@ void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt,
ASSERT(back_edge_target->is_bound());
int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
weight = Min(kMaxBackEdgeWeight,
Max(1, distance / kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
__ j(positive, &ok, Label::kNear);
@ -392,7 +392,7 @@ void FullCodeGenerator::EmitReturnSequence() {
} else if (FLAG_weighted_back_edges) {
int distance = masm_->pc_offset();
weight = Min(kMaxBackEdgeWeight,
Max(1, distance = kBackEdgeDistanceDivisor));
Max(1, distance / kBackEdgeDistanceUnit));
}
EmitProfilingCounterDecrement(weight);
Label ok;