| OLD | NEW | 
|     1 // Copyright 2011 the V8 project authors. All rights reserved. |     1 // Copyright 2011 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 <limits.h> |     5 #include <limits.h> | 
|     6 #include <stdarg.h> |     6 #include <stdarg.h> | 
|     7 #include <stdlib.h> |     7 #include <stdlib.h> | 
|     8 #include <cmath> |     8 #include <cmath> | 
|     9  |     9  | 
|    10 #if V8_TARGET_ARCH_MIPS |    10 #if V8_TARGET_ARCH_MIPS | 
| (...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2341     } |  2341     } | 
|  2342   } |  2342   } | 
|  2343 } |  2343 } | 
|  2344  |  2344  | 
|  2345  |  2345  | 
|  2346 void Simulator::SignalException(Exception e) { |  2346 void Simulator::SignalException(Exception e) { | 
|  2347   V8_Fatal(__FILE__, __LINE__, "Error: Exception %i raised.", |  2347   V8_Fatal(__FILE__, __LINE__, "Error: Exception %i raised.", | 
|  2348            static_cast<int>(e)); |  2348            static_cast<int>(e)); | 
|  2349 } |  2349 } | 
|  2350  |  2350  | 
 |  2351 // Min/Max template functions for Double and Single arguments. | 
 |  2352  | 
|  2351 template <typename T> |  2353 template <typename T> | 
|  2352 T FPAbs(T a); |  2354 static T FPAbs(T a); | 
|  2353  |  2355  | 
|  2354 template <> |  2356 template <> | 
|  2355 double FPAbs<double>(double a) { |  2357 double FPAbs<double>(double a) { | 
|  2356   return fabs(a); |  2358   return fabs(a); | 
|  2357 } |  2359 } | 
|  2358  |  2360  | 
|  2359 template <> |  2361 template <> | 
|  2360 float FPAbs<float>(float a) { |  2362 float FPAbs<float>(float a) { | 
|  2361   return fabsf(a); |  2363   return fabsf(a); | 
|  2362 } |  2364 } | 
|  2363  |  2365  | 
|  2364 template <typename T> |  2366 template <typename T> | 
|  2365 bool Simulator::FPUProcessNaNsAndZeros(T a, T b, IsMin min, T& result) { |  2367 static bool FPUProcessNaNsAndZeros(T a, T b, MaxMinKind kind, T& result) { | 
|  2366   if (std::isnan(a) && std::isnan(b)) { |  2368   if (std::isnan(a) && std::isnan(b)) { | 
|  2367     result = a; |  2369     result = a; | 
|  2368   } else if (std::isnan(a)) { |  2370   } else if (std::isnan(a)) { | 
|  2369     result = b; |  2371     result = b; | 
|  2370   } else if (std::isnan(b)) { |  2372   } else if (std::isnan(b)) { | 
|  2371     result = a; |  2373     result = a; | 
|  2372   } else if (b == a) { |  2374   } else if (b == a) { | 
|  2373     // Handle -0.0 == 0.0 case. |  2375     // Handle -0.0 == 0.0 case. | 
|  2374     // std::signbit() returns int 0 or 1 so substracting IsMin::kMax negates the |  2376     // std::signbit() returns int 0 or 1 so substracting MaxMinKind::kMax | 
|  2375     // result. |  2377     // negates the result. | 
|  2376     result = std::signbit(b) - static_cast<int>(min) ? b : a; |  2378     result = std::signbit(b) - static_cast<int>(kind) ? b : a; | 
|  2377   } else { |  2379   } else { | 
|  2378     return false; |  2380     return false; | 
|  2379   } |  2381   } | 
|  2380   return true; |  2382   return true; | 
|  2381 } |  2383 } | 
|  2382  |  2384  | 
|  2383 template <typename T> |  2385 template <typename T> | 
|  2384 T Simulator::FPUMin(T a, T b) { |  2386 static T FPUMin(T a, T b) { | 
|  2385   T result; |  2387   T result; | 
|  2386   if (FPUProcessNaNsAndZeros(a, b, IsMin::kMin, result)) { |  2388   if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, result)) { | 
|  2387     return result; |  2389     return result; | 
|  2388   } else { |  2390   } else { | 
|  2389     return b < a ? b : a; |  2391     return b < a ? b : a; | 
|  2390   } |  2392   } | 
|  2391 } |  2393 } | 
|  2392  |  2394  | 
|  2393 template <typename T> |  2395 template <typename T> | 
|  2394 T Simulator::FPUMax(T a, T b) { |  2396 static T FPUMax(T a, T b) { | 
|  2395   T result; |  2397   T result; | 
|  2396   if (FPUProcessNaNsAndZeros(a, b, IsMin::kMax, result)) { |  2398   if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMax, result)) { | 
|  2397     return result; |  2399     return result; | 
|  2398   } else { |  2400   } else { | 
|  2399     return b > a ? b : a; |  2401     return b > a ? b : a; | 
|  2400   } |  2402   } | 
|  2401 } |  2403 } | 
|  2402  |  2404  | 
|  2403 template <typename T> |  2405 template <typename T> | 
|  2404 T Simulator::FPUMinA(T a, T b) { |  2406 static T FPUMinA(T a, T b) { | 
|  2405   T result; |  2407   T result; | 
|  2406   if (!FPUProcessNaNsAndZeros(a, b, IsMin::kMin, result)) { |  2408   if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, result)) { | 
|  2407     if (FPAbs(a) < FPAbs(b)) { |  2409     if (FPAbs(a) < FPAbs(b)) { | 
|  2408       result = a; |  2410       result = a; | 
|  2409     } else if (FPAbs(b) < FPAbs(a)) { |  2411     } else if (FPAbs(b) < FPAbs(a)) { | 
|  2410       result = b; |  2412       result = b; | 
|  2411     } else { |  2413     } else { | 
|  2412       result = a < b ? a : b; |  2414       result = a < b ? a : b; | 
|  2413     } |  2415     } | 
|  2414   } |  2416   } | 
|  2415   return result; |  2417   return result; | 
|  2416 } |  2418 } | 
|  2417  |  2419  | 
|  2418 template <typename T> |  2420 template <typename T> | 
|  2419 T Simulator::FPUMaxA(T a, T b) { |  2421 static T FPUMaxA(T a, T b) { | 
|  2420   T result; |  2422   T result; | 
|  2421   if (!FPUProcessNaNsAndZeros(a, b, IsMin::kMin, result)) { |  2423   if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, result)) { | 
|  2422     if (FPAbs(a) > FPAbs(b)) { |  2424     if (FPAbs(a) > FPAbs(b)) { | 
|  2423       result = a; |  2425       result = a; | 
|  2424     } else if (FPAbs(b) > FPAbs(a)) { |  2426     } else if (FPAbs(b) > FPAbs(a)) { | 
|  2425       result = b; |  2427       result = b; | 
|  2426     } else { |  2428     } else { | 
|  2427       result = a > b ? a : b; |  2429       result = a > b ? a : b; | 
|  2428     } |  2430     } | 
|  2429   } |  2431   } | 
|  2430   return result; |  2432   return result; | 
|  2431 } |  2433 } | 
| (...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4602  |  4604  | 
|  4603  |  4605  | 
|  4604 #undef UNSUPPORTED |  4606 #undef UNSUPPORTED | 
|  4605  |  4607  | 
|  4606 }  // namespace internal |  4608 }  // namespace internal | 
|  4607 }  // namespace v8 |  4609 }  // namespace v8 | 
|  4608  |  4610  | 
|  4609 #endif  // USE_SIMULATOR |  4611 #endif  // USE_SIMULATOR | 
|  4610  |  4612  | 
|  4611 #endif  // V8_TARGET_ARCH_MIPS |  4613 #endif  // V8_TARGET_ARCH_MIPS | 
| OLD | NEW |