From 27663efb8563ecad45e67542ed4983e9758515c0 Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Thu, 25 Mar 2010 14:55:53 +0000 Subject: [PATCH] Align OProfile agent invocations style with logging. This allows to unclutter logging-related code. I also fixed compilation issues with 'profilingsupport=off'. Review URL: http://codereview.chromium.org/1317003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4285 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/code-stubs.cc | 10 ++--- src/compiler.cc | 92 ++++++++++++++++++------------------------- src/compiler.h | 15 +++---- src/oprofile-agent.cc | 58 ++++++++++++--------------- src/oprofile-agent.h | 10 ++++- src/platform.h | 2 +- 6 files changed, 83 insertions(+), 104 deletions(-) diff --git a/src/code-stubs.cc b/src/code-stubs.cc index e42f75894b..ea74898016 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -61,13 +61,9 @@ void CodeStub::GenerateCode(MacroAssembler* masm) { void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) { code->set_major_key(MajorKey()); -#ifdef ENABLE_OPROFILE_AGENT - // Register the generated stub with the OPROFILE agent. - OProfileAgent::CreateNativeCodeRegion(GetName(), - code->instruction_start(), - code->instruction_size()); -#endif - + OPROFILE(CreateNativeCodeRegion(GetName(), + code->instruction_start(), + code->instruction_size())); LOG(CodeCreateEvent(Logger::STUB_TAG, code, GetName())); Counters::total_stubs_code_size.Increment(code->instruction_size()); diff --git a/src/compiler.cc b/src/compiler.cc index e2021fa2ae..e85590e2e6 100755 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -235,27 +235,19 @@ static Handle MakeFunctionInfo(bool is_global, return Handle::null(); } -#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT - // Log the code generation for the script. Check explicit whether logging is - // to avoid allocating when not required. - if (Logger::is_logging() || OProfileAgent::is_enabled()) { - if (script->name()->IsString()) { - SmartPointer data = - String::cast(script->name())->ToCString(DISALLOW_NULLS); - LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG, - *code, *data)); - OProfileAgent::CreateNativeCodeRegion(*data, - code->instruction_start(), - code->instruction_size()); - } else { - LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG, - *code, "")); - OProfileAgent::CreateNativeCodeRegion(is_eval ? "Eval" : "Script", - code->instruction_start(), - code->instruction_size()); - } + if (script->name()->IsString()) { + LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG, + *code, String::cast(script->name()))); + OPROFILE(CreateNativeCodeRegion(String::cast(script->name()), + code->instruction_start(), + code->instruction_size())); + } else { + LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG, + *code, "")); + OPROFILE(CreateNativeCodeRegion(is_eval ? "Eval" : "Script", + code->instruction_start(), + code->instruction_size())); } -#endif // Allocate function. Handle result = @@ -443,14 +435,12 @@ bool Compiler::CompileLazy(CompilationInfo* info) { return false; } -#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT - LogCodeCreateEvent(Logger::LAZY_COMPILE_TAG, - name, - Handle(shared->inferred_name()), - start_position, - info->script(), - code); -#endif + RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, + name, + Handle(shared->inferred_name()), + start_position, + info->script(), + code); // Update the shared function info with the compiled code. shared->set_code(*code); @@ -578,15 +568,12 @@ Handle Compiler::BuildFunctionInfo(FunctionLiteral* literal, } // Function compilation complete. - -#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT - LogCodeCreateEvent(Logger::FUNCTION_TAG, - literal->name(), - literal->inferred_name(), - literal->start_position(), - script, - code); -#endif + RecordFunctionCompilation(Logger::FUNCTION_TAG, + literal->name(), + literal->inferred_name(), + literal->start_position(), + script, + code); } // Create a boilerplate function. @@ -628,13 +615,12 @@ void Compiler::SetFunctionInfo(Handle function_info, } -#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT -void Compiler::LogCodeCreateEvent(Logger::LogEventsAndTags tag, - Handle name, - Handle inferred_name, - int start_position, - Handle