Commit 5df5a28f authored by lpy's avatar lpy Committed by Commit bot

Revert of [Tracing] Use TracingCategoryObserver in runtime statistics...

Revert of [Tracing] Use TracingCategoryObserver in runtime statistics (patchset #6 id:140001 of https://codereview.chromium.org/2460973003/ )

Reason for revert:
Static-Initializers failed on Ubuntu-12.04

Original issue's description:
> [Tracing] Use TracingCategoryObserver in runtime statistics
>
> This patch is a follow-up patch to enable runtime statistics to use
> TracingCategoryObserver.
>
> BUG=v8:5590

TBR=cbruni@chromium.org,fmeawad@chromium.org,alph@chromium.org,bmeurer@chromium.org,mlippautz@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5590

Review-Url: https://codereview.chromium.org/2469403005
Cr-Commit-Position: refs/heads/master@{#40743}
parent 059e0778
......@@ -96,7 +96,8 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
Type Name(int args_length, Object** args_object, Isolate* isolate) { \
DCHECK(isolate->context() == nullptr || isolate->context()->IsContext()); \
CLOBBER_DOUBLE_REGISTERS(); \
if (V8_UNLIKELY(FLAG_runtime_stats)) { \
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \
FLAG_runtime_call_stats)) { \
return Stats_##Name(args_length, args_object, isolate); \
} \
Arguments args(args_length, args_object); \
......
......@@ -91,7 +91,8 @@ class BuiltinArguments : public Arguments {
MUST_USE_RESULT Object* Builtin_##name( \
int args_length, Object** args_object, Isolate* isolate) { \
DCHECK(isolate->context() == nullptr || isolate->context()->IsContext()); \
if (V8_UNLIKELY(FLAG_runtime_stats)) { \
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \
FLAG_runtime_call_stats)) { \
return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \
} \
BuiltinArguments args(args_length, args_object); \
......
......@@ -23,7 +23,8 @@ CompilerDispatcherTracer::Scope::Scope(CompilerDispatcherTracer* tracer,
: tracer_(tracer), scope_id_(scope_id), num_(num) {
start_time_ = MonotonicallyIncreasingTimeInMs();
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Enter(tracer_->runtime_call_stats_, &timer_,
&RuntimeCallStats::CompilerDispatcher);
}
......@@ -52,7 +53,8 @@ CompilerDispatcherTracer::Scope::~Scope() {
break;
}
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Leave(tracer_->runtime_call_stats_, &timer_);
}
}
......
......@@ -12,14 +12,16 @@ namespace internal {
RuntimeCallTimerScope::RuntimeCallTimerScope(
Isolate* isolate, RuntimeCallStats::CounterId counter_id) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats)) {
Initialize(isolate, counter_id);
}
}
RuntimeCallTimerScope::RuntimeCallTimerScope(
HeapObject* heap_object, RuntimeCallStats::CounterId counter_id) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats)) {
Initialize(heap_object->GetIsolate(), counter_id);
}
}
......
......@@ -344,8 +344,9 @@ void RuntimeCallStats::Print(std::ostream& os) {
}
void RuntimeCallStats::Reset() {
if (V8_LIKELY(FLAG_runtime_stats == 0)) return;
if (!FLAG_runtime_call_stats &&
!TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED())
return;
#define RESET_COUNTER(name) this->name.Reset();
FOR_EACH_MANUAL_COUNTER(RESET_COUNTER)
#undef RESET_COUNTER
......
......@@ -853,13 +853,14 @@ class RuntimeCallStats {
bool in_use_;
};
#define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \
do { \
if (V8_UNLIKELY(FLAG_runtime_stats)) { \
RuntimeCallStats::CorrectCurrentCounterId( \
isolate->counters()->runtime_call_stats(), \
&RuntimeCallStats::counter_name); \
} \
#define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \
do { \
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \
FLAG_runtime_call_stats)) { \
RuntimeCallStats::CorrectCurrentCounterId( \
isolate->counters()->runtime_call_stats(), \
&RuntimeCallStats::counter_name); \
} \
} while (false)
#define TRACE_HANDLER_STATS(isolate, counter_name) \
......
......@@ -8893,7 +8893,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
bool HOptimizedGraphBuilder::TryInlineApiFunctionCall(Call* expr,
HValue* receiver) {
if (V8_UNLIKELY(FLAG_runtime_stats)) return false;
if (FLAG_runtime_call_stats) return false;
Handle<JSFunction> function = expr->target();
int argc = expr->arguments()->length();
SmallMapList receiver_maps;
......@@ -8906,7 +8906,7 @@ bool HOptimizedGraphBuilder::TryInlineApiMethodCall(
Call* expr,
HValue* receiver,
SmallMapList* receiver_maps) {
if (V8_UNLIKELY(FLAG_runtime_stats)) return false;
if (FLAG_runtime_call_stats) return false;
Handle<JSFunction> function = expr->target();
int argc = expr->arguments()->length();
return TryInlineApiCall(function, receiver, receiver_maps, argc, expr->id(),
......@@ -8916,7 +8916,7 @@ bool HOptimizedGraphBuilder::TryInlineApiMethodCall(
bool HOptimizedGraphBuilder::TryInlineApiGetter(Handle<Object> function,
Handle<Map> receiver_map,
BailoutId ast_id) {
if (V8_UNLIKELY(FLAG_runtime_stats)) return false;
if (FLAG_runtime_call_stats) return false;
SmallMapList receiver_maps(1, zone());
receiver_maps.Add(receiver_map, zone());
return TryInlineApiCall(function,
......@@ -8940,7 +8940,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(
Handle<Object> function, HValue* receiver, SmallMapList* receiver_maps,
int argc, BailoutId ast_id, ApiCallType call_type,
TailCallMode syntactic_tail_call_mode) {
if (V8_UNLIKELY(FLAG_runtime_stats)) return false;
if (FLAG_runtime_call_stats) return false;
if (function->IsJSFunction() &&
Handle<JSFunction>::cast(function)->context()->native_context() !=
top_info()->closure()->context()->native_context()) {
......
......@@ -2831,7 +2831,8 @@ int Shell::Main(int argc, char* argv[]) {
platform::tracing::TraceWriter::CreateJSONTraceWriter(trace_file));
tracing_controller->Initialize(trace_buffer);
if (!i::FLAG_verify_predictable) {
platform::SetTracingController(g_platform, tracing_controller.release());
platform::SetTracingController(g_platform, tracing_controller.get());
tracing_controller.release();
}
}
......
......@@ -31,7 +31,8 @@ GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
STATIC_ASSERT(FIRST_INCREMENTAL_SCOPE == 0);
start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs();
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Enter(
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_,
&RuntimeCallStats::GC);
......@@ -42,7 +43,8 @@ GCTracer::Scope::~Scope() {
tracer_->AddScopeSample(
scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_);
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Leave(
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_);
}
......@@ -203,7 +205,8 @@ void GCTracer::Start(GarbageCollector collector,
committed_memory);
counters->aggregated_memory_heap_used()->AddSample(start_time, used_memory);
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(),
&timer_, &RuntimeCallStats::GC);
}
......@@ -293,7 +296,8 @@ void GCTracer::Stop(GarbageCollector collector) {
}
// TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() ||
FLAG_runtime_call_stats) {
RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(),
&timer_);
}
......
......@@ -212,7 +212,7 @@ Handle<Code> NamedLoadHandlerCompiler::CompileLoadNonexistent(
Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback(
Handle<Name> name, Handle<AccessorInfo> callback, Handle<Code> slow_stub) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (FLAG_runtime_call_stats) {
GenerateTailCall(masm(), slow_stub);
}
Register reg = Frontend(name);
......@@ -224,7 +224,7 @@ Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback(
Handle<Name> name, const CallOptimization& call_optimization,
int accessor_index, Handle<Code> slow_stub) {
DCHECK(call_optimization.is_simple_api_call());
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (FLAG_runtime_call_stats) {
GenerateTailCall(masm(), slow_stub);
}
Register holder = Frontend(name);
......@@ -578,7 +578,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<Name> name,
const CallOptimization& call_optimization, int accessor_index,
Handle<Code> slow_stub) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (FLAG_runtime_call_stats) {
GenerateTailCall(masm(), slow_stub);
}
Register holder = Frontend(name);
......
......@@ -2986,7 +2986,7 @@ RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) {
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 5);
HandleScope scope(isolate);
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (FLAG_runtime_call_stats) {
RETURN_RESULT_OR_FAILURE(
isolate, Runtime::SetObjectProperty(isolate, receiver, name, value,
language_mode));
......
......@@ -42,7 +42,6 @@
#include "src/runtime-profiler.h"
#include "src/simulator.h"
#include "src/snapshot/deserializer.h"
#include "src/tracing/tracing-category-observer.h"
#include "src/v8.h"
#include "src/version.h"
#include "src/vm-state-inl.h"
......@@ -2738,8 +2737,8 @@ void Isolate::DumpAndResetCompilationStats() {
turbo_statistics_ = nullptr;
delete hstatistics_;
hstatistics_ = nullptr;
if (V8_UNLIKELY(FLAG_runtime_stats ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) {
if (FLAG_runtime_call_stats &&
!TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) {
OFStream os(stdout);
counters()->runtime_call_stats()->Print(os);
counters()->runtime_call_stats()->Reset();
......
......@@ -27,7 +27,6 @@
#include "src/runtime-profiler.h"
#include "src/source-position-table.h"
#include "src/string-stream.h"
#include "src/tracing/tracing-category-observer.h"
#include "src/vm-state-inl.h"
namespace v8 {
......@@ -1284,8 +1283,7 @@ void Logger::RuntimeCallTimerEvent() {
void Logger::TickEvent(v8::TickSample* sample, bool overflow) {
if (!log_->IsEnabled() || !FLAG_prof_cpp) return;
if (V8_UNLIKELY(FLAG_runtime_stats ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) {
if (FLAG_runtime_call_stats) {
RuntimeCallTimerEvent();
}
Log::MessageBuilder msg(log_);
......
......@@ -15,6 +15,10 @@ namespace v8 {
namespace internal {
namespace tracing {
// A global flag used as a shortcut to check for the
// v8.runtime-call-stats category due to its high frequency use.
base::Atomic32 kRuntimeCallStatsTracingEnabled = false;
v8::Platform* TraceEventHelper::GetCurrentPlatform() {
return v8::internal::V8::GetCurrentPlatform();
}
......
......@@ -249,10 +249,20 @@ enum CategoryGroupEnabledFlags {
INTERNAL_TRACE_EVENT_UID(ScopedContext) \
INTERNAL_TRACE_EVENT_UID(scoped_context)(context);
#define TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() \
base::NoBarrier_Load(&v8::internal::tracing::kRuntimeCallStatsTracingEnabled)
#define TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name) \
INTERNAL_TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name)
#define INTERNAL_TRACE_EVENT_CALL_STATS_SCOPED(isolate, category_group, name) \
{ \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO( \
TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats")); \
base::NoBarrier_Store( \
&v8::internal::tracing::kRuntimeCallStatsTracingEnabled, \
INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()); \
} \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
v8::internal::tracing::CallStatsScopedTracer INTERNAL_TRACE_EVENT_UID( \
tracer); \
......
......@@ -17,7 +17,6 @@ void TracingCategoryObserver::SetUp() {
TracingCategoryObserver::instance_ = new TracingCategoryObserver();
v8::internal::V8::GetCurrentPlatform()->AddTraceStateObserver(
TracingCategoryObserver::instance_);
TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"));
}
void TracingCategoryObserver::TearDown() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment