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 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2893 XMMRegister xmm_scratch = xmm0; | 2893 XMMRegister xmm_scratch = xmm0; |
2894 Register output_reg = ToRegister(instr->result()); | 2894 Register output_reg = ToRegister(instr->result()); |
2895 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2895 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
2896 | 2896 |
2897 Label below_half, done; | 2897 Label below_half, done; |
2898 // xmm_scratch = 0.5 | 2898 // xmm_scratch = 0.5 |
2899 ExternalReference one_half = ExternalReference::address_of_one_half(); | 2899 ExternalReference one_half = ExternalReference::address_of_one_half(); |
2900 __ movdbl(xmm_scratch, Operand::StaticVariable(one_half)); | 2900 __ movdbl(xmm_scratch, Operand::StaticVariable(one_half)); |
2901 __ ucomisd(xmm_scratch, input_reg); | 2901 __ ucomisd(xmm_scratch, input_reg); |
2902 __ j(above, &below_half); | 2902 __ j(above, &below_half); |
2903 // input = input + 0.5 | 2903 // xmm_scratch = input + 0.5 |
2904 __ addsd(input_reg, xmm_scratch); | 2904 __ addsd(xmm_scratch, input_reg); |
2905 | 2905 |
2906 // Compute Math.floor(value + 0.5). | 2906 // Compute Math.floor(value + 0.5). |
2907 // Use truncating instruction (OK because input is positive). | 2907 // Use truncating instruction (OK because input is positive). |
2908 __ cvttsd2si(output_reg, Operand(input_reg)); | 2908 __ cvttsd2si(output_reg, Operand(xmm_scratch)); |
2909 | 2909 |
2910 // Overflow is signalled with minint. | 2910 // Overflow is signalled with minint. |
2911 __ cmp(output_reg, 0x80000000u); | 2911 __ cmp(output_reg, 0x80000000u); |
2912 DeoptimizeIf(equal, instr->environment()); | 2912 DeoptimizeIf(equal, instr->environment()); |
2913 __ jmp(&done); | 2913 __ jmp(&done); |
2914 | 2914 |
2915 __ bind(&below_half); | 2915 __ bind(&below_half); |
2916 | 2916 |
2917 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if | 2917 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if |
2918 // we can ignore the difference between a result of -0 and +0. | 2918 // we can ignore the difference between a result of -0 and +0. |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4608 this, pointers, Safepoint::kLazyDeopt); | 4608 this, pointers, Safepoint::kLazyDeopt); |
4609 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4609 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4610 } | 4610 } |
4611 | 4611 |
4612 | 4612 |
4613 #undef __ | 4613 #undef __ |
4614 | 4614 |
4615 } } // namespace v8::internal | 4615 } } // namespace v8::internal |
4616 | 4616 |
4617 #endif // V8_TARGET_ARCH_IA32 | 4617 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |