From bc11dbcb8a0a1f4a8842dfd8541f109ad4af3940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marja=20H=C3=B6ltt=C3=A4?= Date: Mon, 10 May 2021 16:53:12 +0200 Subject: [PATCH] [web snapshot] web snapshot <3 RuntimeCallStats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: v8:11525 Change-Id: I1c8e2346ed1581dc6b44e8df203d1ad0bcd1639a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2883357 Commit-Queue: Marja Hölttä Reviewed-by: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#74664} --- src/logging/runtime-call-stats.h | 9 ++++++++- src/web-snapshot/web-snapshot.cc | 11 ++++++++++- tools/callstats.html | 8 ++++++++ tools/callstats_groups.py | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/logging/runtime-call-stats.h b/src/logging/runtime-call-stats.h index 7593170d86..db5fa3ac1a 100644 --- a/src/logging/runtime-call-stats.h +++ b/src/logging/runtime-call-stats.h @@ -470,7 +470,14 @@ class RuntimeCallTimer final { V(StringLengthGetter) \ V(TestCounter1) \ V(TestCounter2) \ - V(TestCounter3) + V(TestCounter3) \ + V(WebSnapshotDeserialize) \ + V(WebSnapshotDeserialize_Contexts) \ + V(WebSnapshotDeserialize_Exports) \ + V(WebSnapshotDeserialize_Functions) \ + V(WebSnapshotDeserialize_Maps) \ + V(WebSnapshotDeserialize_Objects) \ + V(WebSnapshotDeserialize_Strings) #define FOR_EACH_HANDLER_COUNTER(V) \ V(KeyedLoadIC_KeyedLoadSloppyArgumentsStub) \ diff --git a/src/web-snapshot/web-snapshot.cc b/src/web-snapshot/web-snapshot.cc index f36698a351..8ceb724379 100644 --- a/src/web-snapshot/web-snapshot.cc +++ b/src/web-snapshot/web-snapshot.cc @@ -66,6 +66,9 @@ bool WebSnapshotSerializer::TakeSnapshot( } v8::Isolate* v8_isolate = reinterpret_cast(isolate_); for (const std::string& export_name : exports) { + if (export_name.length() == 0) { + continue; + } v8::ScriptCompiler::Source source( v8::String::NewFromUtf8(v8_isolate, export_name.c_str(), NewStringType::kNormal, @@ -479,13 +482,13 @@ void WebSnapshotDeserializer::Throw(const char* message) { bool WebSnapshotDeserializer::UseWebSnapshot(const uint8_t* data, size_t buffer_size) { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize); if (deserialized_) { Throw("Web snapshot: Can't reuse WebSnapshotDeserializer"); return false; } deserialized_ = true; - // TODO(v8:11525): Add RuntimeCallStats. base::ElapsedTimer timer; if (FLAG_trace_web_snapshot) { timer.Start(); @@ -514,6 +517,7 @@ bool WebSnapshotDeserializer::UseWebSnapshot(const uint8_t* data, } void WebSnapshotDeserializer::DeserializeStrings() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Strings); if (!deserializer_->ReadUint32(&string_count_) || string_count_ > kMaxItemCount) { Throw("Web snapshot: Malformed string table"); @@ -550,6 +554,7 @@ Handle WebSnapshotDeserializer::ReadString(bool internalize) { } void WebSnapshotDeserializer::DeserializeMaps() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Maps); if (!deserializer_->ReadUint32(&map_count_) || map_count_ > kMaxItemCount) { Throw("Web snapshot: Malformed shape table"); return; @@ -591,6 +596,7 @@ void WebSnapshotDeserializer::DeserializeMaps() { } void WebSnapshotDeserializer::DeserializeContexts() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Contexts); if (!deserializer_->ReadUint32(&context_count_) || context_count_ > kMaxItemCount) { Throw("Web snapshot: Malformed context table"); @@ -702,6 +708,7 @@ Handle WebSnapshotDeserializer::CreateScopeInfo( } void WebSnapshotDeserializer::DeserializeFunctions() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Functions); if (!deserializer_->ReadUint32(&function_count_) || function_count_ > kMaxItemCount) { Throw("Web snapshot: Malformed function table"); @@ -793,6 +800,7 @@ void WebSnapshotDeserializer::DeserializeFunctions() { } void WebSnapshotDeserializer::DeserializeObjects() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Objects); if (!deserializer_->ReadUint32(&object_count_) || object_count_ > kMaxItemCount) { Throw("Web snapshot: Malformed objects table"); @@ -838,6 +846,7 @@ void WebSnapshotDeserializer::DeserializeObjects() { } void WebSnapshotDeserializer::DeserializeExports() { + RCS_SCOPE(isolate_, RuntimeCallCounterId::kWebSnapshotDeserialize_Exports); uint32_t count; if (!deserializer_->ReadUint32(&count) || count > kMaxItemCount) { Throw("Web snapshot: Malformed export table"); diff --git a/tools/callstats.html b/tools/callstats.html index 701e5bee87..d00f48d8b5 100644 --- a/tools/callstats.html +++ b/tools/callstats.html @@ -411,6 +411,12 @@ code is governed by a BSD-style license that can be found in the LICENSE file. } function diffColorFromRatio(ratio) { + if (ratio == Infinity) { + return '#ff0000'; + } + if (ratio == -Infinity) { + return '#00ff00'; + } if (ratio > 1) { // ratio > 1: #FFFFFF => #00FF00 const red = clamp(((ratio - 1) * 255 * 10) | 0, 0, 255); @@ -1934,6 +1940,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. Group.groups.get('gc-background').entry(), Group.groups.get('gc').entry(), Group.groups.get('javascript').entry(), + Group.groups.get('websnapshot').entry(), Group.groups.get('runtime').entry(), this.unclassified ]; @@ -2260,6 +2267,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. new Group('GC', /GC_.*|AllocateInTargetSpace|GC/, "#00799c")); Group.add('javascript', new Group('JavaScript', /JS_Execution|JavaScript/, "#DD4477")); + Group.add('websnapshot', new Group('WebSnapshot', /.*Web.*/, "#E8E11C")); Group.add('runtime', new Group('V8 C++', /.*/, "#88BB00")); Group.add('blink', new Group('Blink RCS', /.*Blink_.*/, "#006600", false, false)); diff --git a/tools/callstats_groups.py b/tools/callstats_groups.py index 62898c61c8..cd8712d499 100644 --- a/tools/callstats_groups.py +++ b/tools/callstats_groups.py @@ -19,4 +19,5 @@ RUNTIME_CALL_STATS_GROUPS = [ ('Group-GC-Background', re.compile(".*GC.*BACKGROUND.*")), ('Group-GC', re.compile("GC_.*|AllocateInTargetSpace")), ('Group-JavaScript', re.compile("JS_Execution")), + ('Group-WebSnapshot', re.compile("WebSnapshot.*")), ('Group-Runtime', re.compile(".*"))]