Revision: 11932
Author:   [email protected]
Date:     Tue Jun 26 06:56:48 2012
Log:      Port r7868 (constant masking) to x64.

BUG=v8:1374
TEST=test-compiler/SplitConstantsInFullCompiler

Review URL: https://chromiumcodereview.appspot.com/10662045
http://code.google.com/p/v8/source/detail?r=11932

Modified:
 /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.h
 /branches/bleeding_edge/test/cctest/test-compiler.cc

=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Wed Jun 20 01:58:41 2012 +++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Tue Jun 26 06:56:48 2012
@@ -227,7 +227,7 @@
     __ lea(edx,
            Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset));
     __ push(edx);
-    __ SafePush(Immediate(Smi::FromInt(num_parameters)));
+    __ push(Immediate(Smi::FromInt(num_parameters)));
     // Arguments to ArgumentsAccessStub:
     //   function, receiver address, parameter count.
     // The stub will rewrite receiver and parameter count if the previous
@@ -2491,7 +2491,7 @@
   SetSourcePosition(expr->position());

   // Load function and argument count into edi and eax.
-  __ SafeSet(eax, Immediate(arg_count));
+  __ Set(eax, Immediate(arg_count));
   __ mov(edi, Operand(esp, arg_count * kPointerSize));

   // Record call targets in unoptimized code, but not in the snapshot.
@@ -2849,7 +2849,7 @@
   // parameter count in eax.
   VisitForAccumulatorValue(args->at(0));
   __ mov(edx, eax);
- __ SafeSet(eax, Immediate(Smi::FromInt(info_->scope()->num_parameters())));
+  __ Set(eax, Immediate(Smi::FromInt(info_->scope()->num_parameters())));
   ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT);
   __ CallStub(&stub);
   context()->Plug(eax);
@@ -2861,7 +2861,7 @@

   Label exit;
   // Get the number of formal parameters.
- __ SafeSet(eax, Immediate(Smi::FromInt(info_->scope()->num_parameters())));
+  __ Set(eax, Immediate(Smi::FromInt(info_->scope()->num_parameters())));

   // Check if the calling frame is an arguments adaptor frame.
   __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Wed Jun 20 01:58:41 2012 +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Tue Jun 26 06:56:48 2012
@@ -504,12 +504,20 @@

 void FullCodeGenerator::AccumulatorValueContext::Plug(
     Handle<Object> lit) const {
-  __ Move(result_register(), lit);
+  if (lit->IsSmi()) {
+    __ SafeMove(result_register(), Smi::cast(*lit));
+  } else {
+    __ Move(result_register(), lit);
+  }
 }


 void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
-  __ Push(lit);
+  if (lit->IsSmi()) {
+    __ SafePush(Smi::cast(*lit));
+  } else {
+    __ Push(lit);
+  }
 }


=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Sun Jun 10 23:59:56 2012 +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Tue Jun 26 06:56:48 2012
@@ -891,6 +891,38 @@
     movq(dst, kScratchRegister);
   }
 }
+
+
+bool MacroAssembler::IsUnsafeInt(const int x) {
+  static const int kMaxBits = 17;
+  return !is_intn(x, kMaxBits);
+}
+
+
+void MacroAssembler::SafeMove(Register dst, Smi* src) {
+  ASSERT(!dst.is(kScratchRegister));
+  ASSERT(kSmiValueSize == 32);  // JIT cookie can be converted to Smi.
+  if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
+    Move(dst, Smi::FromInt(src->value() ^ jit_cookie()));
+    Move(kScratchRegister, Smi::FromInt(jit_cookie()));
+    xor_(dst, kScratchRegister);
+  } else {
+    Move(dst, src);
+  }
+}
+
+
+void MacroAssembler::SafePush(Smi* src) {
+  ASSERT(kSmiValueSize == 32);  // JIT cookie can be converted to Smi.
+  if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
+    Push(Smi::FromInt(src->value() ^ jit_cookie()));
+    Move(kScratchRegister, Smi::FromInt(jit_cookie()));
+    xor_(Operand(rsp, 0), kScratchRegister);
+  } else {
+    Push(src);
+  }
+}
+

// ----------------------------------------------------------------------------
 // Smi tagging, untagging and tag detection.
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.h Wed May 23 07:24:29 2012 +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.h Tue Jun 26 06:56:48 2012
@@ -774,6 +774,11 @@
   // Move if the registers are not identical.
   void Move(Register target, Register source);

+  // Support for constant splitting.
+  bool IsUnsafeInt(const int x);
+  void SafeMove(Register dst, Smi* src);
+  void SafePush(Smi* src);
+
   // Bit-field support.
   void TestBit(const Operand& dst, int bit_index);

=======================================
--- /branches/bleeding_edge/test/cctest/test-compiler.cc Fri Jun 22 05:47:11 2012 +++ /branches/bleeding_edge/test/cctest/test-compiler.cc Tue Jun 26 06:56:48 2012
@@ -406,15 +406,16 @@
     Address end = pc + decode_size;

     v8::internal::EmbeddedVector<char, 128> decode_buffer;
+    v8::internal::EmbeddedVector<char, 128> smi_hex_buffer;
+    Smi* smi = Smi::FromInt(12345678);
+    OS::SNPrintF(smi_hex_buffer, "0x%lx", reinterpret_cast<intptr_t>(smi));
     while (pc < end) {
       int num_const = d.ConstantPoolSizeAt(pc);
       if (num_const >= 0) {
         pc += (num_const + 1) * kPointerSize;
       } else {
         pc += d.InstructionDecode(decode_buffer, pc);
-        CHECK(strstr(decode_buffer.start(), "mov eax,0x178c29c") == NULL);
-        CHECK(strstr(decode_buffer.start(), "push 0x178c29c") == NULL);
-        CHECK(strstr(decode_buffer.start(), "0x178c29c") == NULL);
+ CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL);
       }
     }
   }

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

Reply via email to