diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index b8dda17b64..bc28710f93 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -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_; diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 610017bef5..ba226168d7 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -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); diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc index f7369a8b7f..444a1b711f 100644 --- a/src/ia32/ic-ia32.cc +++ b/src/ia32/ic-ia32.cc @@ -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. diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index cf79a435bb..855c94c7e6 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -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_; diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index e17a55d828..afb90ea243 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -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(); diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc index 820909122a..8189053c7e 100644 --- a/src/x64/ic-x64.cc +++ b/src/x64/ic-x64.cc @@ -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));