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

Side by Side Diff: src/strtod.cc

Issue 3813009: Disable double strtod in ARM-simulator. (Closed)
Patch Set: Removed unnecessary space. Created 10 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 ASSERT(0 <= digit && digit <= 9); 145 ASSERT(0 <= digit && digit <= 9);
146 result = 10 * result + digit; 146 result = 10 * result + digit;
147 } 147 }
148 return result; 148 return result;
149 } 149 }
150 150
151 151
152 static bool DoubleStrtod(Vector<const char> trimmed, 152 static bool DoubleStrtod(Vector<const char> trimmed,
153 int exponent, 153 int exponent,
154 double* result) { 154 double* result) {
155 #if defined(V8_TARGET_ARCH_IA32) && !defined(WIN32) 155 #if (defined(V8_TARGET_ARCH_IA32) || defined(USE_SIMULATOR)) && !defined(WIN32)
156 // On x86 the floating-point stack can be 64 or 80 bits wide. If it is 156 // On x86 the floating-point stack can be 64 or 80 bits wide. If it is
157 // 80 bits wide (as is the case on Linux) then double-rounding occurs and the 157 // 80 bits wide (as is the case on Linux) then double-rounding occurs and the
158 // result is not accurate. 158 // result is not accurate.
159 // We know that Windows32 uses 64 bits and is therefore accurate. 159 // We know that Windows32 uses 64 bits and is therefore accurate.
160 // Note that the ARM simulator is compiled for 32bits. It therefore exhibits
161 // the same problem.
160 return false; 162 return false;
161 #endif 163 #endif
162 if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) { 164 if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) {
163 // The trimmed input fits into a double. 165 // The trimmed input fits into a double.
164 // If the 10^exponent (resp. 10^-exponent) fits into a double too then we 166 // If the 10^exponent (resp. 10^-exponent) fits into a double too then we
165 // can compute the result-double simply by multiplying (resp. dividing) the 167 // can compute the result-double simply by multiplying (resp. dividing) the
166 // two numbers. 168 // two numbers.
167 // This is possible because IEEE guarantees that floating-point operations 169 // This is possible because IEEE guarantees that floating-point operations
168 // return the best possible approximation. 170 // return the best possible approximation.
169 if (exponent < 0 && -exponent < kExactPowersOfTenSize) { 171 if (exponent < 0 && -exponent < kExactPowersOfTenSize) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) return V8_INFINITY; 205 if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) return V8_INFINITY;
204 if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0; 206 if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0;
205 double result; 207 double result;
206 if (DoubleStrtod(trimmed, exponent, &result)) { 208 if (DoubleStrtod(trimmed, exponent, &result)) {
207 return result; 209 return result;
208 } 210 }
209 return old_strtod(trimmed, exponent); 211 return old_strtod(trimmed, exponent);
210 } 212 }
211 213
212 } } // namespace v8::internal 214 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698