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