Reviewers: Hannes Payer,

Description:
Removed confusing defensive programming in GenerateJumpTable.

For a given address/type pair we should always find a deoptimization
bailout ID, otherwise something is wrong. This was already asserted on
ARM, but we now do this consistently on all platforms.

Removed some usesless naming creativity on the way.

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+24, -48 lines):
  M src/arm/lithium-codegen-arm.h
  M src/arm/lithium-codegen-arm.cc
  M src/arm64/lithium-codegen-arm64.cc
  M src/ia32/lithium-codegen-ia32.cc
  M src/mips/lithium-codegen-mips.h
  M src/mips/lithium-codegen-mips.cc
  M src/mips64/lithium-codegen-mips64.h
  M src/mips64/lithium-codegen-mips64.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 b20f8b080bc108b0283b62c8a3cc273cae989f56..11b170b73818ab61ea2317107525b1ede4a64490 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -52,11 +52,8 @@ bool LCodeGen::GenerateCode() {
   // 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();
 }


@@ -313,7 +310,7 @@ bool LCodeGen::GenerateDeferredCode() {
 }


-bool LCodeGen::GenerateDeoptJumpTable() {
+bool LCodeGen::GenerateJumpTable() {
// Check that the jump table is accessible from everywhere in the function // code, i.e. that offsets to the table can be encoded in the 24bit signed
   // immediate of a branch instruction.
@@ -343,7 +340,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
       DCHECK(type == deopt_jump_table_[0].bailout_type);
       Address entry = table_entry->address;
       int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
-      DCHECK(id != Deoptimizer::kNotDeoptimizationEntry);
+      DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
       DeoptComment(table_entry->mnemonic, table_entry->reason);

Index: src/arm/lithium-codegen-arm.h
diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h
index a08768c0dfcce7c1b428793e0d93c6ac63f62c2a..ca8c563029152f4b3713cb2e020a2518fddd54f5 100644
--- a/src/arm/lithium-codegen-arm.h
+++ b/src/arm/lithium-codegen-arm.h
@@ -172,7 +172,7 @@ class LCodeGen: public LCodeGenBase {
   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.
Index: src/arm64/lithium-codegen-arm64.cc
diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index b08321577a80e4c65f5c0ffe6fe72cf043ac0f08..a7ea29b9f3d2dba5201b1a9888cd0c07114371aa 100644
--- a/src/arm64/lithium-codegen-arm64.cc
+++ b/src/arm64/lithium-codegen-arm64.cc
@@ -842,11 +842,8 @@ bool LCodeGen::GenerateJumpTable() {
       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);
-      }
+      DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
+ 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
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index c11d74f11c5e66f68c8bbdb6f98bf95d75efa3c6..259fbf0c39a42bb92a6e96a22c407b84ad83e698 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -388,11 +388,8 @@ bool LCodeGen::GenerateJumpTable() {
     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);
-    }
+    DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
+    Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     DeoptComment(table_entry->mnemonic, table_entry->reason);
     if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 6d73c831ebe09b9fcf7ff4e252f5bb850f5af85d..089fc5cf3c8c5e0e2b8c15d115b1a17b4945352e 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -76,11 +76,8 @@ bool LCodeGen::GenerateCode() {
   // 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();
 }


@@ -326,7 +323,7 @@ bool LCodeGen::GenerateDeferredCode() {
 }


-bool LCodeGen::GenerateDeoptJumpTable() {
+bool LCodeGen::GenerateJumpTable() {
   if (deopt_jump_table_.length() > 0) {
     Label needs_frame, call_deopt_entry;

@@ -343,7 +340,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
       DCHECK(type == deopt_jump_table_[0].bailout_type);
       Address entry = deopt_jump_table_[i].address;
       int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
-      DCHECK(id != Deoptimizer::kNotDeoptimizationEntry);
+      DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);

// Second-level deopt table entries are contiguous and small, so instead
Index: src/mips/lithium-codegen-mips.h
diff --git a/src/mips/lithium-codegen-mips.h b/src/mips/lithium-codegen-mips.h index ca25c891197e758db232b648f11d67ae0fc831cc..f5087a9a6e1d007b78724637e373f2607b4abb43 100644
--- a/src/mips/lithium-codegen-mips.h
+++ b/src/mips/lithium-codegen-mips.h
@@ -172,7 +172,7 @@ class LCodeGen: public LCodeGenBase {
   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.
Index: src/mips64/lithium-codegen-mips64.cc
diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index 965486cb244790402b7c80bdcb61bba6be951971..de619d6a8f53c43ece1293bcba6ea2513745ae5e 100644
--- a/src/mips64/lithium-codegen-mips64.cc
+++ b/src/mips64/lithium-codegen-mips64.cc
@@ -51,11 +51,8 @@ bool LCodeGen::GenerateCode() {
   // 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();
 }


@@ -302,7 +299,7 @@ bool LCodeGen::GenerateDeferredCode() {
 }


-bool LCodeGen::GenerateDeoptJumpTable() {
+bool LCodeGen::GenerateJumpTable() {
   if (deopt_jump_table_.length() > 0) {
     Comment(";;; -------------------- Jump table --------------------");
   }
@@ -315,11 +312,8 @@ bool LCodeGen::GenerateDeoptJumpTable() {
     Address entry = deopt_jump_table_[i].address;
     Deoptimizer::BailoutType type = deopt_jump_table_[i].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);
-    }
+    DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
+    Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     __ li(t9, Operand(ExternalReference::ForDeoptEntry(entry)));
     if (deopt_jump_table_[i].needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
Index: src/mips64/lithium-codegen-mips64.h
diff --git a/src/mips64/lithium-codegen-mips64.h b/src/mips64/lithium-codegen-mips64.h index b2193ae8afb704503370a7972c101dd1ae376253..3207f19fb9835eed70674bcb65e66eb67e2c7c59 100644
--- a/src/mips64/lithium-codegen-mips64.h
+++ b/src/mips64/lithium-codegen-mips64.h
@@ -173,7 +173,7 @@ class LCodeGen: public LCodeGenBase {
   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.
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 46456a1ef690e50118c4476ffabe5bcc3ab72ccd..15003a96456cdb0f0995d5c7660392f0c3d83dd0 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -308,11 +308,8 @@ bool LCodeGen::GenerateJumpTable() {
     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);
-    }
+    DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
+    Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     DeoptComment(table_entry->mnemonic, table_entry->reason);
     if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index ac67bb2f748e4918dc2d3e6cb96b79df8c76a759..ded2cd94ae6e08cd7865f075fe18b61e7e594ad3 100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -369,11 +369,8 @@ bool LCodeGen::GenerateJumpTable() {
     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);
-    }
+    DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id);
+    Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id);
     DeoptComment(table_entry->mnemonic, table_entry->reason);
     if (table_entry->needs_frame) {
       DCHECK(!info()->saves_caller_doubles());


--
--
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