| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3417 if (instr->needs_check()) { | 3417 if (instr->needs_check()) { |
| 3418 __ test(ToRegister(input), Immediate(kSmiTagMask)); | 3418 __ test(ToRegister(input), Immediate(kSmiTagMask)); |
| 3419 DeoptimizeIf(not_zero, instr->environment()); | 3419 DeoptimizeIf(not_zero, instr->environment()); |
| 3420 } | 3420 } |
| 3421 __ SmiUntag(ToRegister(input)); | 3421 __ SmiUntag(ToRegister(input)); |
| 3422 } | 3422 } |
| 3423 | 3423 |
| 3424 | 3424 |
| 3425 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3425 void LCodeGen::EmitNumberUntagD(Register input_reg, |
| 3426 XMMRegister result_reg, | 3426 XMMRegister result_reg, |
| 3427 bool deoptimize_on_undefined, |
| 3427 LEnvironment* env) { | 3428 LEnvironment* env) { |
| 3428 NearLabel load_smi, heap_number, done; | 3429 NearLabel load_smi, done; |
| 3429 | 3430 |
| 3430 // Smi check. | 3431 // Smi check. |
| 3431 __ test(input_reg, Immediate(kSmiTagMask)); | 3432 __ test(input_reg, Immediate(kSmiTagMask)); |
| 3432 __ j(zero, &load_smi, not_taken); | 3433 __ j(zero, &load_smi, not_taken); |
| 3433 | 3434 |
| 3434 // Heap number map check. | 3435 // Heap number map check. |
| 3435 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 3436 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 3436 factory()->heap_number_map()); | 3437 factory()->heap_number_map()); |
| 3437 __ j(equal, &heap_number); | 3438 if (deoptimize_on_undefined) { |
| 3439 DeoptimizeIf(not_equal, env); |
| 3440 } else { |
| 3441 NearLabel heap_number; |
| 3442 __ j(equal, &heap_number); |
| 3443 __ cmp(input_reg, factory()->undefined_value()); |
| 3444 DeoptimizeIf(not_equal, env); |
| 3438 | 3445 |
| 3439 __ cmp(input_reg, factory()->undefined_value()); | 3446 // Convert undefined to NaN. |
| 3440 DeoptimizeIf(not_equal, env); | 3447 ExternalReference nan = ExternalReference::address_of_nan(); |
| 3448 __ movdbl(result_reg, Operand::StaticVariable(nan)); |
| 3449 __ jmp(&done); |
| 3441 | 3450 |
| 3442 // Convert undefined to NaN. | 3451 __ bind(&heap_number); |
| 3443 ExternalReference nan = ExternalReference::address_of_nan(); | 3452 } |
| 3444 __ movdbl(result_reg, Operand::StaticVariable(nan)); | |
| 3445 __ jmp(&done); | |
| 3446 | |
| 3447 // Heap number to XMM conversion. | 3453 // Heap number to XMM conversion. |
| 3448 __ bind(&heap_number); | |
| 3449 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3454 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 3450 __ jmp(&done); | 3455 __ jmp(&done); |
| 3451 | 3456 |
| 3452 // Smi to XMM conversion | 3457 // Smi to XMM conversion |
| 3453 __ bind(&load_smi); | 3458 __ bind(&load_smi); |
| 3454 __ SmiUntag(input_reg); // Untag smi before converting to float. | 3459 __ SmiUntag(input_reg); // Untag smi before converting to float. |
| 3455 __ cvtsi2sd(result_reg, Operand(input_reg)); | 3460 __ cvtsi2sd(result_reg, Operand(input_reg)); |
| 3456 __ SmiTag(input_reg); // Retag smi. | 3461 __ SmiTag(input_reg); // Retag smi. |
| 3457 __ bind(&done); | 3462 __ bind(&done); |
| 3458 } | 3463 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3571 | 3576 |
| 3572 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3577 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
| 3573 LOperand* input = instr->InputAt(0); | 3578 LOperand* input = instr->InputAt(0); |
| 3574 ASSERT(input->IsRegister()); | 3579 ASSERT(input->IsRegister()); |
| 3575 LOperand* result = instr->result(); | 3580 LOperand* result = instr->result(); |
| 3576 ASSERT(result->IsDoubleRegister()); | 3581 ASSERT(result->IsDoubleRegister()); |
| 3577 | 3582 |
| 3578 Register input_reg = ToRegister(input); | 3583 Register input_reg = ToRegister(input); |
| 3579 XMMRegister result_reg = ToDoubleRegister(result); | 3584 XMMRegister result_reg = ToDoubleRegister(result); |
| 3580 | 3585 |
| 3581 EmitNumberUntagD(input_reg, result_reg, instr->environment()); | 3586 EmitNumberUntagD(input_reg, result_reg, |
| 3587 instr->hydrogen()->deoptimize_on_undefined(), |
| 3588 instr->environment()); |
| 3582 } | 3589 } |
| 3583 | 3590 |
| 3584 | 3591 |
| 3585 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3592 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
| 3586 LOperand* input = instr->InputAt(0); | 3593 LOperand* input = instr->InputAt(0); |
| 3587 ASSERT(input->IsDoubleRegister()); | 3594 ASSERT(input->IsDoubleRegister()); |
| 3588 LOperand* result = instr->result(); | 3595 LOperand* result = instr->result(); |
| 3589 ASSERT(result->IsRegister()); | 3596 ASSERT(result->IsRegister()); |
| 3590 | 3597 |
| 3591 XMMRegister input_reg = ToDoubleRegister(input); | 3598 XMMRegister input_reg = ToDoubleRegister(input); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4165 ASSERT(osr_pc_offset_ == -1); | 4172 ASSERT(osr_pc_offset_ == -1); |
| 4166 osr_pc_offset_ = masm()->pc_offset(); | 4173 osr_pc_offset_ = masm()->pc_offset(); |
| 4167 } | 4174 } |
| 4168 | 4175 |
| 4169 | 4176 |
| 4170 #undef __ | 4177 #undef __ |
| 4171 | 4178 |
| 4172 } } // namespace v8::internal | 4179 } } // namespace v8::internal |
| 4173 | 4180 |
| 4174 #endif // V8_TARGET_ARCH_IA32 | 4181 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |