Revision: 24061
Author:   [email protected]
Date:     Fri Sep 19 06:27:06 2014 UTC
Log:      Emit comment with instruction+reason before deopt calls.

Note that we still need to migrate from sometimes emitting those
comments by hand to passing a reason explicitly, but this can be done
incrementally in separate CLs.

[email protected]

Review URL: https://codereview.chromium.org/582743002
https://code.google.com/p/v8/source/detail?r=24061

Modified:
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.h
 /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc
 /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.h
 /branches/bleeding_edge/src/deoptimizer.h
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h
 /branches/bleeding_edge/src/lithium-codegen.cc
 /branches/bleeding_edge/src/lithium-codegen.h
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h
 /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.cc
 /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.h
 /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc
 /branches/bleeding_edge/src/x87/lithium-codegen-x87.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Fri Sep 19 06:27:06 2014 UTC
@@ -336,21 +336,23 @@

     int length = deopt_jump_table_.length();
     for (int i = 0; i < length; i++) {
-      __ bind(&deopt_jump_table_[i].label);
+      Deoptimizer::JumpTableEntry* table_entry = &deopt_jump_table_[i];
+      __ bind(&table_entry->label);

-      Deoptimizer::BailoutType type = deopt_jump_table_[i].bailout_type;
+      Deoptimizer::BailoutType type = table_entry->bailout_type;
       DCHECK(type == deopt_jump_table_[0].bailout_type);
-      Address entry = deopt_jump_table_[i].address;
+      Address entry = table_entry->address;
       int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
       DCHECK(id != Deoptimizer::kNotDeoptimizationEntry);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
+      DeoptComment(table_entry->mnemonic, table_entry->reason);

// Second-level deopt table entries are contiguous and small, so instead // of loading the full, absolute address of each one, load an immediate
       // offset which will be added to the base address later.
       __ mov(entry_offset, Operand(entry - base));

-      if (deopt_jump_table_[i].needs_frame) {
+      if (table_entry->needs_frame) {
         DCHECK(!info()->saves_caller_doubles());
         if (needs_frame.is_bound()) {
           __ b(&needs_frame);
@@ -847,6 +849,7 @@


 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
+                            const char* reason,
                             Deoptimizer::BailoutType bailout_type) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
@@ -904,6 +907,7 @@
   // restore caller doubles.
   if (condition == al && frame_is_built_ &&
       !info()->saves_caller_doubles()) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -912,9 +916,8 @@
         (deopt_jump_table_.last().address != entry) ||
         (deopt_jump_table_.last().bailout_type != bailout_type) ||
         (deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       deopt_jump_table_.Add(table_entry, zone());
     }
     __ b(condition, &deopt_jump_table_.last().label);
@@ -922,11 +925,12 @@
 }


-void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr) {
+void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(condition, instr, bailout_type);
+  DeoptimizeIf(condition, instr, reason, bailout_type);
 }


@@ -5665,8 +5669,7 @@
     type = Deoptimizer::LAZY;
   }

-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(al, instr, type);
+  DeoptimizeIf(al, instr, instr->hydrogen()->reason(), type);
 }


=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Fri Sep 19 06:27:06 2014 UTC
@@ -235,8 +235,9 @@
   void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
                                             Safepoint::DeoptMode mode);
   void DeoptimizeIf(Condition condition, LInstruction* instr,
-                    Deoptimizer::BailoutType bailout_type);
-  void DeoptimizeIf(Condition condition, LInstruction* instr);
+ const char* reason, Deoptimizer::BailoutType bailout_type);
+  void DeoptimizeIf(Condition condition, LInstruction* instr,
+                    const char* reason = NULL);

   void AddToTranslation(LEnvironment* environment,
                         Translation* translation,
=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Fri Sep 19 06:27:06 2014 UTC
@@ -593,11 +593,8 @@
   // the frame (that is done in GeneratePrologue).
   FrameScope frame_scope(masm_, StackFrame::NONE);

-  return GeneratePrologue() &&
-      GenerateBody() &&
-      GenerateDeferredCode() &&
-      GenerateDeoptJumpTable() &&
-      GenerateSafepointTable();
+  return GeneratePrologue() && GenerateBody() && GenerateDeferredCode() &&
+         GenerateJumpTable() && GenerateSafepointTable();
 }


