OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 } | 2167 } |
2168 | 2168 |
2169 | 2169 |
2170 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2170 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
2171 XMMRegister input_reg = ToDoubleRegister(instr->input()); | 2171 XMMRegister input_reg = ToDoubleRegister(instr->input()); |
2172 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2172 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
2173 __ sqrtsd(input_reg, input_reg); | 2173 __ sqrtsd(input_reg, input_reg); |
2174 } | 2174 } |
2175 | 2175 |
2176 | 2176 |
| 2177 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { |
| 2178 XMMRegister xmm_scratch = xmm0; |
| 2179 XMMRegister input_reg = ToDoubleRegister(instr->input()); |
| 2180 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
| 2181 ExternalReference negative_infinity = |
| 2182 ExternalReference::address_of_negative_infinity(); |
| 2183 __ movdbl(xmm_scratch, Operand::StaticVariable(negative_infinity)); |
| 2184 __ ucomisd(xmm_scratch, input_reg); |
| 2185 DeoptimizeIf(equal, instr->environment()); |
| 2186 __ sqrtsd(input_reg, input_reg); |
| 2187 } |
| 2188 |
| 2189 |
| 2190 void LCodeGen::DoPower(LPower* instr) { |
| 2191 LOperand* left = instr->left(); |
| 2192 LOperand* right = instr->right(); |
| 2193 if (instr->exponent_type().IsDouble()) { |
| 2194 // Pass two doubles as arguments on the stack. |
| 2195 __ PrepareCallCFunction(4, eax); |
| 2196 __ movdbl(Operand(esp, 0 * kDoubleSize), ToDoubleRegister(left)); |
| 2197 __ movdbl(Operand(esp, 1 * kDoubleSize), ToDoubleRegister(right)); |
| 2198 __ CallCFunction(ExternalReference::power_double_double_function(), 4); |
| 2199 } else if (instr->exponent_type().IsInteger32()) { |
| 2200 __ PrepareCallCFunction(4, ebx); |
| 2201 __ movdbl(Operand(esp, 0 * kDoubleSize), ToDoubleRegister(left)); |
| 2202 __ mov(Operand(esp, 1 * kDoubleSize), ToRegister(right)); |
| 2203 __ CallCFunction(ExternalReference::power_double_int_function(), 4); |
| 2204 } else { |
| 2205 ASSERT(instr->exponent_type().IsTagged()); |
| 2206 __ PrepareCallCFunction(4, ebx); |
| 2207 __ movdbl(Operand(esp, 0 * kDoubleSize), ToDoubleRegister(left)); |
| 2208 Register right_reg = ToRegister(right); |
| 2209 Label non_smi; |
| 2210 Label done; |
| 2211 __ test(right_reg, Immediate(kSmiTagMask)); |
| 2212 __ j(not_zero, &non_smi); |
| 2213 __ SmiUntag(right_reg); |
| 2214 __ mov(Operand(esp, 1 * kDoubleSize), ToRegister(right)); |
| 2215 __ CallCFunction(ExternalReference::power_double_int_function(), 4); |
| 2216 __ jmp(&done); |
| 2217 |
| 2218 __ bind(&non_smi); |
| 2219 __ CmpObjectType(right_reg, HEAP_NUMBER_TYPE , ebx); |
| 2220 DeoptimizeIf(not_equal, instr->environment()); |
| 2221 __ movdbl(xmm1, FieldOperand(right_reg, HeapNumber::kValueOffset)); |
| 2222 __ movdbl(Operand(esp, 1 * kDoubleSize), xmm1); |
| 2223 __ CallCFunction(ExternalReference::power_double_double_function(), 4); |
| 2224 |
| 2225 __ bind(&done); |
| 2226 } |
| 2227 |
| 2228 // Return value is in st(0) on ia32. |
| 2229 // Store it into the (fixed) result register. |
| 2230 __ sub(Operand(esp), Immediate(kDoubleSize)); |
| 2231 __ fstp_d(Operand(esp, 0)); |
| 2232 __ movdbl(ToDoubleRegister(instr->result()), Operand(esp, 0)); |
| 2233 __ add(Operand(esp), Immediate(kDoubleSize)); |
| 2234 } |
| 2235 |
| 2236 |
2177 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { | 2237 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { |
2178 switch (instr->op()) { | 2238 switch (instr->op()) { |
2179 case kMathAbs: | 2239 case kMathAbs: |
2180 DoMathAbs(instr); | 2240 DoMathAbs(instr); |
2181 break; | 2241 break; |
2182 case kMathFloor: | 2242 case kMathFloor: |
2183 DoMathFloor(instr); | 2243 DoMathFloor(instr); |
2184 break; | 2244 break; |
2185 case kMathRound: | 2245 case kMathRound: |
2186 DoMathRound(instr); | 2246 DoMathRound(instr); |
2187 break; | 2247 break; |
2188 case kMathSqrt: | 2248 case kMathSqrt: |
2189 DoMathSqrt(instr); | 2249 DoMathSqrt(instr); |
2190 break; | 2250 break; |
| 2251 case kMathPowHalf: |
| 2252 DoMathPowHalf(instr); |
| 2253 break; |
2191 default: | 2254 default: |
2192 UNREACHABLE(); | 2255 UNREACHABLE(); |
2193 } | 2256 } |
2194 } | 2257 } |
2195 | 2258 |
2196 | 2259 |
2197 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 2260 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
2198 ASSERT(ToRegister(instr->result()).is(eax)); | 2261 ASSERT(ToRegister(instr->result()).is(eax)); |
2199 | 2262 |
2200 int arity = instr->arity(); | 2263 int arity = instr->arity(); |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 ASSERT(!environment->HasBeenRegistered()); | 3154 ASSERT(!environment->HasBeenRegistered()); |
3092 RegisterEnvironmentForDeoptimization(environment); | 3155 RegisterEnvironmentForDeoptimization(environment); |
3093 ASSERT(osr_pc_offset_ == -1); | 3156 ASSERT(osr_pc_offset_ == -1); |
3094 osr_pc_offset_ = masm()->pc_offset(); | 3157 osr_pc_offset_ = masm()->pc_offset(); |
3095 } | 3158 } |
3096 | 3159 |
3097 | 3160 |
3098 #undef __ | 3161 #undef __ |
3099 | 3162 |
3100 } } // namespace v8::internal | 3163 } } // namespace v8::internal |
OLD | NEW |