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

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

Issue 6532054: X64 Crankshaft: Implement MathRound, MathFloor, MathSqrt, and MathPowHalf Una... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 months 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-ia32.cc ('k') | src/x64/lithium-x64.cc » ('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 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 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 Abort("Unimplemented: %s", "DoDeferredMathAbsTaggedHeapNumber"); 2090 Abort("Unimplemented: %s", "DoDeferredMathAbsTaggedHeapNumber");
2091 } 2091 }
2092 2092
2093 2093
2094 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { 2094 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
2095 Abort("Unimplemented: %s", "DoMathAbs"); 2095 Abort("Unimplemented: %s", "DoMathAbs");
2096 } 2096 }
2097 2097
2098 2098
2099 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { 2099 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
2100 Abort("Unimplemented: %s", "DoMathFloor"); 2100 XMMRegister xmm_scratch = xmm0;
2101 Register output_reg = ToRegister(instr->result());
2102 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2103 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2104 __ ucomisd(input_reg, xmm_scratch);
2105
2106 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2107 DeoptimizeIf(below_equal, instr->environment());
2108 } else {
2109 DeoptimizeIf(below, instr->environment());
2110 }
2111
2112 // Use truncating instruction (OK because input is positive).
2113 __ cvttsd2si(output_reg, input_reg);
2114
2115 // Overflow is signalled with minint.
2116 __ cmpl(output_reg, Immediate(0x80000000));
2117 DeoptimizeIf(equal, instr->environment());
2101 } 2118 }
2102 2119
2103 2120
2104 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) { 2121 void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
2105 Abort("Unimplemented: %s", "DoMathRound"); 2122 const XMMRegister xmm_scratch = xmm0;
2123 Register output_reg = ToRegister(instr->result());
2124 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2125
2126 // xmm_scratch = 0.5
2127 __ movq(kScratchRegister, V8_INT64_C(0x3FE0000000000000), RelocInfo::NONE);
2128 __ movq(xmm_scratch, kScratchRegister);
2129
2130 // input = input + 0.5
2131 __ addsd(input_reg, xmm_scratch);
2132
2133 // We need to return -0 for the input range [-0.5, 0[, otherwise
2134 // compute Math.floor(value + 0.5).
2135 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2136 __ ucomisd(input_reg, xmm_scratch);
2137 DeoptimizeIf(below_equal, instr->environment());
2138 } else {
2139 // If we don't need to bailout on -0, we check only bailout
2140 // on negative inputs.
2141 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2142 __ ucomisd(input_reg, xmm_scratch);
2143 DeoptimizeIf(below, instr->environment());
2144 }
2145
2146 // Compute Math.floor(value + 0.5).
2147 // Use truncating instruction (OK because input is positive).
2148 __ cvttsd2si(output_reg, input_reg);
2149
2150 // Overflow is signalled with minint.
2151 __ cmpl(output_reg, Immediate(0x80000000));
2152 DeoptimizeIf(equal, instr->environment());
2106 } 2153 }
2107 2154
2108 2155
2109 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { 2156 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
2110 Abort("Unimplemented: %s", "DoMathSqrt"); 2157 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2158 ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2159 __ sqrtsd(input_reg, input_reg);
2111 } 2160 }
2112 2161
2113 2162
2114 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { 2163 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) {
2115 Abort("Unimplemented: %s", "DoMathPowHalf"); 2164 XMMRegister xmm_scratch = xmm0;
2165 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2166 ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2167 __ xorpd(xmm_scratch, xmm_scratch);
2168 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0.
2169 __ sqrtsd(input_reg, input_reg);
2116 } 2170 }
2117 2171
2118 2172
2119 void LCodeGen::DoPower(LPower* instr) { 2173 void LCodeGen::DoPower(LPower* instr) {
2120 Abort("Unimplemented: %s", "DoPower"); 2174 Abort("Unimplemented: %s", "DoPower");
2121 } 2175 }
2122 2176
2123 2177
2124 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { 2178 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) {
2125 Abort("Unimplemented: %s", "DoMathLog"); 2179 Abort("Unimplemented: %s", "DoMathLog");
2126 } 2180 }
2127 2181
2128 2182
2129 void LCodeGen::DoMathCos(LUnaryMathOperation* instr) { 2183 void LCodeGen::DoMathCos(LUnaryMathOperation* instr) {
2130 Abort("Unimplemented: %s", "DoMathCos"); 2184 Abort("Unimplemented: %s", "DoMathCos");
2131 } 2185 }
2132 2186
2133 2187
2134 void LCodeGen::DoMathSin(LUnaryMathOperation* instr) { 2188 void LCodeGen::DoMathSin(LUnaryMathOperation* instr) {
2135 Abort("Unimplemented: %s", "DoMathSin"); 2189 Abort("Unimplemented: %s", "DoMathSin");
2136 } 2190 }
2137 2191
2138 2192
2139 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { 2193 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) {
2140 Abort("Unimplemented: %s", "DoUnaryMathOperation"); 2194 switch (instr->op()) {
2195 case kMathAbs:
2196 DoMathAbs(instr);
2197 break;
2198 case kMathFloor:
2199 DoMathFloor(instr);
2200 break;
2201 case kMathRound:
2202 DoMathRound(instr);
2203 break;
2204 case kMathSqrt:
2205 DoMathSqrt(instr);
2206 break;
2207 case kMathPowHalf:
2208 DoMathPowHalf(instr);
2209 break;
2210 case kMathCos:
2211 DoMathCos(instr);
2212 break;
2213 case kMathSin:
2214 DoMathSin(instr);
2215 break;
2216 case kMathLog:
2217 DoMathLog(instr);
2218 break;
2219
2220 default:
2221 UNREACHABLE();
2222 }
2141 } 2223 }
2142 2224
2143 2225
2144 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { 2226 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2145 Abort("Unimplemented: %s", "DoCallKeyed"); 2227 Abort("Unimplemented: %s", "DoCallKeyed");
2146 } 2228 }
2147 2229
2148 2230
2149 void LCodeGen::DoCallNamed(LCallNamed* instr) { 2231 void LCodeGen::DoCallNamed(LCallNamed* instr) {
2150 ASSERT(ToRegister(instr->result()).is(rax)); 2232 ASSERT(ToRegister(instr->result()).is(rax));
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 RegisterEnvironmentForDeoptimization(environment); 3139 RegisterEnvironmentForDeoptimization(environment);
3058 ASSERT(osr_pc_offset_ == -1); 3140 ASSERT(osr_pc_offset_ == -1);
3059 osr_pc_offset_ = masm()->pc_offset(); 3141 osr_pc_offset_ = masm()->pc_offset();
3060 } 3142 }
3061 3143
3062 #undef __ 3144 #undef __
3063 3145
3064 } } // namespace v8::internal 3146 } } // namespace v8::internal
3065 3147
3066 #endif // V8_TARGET_ARCH_X64 3148 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698