Reviewers: alph, yurys, Sven Panne,

Message:
PTAL

Description:
CpuProfiler: log pc offset for deopts.

This is the fifth part of https://codereview.chromium.org/1012633002
In this part we collect the offsets of deopt calls and save it into
an inlined function info.

On the Next:
Later when deopt happens we will get the offset of deopt call and
searc it among inlined infos.

BUG=chromium:452067
LOG=n

Please review this at https://codereview.chromium.org/1011113004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+45, -0 lines):
  M src/arm/lithium-codegen-arm.cc
  M src/arm64/lithium-codegen-arm64.cc
  M src/compiler.h
  M src/compiler.cc
  M src/ia32/lithium-codegen-ia32.cc
  M src/mips/lithium-codegen-mips.cc
  M src/mips64/lithium-codegen-mips64.cc
  M src/ppc/lithium-codegen-ppc.cc
  M src/x64/lithium-codegen-x64.cc
  M src/x87/lithium-codegen-x87.cc


Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index fea392b567bd55db95be0c3a048fe6c7f7eee84a..646e1a9689a6e56ae7a460a5dc6f1efe5adbd01b 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -352,6 +352,8 @@ bool LCodeGen::GenerateJumpTable() {
       } else {
         __ bl(&call_deopt_entry);
       }
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
       masm()->CheckConstPool(false, false);
     }

@@ -887,6 +889,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
       !info()->saves_caller_doubles()) {
     DeoptComment(deopt_info);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);
Index: src/arm64/lithium-codegen-arm64.cc
diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index 620f841d8c220862343af542e5930796a120a747..2c99a607f53eefc812b0a366829507bbb3d52cc0 100644
--- a/src/arm64/lithium-codegen-arm64.cc
+++ b/src/arm64/lithium-codegen-arm64.cc
@@ -876,6 +876,8 @@ bool LCodeGen::GenerateJumpTable() {
         // table.
         __ Bl(&call_deopt_entry);
       }
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);

       masm()->CheckConstPool(false, false);
     }
@@ -1061,6 +1063,7 @@ void LCodeGen::DeoptimizeBranch(
       frame_is_built_ && !info()->saves_caller_doubles()) {
     DeoptComment(deopt_info);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
     Deoptimizer::JumpTableEntry* table_entry =
         new (zone()) Deoptimizer::JumpTableEntry(
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 35c581f6b09b2bdb09fc3edb499e15ced5005e43..b622d9ce8574932f79225fcef40f9ec7b6997da4 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -322,6 +322,14 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
 }


+void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) {
+  if (!track_positions_ || IsStub()) return;
+ DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_->size());
+  inlined_function_infos_->at(inlining_id)
+      .deopt_pc_offsets.push_back(pc_offset);
+}
+
+
 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
  public:
   explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 3f2aa4beb9474976891c293d3a041475f780fd5e..630e9cb74e47343efc66ed4c75894cebf792f762 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -97,6 +97,7 @@ struct InlinedFunctionInfo {
   SourcePosition inline_position;
   int script_id;
   int start_position;
+  std::vector<int> deopt_pc_offsets;

   static const int kNoParentId = -1;
 };
@@ -342,6 +343,13 @@ class CompilationInfo {
   std::vector<InlinedFunctionInfo>* inlined_function_infos() {
     return inlined_function_infos_;
   }
+  std::vector<InlinedFunctionInfo>* ReleaseInlinedFunctionInfos() {
+    std::vector<InlinedFunctionInfo>* tmp = inlined_function_infos_;
+    inlined_function_infos_ = NULL;
+    return tmp;
+  }
+
+  void LogDeoptCallPosition(int pc_offset, int inlining_id);
   int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
                            SourcePosition position, int pareint_id);

Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index a37935ad98ca32327de74c99165bc6b082e65f24..7228622030c35a7c5923a3f8e2754fff47dab97b 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -405,6 +405,8 @@ bool LCodeGen::GenerateJumpTable() {
         // inside the code body.
         Label push_approx_pc;
         __ call(&push_approx_pc);
+        info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                     table_entry->deopt_info.inlining_id);
         __ bind(&push_approx_pc);
         // Push the continuation which was stashed were the ebp should
         // be. Replace it with the saved ebp.