@@ -827,28 +824,30 @@
 }


-bool LCodeGen::GenerateDeoptJumpTable() {
+bool LCodeGen::GenerateJumpTable() {
   Label needs_frame, restore_caller_doubles, call_deopt_entry;

-  if (deopt_jump_table_.length() > 0) {
+  if (jump_table_.length() > 0) {
     Comment(";;; -------------------- Jump table --------------------");
-    Address base = deopt_jump_table_[0]->address;
+    Address base = jump_table_[0]->address;

     UseScratchRegisterScope temps(masm());
     Register entry_offset = temps.AcquireX();

-    int length = deopt_jump_table_.length();
+    int length = jump_table_.length();
     for (int i = 0; i < length; i++) {
-      __ Bind(&deopt_jump_table_[i]->label);
+      Deoptimizer::JumpTableEntry* table_entry = jump_table_[i];
+      __ Bind(&table_entry->label);

-      Deoptimizer::BailoutType type = deopt_jump_table_[i]->bailout_type;
-      Address entry = deopt_jump_table_[i]->address;
+      Deoptimizer::BailoutType type = table_entry->bailout_type;
+      Address entry = table_entry->address;
       int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
       if (id == Deoptimizer::kNotDeoptimizationEntry) {
         Comment(";;; jump table entry %d.", i);
       } else {
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
       }
+      DeoptComment(table_entry->mnemonic, table_entry->reason);

// Second-level deopt table entries are contiguous and small, so instead
       // of loading the full, absolute address of each one, load the base
@@ -859,7 +858,7 @@
       // branch.
       bool last_entry = (i + 1) == length;

-      if (deopt_jump_table_[i]->needs_frame) {
+      if (table_entry->needs_frame) {
         DCHECK(!info()->saves_caller_doubles());
         if (!needs_frame.is_bound()) {
// This variant of deopt can only be used with stubs. Since we don't
@@ -997,8 +996,8 @@


 void LCodeGen::DeoptimizeBranch(
-    LInstruction* instr, BranchType branch_type, Register reg, int bit,
-    Deoptimizer::BailoutType* override_bailout_type) {
+    LInstruction* instr, const char* reason, BranchType branch_type,
+ Register reg, int bit, Deoptimizer::BailoutType* override_bailout_type) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
   Deoptimizer::BailoutType bailout_type =
@@ -1052,91 +1051,98 @@
// Go through jump table if we need to build frame, or restore caller doubles.
   if (branch_type == always &&
       frame_is_built_ && !info()->saves_caller_doubles()) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
     // We often have several deopts to the same entry, reuse the last
     // jump entry if this is the case.
-    if (deopt_jump_table_.is_empty() ||
-        (deopt_jump_table_.last()->address != entry) ||
-        (deopt_jump_table_.last()->bailout_type != bailout_type) ||
-        (deopt_jump_table_.last()->needs_frame != !frame_is_built_)) {
+    if (jump_table_.is_empty() || (jump_table_.last()->address != entry) ||
+        (jump_table_.last()->bailout_type != bailout_type) ||
+        (jump_table_.last()->needs_frame != !frame_is_built_)) {
       Deoptimizer::JumpTableEntry* table_entry =
-        new(zone()) Deoptimizer::JumpTableEntry(entry,
-                                                bailout_type,
-                                                !frame_is_built_);
-      deopt_jump_table_.Add(table_entry, zone());
+          new (zone()) Deoptimizer::JumpTableEntry(
+ entry, instr->Mnemonic(), reason, bailout_type, !frame_is_built_);
+      jump_table_.Add(table_entry, zone());
     }
-    __ B(&deopt_jump_table_.last()->label,
-         branch_type, reg, bit);
+    __ B(&jump_table_.last()->label, branch_type, reg, bit);
   }
 }


 void LCodeGen::Deoptimize(LInstruction* instr,
- Deoptimizer::BailoutType* override_bailout_type) {
-  DeoptimizeBranch(instr, always, NoReg, -1, override_bailout_type);
+                          Deoptimizer::BailoutType* override_bailout_type,
+                          const char* reason) {
+ DeoptimizeBranch(instr, reason, always, NoReg, -1, override_bailout_type);
 }


-void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr) {
-  DeoptimizeBranch(instr, static_cast<BranchType>(cond));
+void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr,
+                            const char* reason) {
+  DeoptimizeBranch(instr, reason, static_cast<BranchType>(cond));
 }


-void LCodeGen::DeoptimizeIfZero(Register rt, LInstruction* instr) {
-  DeoptimizeBranch(instr, reg_zero, rt);
+void LCodeGen::DeoptimizeIfZero(Register rt, LInstruction* instr,
+                                const char* reason) {
+  DeoptimizeBranch(instr, reason, reg_zero, rt);
 }


-void LCodeGen::DeoptimizeIfNotZero(Register rt, LInstruction* instr) {
-  DeoptimizeBranch(instr, reg_not_zero, rt);
+void LCodeGen::DeoptimizeIfNotZero(Register rt, LInstruction* instr,
+                                   const char* reason) {
+  DeoptimizeBranch(instr, reason, reg_not_zero, rt);
 }


-void LCodeGen::DeoptimizeIfNegative(Register rt, LInstruction* instr) {
+void LCodeGen::DeoptimizeIfNegative(Register rt, LInstruction* instr,
+                                    const char* reason) {
   int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit;
-  DeoptimizeIfBitSet(rt, sign_bit, instr);
+  DeoptimizeIfBitSet(rt, sign_bit, instr, reason);
 }


-void LCodeGen::DeoptimizeIfSmi(Register rt, LInstruction* instr) {
-  DeoptimizeIfBitClear(rt, MaskToBit(kSmiTagMask), instr);
+void LCodeGen::DeoptimizeIfSmi(Register rt, LInstruction* instr,
+                               const char* reason) {
+  DeoptimizeIfBitClear(rt, MaskToBit(kSmiTagMask), instr, reason);
 }


-void LCodeGen::DeoptimizeIfNotSmi(Register rt, LInstruction* instr) {
-  DeoptimizeIfBitSet(rt, MaskToBit(kSmiTagMask), instr);
+void LCodeGen::DeoptimizeIfNotSmi(Register rt, LInstruction* instr,
+                                  const char* reason) {
+  DeoptimizeIfBitSet(rt, MaskToBit(kSmiTagMask), instr, reason);
 }


 void LCodeGen::DeoptimizeIfRoot(Register rt, Heap::RootListIndex index,
-                                LInstruction* instr) {
+                                LInstruction* instr, const char* reason) {
   __ CompareRoot(rt, index);
-  DeoptimizeIf(eq, instr);
+  DeoptimizeIf(eq, instr, reason);
 }


 void LCodeGen::DeoptimizeIfNotRoot(Register rt, Heap::RootListIndex index,
-                                   LInstruction* instr) {
+ LInstruction* instr, const char* reason) {
   __ CompareRoot(rt, index);
-  DeoptimizeIf(ne, instr);
+  DeoptimizeIf(ne, instr, reason);
 }


-void LCodeGen::DeoptimizeIfMinusZero(DoubleRegister input,
-                                     LInstruction* instr) {
+void LCodeGen::DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr,
+                                     const char* reason) {
   __ TestForMinusZero(input);
-  DeoptimizeIf(vs, instr);
+  DeoptimizeIf(vs, instr, reason);
 }


-void LCodeGen::DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr) {
-  DeoptimizeBranch(instr, reg_bit_set, rt, bit);
+void LCodeGen::DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr,
+                                  const char* reason) {
+  DeoptimizeBranch(instr, reason, reg_bit_set, rt, bit);
 }


-void LCodeGen::DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr) {
-  DeoptimizeBranch(instr, reg_bit_clear, rt, bit);
+void LCodeGen::DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr,
+                                    const char* reason) {
+  DeoptimizeBranch(instr, reason, reg_bit_clear, rt, bit);
 }


@@ -2685,8 +2691,7 @@
     type = Deoptimizer::LAZY;
   }

-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  Deoptimize(instr, &type);
+  Deoptimize(instr, &type, instr->hydrogen()->reason());
 }


=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.h Fri Sep 19 06:27:06 2014 UTC
@@ -27,7 +27,7 @@
   LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
       : LCodeGenBase(chunk, assembler, info),
         deoptimizations_(4, info->zone()),
-        deopt_jump_table_(4, info->zone()),
+        jump_table_(4, info->zone()),
         deoptimization_literals_(8, info->zone()),
         inlined_function_count_(0),
         scope_(info->scope()),
@@ -213,24 +213,35 @@
                                    Register temp,
                                    LOperand* index,
                                    String::Encoding encoding);
-  void DeoptimizeBranch(LInstruction* instr, BranchType branch_type,
-                        Register reg = NoReg, int bit = -1,
+  void DeoptimizeBranch(LInstruction* instr, const char* reason,
+                        BranchType branch_type, Register reg = NoReg,
+                        int bit = -1,
Deoptimizer::BailoutType* override_bailout_type = NULL);
   void Deoptimize(LInstruction* instr,
-                  Deoptimizer::BailoutType* override_bailout_type = NULL);
-  void DeoptimizeIf(Condition cond, LInstruction* instr);
-  void DeoptimizeIfZero(Register rt, LInstruction* instr);
-  void DeoptimizeIfNotZero(Register rt, LInstruction* instr);
-  void DeoptimizeIfNegative(Register rt, LInstruction* instr);
-  void DeoptimizeIfSmi(Register rt, LInstruction* instr);
-  void DeoptimizeIfNotSmi(Register rt, LInstruction* instr);
+                  Deoptimizer::BailoutType* override_bailout_type = NULL,
+                  const char* reason = NULL);
+  void DeoptimizeIf(Condition cond, LInstruction* instr,
+                    const char* reason = NULL);
+  void DeoptimizeIfZero(Register rt, LInstruction* instr,
+                        const char* reason = NULL);
+  void DeoptimizeIfNotZero(Register rt, LInstruction* instr,
+                           const char* reason = NULL);
+  void DeoptimizeIfNegative(Register rt, LInstruction* instr,
+                            const char* reason = NULL);
+  void DeoptimizeIfSmi(Register rt, LInstruction* instr,
+                       const char* reason = NULL);
+  void DeoptimizeIfNotSmi(Register rt, LInstruction* instr,
+                          const char* reason = NULL);
   void DeoptimizeIfRoot(Register rt, Heap::RootListIndex index,
-                        LInstruction* instr);
+                        LInstruction* instr, const char* reason = NULL);
   void DeoptimizeIfNotRoot(Register rt, Heap::RootListIndex index,
-                           LInstruction* instr);
-  void DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr);
-  void DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr);
-  void DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr);
+                           LInstruction* instr, const char* reason = NULL);
+  void DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr,
+                             const char* reason = NULL);
+  void DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr,
+                          const char* reason = NULL);
+  void DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr,
+                            const char* reason = NULL);

   MemOperand PrepareKeyedExternalArrayOperand(Register key,
                                               Register base,
@@ -273,7 +284,7 @@
   void GenerateBodyInstructionPre(LInstruction* instr) OVERRIDE;
   bool GeneratePrologue();
   bool GenerateDeferredCode();
-  bool GenerateDeoptJumpTable();
+  bool GenerateJumpTable();
   bool GenerateSafepointTable();

   // Generates the custom OSR entrypoint and sets the osr_pc_offset.
@@ -338,7 +349,7 @@
   void EnsureSpaceForLazyDeopt(int space_needed) OVERRIDE;

   ZoneList<LEnvironment*> deoptimizations_;
-  ZoneList<Deoptimizer::JumpTableEntry*> deopt_jump_table_;
+  ZoneList<Deoptimizer::JumpTableEntry*> jump_table_;
   ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;
=======================================
--- /branches/bleeding_edge/src/deoptimizer.h   Mon Sep 15 10:57:52 2014 UTC
+++ /branches/bleeding_edge/src/deoptimizer.h   Fri Sep 19 06:27:06 2014 UTC
@@ -102,15 +102,19 @@
   static const int kBailoutTypesWithCodeEntry = SOFT + 1;

   struct JumpTableEntry : public ZoneObject {
-    inline JumpTableEntry(Address entry,
-                          Deoptimizer::BailoutType type,
+    inline JumpTableEntry(Address entry, const char* the_mnemonic,
+ const char* the_reason, Deoptimizer::BailoutType type,
                           bool frame)
         : label(),
           address(entry),
+          mnemonic(the_mnemonic),
+          reason(the_reason),
           bailout_type(type),
-          needs_frame(frame) { }
+          needs_frame(frame) {}
     Label label;
     Address address;
+    const char* mnemonic;
+    const char* reason;
     Deoptimizer::BailoutType bailout_type;
     bool needs_frame;
   };
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Fri Sep 19 06:27:06 2014 UTC
@@ -383,16 +383,18 @@
     Comment(";;; -------------------- Jump table --------------------");
   }
   for (int i = 0; i < jump_table_.length(); i++) {
-    __ bind(&jump_table_[i].label);
-    Address entry = jump_table_[i].address;
-    Deoptimizer::BailoutType type = jump_table_[i].bailout_type;
+    Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
+    __ bind(&table_entry->label);
+    Address entry = table_entry->address;
+    Deoptimizer::BailoutType type = table_entry->bailout_type;
     int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
     if (id == Deoptimizer::kNotDeoptimizationEntry) {
       Comment(";;; jump table entry %d.", i);
     } else {
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     }
-    if (jump_table_[i].needs_frame) {
+    DeoptComment(table_entry->mnemonic, table_entry->reason);
+    if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
       __ push(Immediate(ExternalReference::ForDeoptEntry(entry)));
       if (needs_frame.is_bound()) {
@@ -826,6 +828,7 @@


 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason,
                             Deoptimizer::BailoutType bailout_type) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
@@ -869,6 +872,7 @@

   DCHECK(info()->IsStub() || frame_is_built_);
   if (cc == no_condition && frame_is_built_) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ call(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -877,9 +881,8 @@
         jump_table_.last().address != entry ||
         jump_table_.last().needs_frame != !frame_is_built_ ||
         jump_table_.last().bailout_type != bailout_type) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       jump_table_.Add(table_entry, zone());
     }
     if (cc == no_condition) {
@@ -891,11 +894,12 @@
 }


-void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr) {
+void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(cc, instr, bailout_type);
+  DeoptimizeIf(cc, instr, reason, bailout_type);
 }


@@ -5463,8 +5467,7 @@
   if (info()->IsStub() && type == Deoptimizer::EAGER) {
     type = Deoptimizer::LAZY;
   }
-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(no_condition, instr, type);
+  DeoptimizeIf(no_condition, instr, instr->hydrogen()->reason(), type);
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Fri Sep 19 06:27:06 2014 UTC
@@ -209,9 +209,10 @@

   void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
                                             Safepoint::DeoptMode mode);
