Commit cab2794e authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6a949119
......@@ -1166,6 +1166,19 @@ void Assembler::shr_cl(Register dst) {
}
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) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
......
......@@ -590,6 +590,7 @@ class Assembler : public Malloced {
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);
......
......@@ -298,7 +298,6 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
__ 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 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
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 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
__ 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.
......
......@@ -913,6 +913,27 @@ void Assembler::decl(const Operand& 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) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
......
......@@ -703,6 +703,8 @@ class Assembler : public Malloced {
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();
......
......@@ -491,11 +491,8 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment