Reviewers: Lasse Reichstein,

Description:
X64: Add a jumptable to for deoptimization checks on X64.

The current version includes an extra jump compared to IA32, because
we need to load the jump address into a register and do an indirect
jump, but in the normal case we just jump over this by negating the
deoptimization conditional.


Please review this at http://codereview.chromium.org/6596032/

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

Affected files:
  M     src/x64/lithium-codegen-x64.h
  M     src/x64/lithium-codegen-x64.cc


Index: src/x64/lithium-codegen-x64.cc
===================================================================
--- src/x64/lithium-codegen-x64.cc      (revision 6957)
+++ src/x64/lithium-codegen-x64.cc      (working copy)
@@ -77,6 +77,7 @@
   return GeneratePrologue() &&
       GenerateBody() &&
       GenerateDeferredCode() &&
+      GenerateJumpTable() &&
       GenerateSafepointTable();
 }

@@ -240,6 +241,16 @@
 }


+bool LCodeGen::GenerateJumpTable() {
+ for (int i = 0; i < jump_table_.length(); i++) {
+    JumpTableEntry* info = jump_table_[i];
+    __ bind(&(info->label));
+    __ Jump(info->address, RelocInfo::RUNTIME_ENTRY);
+  }
+  return !is_aborted();
+}
+
+
 bool LCodeGen::GenerateDeferredCode() {
   ASSERT(is_generating());
   for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
@@ -512,10 +523,10 @@
   if (cc == no_condition) {
     __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
   } else {
-    NearLabel done;
-    __ j(NegateCondition(cc), &done);
-    __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
-    __ bind(&done);
+    JumpTableEntry* jump_info = new JumpTableEntry();
+    jump_info->address = entry;
+    __ j(cc, &jump_info->label);
+    jump_table_.Add(jump_info);
   }
 }

Index: src/x64/lithium-codegen-x64.h
===================================================================
--- src/x64/lithium-codegen-x64.h       (revision 6957)
+++ src/x64/lithium-codegen-x64.h       (working copy)
@@ -53,6 +53,7 @@
         current_instruction_(-1),
         instructions_(chunk->instructions()),
         deoptimizations_(4),
+        jump_table_(4),
         deoptimization_literals_(8),
         inlined_function_count_(0),
         scope_(chunk->graph()->info()->scope()),
@@ -147,6 +148,7 @@
   bool GeneratePrologue();
   bool GenerateBody();
   bool GenerateDeferredCode();
+  bool GenerateJumpTable();
   bool GenerateSafepointTable();

   void CallCode(Handle<Code> code,
@@ -234,6 +236,11 @@
   // Emits code for pushing a constant operand.
   void EmitPushConstantOperand(LOperand* operand);

+  struct JumpTableEntry {
+    Label label;
+    Address address;
+  };
+
   LChunk* const chunk_;
   MacroAssembler* const masm_;
   CompilationInfo* const info_;
@@ -242,6 +249,7 @@
   int current_instruction_;
   const ZoneList<LInstruction*>* instructions_;
   ZoneList<LEnvironment*> deoptimizations_;
+  ZoneList<JumpTableEntry*> jump_table_;
   ZoneList<Handle<Object> > deoptimization_literals_;
   int inlined_function_count_;
   Scope* const scope_;


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to