Commit df421e87 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Add RCS to V8PerIsolateData and cmdline switch

- Adds an instance of RCS to V8PerIsolateData
- Logs RCS table in RenderThread::Shutdown (behind a flag)

Bug: 724542
Change-Id: I496c76c4e79ba5011b90b512c2bd02cd5b6056a2
Reviewed-on: https://chromium-review.googlesource.com/517562
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476337}
parent 3c26208e
......@@ -333,6 +333,10 @@ const char kDisable2dCanvasClipAntialiasing[] = "disable-2d-canvas-clip-aa";
const char kDisableAcceleratedJpegDecoding[] =
"disable-accelerated-jpeg-decoding";
// Logs Runtime Call Stats for Blink. --single-process also needs to be
// used along with this for the stats to be logged.
const char kDumpBlinkRuntimeCallStats[] = "dump-blink-runtime-call-stats";
// Enables LCD text.
const char kEnableLCDText[] = "enable-lcd-text";
......
......@@ -106,6 +106,7 @@ CONTENT_EXPORT extern const char kDisableZeroCopy[];
CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[];
CONTENT_EXPORT extern const char kDomAutomationController[];
extern const char kDisable2dCanvasClipAntialiasing[];
CONTENT_EXPORT extern const char kDumpBlinkRuntimeCallStats[];
CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[];
CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
CONTENT_EXPORT extern const char kEnableBlinkFeatures[];
......
......@@ -932,6 +932,10 @@ void RenderThreadImpl::Shutdown() {
// evaluation and debugging.
blink::MainThreadIsolate()->DumpAndResetStats();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDumpBlinkRuntimeCallStats))
blink::LogRuntimeCallStats();
// In a single-process mode, we cannot call _exit(0) in Shutdown() because
// it will exit the process before the browser side is ready to exit.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
......
......@@ -6,6 +6,7 @@
#include <inttypes.h>
#include <algorithm>
#include "platform/bindings/V8PerIsolateData.h"
#include "platform/wtf/text/StringBuilder.h"
namespace blink {
......@@ -43,6 +44,11 @@ RuntimeCallStats::RuntimeCallStats() {
}
}
// static
RuntimeCallStats* RuntimeCallStats::From(v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->GetRuntimeCallStats();
}
void RuntimeCallStats::Reset() {
for (int i = 0; i < number_of_counters_; i++) {
counters_[i].Reset();
......@@ -55,7 +61,7 @@ String RuntimeCallStats::ToString() const {
builder.Append("Name Count Time (ms)\n\n");
for (int i = 0; i < number_of_counters_; i++) {
const RuntimeCallCounter* counter = &counters_[i];
builder.Append(String::Format("%-32s %8" PRIu64 "%8.3f\n",
builder.Append(String::Format("%-32s %8" PRIu64 " %9.3f\n",
counter->GetName(), counter->GetCount(),
counter->GetTime().InMillisecondsF()));
}
......
......@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file contains the Blink version of RuntimeCallStats which is implemented
// by V8 in //v8/src/counters.h
#ifndef RuntimeCallStats_h
#define RuntimeCallStats_h
......@@ -9,6 +12,7 @@
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Time.h"
#include "platform/wtf/text/WTFString.h"
#include "v8/include/v8.h"
namespace blink {
......@@ -90,6 +94,8 @@ class PLATFORM_EXPORT RuntimeCallTimer {
class PLATFORM_EXPORT RuntimeCallStats {
public:
RuntimeCallStats();
// Get RuntimeCallStats object associated with the given isolate.
static RuntimeCallStats* From(v8::Isolate*);
// Counters
#define FOR_EACH_COUNTER(V) \
......
......@@ -31,6 +31,7 @@
#include "gin/public/isolate_holder.h"
#include "gin/public/v8_idle_task_runner.h"
#include "platform/PlatformExport.h"
#include "platform/bindings/RuntimeCallStats.h"
#include "platform/bindings/ScopedPersistent.h"
#include "platform/bindings/ScriptState.h"
#include "platform/bindings/ScriptWrappableVisitor.h"
......@@ -120,6 +121,8 @@ class PLATFORM_EXPORT V8PerIsolateData {
StringCache* GetStringCache() { return string_cache_.get(); }
RuntimeCallStats* GetRuntimeCallStats() { return &runtime_call_stats_; }
bool IsHandlingRecursionLevelError() const {
return is_handling_recursion_level_error_;
}
......@@ -267,6 +270,8 @@ class PLATFORM_EXPORT V8PerIsolateData {
Persistent<ActiveScriptWrappableSet> active_script_wrappables_;
std::unique_ptr<ScriptWrappableVisitor> script_wrappable_visitor_;
RuntimeCallStats runtime_call_stats_;
};
} // namespace blink
......
......@@ -141,4 +141,10 @@ void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode rail_mode) {
WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates(rail_mode);
}
void LogRuntimeCallStats() {
LOG(INFO)
<< "\n"
<< RuntimeCallStats::From(MainThreadIsolate())->ToString().Utf8().data();
}
} // namespace blink
......@@ -75,6 +75,9 @@ BLINK_EXPORT void MemoryPressureNotificationToWorkerThreadIsolates(
// Set the RAIL performance mode on all worker thread isolates.
BLINK_EXPORT void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode);
// Logs Runtime Call Stats table for Blink.
BLINK_EXPORT void LogRuntimeCallStats();
} // namespace blink
#endif
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