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

[profiler] Include the generic js-to-wasm builtin in profiles

This CL fixes two things:
1) It properly creates code entries for the generic js-to-wasm builtin
(others are left out because we don't want to include all builtins in
profiles).
2) It includes js-to-wasm frames in profiles. The generic js-to-wasm
builtin will map to that frame type in the future (see referenced
bug). js-to-wasm frames are currently included because they are wrongly
mapped to OPTIMIZED frames by the SafeStackTraceIterator.

R=petermarshall@chromium.org
CC=ahaas@chromium.org, evih@google.com

Bug: v8:10701
Change-Id: I26e3fa6901890e041feab7c001069e67a616c986
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2416495Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70095}
parent 5259691c
...@@ -335,7 +335,7 @@ inline StackFrame* SafeStackFrameIterator::frame() const { ...@@ -335,7 +335,7 @@ inline StackFrame* SafeStackFrameIterator::frame() const {
DCHECK(!done()); DCHECK(!done());
DCHECK(frame_->is_java_script() || frame_->is_exit() || DCHECK(frame_->is_java_script() || frame_->is_exit() ||
frame_->is_builtin_exit() || frame_->is_wasm() || frame_->is_builtin_exit() || frame_->is_wasm() ||
frame_->is_wasm_to_js()); frame_->is_wasm_to_js() || frame_->is_js_to_wasm());
return frame_; return frame_;
} }
......
...@@ -458,7 +458,7 @@ void SafeStackFrameIterator::Advance() { ...@@ -458,7 +458,7 @@ void SafeStackFrameIterator::Advance() {
external_callback_scope_ = external_callback_scope_->previous(); external_callback_scope_ = external_callback_scope_->previous();
} }
if (frame_->is_java_script() || frame_->is_wasm() || if (frame_->is_java_script() || frame_->is_wasm() ||
frame_->is_wasm_to_js()) { frame_->is_wasm_to_js() || frame_->is_js_to_wasm()) {
break; break;
} }
if (frame_->is_exit() || frame_->is_builtin_exit()) { if (frame_->is_exit() || frame_->is_builtin_exit()) {
......
...@@ -205,6 +205,7 @@ class StackFrame { ...@@ -205,6 +205,7 @@ class StackFrame {
(type == JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH); (type == JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH);
} }
bool is_wasm_to_js() const { return type() == WASM_TO_JS; } bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
// Accessors. // Accessors.
Address sp() const { return state_.sp; } Address sp() const { return state_.sp; }
......
...@@ -45,12 +45,15 @@ void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) { ...@@ -45,12 +45,15 @@ void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) { void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
CodeEntry* entry = code_map->FindEntry(instruction_start); CodeEntry* entry = code_map->FindEntry(instruction_start);
if (!entry) { if (entry) {
// Code objects for builtins should already have been added to the map but entry->SetBuiltinId(builtin_id);
// some of them have been filtered out by CpuProfiler. } else if (builtin_id == Builtins::kGenericJSToWasmWrapper) {
return; // Make sure to add the generic js-to-wasm wrapper builtin, because that
// one is supposed to show up in profiles.
entry = new CodeEntry(CodeEventListener::BUILTIN_TAG,
Builtins::name(builtin_id));
code_map->AddCode(instruction_start, entry, instruction_size);
} }
entry->SetBuiltinId(builtin_id);
} }
TickSample* SamplingEventsProcessor::StartTickSample() { TickSample* SamplingEventsProcessor::StartTickSample() {
......
...@@ -359,7 +359,9 @@ void ProfilerCodeObserver::LogBuiltins() { ...@@ -359,7 +359,9 @@ void ProfilerCodeObserver::LogBuiltins() {
CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN);
ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
Builtins::Name id = static_cast<Builtins::Name>(i); Builtins::Name id = static_cast<Builtins::Name>(i);
rec->instruction_start = builtins->builtin(id).InstructionStart(); Code code = builtins->builtin(id);
rec->instruction_start = code.InstructionStart();
rec->instruction_size = code.InstructionSize();
rec->builtin_id = id; rec->builtin_id = id;
CodeEventHandlerInternal(evt_rec); CodeEventHandlerInternal(evt_rec);
} }
......
...@@ -92,6 +92,7 @@ class CodeDeoptEventRecord : public CodeEventRecord { ...@@ -92,6 +92,7 @@ class CodeDeoptEventRecord : public CodeEventRecord {
class ReportBuiltinEventRecord : public CodeEventRecord { class ReportBuiltinEventRecord : public CodeEventRecord {
public: public:
Address instruction_start; Address instruction_start;
unsigned instruction_size;
Builtins::Name builtin_id; Builtins::Name builtin_id;
V8_INLINE void UpdateCodeMap(CodeMap* code_map); V8_INLINE void UpdateCodeMap(CodeMap* code_map);
......
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