+  void DeoptimizeIf(Condition cc, LInstruction* instr, const char* reason,
+                    Deoptimizer::BailoutType bailout_type);
   void DeoptimizeIf(Condition cc, LInstruction* instr,
-                    Deoptimizer::BailoutType bailout_type);
-  void DeoptimizeIf(Condition cc, LInstruction* instr);
+                    const char* reason = NULL);

   bool DeoptEveryNTimes() {
     return FLAG_deopt_every_n_times != 0 && !info()->IsStub();
=======================================
--- /branches/bleeding_edge/src/lithium-codegen.cc Tue Aug 26 09:19:24 2014 UTC +++ /branches/bleeding_edge/src/lithium-codegen.cc Fri Sep 19 06:27:06 2014 UTC
@@ -145,6 +145,12 @@
   MemCopy(copy.start(), builder.Finalize(), copy.length());
   masm()->RecordComment(copy.start());
 }
+
+
+void LCodeGenBase::DeoptComment(const char* mnemonic, const char* reason) {
+  Comment(";;; deoptimize %s: %s", mnemonic,
+          reason == NULL ? "unknown reason" : reason);
+}


 int LCodeGenBase::GetNextEmittedBlock() const {
=======================================
--- /branches/bleeding_edge/src/lithium-codegen.h Tue Jun 3 08:12:43 2014 UTC +++ /branches/bleeding_edge/src/lithium-codegen.h Fri Sep 19 06:27:06 2014 UTC
@@ -33,6 +33,7 @@
   HGraph* graph() const;

   void FPRINTF_CHECKING Comment(const char* format, ...);
+  void DeoptComment(const char* mnemonic, const char* reason);

   bool GenerateBody();
   virtual void GenerateBodyInstructionPre(LInstruction* instr) {}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Fri Sep 19 06:27:06 2014 UTC
@@ -821,7 +821,8 @@

 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
                             Deoptimizer::BailoutType bailout_type,
-                            Register src1, const Operand& src2) {
+                            Register src1, const Operand& src2,
+                            const char* reason) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
   DCHECK(environment->HasBeenRegistered());
