Reviewers: Jakob,
Message:
PTAL.
Description:
Fix --hydrogen-stats.
Timing happens in a scope. Since crankshaft has been chopped up into three
methods, this approach is wrong.
BUG=
Please review this at http://codereview.chromium.org/11411065/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/compiler.cc
M src/hydrogen.h
M src/hydrogen.cc
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
82a3e7c80312803dd99b0868cfc488c8622448e8..7e88d58c5f44360f6a64a46afd1e75532da12eec
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -324,7 +324,8 @@ OptimizingCompiler::Status
OptimizingCompiler::CreateGraph() {
oracle_ = new(info()->zone()) TypeFeedbackOracle(
code, native_context, info()->isolate(), info()->zone());
graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_);
- HPhase phase(HPhase::kTotal);
+
+ HPhase phase(HPhase::kCreateGraph);
graph_ = graph_builder_->CreateGraph();
if (info()->isolate()->has_pending_exception()) {
@@ -352,6 +353,7 @@ OptimizingCompiler::Status
OptimizingCompiler::OptimizeGraph() {
AssertNoAllocation no_gc;
NoHandleAllocation no_handles;
+ HPhase phase(HPhase::kOptimizeGraph);
ASSERT(last_status() == SUCCEEDED);
Timer t(this, &time_taken_to_optimize_);
ASSERT(graph_ != NULL);
@@ -370,6 +372,7 @@ OptimizingCompiler::Status
OptimizingCompiler::OptimizeGraph() {
OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() {
+ HPhase phase(HPhase::kGenerateCode);
ASSERT(last_status() == SUCCEEDED);
Timer timer(this, &time_taken_to_codegen_);
ASSERT(chunk_ != NULL);
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
da69d79260759d7c5c5bffab557fa4c04b937173..b5e6569e633cc52ea6a3e55f023eb0199a5a3e0f
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -9959,28 +9959,49 @@ void HStatistics::Print() {
double size_percent = static_cast<double>(size) * 100 / total_size_;
PrintF(" %8u bytes / %4.1f %%\n", size, size_percent);
}
+
+
PrintF("---------------------------------------------------------------\n");
+ int64_t total = create_graph_ + optimize_graph_ + generate_code_;
+ PrintF("%30s - %7.3f ms / %4.1f %% \n",
+ HPhase::kCreateGraph,
+ static_cast<double>(create_graph_) / 1000,
+ static_cast<double>(create_graph_) * 100 / total);
+ PrintF("%30s - %7.3f ms / %4.1f %% \n",
+ HPhase::kOptimizeGraph,
+ static_cast<double>(optimize_graph_) / 1000,
+ static_cast<double>(optimize_graph_) * 100 / total);
+ PrintF("%30s - %7.3f ms / %4.1f %% \n",
+ HPhase::kGenerateCode,
+ static_cast<double>(generate_code_) / 1000,
+ static_cast<double>(generate_code_) * 100 / total);
+
PrintF("---------------------------------------------------------------\n");
+ PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n",
+ "Total",
+ static_cast<double>(total) / 1000,
+ static_cast<double>(total) / full_code_gen_);
+
double source_size_in_kb = static_cast<double>(source_size_) / 1024;
double normalized_time = source_size_in_kb > 0
- ? (static_cast<double>(sum) / 1000) / source_size_in_kb
+ ? (static_cast<double>(total) / 1000) / source_size_in_kb
: 0;
- double normalized_bytes = source_size_in_kb > 0
- ? total_size_ / source_size_in_kb
+ double normalized_size_in_kb = source_size_in_kb > 0
+ ? total_size_ / 1024 / source_size_in_kb
: 0;
- PrintF("%30s - %7.3f ms %7.3f bytes\n", "Sum",
- normalized_time, normalized_bytes);
-
PrintF("---------------------------------------------------------------\n");
- PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n",
- "Total",
- static_cast<double>(total_) / 1000,
- static_cast<double>(total_) / full_code_gen_);
+ PrintF("%30s - %7.3f ms %7.3f kB code\n",
+ "Average per kB source",
+ normalized_time, normalized_size_in_kb);
}
void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned
size) {
if (name == HPhase::kFullCodeGen) {
full_code_gen_ += ticks;
- } else if (name == HPhase::kTotal) {
- total_ += ticks;
+ } else if (name == HPhase::kCreateGraph) {
+ create_graph_ += ticks;
+ } else if (name == HPhase::kOptimizeGraph) {
+ optimize_graph_ += ticks;
+ } else if (name == HPhase::kGenerateCode) {
+ generate_code_ += ticks;
} else {
total_size_ += size;
for (int i = 0; i < names_.length(); ++i) {
@@ -9998,7 +10019,9 @@ void HStatistics::SaveTiming(const char* name,
int64_t ticks, unsigned size) {
const char* const HPhase::kFullCodeGen = "Full code generator";
-const char* const HPhase::kTotal = "Total";
+const char* const HPhase::kCreateGraph = "Create graph";
+const char* const HPhase::kOptimizeGraph = "Optimize graph";
+const char* const HPhase::kGenerateCode = "Generate code";
void HPhase::Begin(const char* name,
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
78ab571b5c52376549a07423a1dfcc2b9decd74f..508f519f27a73db080594671362108ecc89b0696
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1383,7 +1383,9 @@ class HStatistics: public Malloced {
: timing_(5),
names_(5),
sizes_(5),
- total_(0),
+ create_graph_(0),
+ optimize_graph_(0),
+ generate_code_(0),
total_size_(0),
full_code_gen_(0),
source_size_(0) { }
@@ -1391,7 +1393,9 @@ class HStatistics: public Malloced {
List<int64_t> timing_;
List<const char*> names_;
List<unsigned> sizes_;
- int64_t total_;
+ int64_t create_graph_;
+ int64_t optimize_graph_;
+ int64_t generate_code_;
unsigned total_size_;
int64_t full_code_gen_;
double source_size_;
@@ -1401,7 +1405,9 @@ class HStatistics: public Malloced {
class HPhase BASE_EMBEDDED {
public:
static const char* const kFullCodeGen;
- static const char* const kTotal;
+ static const char* const kCreateGraph;
+ static const char* const kOptimizeGraph;
+ static const char* const kGenerateCode;
explicit HPhase(const char* name) { Begin(name, NULL, NULL, NULL); }
HPhase(const char* name, HGraph* graph) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev