| Index: src/ia32/lithium-codegen-ia32.cc
|
| diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
|
| index 06628ffd81c334a85e992e72308fef4106825918..d50b780d71e4c6b2f6d379a2346d4286bfddc6d8 100644
|
| --- a/src/ia32/lithium-codegen-ia32.cc
|
| +++ b/src/ia32/lithium-codegen-ia32.cc
|
| @@ -1733,9 +1733,9 @@ void LCodeGen::DoMulI(LMulI* instr) {
|
| case 9:
|
| __ lea(left, Operand(left, left, times_8, 0));
|
| break;
|
| - case 16:
|
| - __ shl(left, 4);
|
| - break;
|
| + case 16:
|
| + __ shl(left, 4);
|
| + break;
|
| default:
|
| __ imul(left, left, constant);
|
| break;
|
| @@ -2208,6 +2208,8 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
|
| XMMRegister left = ToDoubleRegister(instr->left());
|
| XMMRegister right = ToDoubleRegister(instr->right());
|
| XMMRegister result = ToDoubleRegister(instr->result());
|
| + // Modulo uses a fixed result register.
|
| + ASSERT(instr->op() == Token::MOD || left.is(result));
|
| switch (instr->op()) {
|
| case Token::ADD:
|
| __ addsd(left, right);
|
| @@ -2234,7 +2236,7 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
|
| 4);
|
|
|
| // Return value is in st(0) on ia32.
|
| - // Store it into the result register.
|
| + // Store it into the (fixed) result register.
|
| __ sub(Operand(esp), Immediate(kDoubleSize));
|
| __ fstp_d(Operand(esp, 0));
|
| __ movdbl(result, Operand(esp, 0));
|
| @@ -2338,6 +2340,25 @@ void LCodeGen::EmitFalseBranch(InstrType instr, Condition cc) {
|
| }
|
|
|
|
|
| +void LCodeGen::DoIsNumberAndBranch(LIsNumberAndBranch* instr) {
|
| + Representation r = instr->hydrogen()->value()->representation();
|
| + if (r.IsSmiOrInteger32() || r.IsDouble()) {
|
| + EmitBranch(instr, no_condition);
|
| + } else {
|
| + ASSERT(r.IsTagged());
|
| + Register reg = ToRegister(instr->value());
|
| + HType type = instr->hydrogen()->value()->type();
|
| + if (type.IsTaggedNumber()) {
|
| + EmitBranch(instr, no_condition);
|
| + }
|
| + __ JumpIfSmi(reg, instr->TrueLabel(chunk_));
|
| + __ cmp(FieldOperand(reg, HeapObject::kMapOffset),
|
| + factory()->heap_number_map());
|
| + EmitBranch(instr, equal);
|
| + }
|
| +}
|
| +
|
| +
|
| void LCodeGen::DoBranch(LBranch* instr) {
|
| Representation r = instr->hydrogen()->value()->representation();
|
| if (r.IsSmiOrInteger32()) {
|
| @@ -2535,18 +2556,10 @@ void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
|
| EmitGoto(next_block);
|
| } else {
|
| if (instr->is_double()) {
|
| - if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
|
| - CpuFeatureScope scope(masm(), SSE2);
|
| - __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
|
| - } else {
|
| - X87Fxch(ToX87Register(right));
|
| - X87Fxch(ToX87Register(left), 1);
|
| - __ fld(0);
|
| - __ fld(2);
|
| - __ FCmp();
|
| - }
|
| + CpuFeatureScope scope(masm(), SSE2);
|
| // Don't base result on EFLAGS when a NaN is involved. Instead
|
| // jump to the false block.
|
| + __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
|
| __ j(parity_even, instr->FalseLabel(chunk_));
|
| } else {
|
| if (right->IsConstantOperand()) {
|
| @@ -3964,7 +3977,7 @@ void LCodeGen::DoMathFloor(LMathFloor* instr) {
|
| __ bind(&negative_sign);
|
| // Truncate, then compare and compensate.
|
| __ cvttsd2si(output_reg, Operand(input_reg));
|
| - __ Cvtsi2sd(xmm_scratch, output_reg);
|
| + __ cvtsi2sd(xmm_scratch, output_reg);
|
| __ ucomisd(input_reg, xmm_scratch);
|
| __ j(equal, &done, Label::kNear);
|
| __ sub(output_reg, Immediate(1));
|
| @@ -4014,7 +4027,7 @@ void LCodeGen::DoMathRound(LMathRound* instr) {
|
| __ RecordComment("D2I conversion overflow");
|
| DeoptimizeIf(equal, instr->environment());
|
|
|
| - __ Cvtsi2sd(xmm_scratch, output_reg);
|
| + __ cvtsi2sd(xmm_scratch, output_reg);
|
| __ ucomisd(xmm_scratch, input_temp);
|
| __ j(equal, &done);
|
| __ sub(output_reg, Immediate(1));
|
| @@ -4965,7 +4978,7 @@ void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
|
| ASSERT(output->IsDoubleRegister());
|
| if (CpuFeatures::IsSupported(SSE2)) {
|
| CpuFeatureScope scope(masm(), SSE2);
|
| - __ Cvtsi2sd(ToDoubleRegister(output), ToOperand(input));
|
| + __ cvtsi2sd(ToDoubleRegister(output), ToOperand(input));
|
| } else if (input->IsRegister()) {
|
| Register input_reg = ToRegister(input);
|
| __ push(input_reg);
|
| @@ -5074,7 +5087,7 @@ void LCodeGen::DoDeferredNumberTagI(LInstruction* instr,
|
| __ xor_(reg, 0x80000000);
|
| if (CpuFeatures::IsSupported(SSE2)) {
|
| CpuFeatureScope feature_scope(masm(), SSE2);
|
| - __ Cvtsi2sd(xmm0, Operand(reg));
|
| + __ cvtsi2sd(xmm0, Operand(reg));
|
| } else {
|
| __ push(reg);
|
| __ fild_s(Operand(esp, 0));
|
| @@ -5295,7 +5308,7 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
|
| bool deoptimize_on_minus_zero,
|
| LEnvironment* env,
|
| NumberUntagDMode mode) {
|
| - Label convert, load_smi, done;
|
| + Label load_smi, done;
|
|
|
| if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) {
|
| // Smi check.
|
| @@ -5304,15 +5317,26 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
|
| // Heap number map check.
|
| __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
|
| factory()->heap_number_map());
|
| - if (can_convert_undefined_to_nan) {
|
| - __ j(not_equal, &convert, Label::kNear);
|
| + if (!can_convert_undefined_to_nan) {
|
| + DeoptimizeIf(not_equal, env);
|
| } else {
|
| + Label heap_number, convert;
|
| + __ j(equal, &heap_number, Label::kNear);
|
| +
|
| + // Convert undefined (and hole) to NaN.
|
| + __ cmp(input_reg, factory()->undefined_value());
|
| DeoptimizeIf(not_equal, env);
|
| - }
|
|
|
| + __ bind(&convert);
|
| + ExternalReference nan =
|
| + ExternalReference::address_of_canonical_non_hole_nan();
|
| + __ movdbl(result_reg, Operand::StaticVariable(nan));
|
| + __ jmp(&done, Label::kNear);
|
| +
|
| + __ bind(&heap_number);
|
| + }
|
| // Heap number to XMM conversion.
|
| __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
|
| -
|
| if (deoptimize_on_minus_zero) {
|
| XMMRegister xmm_scratch = xmm0;
|
| __ xorps(xmm_scratch, xmm_scratch);
|
| @@ -5323,19 +5347,6 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
|
| DeoptimizeIf(not_zero, env);
|
| }
|
| __ jmp(&done, Label::kNear);
|
| -
|
| - if (can_convert_undefined_to_nan) {
|
| - __ bind(&convert);
|
| -
|
| - // Convert undefined (and hole) to NaN.
|
| - __ cmp(input_reg, factory()->undefined_value());
|
| - DeoptimizeIf(not_equal, env);
|
| -
|
| - ExternalReference nan =
|
| - ExternalReference::address_of_canonical_non_hole_nan();
|
| - __ movdbl(result_reg, Operand::StaticVariable(nan));
|
| - __ jmp(&done, Label::kNear);
|
| - }
|
| } else {
|
| ASSERT(mode == NUMBER_CANDIDATE_IS_SMI);
|
| }
|
| @@ -5345,7 +5356,7 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
|
| // input register since we avoid dependencies.
|
| __ mov(temp_reg, input_reg);
|
| __ SmiUntag(temp_reg); // Untag smi before converting to float.
|
| - __ Cvtsi2sd(result_reg, Operand(temp_reg));
|
| + __ cvtsi2sd(result_reg, Operand(temp_reg));
|
| __ bind(&done);
|
| }
|
|
|
| @@ -5406,16 +5417,12 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
|
| Register input_reg = ToRegister(input);
|
| ASSERT(input_reg.is(ToRegister(instr->result())));
|
|
|
| - if (instr->hydrogen()->value()->representation().IsSmi()) {
|
| - __ SmiUntag(input_reg);
|
| - } else {
|
| - DeferredTaggedToI* deferred =
|
| - new(zone()) DeferredTaggedToI(this, instr, x87_stack_);
|
| + DeferredTaggedToI* deferred =
|
| + new(zone()) DeferredTaggedToI(this, instr, x87_stack_);
|
|
|
| - __ JumpIfNotSmi(input_reg, deferred->entry());
|
| - __ SmiUntag(input_reg);
|
| - __ bind(deferred->exit());
|
| - }
|
| + __ JumpIfNotSmi(input_reg, deferred->entry());
|
| + __ SmiUntag(input_reg);
|
| + __ bind(deferred->exit());
|
| }
|
|
|
|
|
|
|