@@ -867,6 +868,7 @@
   // restore caller doubles.
   if (condition == al && frame_is_built_ &&
       !info()->saves_caller_doubles()) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -875,9 +877,8 @@
         (deopt_jump_table_.last().address != entry) ||
         (deopt_jump_table_.last().bailout_type != bailout_type) ||
         (deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       deopt_jump_table_.Add(table_entry, zone());
     }
     __ Branch(&deopt_jump_table_.last().label, condition, src1, src2);
@@ -886,11 +887,12 @@


 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
-                            Register src1, const Operand& src2) {
+                            Register src1, const Operand& src2,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(condition, instr, bailout_type, src1, src2);
+  DeoptimizeIf(condition, instr, bailout_type, src1, src2, reason);
 }


@@ -5676,8 +5678,8 @@
     type = Deoptimizer::LAZY;
   }

-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg));
+  DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg),
+               instr->hydrogen()->reason());
 }


=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Fri Sep 19 06:27:06 2014 UTC
@@ -231,10 +231,12 @@
   void DeoptimizeIf(Condition condition, LInstruction* instr,
                     Deoptimizer::BailoutType bailout_type,
                     Register src1 = zero_reg,
-                    const Operand& src2 = Operand(zero_reg));
+                    const Operand& src2 = Operand(zero_reg),
+                    const char* reason = NULL);
   void DeoptimizeIf(Condition condition, LInstruction* instr,
                     Register src1 = zero_reg,
-                    const Operand& src2 = Operand(zero_reg));
+                    const Operand& src2 = Operand(zero_reg),
+                    const char* reason = NULL);

   void AddToTranslation(LEnvironment* environment,
                         Translation* translation,
=======================================
--- /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.cc Fri Sep 19 06:27:06 2014 UTC
@@ -774,7 +774,8 @@

 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
                             Deoptimizer::BailoutType bailout_type,
-                            Register src1, const Operand& src2) {
+                            Register src1, const Operand& src2,
+                            const char* reason) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
   DCHECK(environment->HasBeenRegistered());
