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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 425943002: Inline Math.fround in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: arm64 port Created 6 years, 4 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/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/double.h" 7 #include "src/double.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/hydrogen-infer-representation.h" 9 #include "src/hydrogen-infer-representation.h"
10 #include "src/property-details-inl.h" 10 #include "src/property-details-inl.h"
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 os << " [true]"; 1196 os << " [true]";
1197 } else if (known_successor_index() == 1) { 1197 } else if (known_successor_index() == 1) {
1198 os << " [false]"; 1198 os << " [false]";
1199 } 1199 }
1200 return os; 1200 return os;
1201 } 1201 }
1202 1202
1203 1203
1204 const char* HUnaryMathOperation::OpName() const { 1204 const char* HUnaryMathOperation::OpName() const {
1205 switch (op()) { 1205 switch (op()) {
1206 case kMathFloor: return "floor"; 1206 case kMathFloor:
1207 case kMathRound: return "round"; 1207 return "floor";
1208 case kMathAbs: return "abs"; 1208 case kMathFround:
1209 case kMathLog: return "log"; 1209 return "fround";
1210 case kMathExp: return "exp"; 1210 case kMathRound:
1211 case kMathSqrt: return "sqrt"; 1211 return "round";
1212 case kMathPowHalf: return "pow-half"; 1212 case kMathAbs:
1213 case kMathClz32: return "clz32"; 1213 return "abs";
1214 case kMathLog:
1215 return "log";
1216 case kMathExp:
1217 return "exp";
1218 case kMathSqrt:
1219 return "sqrt";
1220 case kMathPowHalf:
1221 return "pow-half";
1222 case kMathClz32:
1223 return "clz32";
1214 default: 1224 default:
1215 UNREACHABLE(); 1225 UNREACHABLE();
1216 return NULL; 1226 return NULL;
1217 } 1227 }
1218 } 1228 }
1219 1229
1220 1230
1221 Range* HUnaryMathOperation::InferRange(Zone* zone) { 1231 Range* HUnaryMathOperation::InferRange(Zone* zone) {
1222 Representation r = representation(); 1232 Representation r = representation();
1223 if (op() == kMathClz32) return new(zone) Range(0, 32); 1233 if (op() == kMathClz32) return new(zone) Range(0, 32);
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 switch (op) { 4138 switch (op) {
4129 case kMathExp: 4139 case kMathExp:
4130 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); 4140 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0);
4131 case kMathLog: 4141 case kMathLog:
4132 case kMathSqrt: 4142 case kMathSqrt:
4133 return H_CONSTANT_DOUBLE((d > 0.0) ? d : base::OS::nan_value()); 4143 return H_CONSTANT_DOUBLE((d > 0.0) ? d : base::OS::nan_value());
4134 case kMathPowHalf: 4144 case kMathPowHalf:
4135 case kMathAbs: 4145 case kMathAbs:
4136 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); 4146 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d);
4137 case kMathRound: 4147 case kMathRound:
4148 case kMathFround:
4138 case kMathFloor: 4149 case kMathFloor:
4139 return H_CONSTANT_DOUBLE(d); 4150 return H_CONSTANT_DOUBLE(d);
4140 case kMathClz32: 4151 case kMathClz32:
4141 return H_CONSTANT_INT(32); 4152 return H_CONSTANT_INT(32);
4142 default: 4153 default:
4143 UNREACHABLE(); 4154 UNREACHABLE();
4144 break; 4155 break;
4145 } 4156 }
4146 } 4157 }
4147 switch (op) { 4158 switch (op) {
4148 case kMathExp: 4159 case kMathExp:
4149 return H_CONSTANT_DOUBLE(fast_exp(d)); 4160 return H_CONSTANT_DOUBLE(fast_exp(d));
4150 case kMathLog: 4161 case kMathLog:
4151 return H_CONSTANT_DOUBLE(std::log(d)); 4162 return H_CONSTANT_DOUBLE(std::log(d));
4152 case kMathSqrt: 4163 case kMathSqrt:
4153 return H_CONSTANT_DOUBLE(fast_sqrt(d)); 4164 return H_CONSTANT_DOUBLE(fast_sqrt(d));
4154 case kMathPowHalf: 4165 case kMathPowHalf:
4155 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5)); 4166 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5));
4156 case kMathAbs: 4167 case kMathAbs:
4157 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d); 4168 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d);
4158 case kMathRound: 4169 case kMathRound:
4159 // -0.5 .. -0.0 round to -0.0. 4170 // -0.5 .. -0.0 round to -0.0.
4160 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); 4171 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0);
4161 // Doubles are represented as Significant * 2 ^ Exponent. If the 4172 // Doubles are represented as Significant * 2 ^ Exponent. If the
4162 // Exponent is not negative, the double value is already an integer. 4173 // Exponent is not negative, the double value is already an integer.
4163 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d); 4174 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d);
4164 return H_CONSTANT_DOUBLE(std::floor(d + 0.5)); 4175 return H_CONSTANT_DOUBLE(std::floor(d + 0.5));
4176 case kMathFround:
4177 return H_CONSTANT_DOUBLE(static_cast<double>(static_cast<float>(d)));
4165 case kMathFloor: 4178 case kMathFloor:
4166 return H_CONSTANT_DOUBLE(std::floor(d)); 4179 return H_CONSTANT_DOUBLE(std::floor(d));
4167 case kMathClz32: { 4180 case kMathClz32: {
4168 uint32_t i = DoubleToUint32(d); 4181 uint32_t i = DoubleToUint32(d);
4169 return H_CONSTANT_INT( 4182 return H_CONSTANT_INT(
4170 (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i)); 4183 (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i));
4171 } 4184 }
4172 default: 4185 default:
4173 UNREACHABLE(); 4186 UNREACHABLE();
4174 break; 4187 break;
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 break; 4783 break;
4771 case HObjectAccess::kExternalMemory: 4784 case HObjectAccess::kExternalMemory:
4772 os << "[external-memory]"; 4785 os << "[external-memory]";
4773 break; 4786 break;
4774 } 4787 }
4775 4788
4776 return os << "@" << access.offset(); 4789 return os << "@" << access.offset();
4777 } 4790 }
4778 4791
4779 } } // namespace v8::internal 4792 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698