Index: runtime/vm/stub_code.cc |
diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc |
index 5b6a5f54c07d90549c4b2165980cbaa2f45aba6e..f98b4a2e4b6b490748a43f4e61fcc9fe08e903b2 100644 |
--- a/runtime/vm/stub_code.cc |
+++ b/runtime/vm/stub_code.cc |
@@ -15,11 +15,14 @@ |
#include "vm/virtual_memory.h" |
#include "vm/visitor.h" |
#include "vm/clustered_snapshot.h" |
+#include "vm/code_statistics.h" |
namespace dart { |
DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); |
+DECLARE_FLAG(bool, print_instruction_stats); |
+ |
#define STUB_CODE_DECLARE(name) StubEntry* StubCode::name##_entry_ = NULL; |
VM_STUB_CODE_LIST(STUB_CODE_DECLARE); |
#undef STUB_CODE_DECLARE |
@@ -141,6 +144,13 @@ RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
Code& stub = Code::Handle(zone, cls.allocation_stub()); |
if (stub.IsNull()) { |
Assembler assembler; |
+ |
+ CodeStatistics* function_stats = NULL; |
+ if (FLAG_print_instruction_stats) { |
+ function_stats = new CodeStatistics(&assembler); |
+ function_stats->SpecialBegin(CombinedCodeStatistics::kTagStubCode); |
+ } |
+ |
const char* name = cls.ToCString(); |
StubCode::GenerateAllocationStubForClass(&assembler, cls); |
@@ -178,6 +188,11 @@ RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
isolate->heap()->CollectAllGarbage(); |
} |
} |
+ if (FLAG_print_instruction_stats) { |
+ function_stats->SpecialEnd(CombinedCodeStatistics::kTagStubCode); |
+ function_stats->Finalize(); |
+ stub.set_stats(function_stats); |
+ } |
#ifndef PRODUCT |
if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
LogBlock lb; |
@@ -221,9 +236,23 @@ const StubEntry* StubCode::UnoptimizedStaticCallEntry( |
RawCode* StubCode::Generate(const char* name, |
void (*GenerateStub)(Assembler* assembler)) { |
Assembler assembler; |
+ |
+ CodeStatistics* function_stats = NULL; |
+ if (FLAG_print_instruction_stats) { |
+ function_stats = new CodeStatistics(&assembler); |
+ function_stats->SpecialBegin(CombinedCodeStatistics::kTagStubCode); |
+ } |
+ |
GenerateStub(&assembler); |
const Code& code = |
Code::Handle(Code::FinalizeCode(name, &assembler, false /* optimized */)); |
+ |
+ if (FLAG_print_instruction_stats) { |
+ function_stats->SpecialEnd(CombinedCodeStatistics::kTagStubCode); |
+ function_stats->Finalize(); |
+ code.set_stats(function_stats); |
+ } |
+ |
#ifndef PRODUCT |
if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
LogBlock lb; |