Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 5640004: Allow the optimizing code generator to call Math.pow with untagged doubles. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
2177 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { 2238 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) {
2178 switch (instr->op()) { 2239 switch (instr->op()) {
2179 case kMathAbs: 2240 case kMathAbs:
2180 DoMathAbs(instr); 2241 DoMathAbs(instr);
2181 break; 2242 break;
2182 case kMathFloor: 2243 case kMathFloor:
2183 DoMathFloor(instr); 2244 DoMathFloor(instr);
2184 break; 2245 break;
2185 case kMathRound: 2246 case kMathRound:
2186 DoMathRound(instr); 2247 DoMathRound(instr);
2187 break; 2248 break;
2188 case kMathSqrt: 2249 case kMathSqrt:
2189 DoMathSqrt(instr); 2250 DoMathSqrt(instr);
2190 break; 2251 break;
2252 case kMathPowHalf:
2253 DoMathPowHalf(instr);
2254 break;
2191 default: 2255 default:
2192 UNREACHABLE(); 2256 UNREACHABLE();
2193 } 2257 }
2194 } 2258 }
2195 2259
2196 2260
2197 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { 2261 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2198 ASSERT(ToRegister(instr->result()).is(eax)); 2262 ASSERT(ToRegister(instr->result()).is(eax));
2199 2263
2200 int arity = instr->arity(); 2264 int arity = instr->arity();
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 ASSERT(!environment->HasBeenRegistered()); 3155 ASSERT(!environment->HasBeenRegistered());
3092 RegisterEnvironmentForDeoptimization(environment); 3156 RegisterEnvironmentForDeoptimization(environment);
3093 ASSERT(osr_pc_offset_ == -1); 3157 ASSERT(osr_pc_offset_ == -1);
3094 osr_pc_offset_ = masm()->pc_offset(); 3158 osr_pc_offset_ = masm()->pc_offset();
3095 } 3159 }
3096 3160
3097 3161
3098 #undef __ 3162 #undef __
3099 3163
3100 } } // namespace v8::internal 3164 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698