@@ -820,6 +821,7 @@
   // restore caller doubles.
   if (condition == al && frame_is_built_ &&
       !info()->saves_caller_doubles()) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -828,9 +830,8 @@
         (deopt_jump_table_.last().address != entry) ||
         (deopt_jump_table_.last().bailout_type != bailout_type) ||
         (deopt_jump_table_.last().needs_frame != !frame_is_built_)) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       deopt_jump_table_.Add(table_entry, zone());
     }
     __ Branch(&deopt_jump_table_.last().label, condition, src1, src2);
@@ -839,11 +840,12 @@


 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
-                            Register src1, const Operand& src2) {
+                            Register src1, const Operand& src2,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(condition, instr, bailout_type, src1, src2);
+  DeoptimizeIf(condition, instr, bailout_type, src1, src2, reason);
 }


@@ -5712,8 +5714,8 @@
     type = Deoptimizer::LAZY;
   }

-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg));
+  DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg),
+               instr->hydrogen()->reason());
 }


=======================================
--- /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/mips64/lithium-codegen-mips64.h Fri Sep 19 06:27:06 2014 UTC
@@ -232,10 +232,12 @@
   void DeoptimizeIf(Condition condition, LInstruction* instr,
                     Deoptimizer::BailoutType bailout_type,
                     Register src1 = zero_reg,
-                    const Operand& src2 = Operand(zero_reg));
+                    const Operand& src2 = Operand(zero_reg),
+                    const char* reason = NULL);
   void DeoptimizeIf(Condition condition, LInstruction* instr,
                     Register src1 = zero_reg,
-                    const Operand& src2 = Operand(zero_reg));
+                    const Operand& src2 = Operand(zero_reg),
+                    const char* reason = NULL);

   void AddToTranslation(LEnvironment* environment,
                         Translation* translation,
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Fri Sep 19 06:27:06 2014 UTC
@@ -303,16 +303,18 @@
     Comment(";;; -------------------- Jump table --------------------");
   }
   for (int i = 0; i < jump_table_.length(); i++) {
-    __ bind(&jump_table_[i].label);
-    Address entry = jump_table_[i].address;
-    Deoptimizer::BailoutType type = jump_table_[i].bailout_type;
+    Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
+    __ bind(&table_entry->label);
+    Address entry = table_entry->address;
+    Deoptimizer::BailoutType type = table_entry->bailout_type;
     int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
     if (id == Deoptimizer::kNotDeoptimizationEntry) {
       Comment(";;; jump table entry %d.", i);
     } else {
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     }
-    if (jump_table_[i].needs_frame) {
+    DeoptComment(table_entry->mnemonic, table_entry->reason);
+    if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
       __ Move(kScratchRegister, ExternalReference::ForDeoptEntry(entry));
       if (needs_frame.is_bound()) {
@@ -730,6 +732,7 @@


 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason,
                             Deoptimizer::BailoutType bailout_type) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
@@ -779,6 +782,7 @@
   // restore caller doubles.
   if (cc == no_condition && frame_is_built_ &&
       !info()->saves_caller_doubles()) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ call(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -787,9 +791,8 @@
         jump_table_.last().address != entry ||
         jump_table_.last().needs_frame != !frame_is_built_ ||
         jump_table_.last().bailout_type != bailout_type) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       jump_table_.Add(table_entry, zone());
     }
     if (cc == no_condition) {
@@ -801,11 +804,12 @@
 }


-void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr) {
+void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(cc, instr, bailout_type);
+  DeoptimizeIf(cc, instr, reason, bailout_type);
 }


