[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: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#52122}
This commit is contained in:
parent
8aa3a37304
commit
9b44ee4b79
@ -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;
|
||||
|
20
src/log.cc
20
src/log.cc
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user