Revision: 6703
Author: [email protected]
Date: Wed Feb  9 06:51:38 2011
Log: x64: Enable inline smi code patching to reenable the inlined code in
the code generated by the full code generator after my previous
change.

The generated code is the same as on ia32 and so is the patching.

Review URL: http://codereview.chromium.org/6456023
http://code.google.com/p/v8/source/detail?r=6703

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/x64/assembler-x64.h
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc
 /branches/bleeding_edge/src/x64/ic-x64.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Wed Feb  2 05:31:52 2011
+++ /branches/bleeding_edge/include/v8.h        Wed Feb  9 06:51:38 2011
@@ -462,7 +462,6 @@

   void Leave();

-
   internal::Object** prev_next_;
   internal::Object** prev_limit_;

=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64.h     Tue Feb  8 06:37:50 2011
+++ /branches/bleeding_edge/src/x64/assembler-x64.h     Wed Feb  9 06:51:38 2011
@@ -567,6 +567,15 @@
   static const byte kTestEaxByte = 0xA9;
   // One byte opcode for test al, 0xXX.
   static const byte kTestAlByte = 0xA8;
+  // One byte opcode for nop.
+  static const byte kNopByte = 0x90;
+
+  // One byte prefix for a short conditional jump.
+  static const byte kJccShortPrefix = 0x70;
+  static const byte kJncShortOpcode = kJccShortPrefix | not_carry;
+  static const byte kJcShortOpcode = kJccShortPrefix | carry;
+
+

// ---------------------------------------------------------------------------
   // Code generation
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Wed Feb 9 04:46:22 2011 +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Wed Feb 9 06:51:38 2011
@@ -1641,9 +1641,9 @@

 void FullCodeGenerator::EmitBinaryOp(Token::Value op,
                                      OverwriteMode mode) {
-  TypeRecordingBinaryOpStub stub(op, mode);
   __ pop(rdx);
-  __ CallStub(&stub);
+  TypeRecordingBinaryOpStub stub(op, mode);
+  EmitCallIC(stub.GetCode(), NULL);  // NULL signals no inlined smi code.
   context()->Plug(rax);
 }

=======================================
--- /branches/bleeding_edge/src/x64/ic-x64.cc   Mon Feb  7 23:49:59 2011
+++ /branches/bleeding_edge/src/x64/ic-x64.cc   Wed Feb  9 06:51:38 2011
@@ -1707,11 +1707,43 @@
            Token::Name(op_));
   }
 #endif
+
+  // Activate inlined smi code.
+  if (previous_state == UNINITIALIZED) {
+    PatchInlinedSmiCode(address());
+  }
 }

 void PatchInlinedSmiCode(Address address) {
-  // Disabled, then patched inline smi code is not implemented on X64.
-  // So we do nothing in this case.
+  // The address of the instruction following the call.
+  Address test_instruction_address =
+      address + Assembler::kCallTargetAddressOffset;
+
+  // If the instruction following the call is not a test al, nothing
+  // was inlined.
+  if (*test_instruction_address != Assembler::kTestAlByte) {
+    ASSERT(*test_instruction_address == Assembler::kNopByte);
+    return;
+  }
+
+  Address delta_address = test_instruction_address + 1;
+  // The delta to the start of the map check instruction and the
+  // condition code uses at the patched jump.
+  int8_t delta = *reinterpret_cast<int8_t*>(delta_address);
+  if (FLAG_trace_ic) {
+    PrintF("[  patching ic at %p, test=%p, delta=%d\n",
+           address, test_instruction_address, delta);
+  }
+
+  // Patch with a short conditional jump. There must be a
+  // short jump-if-carry/not-carry at this position.
+  Address jmp_address = test_instruction_address - delta;
+  ASSERT(*jmp_address == Assembler::kJncShortOpcode ||
+         *jmp_address == Assembler::kJcShortOpcode);
+  Condition cc = *jmp_address == Assembler::kJncShortOpcode
+      ? not_zero
+      : zero;
+  *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
 }


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

Reply via email to