Commit cce670e7 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Improve wasm code logging

This fixes a few thing regarding code logging for profiling:

1) Append the execution tier, otherwise we get two function of the same
   name.
2) Replace "wasm-function[%d]" by "<wasm-unnamed>", since the index is
   appended later anyway.
3) Avoid unneeded JS heap and C++ heap allocations during logging.

R=jkummerow@chromium.org

Bug: chromium:1029470
Change-Id: Ie7af41f21e4595f8d8c574e4ad18273f89f1cb6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1943162
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65285}
parent 44c5262c
......@@ -245,6 +245,8 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
} else {
name_buffer_->AppendInt(code->index());
}
name_buffer_->AppendByte('-');
name_buffer_->AppendBytes(ExecutionTierToString(code->tier()));
LogRecordedBuffer(code, name_buffer_->get(), name_buffer_->size());
}
......
......@@ -194,28 +194,27 @@ void WasmCode::LogCode(Isolate* isolate) const {
std::make_unique<WasmModuleSourceMap>(v8_isolate, source_map_str));
}
if (!name_vec.empty()) {
std::unique_ptr<char[]> name_buffer;
Vector<const char> name;
if (name_vec.empty()) {
name = CStrVector("<wasm-unnamed>");
} else {
HandleScope scope(isolate);
MaybeHandle<String> maybe_name = isolate->factory()->NewStringFromUtf8(
Vector<const char>::cast(name_vec));
Handle<String> name;
if (!maybe_name.ToHandle(&name)) {
name = isolate->factory()->NewStringFromAsciiChecked("<name too long>");
Handle<String> name_string;
if (maybe_name.ToHandle(&name_string)) {
int name_len = 0;
name_buffer = name_string->ToCString(
AllowNullsFlag::DISALLOW_NULLS,
RobustnessFlag::ROBUST_STRING_TRAVERSAL, &name_len);
name = VectorOf(name_buffer.get(), name_len);
} else {
name = CStrVector("<name too long>");
}
int name_length;
auto cname =
name->ToCString(AllowNullsFlag::DISALLOW_NULLS,
RobustnessFlag::ROBUST_STRING_TRAVERSAL, &name_length);
PROFILE(isolate,
CodeCreateEvent(CodeEventListener::FUNCTION_TAG, this,
{cname.get(), static_cast<size_t>(name_length)}));
} else {
EmbeddedVector<char, 32> generated_name;
int length = SNPrintF(generated_name, "wasm-function[%d]", index());
generated_name.Truncate(length);
PROFILE(isolate, CodeCreateEvent(CodeEventListener::FUNCTION_TAG, this,
generated_name));
}
PROFILE(isolate,
CodeCreateEvent(CodeEventListener::FUNCTION_TAG, this, name));
if (!source_positions().empty()) {
LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(instruction_start(),
......
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