Revision: 3033
Author: [email protected]
Date: Thu Oct  8 00:09:46 2009
Log: Change clamping 0..255 instruction sequence for pixel array code.

The subb instruction added to the IA-32 assembler is not used as dec_b  
ended up being used instead.

There is a mesurable difference.
Review URL: http://codereview.chromium.org/246076
http://code.google.com/p/v8/source/detail?r=3033

Modified:
  /branches/bleeding_edge/src/ia32/assembler-ia32.cc
  /branches/bleeding_edge/src/ia32/assembler-ia32.h
  /branches/bleeding_edge/src/ia32/ic-ia32.cc
  /branches/bleeding_edge/src/x64/assembler-x64.cc
  /branches/bleeding_edge/src/x64/assembler-x64.h
  /branches/bleeding_edge/src/x64/ic-x64.cc

=======================================
--- /branches/bleeding_edge/src/ia32/assembler-ia32.cc  Thu Sep 10 06:56:12  
2009
+++ /branches/bleeding_edge/src/ia32/assembler-ia32.cc  Thu Oct  8 00:09:46  
2009
@@ -1164,6 +1164,19 @@
    EMIT(0xD1);
    EMIT(0xE8 | dst.code());
  }
+
+
+void Assembler::subb(const Operand& op, int8_t imm8) {
+  EnsureSpace ensure_space(this);
+  last_pc_ = pc_;
+  if (op.is_reg(eax)) {
+    EMIT(0x2c);
+  } else {
+    EMIT(0x80);
+    emit_operand(ebp, op);  // ebp == 5
+  }
+  EMIT(imm8);
+}


  void Assembler::sub(const Operand& dst, const Immediate& x) {
=======================================
--- /branches/bleeding_edge/src/ia32/assembler-ia32.h   Fri Sep 11 05:41:27  
2009
+++ /branches/bleeding_edge/src/ia32/assembler-ia32.h   Thu Oct  8 00:09:46  
2009
@@ -590,6 +590,7 @@
    void shr(Register dst);
    void shr_cl(Register dst);

+  void subb(const Operand& dst, int8_t imm8);
    void sub(const Operand& dst, const Immediate& x);
    void sub(Register dst, const Operand& src);
    void sub(const Operand& dst, Register src);
=======================================
--- /branches/bleeding_edge/src/ia32/ic-ia32.cc Wed Sep 30 13:18:40 2009
+++ /branches/bleeding_edge/src/ia32/ic-ia32.cc Thu Oct  8 00:09:46 2009
@@ -298,7 +298,6 @@
    __ shl(eax, kSmiTagSize);
    __ ret(0);

-
    // Slow case: Load name and receiver from stack and jump to runtime.
    __ bind(&slow);
    __ IncrementCounter(&Counters::keyed_load_generic_slow, 1);
@@ -427,11 +426,8 @@
      Label done, is_negative;
      __ test(eax, Immediate(0xFFFFFF00));
      __ j(zero, &done);
-    __ j(negative, &is_negative);
-    __ mov(eax, Immediate(255));
-    __ jmp(&done);
-    __ bind(&is_negative);
-    __ xor_(eax, Operand(eax));  // Clear eax.
+    __ setcc(negative, eax);  // 1 if negative, 0 if positive.
+    __ dec_b(eax);  // 0 if negative, 255 if positive.
      __ bind(&done);
    }
    __ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset));
@@ -458,7 +454,6 @@
    __ sub(Operand(ebx), Immediate(1 << kSmiTagSize));  // decrement ebx  
again
    __ jmp(&fast);

-
    // Array case: Get the length and the elements array from the JS
    // array. Check that the array is in fast mode; if it is the
    // length is always a smi.
=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64.cc    Tue Oct  6 06:11:05  
2009
+++ /branches/bleeding_edge/src/x64/assembler-x64.cc    Thu Oct  8 00:09:46  
2009
@@ -911,6 +911,27 @@
    emit(0xFF);
    emit_operand(1, dst);
  }
+
+
+void Assembler::decb(Register dst) {
+  EnsureSpace ensure_space(this);
+  last_pc_ = pc_;
+  if (dst.code() > 3) {
+    // Register is not one of al, bl, cl, dl.  Its encoding needs REX.
+    emit_rex_32(dst);
+  }
+  emit(0xFE);
+  emit_modrm(0x1, dst);
+}
+
+
+void Assembler::decb(const Operand& dst) {
+  EnsureSpace ensure_space(this);
+  last_pc_ = pc_;
+  emit_optional_rex_32(dst);
+  emit(0xFE);
+  emit_operand(1, dst);
+}


  void Assembler::enter(Immediate size) {
=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64.h     Tue Oct  6 06:11:05 2009
+++ /branches/bleeding_edge/src/x64/assembler-x64.h     Thu Oct  8 00:09:46 2009
@@ -703,6 +703,8 @@
    void decq(const Operand& dst);
    void decl(Register dst);
    void decl(const Operand& dst);
+  void decb(Register dst);
+  void decb(const Operand& dst);

    // Sign-extends rax into rdx:rax.
    void cqo();
=======================================
--- /branches/bleeding_edge/src/x64/ic-x64.cc   Wed Sep 30 13:18:40 2009
+++ /branches/bleeding_edge/src/x64/ic-x64.cc   Thu Oct  8 00:09:46 2009
@@ -491,11 +491,8 @@
      Label done, is_negative;
      __ testl(rax, Immediate(0xFFFFFF00));
      __ j(zero, &done);
-    __ j(negative, &is_negative);
-    __ movl(rax, Immediate(255));
-    __ jmp(&done);
-    __ bind(&is_negative);
-    __ xorl(rax, rax);  // Clear rax.
+    __ setcc(negative, rax);  // 1 if negative, 0 if positive.
+    __ decb(rax);  // 0 if negative, 255 if positive.
      __ bind(&done);
    }
    __ movq(rcx, FieldOperand(rcx, PixelArray::kExternalPointerOffset));

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

Reply via email to