| 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 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3355 if (instr->needs_check()) { | 3355 if (instr->needs_check()) { |
| 3356 Condition is_smi = __ CheckSmi(input); | 3356 Condition is_smi = __ CheckSmi(input); |
| 3357 DeoptimizeIf(NegateCondition(is_smi), instr->environment()); | 3357 DeoptimizeIf(NegateCondition(is_smi), instr->environment()); |
| 3358 } | 3358 } |
| 3359 __ SmiToInteger32(input, input); | 3359 __ SmiToInteger32(input, input); |
| 3360 } | 3360 } |
| 3361 | 3361 |
| 3362 | 3362 |
| 3363 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3363 void LCodeGen::EmitNumberUntagD(Register input_reg, |
| 3364 XMMRegister result_reg, | 3364 XMMRegister result_reg, |
| 3365 bool deoptimize_on_undefined, |
| 3365 LEnvironment* env) { | 3366 LEnvironment* env) { |
| 3366 NearLabel load_smi, heap_number, done; | 3367 NearLabel load_smi, done; |
| 3367 | 3368 |
| 3368 // Smi check. | 3369 // Smi check. |
| 3369 __ JumpIfSmi(input_reg, &load_smi); | 3370 __ JumpIfSmi(input_reg, &load_smi); |
| 3370 | 3371 |
| 3371 // Heap number map check. | 3372 // Heap number map check. |
| 3372 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 3373 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 3373 Heap::kHeapNumberMapRootIndex); | 3374 Heap::kHeapNumberMapRootIndex); |
| 3374 __ j(equal, &heap_number); | 3375 if (deoptimize_on_undefined) { |
| 3376 DeoptimizeIf(not_equal, env); |
| 3377 } else { |
| 3378 NearLabel heap_number; |
| 3379 __ j(equal, &heap_number); |
| 3380 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
| 3381 DeoptimizeIf(not_equal, env); |
| 3375 | 3382 |
| 3376 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | 3383 // Convert undefined to NaN. Compute NaN as 0/0. |
| 3377 DeoptimizeIf(not_equal, env); | 3384 __ xorpd(result_reg, result_reg); |
| 3385 __ divsd(result_reg, result_reg); |
| 3386 __ jmp(&done); |
| 3378 | 3387 |
| 3379 // Convert undefined to NaN. Compute NaN as 0/0. | 3388 __ bind(&heap_number); |
| 3380 __ xorpd(result_reg, result_reg); | 3389 } |
| 3381 __ divsd(result_reg, result_reg); | |
| 3382 __ jmp(&done); | |
| 3383 | |
| 3384 // Heap number to XMM conversion. | 3390 // Heap number to XMM conversion. |
| 3385 __ bind(&heap_number); | |
| 3386 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3391 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 3387 __ jmp(&done); | 3392 __ jmp(&done); |
| 3388 | 3393 |
| 3389 // Smi to XMM conversion | 3394 // Smi to XMM conversion |
| 3390 __ bind(&load_smi); | 3395 __ bind(&load_smi); |
| 3391 __ SmiToInteger32(kScratchRegister, input_reg); | 3396 __ SmiToInteger32(kScratchRegister, input_reg); |
| 3392 __ cvtlsi2sd(result_reg, kScratchRegister); | 3397 __ cvtlsi2sd(result_reg, kScratchRegister); |
| 3393 __ bind(&done); | 3398 __ bind(&done); |
| 3394 } | 3399 } |
| 3395 | 3400 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3466 | 3471 |
| 3467 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3472 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
| 3468 LOperand* input = instr->InputAt(0); | 3473 LOperand* input = instr->InputAt(0); |
| 3469 ASSERT(input->IsRegister()); | 3474 ASSERT(input->IsRegister()); |
| 3470 LOperand* result = instr->result(); | 3475 LOperand* result = instr->result(); |
| 3471 ASSERT(result->IsDoubleRegister()); | 3476 ASSERT(result->IsDoubleRegister()); |
| 3472 | 3477 |
| 3473 Register input_reg = ToRegister(input); | 3478 Register input_reg = ToRegister(input); |
| 3474 XMMRegister result_reg = ToDoubleRegister(result); | 3479 XMMRegister result_reg = ToDoubleRegister(result); |
| 3475 | 3480 |
| 3476 EmitNumberUntagD(input_reg, result_reg, instr->environment()); | 3481 EmitNumberUntagD(input_reg, result_reg, |
| 3482 instr->hydrogen()->deoptimize_on_undefined(), |
| 3483 instr->environment()); |
| 3477 } | 3484 } |
| 3478 | 3485 |
| 3479 | 3486 |
| 3480 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3487 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
| 3481 LOperand* input = instr->InputAt(0); | 3488 LOperand* input = instr->InputAt(0); |
| 3482 ASSERT(input->IsDoubleRegister()); | 3489 ASSERT(input->IsDoubleRegister()); |
| 3483 LOperand* result = instr->result(); | 3490 LOperand* result = instr->result(); |
| 3484 ASSERT(result->IsRegister()); | 3491 ASSERT(result->IsRegister()); |
| 3485 | 3492 |
| 3486 XMMRegister input_reg = ToDoubleRegister(input); | 3493 XMMRegister input_reg = ToDoubleRegister(input); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3995 RegisterEnvironmentForDeoptimization(environment); | 4002 RegisterEnvironmentForDeoptimization(environment); |
| 3996 ASSERT(osr_pc_offset_ == -1); | 4003 ASSERT(osr_pc_offset_ == -1); |
| 3997 osr_pc_offset_ = masm()->pc_offset(); | 4004 osr_pc_offset_ = masm()->pc_offset(); |
| 3998 } | 4005 } |
| 3999 | 4006 |
| 4000 #undef __ | 4007 #undef __ |
| 4001 | 4008 |
| 4002 } } // namespace v8::internal | 4009 } } // namespace v8::internal |
| 4003 | 4010 |
| 4004 #endif // V8_TARGET_ARCH_X64 | 4011 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |