Commit bc11dbcb authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[web snapshot] web snapshot <3 RuntimeCallStats

Bug: v8:11525
Change-Id: I1c8e2346ed1581dc6b44e8df203d1ad0bcd1639a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2883357
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74664}
parent 4da83c82
......@@ -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) \
......
......@@ -66,6 +66,9 @@ bool WebSnapshotSerializer::TakeSnapshot(
}
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(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<String> 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<ScopeInfo> 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");
......
......@@ -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));
......
......@@ -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(".*"))]
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