Commit 9b44ee4b authored by Stephan Herhut's avatar Stephan Herhut Committed by Commit Bot

[wasm] Fix tick-processor logging of wasm code

The tick-processor expects a certain format for functions in d8's
cpu profile log (--prof). To make wasm functions look like js functions,
this change adds a fake address to the log output that can be used as
key for the wasm function. This enables basic profiling of wasm code
using the --prof flag and the tick-processor.

Change-Id: Iaeed575499b2d58d0f937c109a047b17615a01d1
Reviewed-on: https://chromium-review.googlesource.com/973373
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52122}
parent 8aa3a373
......@@ -270,7 +270,7 @@ JavaScriptFrame* StackTraceFrameIterator::javascript_frame() const {
inline StackFrame* SafeStackFrameIterator::frame() const {
DCHECK(!done());
DCHECK(frame_->is_java_script() || frame_->is_exit() ||
frame_->is_builtin_exit());
frame_->is_builtin_exit() || frame_->is_wasm());
return frame_;
}
......
......@@ -83,7 +83,7 @@ class Log {
void AppendCharacter(const char character);
// Delegate insertion to the underlying {log_}.
// All appened srings are escaped to maintain one-line log entries.
// All appended strings are escaped to maintain one-line log entries.
template <typename T>
MessageBuilder& operator<<(T value) {
log_->os_ << value;
......
......@@ -57,6 +57,16 @@ static const char* ComputeMarker(SharedFunctionInfo* shared,
}
}
static const char* ComputeMarker(wasm::WasmCode* code) {
switch (code->kind()) {
case wasm::WasmCode::kFunction:
return code->is_liftoff() ? "" : "*";
case wasm::WasmCode::kInterpreterStub:
return "~";
default:
return "";
}
}
class CodeEventLogger::NameBuffer {
public:
......@@ -1110,8 +1120,16 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
if (name.is_empty()) {
msg << "<unknown wasm>";
} else {
msg << name.start();
}
msg.AppendStringPart(name.start(), name.length());
}
// We have to add two extra fields that allow the tick processor to group
// events for the same wasm function, even if it gets compiled again. For
// normal JS functions, we use the shared function info. For wasm, the pointer
// to the native module + function index works well enough.
// TODO(herhut) Clean up the tick processor code instead.
void* tag_ptr =
reinterpret_cast<byte*>(code->native_module()) + code->index();
msg << kNext << tag_ptr << kNext << ComputeMarker(code);
msg.WriteToLogFile();
}
......
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