@@ -5647,9 +5651,7 @@
   if (info()->IsStub() && type == Deoptimizer::EAGER) {
     type = Deoptimizer::LAZY;
   }
-
-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(no_condition, instr, type);
+  DeoptimizeIf(no_condition, instr, instr->hydrogen()->reason(), type);
 }


=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Fri Sep 19 06:27:06 2014 UTC
@@ -206,9 +206,10 @@
                                     int argc);
   void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
                                             Safepoint::DeoptMode mode);
+  void DeoptimizeIf(Condition cc, LInstruction* instr, const char* reason,
+                    Deoptimizer::BailoutType bailout_type);
   void DeoptimizeIf(Condition cc, LInstruction* instr,
-                    Deoptimizer::BailoutType bailout_type);
-  void DeoptimizeIf(Condition cc, LInstruction* instr);
+                    const char* reason = NULL);

   bool DeoptEveryNTimes() {
     return FLAG_deopt_every_n_times != 0 && !info()->IsStub();
=======================================
--- /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc Fri Sep 19 06:27:06 2014 UTC
@@ -364,16 +364,18 @@
     Comment(";;; -------------------- Jump table --------------------");
   }
   for (int i = 0; i < jump_table_.length(); i++) {
-    __ bind(&jump_table_[i].label);
-    Address entry = jump_table_[i].address;
-    Deoptimizer::BailoutType type = jump_table_[i].bailout_type;
+    Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i];
+    __ bind(&table_entry->label);
+    Address entry = table_entry->address;
+    Deoptimizer::BailoutType type = table_entry->bailout_type;
     int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
     if (id == Deoptimizer::kNotDeoptimizationEntry) {
       Comment(";;; jump table entry %d.", i);
     } else {
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     }
-    if (jump_table_[i].needs_frame) {
+    DeoptComment(table_entry->mnemonic, table_entry->reason);
+    if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
       __ push(Immediate(ExternalReference::ForDeoptEntry(entry)));
       if (needs_frame.is_bound()) {
@@ -1008,6 +1010,7 @@


 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason,
                             Deoptimizer::BailoutType bailout_type) {
   LEnvironment* environment = instr->environment();
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
@@ -1062,6 +1065,7 @@

   DCHECK(info()->IsStub() || frame_is_built_);
   if (cc == no_condition && frame_is_built_) {
+    DeoptComment(instr->Mnemonic(), reason);
     __ call(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
     // We often have several deopts to the same entry, reuse the last
@@ -1070,9 +1074,8 @@
         jump_table_.last().address != entry ||
         jump_table_.last().needs_frame != !frame_is_built_ ||
         jump_table_.last().bailout_type != bailout_type) {
-      Deoptimizer::JumpTableEntry table_entry(entry,
-                                              bailout_type,
-                                              !frame_is_built_);
+ Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, + bailout_type, !frame_is_built_);
       jump_table_.Add(table_entry, zone());
     }
     if (cc == no_condition) {
@@ -1084,11 +1087,12 @@
 }


-void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr) {
+void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
+                            const char* reason) {
   Deoptimizer::BailoutType bailout_type = info()->IsStub()
       ? Deoptimizer::LAZY
       : Deoptimizer::EAGER;
-  DeoptimizeIf(cc, instr, bailout_type);
+  DeoptimizeIf(cc, instr, reason, bailout_type);
 }


@@ -5528,8 +5532,7 @@
   if (info()->IsStub() && type == Deoptimizer::EAGER) {
     type = Deoptimizer::LAZY;
   }
-  Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
-  DeoptimizeIf(no_condition, instr, type);
+  DeoptimizeIf(no_condition, instr, instr->hydrogen()->reason(), type);
 }


=======================================
--- /branches/bleeding_edge/src/x87/lithium-codegen-x87.h Thu Sep 18 09:53:08 2014 UTC +++ /branches/bleeding_edge/src/x87/lithium-codegen-x87.h Fri Sep 19 06:27:06 2014 UTC
@@ -234,9 +234,10 @@

   void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
                                             Safepoint::DeoptMode mode);
+  void DeoptimizeIf(Condition cc, LInstruction* instr, const char* reason,
+                    Deoptimizer::BailoutType bailout_type);
   void DeoptimizeIf(Condition cc, LInstruction* instr,
-                    Deoptimizer::BailoutType bailout_type);
-  void DeoptimizeIf(Condition cc, LInstruction* instr);
+                    const char* reason = NULL);

   bool DeoptEveryNTimes() {
     return FLAG_deopt_every_n_times != 0 && !info()->IsStub();

--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to