From 29ea4d1ef5360e71c61ecf8db6a5a0a0c3391fd1 Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Fri, 18 May 2018 09:38:14 +0200 Subject: [PATCH] [cpu-profiler] Move bailout reason into rare_info struct This was set very regularly in FillFunctionInfo, but it was almost always set to kNoReason, because the associated SFI had no bailout reason. Given that having a bailout reason is the rare case, we just assume an empty bailout reason, and use the rare_data_ struct to store the string pointer if we do need it. This saves another pointer of space on the CodeEntry object (approx 1.4 MiB on the node server example). Bug: v8:7719 Change-Id: I8e2272b572285ddf353ba0b303e6da095b7d5272 Reviewed-on: https://chromium-review.googlesource.com/1064370 Commit-Queue: Peter Marshall Reviewed-by: Alexei Filippov Cr-Commit-Position: refs/heads/master@{#53244} --- src/profiler/profile-generator-inl.h | 1 - src/profiler/profile-generator.cc | 4 +++- src/profiler/profile-generator.h | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/profiler/profile-generator-inl.h b/src/profiler/profile-generator-inl.h index 20510b6199..7ed6d54e17 100644 --- a/src/profiler/profile-generator-inl.h +++ b/src/profiler/profile-generator-inl.h @@ -23,7 +23,6 @@ CodeEntry::CodeEntry(CodeEventListener::LogEventsAndTags tag, const char* name, column_number_(column_number), script_id_(v8::UnboundScript::kNoScriptId), position_(0), - bailout_reason_(kEmptyBailoutReason), line_info_(std::move(line_info)), instruction_start_(instruction_start) {} diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc index 033b2c62e9..db5dd08d47 100644 --- a/src/profiler/profile-generator.cc +++ b/src/profiler/profile-generator.cc @@ -145,7 +145,9 @@ void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { Script* script = Script::cast(shared->script()); set_script_id(script->id()); set_position(shared->StartPosition()); - set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); + if (shared->optimization_disabled()) { + set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); + } } CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { diff --git a/src/profiler/profile-generator.h b/src/profiler/profile-generator.h index 239e97b8bb..5acc786cc6 100644 --- a/src/profiler/profile-generator.h +++ b/src/profiler/profile-generator.h @@ -56,9 +56,11 @@ class CodeEntry { int position() const { return position_; } void set_position(int position) { position_ = position; } void set_bailout_reason(const char* bailout_reason) { - bailout_reason_ = bailout_reason; + EnsureRareData()->bailout_reason_ = bailout_reason; + } + const char* bailout_reason() const { + return rare_data_ ? rare_data_->bailout_reason_ : kEmptyBailoutReason; } - const char* bailout_reason() const { return bailout_reason_; } void set_deopt_info(const char* deopt_reason, int deopt_id) { DCHECK(!has_deopt_info()); @@ -127,6 +129,7 @@ class CodeEntry { private: struct RareData { const char* deopt_reason_ = kNoDeoptReason; + const char* bailout_reason_ = kEmptyBailoutReason; int deopt_id_ = kNoDeoptimizationId; std::unordered_map>> inline_locations_; @@ -169,7 +172,6 @@ class CodeEntry { int column_number_; int script_id_; int position_; - const char* bailout_reason_; std::unique_ptr line_info_; Address instruction_start_; std::unique_ptr rare_data_;