@@ -416,6 +418,8 @@ bool LCodeGen::GenerateJumpTable() {
     } else {
       if (info()->saves_caller_doubles()) RestoreCallerDoubles();
       __ call(entry, RelocInfo::RUNTIME_ENTRY);
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
     }
   }
   return !is_aborted();
@@ -868,6 +872,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
   if (cc == no_condition && frame_is_built_) {
     DeoptComment(deopt_info);
     __ call(entry, RelocInfo::RUNTIME_ENTRY);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index fca001f98b77b382d680111e577541d5ad279043..18d0c9bdae4197cd02fc648bd5105acae8f623b1 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -353,6 +353,8 @@ bool LCodeGen::GenerateJumpTable() {
       } else {
         __ Call(&call_deopt_entry);
       }
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
     }

     if (needs_frame.is_linked()) {
@@ -853,6 +855,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
       !info()->saves_caller_doubles()) {
     DeoptComment(deopt_info);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);
Index: src/mips64/lithium-codegen-mips64.cc
diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index 1471d58b89cbc7c36d3be07e5438ea5f3979f795..51c5ec48fe3ebca563d0d82a479a43e1deb0bc72 100644
--- a/src/mips64/lithium-codegen-mips64.cc
+++ b/src/mips64/lithium-codegen-mips64.cc
@@ -320,6 +320,8 @@ bool LCodeGen::GenerateJumpTable() {
     } else {
       __ Call(&call_deopt_entry);
     }
+    info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                 table_entry->deopt_info.inlining_id);
   }
   if (needs_frame.is_linked()) {
     __ bind(&needs_frame);
@@ -820,6 +822,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
       !info()->saves_caller_doubles()) {
     DeoptComment(deopt_info);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);
Index: src/ppc/lithium-codegen-ppc.cc
diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc
index f67f4c94de071b571139651df731b2c1d1610f3d..9af13ae23525989c6194b0905028e8aa135d6656 100644
--- a/src/ppc/lithium-codegen-ppc.cc
+++ b/src/ppc/lithium-codegen-ppc.cc
@@ -343,6 +343,8 @@ bool LCodeGen::GenerateJumpTable() {
       } else {
         __ b(&call_deopt_entry, SetLK);
       }
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
     }

     if (needs_frame.is_linked()) {
@@ -809,6 +811,7 @@ void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr,
   if (cond == al && frame_is_built_ && !info()->saves_caller_doubles()) {
     DeoptComment(deopt_info);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 82c912efcfdf27912a5d94e7fc05e8a6b49ff75e..871344dc4b7c77a34a77ffe9f5750cb4dacc761b 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -325,6 +325,8 @@ bool LCodeGen::GenerateJumpTable() {
         __ Push(rsi);
         __ movp(rsi, MemOperand(rsp, kPointerSize));
         __ call(kScratchRegister);
+        info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                     table_entry->deopt_info.inlining_id);
       }
     } else {
       if (info()->saves_caller_doubles()) {
@@ -332,6 +334,8 @@ bool LCodeGen::GenerateJumpTable() {
         RestoreCallerDoubles();
       }
       __ call(entry, RelocInfo::RUNTIME_ENTRY);
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
     }
   }
   return !is_aborted();
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index 81c55154ed40b3aa85b38125031d534750e4e824..23ebcac7622a1c8fdb4b653100f9e8890c1d9418 100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -402,6 +402,8 @@ bool LCodeGen::GenerateJumpTable() {
         // inside the code body.
         Label push_approx_pc;
         __ call(&push_approx_pc);
+        info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                     table_entry->deopt_info.inlining_id);
         __ bind(&push_approx_pc);
         // Push the continuation which was stashed were the ebp should
         // be. Replace it with the saved ebp.
@@ -412,6 +414,8 @@ bool LCodeGen::GenerateJumpTable() {
       }
     } else {
       __ call(entry, RelocInfo::RUNTIME_ENTRY);
+      info()->LogDeoptCallPosition(masm()->pc_offset(),
+                                   table_entry->deopt_info.inlining_id);
     }
   }
   return !is_aborted();
@@ -1150,6 +1154,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
   if (cc == no_condition && frame_is_built_) {
     DeoptComment(deopt_info);
     __ call(entry, RelocInfo::RUNTIME_ENTRY);
+ info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
   } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
                                             !frame_is_built_);


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to