Reviewers: Jakob,
Description:
Classify small functions platform-dependently.
BUG=
TEST=
Please review this at http://codereview.chromium.org/10829009/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/full-codegen-arm.cc
M src/full-codegen.h
M src/ia32/full-codegen-ia32.cc
M src/mips/full-codegen-mips.cc
M src/runtime-profiler.cc
M src/x64/full-codegen-x64.cc
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index
f55956cd7f4fa1084ea0e082a672ff4e2f5d7b2c..750e5cee33ee82f84c6ba7e26e2bd5d5622621ed
100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -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;
Index: src/full-codegen.h
diff --git a/src/full-codegen.h b/src/full-codegen.h
index
a07df9107db45189f2f7868e2bb23bcec1365fa1..0c3291932420836b5fa82086ad88806bfb78ca20
100644
--- a/src/full-codegen.h
+++ b/src/full-codegen.h
@@ -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;
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index
cdf965e7322968e4bcff7d21f787b23a2d6e8c2b..4ad0a8d5fd386a51473a8f4f5ea312806d15cd9d
100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -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;
Index: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index
6f4869e2451d134497d6294478f75dcad99da9f8..8e4ad98e31ff570230dd38cd0d83a8efe9611ad0
100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -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;
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index
1856359f764143c686fd8d68a10ac83ebf03f4b9..e0e981271205b5016b9d56eb4b57b8c29c505012
100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -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");
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index
3eb6493dc783ef6cd4440e4ad6aa6efb981544d4..efd369b5daf3a552975fe55c7cf7dd78bc4d5158
100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -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;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev