Chromium Code Reviews| 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 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2074 Abort("Unimplemented: %s", "DoDeferredMathAbsTaggedHeapNumber"); | 2074 Abort("Unimplemented: %s", "DoDeferredMathAbsTaggedHeapNumber"); |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 | 2077 |
| 2078 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { | 2078 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { |
| 2079 Abort("Unimplemented: %s", "DoMathAbs"); | 2079 Abort("Unimplemented: %s", "DoMathAbs"); |
| 2080 } | 2080 } |
| 2081 | 2081 |
| 2082 | 2082 |
| 2083 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2083 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
| 2084 Abort("Unimplemented: %s", "DoMathFloor"); | 2084 XMMRegister xmm_scratch = xmm0; |
| 2085 Register output_reg = ToRegister(instr->result()); | |
| 2086 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | |
| 2087 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. | |
| 2088 __ ucomisd(input_reg, xmm_scratch); | |
| 2089 | |
| 2090 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
| 2091 DeoptimizeIf(below_equal, instr->environment()); | |
| 2092 } else { | |
| 2093 DeoptimizeIf(below, instr->environment()); | |
| 2094 } | |
| 2095 | |
| 2096 // Use truncating instruction (OK because input is positive). | |
| 2097 __ cvttsd2si(output_reg, input_reg); | |
|
Lasse Reichstein
2011/02/18 14:13:47
Use the "q" version, so you can properly handle mi
William Hesse
2011/02/18 14:33:28
But then we have much more complicated tests, beca
| |
| 2098 | |
| 2099 // Overflow is signalled with minint. | |
| 2100 __ cmpl(output_reg, Immediate(0x80000000)); | |
| 2101 DeoptimizeIf(equal, instr->environment()); | |
| 2085 } | 2102 } |
| 2086 | 2103 |
| 2087 | 2104 |
| 2088 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { | 2105 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { |
| 2089 Abort("Unimplemented: %s", "DoMathRound"); | 2106 const XMMRegister xmm_scratch = xmm0; |
| 2107 Register output_reg = ToRegister(instr->result()); | |
| 2108 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | |
| 2109 | |
| 2110 // xmm_scratch = 0.5 | |
| 2111 ExternalReference one_half = ExternalReference::address_of_one_half(); | |
| 2112 __ movq(kScratchRegister, one_half); | |
| 2113 __ movsd(xmm_scratch, Operand(kScratchRegister, 0)); | |
|
Lasse Reichstein
2011/02/18 14:13:47
Why load from memory when we have 64-bit immediate
William Hesse
2011/02/18 14:33:28
Done.
| |
| 2114 | |
| 2115 // input = input + 0.5 | |
| 2116 __ addsd(input_reg, xmm_scratch); | |
| 2117 | |
| 2118 // We need to return -0 for the input range [-0.5, 0[, otherwise | |
| 2119 // compute Math.floor(value + 0.5). | |
| 2120 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
| 2121 __ ucomisd(input_reg, xmm_scratch); | |
| 2122 DeoptimizeIf(below_equal, instr->environment()); | |
| 2123 } else { | |
| 2124 // If we don't need to bailout on -0, we check only bailout | |
| 2125 // on negative inputs. | |
| 2126 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. | |
| 2127 __ ucomisd(input_reg, xmm_scratch); | |
| 2128 DeoptimizeIf(below, instr->environment()); | |
| 2129 } | |
| 2130 | |
| 2131 // Compute Math.floor(value + 0.5). | |
| 2132 // Use truncating instruction (OK because input is positive). | |
| 2133 __ cvttsd2si(output_reg, input_reg); | |
| 2134 | |
| 2135 // Overflow is signalled with minint. | |
| 2136 __ cmpl(output_reg, Immediate(0x80000000)); | |
| 2137 DeoptimizeIf(equal, instr->environment()); | |
| 2090 } | 2138 } |
| 2091 | 2139 |
| 2092 | 2140 |
| 2093 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2141 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
| 2094 Abort("Unimplemented: %s", "DoMathSqrt"); | 2142 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2143 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | |
| 2144 __ sqrtsd(input_reg, input_reg); | |
| 2095 } | 2145 } |
| 2096 | 2146 |
| 2097 | 2147 |
| 2098 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { | 2148 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { |
| 2099 Abort("Unimplemented: %s", "DoMathPowHalf"); | 2149 XMMRegister xmm_scratch = xmm0; |
| 2150 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | |
| 2151 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | |
| 2152 __ xorpd(xmm_scratch, xmm_scratch); | |
| 2153 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. | |
| 2154 __ sqrtsd(input_reg, input_reg); | |
| 2100 } | 2155 } |
| 2101 | 2156 |
| 2102 | 2157 |
| 2103 void LCodeGen::DoPower(LPower* instr) { | 2158 void LCodeGen::DoPower(LPower* instr) { |
| 2104 Abort("Unimplemented: %s", "DoPower"); | 2159 Abort("Unimplemented: %s", "DoPower"); |
| 2105 } | 2160 } |
| 2106 | 2161 |
| 2107 | 2162 |
| 2108 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { | 2163 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { |
| 2109 Abort("Unimplemented: %s", "DoMathLog"); | 2164 Abort("Unimplemented: %s", "DoMathLog"); |
| 2110 } | 2165 } |
| 2111 | 2166 |
| 2112 | 2167 |
| 2113 void LCodeGen::DoMathCos(LUnaryMathOperation* instr) { | 2168 void LCodeGen::DoMathCos(LUnaryMathOperation* instr) { |
| 2114 Abort("Unimplemented: %s", "DoMathCos"); | 2169 Abort("Unimplemented: %s", "DoMathCos"); |
| 2115 } | 2170 } |
| 2116 | 2171 |
| 2117 | 2172 |
| 2118 void LCodeGen::DoMathSin(LUnaryMathOperation* instr) { | 2173 void LCodeGen::DoMathSin(LUnaryMathOperation* instr) { |
| 2119 Abort("Unimplemented: %s", "DoMathSin"); | 2174 Abort("Unimplemented: %s", "DoMathSin"); |
| 2120 } | 2175 } |
| 2121 | 2176 |
| 2122 | 2177 |
| 2123 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { | 2178 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { |
| 2124 Abort("Unimplemented: %s", "DoUnaryMathOperation"); | 2179 switch (instr->op()) { |
| 2180 case kMathAbs: | |
| 2181 DoMathAbs(instr); | |
| 2182 break; | |
| 2183 case kMathFloor: | |
| 2184 DoMathFloor(instr); | |
| 2185 break; | |
| 2186 case kMathRound: | |
| 2187 DoMathRound(instr); | |
| 2188 break; | |
| 2189 case kMathSqrt: | |
| 2190 DoMathSqrt(instr); | |
| 2191 break; | |
| 2192 case kMathPowHalf: | |
| 2193 DoMathPowHalf(instr); | |
| 2194 break; | |
| 2195 case kMathCos: | |
| 2196 DoMathCos(instr); | |
| 2197 break; | |
| 2198 case kMathSin: | |
| 2199 DoMathSin(instr); | |
| 2200 break; | |
| 2201 case kMathLog: | |
| 2202 DoMathLog(instr); | |
| 2203 break; | |
| 2204 | |
| 2205 default: | |
| 2206 UNREACHABLE(); | |
| 2207 } | |
| 2125 } | 2208 } |
| 2126 | 2209 |
| 2127 | 2210 |
| 2128 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 2211 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
| 2129 Abort("Unimplemented: %s", "DoCallKeyed"); | 2212 Abort("Unimplemented: %s", "DoCallKeyed"); |
| 2130 } | 2213 } |
| 2131 | 2214 |
| 2132 | 2215 |
| 2133 void LCodeGen::DoCallNamed(LCallNamed* instr) { | 2216 void LCodeGen::DoCallNamed(LCallNamed* instr) { |
| 2134 ASSERT(ToRegister(instr->result()).is(rax)); | 2217 ASSERT(ToRegister(instr->result()).is(rax)); |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2843 RegisterEnvironmentForDeoptimization(environment); | 2926 RegisterEnvironmentForDeoptimization(environment); |
| 2844 ASSERT(osr_pc_offset_ == -1); | 2927 ASSERT(osr_pc_offset_ == -1); |
| 2845 osr_pc_offset_ = masm()->pc_offset(); | 2928 osr_pc_offset_ = masm()->pc_offset(); |
| 2846 } | 2929 } |
| 2847 | 2930 |
| 2848 #undef __ | 2931 #undef __ |
| 2849 | 2932 |
| 2850 } } // namespace v8::internal | 2933 } } // namespace v8::internal |
| 2851 | 2934 |
| 2852 #endif // V8_TARGET_ARCH_X64 | 2935 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |