UnaryMathFunction CreateExpFunction() {
- if (!FLAG_fast_math) return &exp;
+ if (!FLAG_fast_math) return &std::exp;
size_t actual_size;
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
- if (buffer == NULL) return &exp;
+ if (buffer == NULL) return &std::exp;
ExternalReference::InitializeMathExpData();
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <stdarg.h>
#include <stdlib.h>
#include <cmath>
-#include <cstdarg>
+
#include "v8.h"
#if V8_TARGET_ARCH_ARM
} else if ((instr->Opc2Value() == 0x0) && (instr->Opc3Value() == 0x3)) {
// vabs
double dm_value = get_double_from_d_register(vm);
- double dd_value = fabs(dm_value);
+ double dd_value = std::fabs(dm_value);
dd_value = canonicalizeNaN(dd_value);
set_d_register_from_double(vd, dd_value);
} else if ((instr->Opc2Value() == 0x1) && (instr->Opc3Value() == 0x1)) {
} else if (((instr->Opc2Value() == 0x1)) && (instr->Opc3Value() == 0x3)) {
// vsqrt
double dm_value = get_double_from_d_register(vm);
- double dd_value = sqrt(dm_value);
+ double dd_value = std::sqrt(dm_value);
dd_value = canonicalizeNaN(dd_value);
set_d_register_from_double(vd, dd_value);
} else if (instr->Opc3Value() == 0x0) {
inv_op_vfp_flag_ = get_inv_op_vfp_flag(mode, val, unsigned_integer);
double abs_diff =
- unsigned_integer ? fabs(val - static_cast<uint32_t>(temp))
- : fabs(val - temp);
+ unsigned_integer ? std::fabs(val - static_cast<uint32_t>(temp))
+ : std::fabs(val - temp);
inexact_vfp_flag_ = (abs_diff != 0);
// The rest is black magic. Do not attempt to understand it. It is
// loosely based on the "expd" function published at:
// http://herumi.blogspot.com/2011/08/fast-double-precision-exponential.html
- const double constant3 = (1 << kTableSizeBits) / log(2.0);
+ const double constant3 = (1 << kTableSizeBits) / std::log(2.0);
math_exp_constants_array[3] = constant3;
math_exp_constants_array[4] =
static_cast<double>(static_cast<int64_t>(3) << 51);
math_exp_log_table_array = new double[kTableSize];
for (int i = 0; i < kTableSize; i++) {
- double value = pow(2, i / kTableSizeDouble);
+ double value = std::pow(2, i / kTableSizeDouble);
uint64_t bits = BitCast<uint64_t, double>(value);
bits &= (static_cast<uint64_t>(1) << 52) - 1;
double mantissa = BitCast<double, uint64_t>(bits);
Isolate* isolate) {
typedef double (*d2d)(double x);
return ExternalReference(Redirect(isolate,
- FUNCTION_ADDR(static_cast<d2d>(log)),
+ FUNCTION_ADDR(static_cast<d2d>(std::log)),
BUILTIN_FP_CALL));
}
// special cases that are different.
if ((x == 0.0 || std::isinf(x)) && std::isfinite(y)) {
double f;
- if (modf(y, &f) != 0.0) return ((x == 0.0) ^ (y > 0)) ? V8_INFINITY : 0;
+ if (std::modf(y, &f) != 0.0) {
+ return ((x == 0.0) ^ (y > 0)) ? V8_INFINITY : 0;
+ }
}
if (x == 2.0) {
int y_int = static_cast<int>(y);
- if (y == y_int) return ldexp(1.0, y_int);
+ if (y == y_int) {
+ return std::ldexp(1.0, y_int);
+ }
}
#endif
if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) {
return OS::nan_value();
}
- return pow(x, y);
+ return std::pow(x, y);
}
// For doubles len(f) == 53 (don't forget the hidden bit).
const int kSignificandSize = 53;
- double estimate = ceil((exponent + kSignificandSize - 1) * k1Log10 - 1e-10);
+ double estimate =
+ std::ceil((exponent + kSignificandSize - 1) * k1Log10 - 1e-10);
return static_cast<int>(estimate);
}
int kQ = DiyFp::kSignificandSize;
// Some platforms return incorrect sign on 0 result. We can ignore that here,
// which means we can avoid depending on platform.h.
- double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
+ double k = std::ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
int foo = kCachedPowersOffset;
int index =
(foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
inline double DoubleToInteger(double x) {
if (std::isnan(x)) return 0;
if (!std::isfinite(x) || x == 0) return x;
- return (x >= 0) ? floor(x) : ceil(x);
+ return (x >= 0) ? std::floor(x) : std::ceil(x);
}
}
ASSERT(number != 0);
- return ldexp(static_cast<double>(negative ? -number : number), exponent);
+ return std::ldexp(static_cast<double>(negative ? -number : number), exponent);
}
if (is_negative) value = -value;
// Get the integer part and the decimal part.
- double integer_part = floor(value);
+ double integer_part = std::floor(value);
double decimal_part = value - integer_part;
// Convert the integer part starting from the back. Always generate
// at least one digit.
int integer_pos = kBufferSize - 2;
do {
- double remainder = fmod(integer_part, radix);
+ double remainder = std::fmod(integer_part, radix);
integer_buffer[integer_pos--] = chars[static_cast<int>(remainder)];
integer_part -= remainder;
integer_part /= radix;
while ((decimal_part > 0.0) && (decimal_pos < kBufferSize - 1)) {
decimal_part *= radix;
decimal_buffer[decimal_pos++] =
- chars[static_cast<int>(floor(decimal_part))];
- decimal_part -= floor(decimal_part);
+ chars[static_cast<int>(std::floor(decimal_part))];
+ decimal_part -= std::floor(decimal_part);
}
decimal_buffer[decimal_pos] = '\0';
#include <sys/syspage.h> // cpuinfo
#endif
+#include <ctype.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <algorithm>
-#include <cctype>
-#include <climits>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
#include "checks.h"
#if V8_OS_WIN
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <cstdio> // NOLINT
+#include <stdio.h> // NOLINT
#include <string.h> // NOLINT
#include <readline/readline.h> // NOLINT
#include <readline/history.h> // NOLINT
#ifndef V8_HEAP_INL_H_
#define V8_HEAP_INL_H_
+#include <cmath>
+
#include "heap.h"
#include "isolate.h"
#include "list-inl.h"
case kMathExp:
return H_CONSTANT_DOUBLE(fast_exp(d));
case kMathLog:
- return H_CONSTANT_DOUBLE(log(d));
+ return H_CONSTANT_DOUBLE(std::log(d));
case kMathSqrt:
return H_CONSTANT_DOUBLE(fast_sqrt(d));
case kMathPowHalf:
// Doubles are represented as Significant * 2 ^ Exponent. If the
// Exponent is not negative, the double value is already an integer.
if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d);
- return H_CONSTANT_DOUBLE(floor(d + 0.5));
+ return H_CONSTANT_DOUBLE(std::floor(d + 0.5));
case kMathFloor:
- return H_CONSTANT_DOUBLE(floor(d));
+ return H_CONSTANT_DOUBLE(std::floor(d));
default:
UNREACHABLE();
break;
UnaryMathFunction CreateExpFunction() {
- if (!CpuFeatures::IsSupported(SSE2)) return &exp;
- if (!FLAG_fast_math) return &exp;
+ if (!CpuFeatures::IsSupported(SSE2)) return &std::exp;
+ if (!FLAG_fast_math) return &std::exp;
size_t actual_size;
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
- if (buffer == NULL) return &exp;
+ if (buffer == NULL) return &std::exp;
ExternalReference::InitializeMathExpData();
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
true));
// If SSE2 is not available, we can use libc's implementation to ensure
// consistency since code by fullcodegen's calls into runtime in that case.
- if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &sqrt;
+ if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &std::sqrt;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
// esp[1 * kPointerSize]: raw double input
// esp[0 * kPointerSize]: return address
double multiplier_f =
static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs;
int64_t multiplier;
- if (multiplier_f - floor(multiplier_f) < 0.5) {
- multiplier = static_cast<int64_t>(floor(multiplier_f));
+ if (multiplier_f - std::floor(multiplier_f) < 0.5) {
+ multiplier = static_cast<int64_t>(std::floor(multiplier_f));
} else {
- multiplier = static_cast<int64_t>(floor(multiplier_f)) + 1;
+ multiplier = static_cast<int64_t>(std::floor(multiplier_f)) + 1;
}
// The multiplier is a uint32.
ASSERT(multiplier > 0 &&
static const int kMaxMaxEvacuationCandidates = 1000;
int number_of_pages = space->CountTotalPages();
int max_evacuation_candidates =
- static_cast<int>(sqrt(number_of_pages / 2.0) + 1);
+ static_cast<int>(std::sqrt(number_of_pages / 2.0) + 1);
if (FLAG_stress_compaction || FLAG_always_compact) {
max_evacuation_candidates = kMaxMaxEvacuationCandidates;
UnaryMathFunction CreateExpFunction() {
- if (!FLAG_fast_math) return &exp;
+ if (!FLAG_fast_math) return &std::exp;
size_t actual_size;
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
- if (buffer == NULL) return &exp;
+ if (buffer == NULL) return &std::exp;
ExternalReference::InitializeMathExpData();
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
#include <cmath>
-#include <cstdarg>
+
#include "v8.h"
#if V8_TARGET_ARCH_MIPS
// In rounding mode 0 it should behave like ROUND.
case ROUND_W_D: // Round double to word (round half to even).
{
- double rounded = floor(fs + 0.5);
+ double rounded = std::floor(fs + 0.5);
int32_t result = static_cast<int32_t>(rounded);
if ((result & 1) != 0 && result - fs == 0.5) {
// If the number is halfway between two integers,
break;
case FLOOR_W_D: // Round double to word towards negative infinity.
{
- double rounded = floor(fs);
+ double rounded = std::floor(fs);
int32_t result = static_cast<int32_t>(rounded);
set_fpu_register(fd_reg, result);
if (set_fcsr_round_error(fs, rounded)) {
break;
case CEIL_W_D: // Round double to word towards positive infinity.
{
- double rounded = ceil(fs);
+ double rounded = std::ceil(fs);
int32_t result = static_cast<int32_t>(rounded);
set_fpu_register(fd_reg, result);
if (set_fcsr_round_error(fs, rounded)) {
break;
}
case ROUND_L_D: { // Mips32r2 instruction.
- double rounded = fs > 0 ? floor(fs + 0.5) : ceil(fs - 0.5);
+ double rounded =
+ fs > 0 ? std::floor(fs + 0.5) : std::ceil(fs - 0.5);
i64 = static_cast<int64_t>(rounded);
set_fpu_register(fd_reg, i64 & 0xffffffff);
set_fpu_register(fd_reg + 1, i64 >> 32);
break;
}
case FLOOR_L_D: // Mips32r2 instruction.
- i64 = static_cast<int64_t>(floor(fs));
+ i64 = static_cast<int64_t>(std::floor(fs));
set_fpu_register(fd_reg, i64 & 0xffffffff);
set_fpu_register(fd_reg + 1, i64 >> 32);
break;
case CEIL_L_D: // Mips32r2 instruction.
- i64 = static_cast<int64_t>(ceil(fs));
+ i64 = static_cast<int64_t>(std::ceil(fs));
set_fpu_register(fd_reg, i64 & 0xffffffff);
set_fpu_register(fd_reg + 1, i64 >> 32);
break;
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return tzname[0]; // The location of the timezone string on Cygwin.
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return t->tm_zone;
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return t->tm_zone;
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return t->tm_zone;
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return t->tm_zone;
// Math functions
double modulo(double x, double y) {
- return fmod(x, y);
+ return std::fmod(x, y);
}
double OS::DaylightSavingsOffset(double time) {
if (std::isnan(time)) return nan_value();
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return nan_value();
return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
const char* OS::LocalTimezone(double time) {
if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+ time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
return tzname[0]; // The location of the timezone string on Solaris.
#ifndef V8_PLATFORM_H_
#define V8_PLATFORM_H_
-#include <cstdarg>
+#include <stdarg.h>
#include "platform/mutex.h"
#include "platform/semaphore.h"
#endif
return intgr;
}
-
#endif // _MSC_VER < 1800
#endif // V8_CC_MSVC
#include "platform/condition-variable.h"
-#include <cerrno>
-#include <ctime>
+#include <errno.h>
+#include <time.h>
#include "platform/time.h"
#include "platform/mutex.h"
-#include <cerrno>
+#include <errno.h>
namespace v8 {
namespace internal {
#include <mach/task.h>
#endif
-#include <cerrno>
+#include <errno.h>
#include "checks.h"
#include "platform/time.h"
#include <unistd.h>
#endif
-#include <cerrno>
+#include <errno.h>
#include "checks.h"
#include "once.h"
#include <mach/mach_time.h>
#endif
-#include <cstring>
+#include <string.h>
#include "checks.h"
#include "cpu.h"
#ifndef V8_PLATFORM_TIME_H_
#define V8_PLATFORM_TIME_H_
-#include <ctime>
+#include <time.h>
#include <limits>
#include "../allocation.h"
isolate->counters()->math_acos()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->AllocateHeapNumber(acos(x));
+ return isolate->heap()->AllocateHeapNumber(std::acos(x));
}
isolate->counters()->math_asin()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->AllocateHeapNumber(asin(x));
+ return isolate->heap()->AllocateHeapNumber(std::asin(x));
}
isolate->counters()->math_atan()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->AllocateHeapNumber(atan(x));
+ return isolate->heap()->AllocateHeapNumber(std::atan(x));
}
if (y < 0) multiplier *= 3;
result = multiplier * kPiDividedBy4;
} else {
- result = atan2(x, y);
+ result = std::atan2(x, y);
}
return isolate->heap()->AllocateHeapNumber(result);
}
isolate->counters()->math_floor()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->NumberFromDouble(floor(x));
+ return isolate->heap()->NumberFromDouble(std::floor(x));
}
isolate->counters()->math_log()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->AllocateHeapNumber(log(x));
+ return isolate->heap()->AllocateHeapNumber(std::log(x));
}
if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
// Do not call NumberFromDouble() to avoid extra checks.
- return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
+ return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5));
}
// the number in a Date object representing a particular instant in
// time is milliseconds. Therefore, we floor the result of getting
// the OS time.
- double millis = floor(OS::TimeCurrentMillis());
+ double millis = std::floor(OS::TimeCurrentMillis());
return isolate->heap()->NumberFromDouble(millis);
}
#ifndef V8_UTILS_H_
#define V8_UTILS_H_
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
-#include <climits>
#include "allocation.h"
#include "checks.h"
#include "utils/random-number-generator.h"
-#include <cstdio>
-#include <cstdlib>
+#include <stdio.h>
+#include <stdlib.h>
#include "flags.h"
#include "platform/mutex.h"
UnaryMathFunction CreateExpFunction() {
- if (!FLAG_fast_math) return &exp;
+ if (!FLAG_fast_math) return &std::exp;
size_t actual_size;
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
- if (buffer == NULL) return &exp;
+ if (buffer == NULL) return &std::exp;
ExternalReference::InitializeMathExpData();
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
&actual_size,
true));
- if (buffer == NULL) return &sqrt;
+ if (buffer == NULL) return &std::sqrt;
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
// xmm0: raw double input.
double multiplier_f =
static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs;
int64_t multiplier;
- if (multiplier_f - floor(multiplier_f) < 0.5) {
- multiplier = static_cast<int64_t>(floor(multiplier_f));
+ if (multiplier_f - std::floor(multiplier_f) < 0.5) {
+ multiplier = static_cast<int64_t>(std::floor(multiplier_f));
} else {
- multiplier = static_cast<int64_t>(floor(multiplier_f)) + 1;
+ multiplier = static_cast<int64_t>(std::floor(multiplier_f)) + 1;
}
// The multiplier is a uint32.
ASSERT(multiplier > 0 &&
if (std::isnan(input) || input < -date_limit || input > date_limit) {
return i::OS::nan_value();
}
- return (input < 0) ? -(floor(-input)) : floor(input);
+ return (input < 0) ? -(std::floor(-input)) : std::floor(input);
}
double i = 10;
SignalRunning();
while (IsRunning()) {
- i = sin(i);
+ i = std::sin(i);
i::OS::Sleep(1);
}
}
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <cstdlib>
-
#include "v8.h"
#if V8_OS_POSIX