Revision: 14352
Author: [email protected]
Date: Fri Apr 19 06:26:47 2013
Log: Replace math.h with cmath
This will make it easier to use other STL headers in the future
Review URL: https://codereview.chromium.org/14362023
Patch from Jochen Eisinger <[email protected]>.
http://code.google.com/p/v8/source/detail?r=14352
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/assembler.cc
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/bignum-dtoa.cc
/branches/bleeding_edge/src/cached-powers.cc
/branches/bleeding_edge/src/code-stubs.cc
/branches/bleeding_edge/src/conversions-inl.h
/branches/bleeding_edge/src/conversions.cc
/branches/bleeding_edge/src/dtoa.cc
/branches/bleeding_edge/src/fixed-dtoa.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/json-stringifier.h
/branches/bleeding_edge/src/objects-debug.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/platform-cygwin.cc
/branches/bleeding_edge/src/platform-freebsd.cc
/branches/bleeding_edge/src/platform-linux.cc
/branches/bleeding_edge/src/platform-macos.cc
/branches/bleeding_edge/src/platform-openbsd.cc
/branches/bleeding_edge/src/platform-posix.cc
/branches/bleeding_edge/src/platform-solaris.cc
/branches/bleeding_edge/src/platform-win32.cc
/branches/bleeding_edge/src/platform.h
/branches/bleeding_edge/src/preparser.cc
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/strtod.cc
/branches/bleeding_edge/src/win32-math.cc
/branches/bleeding_edge/src/win32-math.h
=======================================
--- /branches/bleeding_edge/src/api.cc Thu Apr 18 05:46:38 2013
+++ /branches/bleeding_edge/src/api.cc Fri Apr 19 06:26:47 2013
@@ -27,8 +27,8 @@
#include "api.h"
-#include <math.h> // For isnan.
#include <string.h> // For memcpy, strlen.
+#include <cmath> // For isnan.
#include "../include/v8-debug.h"
#include "../include/v8-profiler.h"
#include "../include/v8-testing.h"
@@ -2984,7 +2984,7 @@
double x = obj->Number();
double y = other->Number();
// Must check explicitly for NaN:s on Windows, but -0 works fine.
- return x == y && !isnan(x) && !isnan(y);
+ return x == y && !std::isnan(x) && !std::isnan(y);
} else if (*obj == *other) { // Also covers Booleans.
return true;
} else if (obj->IsSmi()) {
@@ -5568,7 +5568,7 @@
i::Isolate* isolate = i::Isolate::Current();
EnsureInitializedForIsolate(isolate, "v8::Date::New()");
LOG_API(isolate, "Date::New");
- if (isnan(time)) {
+ if (std::isnan(time)) {
// Introduce only canonical NaN value into the VM, to avoid signaling
NaNs.
time = i::OS::nan_value();
}
@@ -5772,7 +5772,7 @@
Local<Number> v8::Number::New(double value) {
i::Isolate* isolate = i::Isolate::Current();
EnsureInitializedForIsolate(isolate, "v8::Number::New()");
- if (isnan(value)) {
+ if (std::isnan(value)) {
// Introduce only canonical NaN value into the VM, to avoid signaling
NaNs.
value = i::OS::nan_value();
}
=======================================
--- /branches/bleeding_edge/src/assembler.cc Mon Apr 15 04:52:34 2013
+++ /branches/bleeding_edge/src/assembler.cc Fri Apr 19 06:26:47 2013
@@ -34,7 +34,7 @@
#include "assembler.h"
-#include <math.h> // For cos, log, pow, sin, tan, etc.
+#include <cmath>
#include "api.h"
#include "builtins.h"
#include "counters.h"
@@ -1459,10 +1459,11 @@
return power_double_int(x, y_int); // Returns 1 if exponent is 0.
}
if (y == 0.5) {
- return (isinf(x)) ? V8_INFINITY : fast_sqrt(x + 0.0); // Convert -0
to +0.
+ return (std::isinf(x)) ? V8_INFINITY
+ : fast_sqrt(x + 0.0); // Convert -0 to +0.
}
if (y == -0.5) {
- return (isinf(x)) ? 0 : 1.0 / fast_sqrt(x + 0.0); // Convert -0 to +0.
+ return (std::isinf(x)) ? 0 : 1.0 / fast_sqrt(x + 0.0); // Convert -0
to +0.
}
return power_double_double(x, y);
}
@@ -1492,7 +1493,7 @@
(!defined(__MINGW64_VERSION_RC) || __MINGW64_VERSION_RC < 1)
// MinGW64 has a custom implementation for pow. This handles certain
// special cases that are different.
- if ((x == 0.0 || isinf(x)) && isfinite(y)) {
+ 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;
}
@@ -1505,7 +1506,9 @@
// The checks for special cases can be dropped in ia32 because it has
already
// been done in generated code before bailing out here.
- if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) return
OS::nan_value();
+ if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) {
+ return OS::nan_value();
+ }
return pow(x, y);
}
=======================================
--- /branches/bleeding_edge/src/ast.cc Tue Apr 9 09:38:51 2013
+++ /branches/bleeding_edge/src/ast.cc Fri Apr 19 06:26:47 2013
@@ -27,7 +27,7 @@
#include "ast.h"
-#include <math.h> // For isfinite.
+#include <cmath> // For isfinite.
#include "builtins.h"
#include "code-stubs.h"
#include "conversions.h"
@@ -241,8 +241,8 @@
if (h2->IsSmi()) return false;
Handle<HeapNumber> n1 = Handle<HeapNumber>::cast(h1);
Handle<HeapNumber> n2 = Handle<HeapNumber>::cast(h2);
- ASSERT(isfinite(n1->value()));
- ASSERT(isfinite(n2->value()));
+ ASSERT(std::isfinite(n1->value()));
+ ASSERT(std::isfinite(n2->value()));
return n1->value() == n2->value();
}
=======================================
--- /branches/bleeding_edge/src/bignum-dtoa.cc Wed Sep 7 05:39:53 2011
+++ /branches/bleeding_edge/src/bignum-dtoa.cc Fri Apr 19 06:26:47 2013
@@ -25,7 +25,7 @@
// (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 <math.h>
+#include <cmath>
#include "../include/v8stdint.h"
#include "checks.h"
=======================================
--- /branches/bleeding_edge/src/cached-powers.cc Fri Oct 7 01:21:21 2011
+++ /branches/bleeding_edge/src/cached-powers.cc Fri Apr 19 06:26:47 2013
@@ -26,8 +26,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdarg.h>
-#include <math.h>
#include <limits.h>
+#include <cmath>
#include "../include/v8stdint.h"
#include "globals.h"
=======================================
--- /branches/bleeding_edge/src/code-stubs.cc Thu Apr 18 13:37:27 2013
+++ /branches/bleeding_edge/src/code-stubs.cc Fri Apr 19 06:26:47 2013
@@ -567,7 +567,7 @@
ASSERT(!object->IsUndetectableObject());
Add(HEAP_NUMBER);
double value = HeapNumber::cast(*object)->value();
- return value != 0 && !isnan(value);
+ return value != 0 && !std::isnan(value);
} else {
// We should never see an internal object at runtime here!
UNREACHABLE();
=======================================
--- /branches/bleeding_edge/src/conversions-inl.h Tue Apr 16 05:30:51 2013
+++ /branches/bleeding_edge/src/conversions-inl.h Fri Apr 19 06:26:47 2013
@@ -29,9 +29,9 @@
#define V8_CONVERSIONS_INL_H_
#include <limits.h> // Required for INT_MAX etc.
-#include <math.h>
#include <float.h> // Required for DBL_MAX and on Win32 for
finite()
#include <stdarg.h>
+#include <cmath>
#include "globals.h" // Required for V8_INFINITY
//
----------------------------------------------------------------------------
@@ -86,8 +86,8 @@
inline double DoubleToInteger(double x) {
- if (isnan(x)) return 0;
- if (!isfinite(x) || x == 0) return x;
+ if (std::isnan(x)) return 0;
+ if (!std::isfinite(x) || x == 0) return x;
return (x >= 0) ? floor(x) : ceil(x);
}
=======================================
--- /branches/bleeding_edge/src/conversions.cc Thu Sep 8 06:06:44 2011
+++ /branches/bleeding_edge/src/conversions.cc Fri Apr 19 06:26:47 2013
@@ -26,14 +26,19 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdarg.h>
-#include <math.h>
#include <limits.h>
+#include <cmath>
#include "conversions-inl.h"
#include "dtoa.h"
#include "strtod.h"
#include "utils.h"
+#ifndef _STLP_VENDOR_CSTD
+// STLPort doesn't import fpclassify into the std namespace.
+using std::fpclassify;
+#endif
+
namespace v8 {
namespace internal {
=======================================
--- /branches/bleeding_edge/src/dtoa.cc Wed Sep 7 05:39:53 2011
+++ /branches/bleeding_edge/src/dtoa.cc Fri Apr 19 06:26:47 2013
@@ -25,7 +25,7 @@
// (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 <math.h>
+#include <cmath>
#include "../include/v8stdint.h"
#include "checks.h"
=======================================
--- /branches/bleeding_edge/src/fixed-dtoa.cc Wed Sep 7 05:39:53 2011
+++ /branches/bleeding_edge/src/fixed-dtoa.cc Fri Apr 19 06:26:47 2013
@@ -25,7 +25,7 @@
// (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 <math.h>
+#include <cmath>
#include "../include/v8stdint.h"
#include "checks.h"
=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Apr 18 02:50:46 2013
+++ /branches/bleeding_edge/src/heap.cc Fri Apr 19 06:26:47 2013
@@ -2745,7 +2745,7 @@
if (!maybe_obj->ToObject(&obj)) return false;
}
set_minus_zero_value(HeapNumber::cast(obj));
- ASSERT(signbit(minus_zero_value()->Number()) != 0);
+ ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
{ MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED);
if (!maybe_obj->ToObject(&obj)) return false;
=======================================
--- /branches/bleeding_edge/src/heap.h Thu Apr 18 02:50:46 2013
+++ /branches/bleeding_edge/src/heap.h Fri Apr 19 06:26:47 2013
@@ -28,7 +28,7 @@
#ifndef V8_HEAP_H_
#define V8_HEAP_H_
-#include <math.h>
+#include <cmath>
#include "allocation.h"
#include "globals.h"
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 18
04:22:29 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Fri Apr 19
06:26:47 2013
@@ -2139,7 +2139,7 @@
has_int32_value_(IsInteger32(double_value)),
has_double_value_(true),
is_internalized_string_(false),
- boolean_value_(double_value != 0 && !isnan(double_value)),
+ boolean_value_(double_value != 0 && !std::isnan(double_value)),
int32_value_(DoubleToInt32(double_value)),
double_value_(double_value) {
Initialize(r);
@@ -3176,7 +3176,7 @@
HConstant* c_code = HConstant::cast(char_code);
Isolate* isolate = Isolate::Current();
if (c_code->HasNumberValue()) {
- if (isfinite(c_code->DoubleValue())) {
+ if (std::isfinite(c_code->DoubleValue())) {
uint32_t code = c_code->NumberValueAsInteger32() & 0xffff;
return new(zone)
HConstant(LookupSingleCharacterStringFromCode(isolate,
code),
@@ -3209,10 +3209,10 @@
HConstant* constant = HConstant::cast(value);
if (!constant->HasNumberValue()) break;
double d = constant->DoubleValue();
- if (isnan(d)) { // NaN poisons everything.
+ if (std::isnan(d)) { // NaN poisons everything.
return H_CONSTANT_DOUBLE(OS::nan_value());
}
- if (isinf(d)) { // +Infinity and -Infinity.
+ if (std::isinf(d)) { // +Infinity and -Infinity.
switch (op) {
case kMathSin:
case kMathCos:
@@ -3276,7 +3276,7 @@
if (c_left->HasNumberValue() && c_right->HasNumberValue()) {
double result = power_helper(c_left->DoubleValue(),
c_right->DoubleValue());
- return H_CONSTANT_DOUBLE(isnan(result) ? OS::nan_value() : result);
+ return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() :
result);
}
}
return new(zone) HPower(left, right);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Apr 18 04:22:29
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Fri Apr 19 06:26:47
2013
@@ -3239,7 +3239,7 @@
return has_double_value_ &&
(BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) ||
FixedDoubleArray::is_the_hole_nan(double_value_) ||
- isnan(double_value_));
+ std::isnan(double_value_));
}
bool ImmortalImmovable() const {
=======================================
--- /branches/bleeding_edge/src/ic.cc Fri Apr 19 01:30:49 2013
+++ /branches/bleeding_edge/src/ic.cc Fri Apr 19 06:26:47 2013
@@ -1260,7 +1260,7 @@
// non-smi keys of keyed loads/stores to a smi or a string.
if (key->IsHeapNumber()) {
double value = Handle<HeapNumber>::cast(key)->value();
- if (isnan(value)) {
+ if (std::isnan(value)) {
key = isolate->factory()->nan_string();
} else {
int int_value = FastD2I(value);
=======================================
--- /branches/bleeding_edge/src/isolate.cc Tue Apr 16 05:30:51 2013
+++ /branches/bleeding_edge/src/isolate.cc Fri Apr 19 06:26:47 2013
@@ -1060,7 +1060,7 @@
GetProperty(Handle<JSObject>::cast(error), "stackTraceLimit");
if (!stack_trace_limit->IsNumber()) return Failure::Exception();
double dlimit = stack_trace_limit->Number();
- int limit = isnan(dlimit) ? 0 : static_cast<int>(dlimit);
+ int limit = std::isnan(dlimit) ? 0 : static_cast<int>(dlimit);
Handle<JSArray> stack_trace = CaptureSimpleStackTrace(
exception, factory()->undefined_value(), limit);
=======================================
--- /branches/bleeding_edge/src/json-stringifier.h Thu Apr 11 02:53:00 2013
+++ /branches/bleeding_edge/src/json-stringifier.h Fri Apr 19 06:26:47 2013
@@ -522,7 +522,7 @@
BasicJsonStringifier::Result BasicJsonStringifier::SerializeDouble(
double number) {
- if (isinf(number) || isnan(number)) {
+ if (std::isinf(number) || std::isnan(number)) {
AppendAscii("null");
return SUCCESS;
}
=======================================
--- /branches/bleeding_edge/src/objects-debug.cc Tue Apr 16 07:16:30 2013
+++ /branches/bleeding_edge/src/objects-debug.cc Fri Apr 19 06:26:47 2013
@@ -401,7 +401,7 @@
for (int i = 0; i < length(); i++) {
if (!is_the_hole(i)) {
double value = get_scalar(i);
- CHECK(!isnan(value) ||
+ CHECK(!std::isnan(value) ||
(BitCast<uint64_t>(value) ==
BitCast<uint64_t>(canonical_not_the_hole_nan_as_double())) ||
((BitCast<uint64_t>(value) & Double::kSignMask) != 0));
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Thu Apr 18 02:50:46 2013
+++ /branches/bleeding_edge/src/objects-inl.h Fri Apr 19 06:26:47 2013
@@ -860,7 +860,7 @@
bool Object::IsNaN() {
- return this->IsHeapNumber() && isnan(HeapNumber::cast(this)->value());
+ return this->IsHeapNumber() &&
std::isnan(HeapNumber::cast(this)->value());
}
@@ -1921,7 +1921,7 @@
ASSERT(map() != HEAP->fixed_cow_array_map() &&
map() != HEAP->fixed_array_map());
int offset = kHeaderSize + index * kDoubleSize;
- if (isnan(value)) value = canonical_not_the_hole_nan_as_double();
+ if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double();
WRITE_DOUBLE_FIELD(this, offset, value);
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Apr 19 01:30:49 2013
+++ /branches/bleeding_edge/src/objects.cc Fri Apr 19 06:26:47 2013
@@ -965,7 +965,7 @@
double this_value = Number();
double other_value = other->Number();
return (this_value == other_value) ||
- (isnan(this_value) && isnan(other_value));
+ (std::isnan(this_value) && std::isnan(other_value));
}
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
@@ -14418,7 +14418,7 @@
}
double time = value()->Number();
- if (isnan(time)) return GetIsolate()->heap()->nan_value();
+ if (std::isnan(time)) return GetIsolate()->heap()->nan_value();
int64_t local_time_ms = date_cache->ToLocal(static_cast<int64_t>(time));
int days = DateCache::DaysFromTime(local_time_ms);
@@ -14437,7 +14437,7 @@
DateCache* date_cache) {
ASSERT(index >= kFirstUTCField);
- if (isnan(value)) return GetIsolate()->heap()->nan_value();
+ if (std::isnan(value)) return GetIsolate()->heap()->nan_value();
int64_t time_ms = static_cast<int64_t>(value);
=======================================
--- /branches/bleeding_edge/src/platform-cygwin.cc Tue Apr 16 05:36:44 2013
+++ /branches/bleeding_edge/src/platform-cygwin.cc Fri Apr 19 06:26:47 2013
@@ -86,7 +86,7 @@
}
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-freebsd.cc Thu Apr 18 03:32:18 2013
+++ /branches/bleeding_edge/src/platform-freebsd.cc Fri Apr 19 06:26:47 2013
@@ -103,7 +103,7 @@
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-linux.cc Thu Apr 18 03:32:18 2013
+++ /branches/bleeding_edge/src/platform-linux.cc Fri Apr 19 06:26:47 2013
@@ -322,7 +322,7 @@
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-macos.cc Tue Apr 16 01:54:33 2013
+++ /branches/bleeding_edge/src/platform-macos.cc Fri Apr 19 06:26:47 2013
@@ -302,7 +302,7 @@
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-openbsd.cc Mon Apr 15 06:57:41 2013
+++ /branches/bleeding_edge/src/platform-openbsd.cc Fri Apr 19 06:26:47 2013
@@ -125,7 +125,7 @@
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-posix.cc Tue Apr 16 05:30:51 2013
+++ /branches/bleeding_edge/src/platform-posix.cc Fri Apr 19 06:26:47 2013
@@ -204,7 +204,7 @@
double OS::DaylightSavingsOffset(double time) {
- if (isnan(time)) return nan_value();
+ if (std::isnan(time)) return nan_value();
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return nan_value();
=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc Mon Apr 15 06:57:41 2013
+++ /branches/bleeding_edge/src/platform-solaris.cc Fri Apr 19 06:26:47 2013
@@ -62,6 +62,7 @@
// SunOS 5.10 Generic_141445-09) which make it difficult or impossible to
// access signbit() despite the availability of other C99 math functions.
#ifndef signbit
+namespace std {
// Test sign - usually defined in math.h
int signbit(double x) {
// We need to take care of the special case of both positive and negative
@@ -74,6 +75,7 @@
return x < 0;
}
}
+} // namespace std
#endif // signbit
namespace v8 {
@@ -116,7 +118,7 @@
const char* OS::LocalTimezone(double time) {
- if (isnan(time)) return "";
+ if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
if (NULL == t) return "";
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc Tue Apr 16 05:30:51 2013
+++ /branches/bleeding_edge/src/platform-win32.cc Fri Apr 19 06:26:47 2013
@@ -188,8 +188,8 @@
// Workaround MS fmod bugs. ECMA-262 says:
// dividend is finite and divisor is an infinity => result equals
dividend
// dividend is a zero and divisor is nonzero finite => result equals
dividend
- if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) &&
- !(x == 0 && (y != 0 && isfinite(y)))) {
+ if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) &&
+ !(x == 0 && (y != 0 && std::isfinite(y)))) {
x = fmod(x, y);
}
return x;
=======================================
--- /branches/bleeding_edge/src/platform.h Tue Apr 16 05:36:44 2013
+++ /branches/bleeding_edge/src/platform.h Fri Apr 19 06:26:47 2013
@@ -46,7 +46,9 @@
#ifdef __sun
# ifndef signbit
+namespace std {
int signbit(double x);
+}
# endif
#endif
=======================================
--- /branches/bleeding_edge/src/preparser.cc Fri Apr 5 06:01:06 2013
+++ /branches/bleeding_edge/src/preparser.cc Fri Apr 19 06:26:47 2013
@@ -25,7 +25,7 @@
// (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 <math.h>
+#include <cmath>
#include "../include/v8stdint.h"
@@ -42,14 +42,18 @@
#include "unicode.h"
#include "utils.h"
-namespace v8 {
-
#ifdef _MSC_VER
+namespace std {
+
// Usually defined in math.h, but not in MSVC.
// Abstracted to work
int isfinite(double value);
+
+} // namespace std
#endif
+namespace v8 {
+
namespace preparser {
PreParser::PreParseResult PreParser::PreParseLazyFunction(
@@ -1712,7 +1716,7 @@
double double_value = StringToDouble(unicode_constants_, key, flags,
0.0);
int length;
const char* string;
- if (!isfinite(double_value)) {
+ if (!std::isfinite(double_value)) {
string = "Infinity";
length = 8; // strlen("Infinity");
} else {
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Apr 19 01:30:49 2013
+++ /branches/bleeding_edge/src/runtime.cc Fri Apr 19 06:26:47 2013
@@ -65,6 +65,12 @@
#include "v8threads.h"
#include "vm-state-inl.h"
+#ifndef _STLP_VENDOR_CSTD
+// STLPort doesn't import fpclassify and isless into the std namespace.
+using std::fpclassify;
+using std::isless;
+#endif
+
namespace v8 {
namespace internal {
@@ -3963,10 +3969,10 @@
// Slow case.
CONVERT_DOUBLE_ARG_CHECKED(value, 0);
- if (isnan(value)) {
+ if (std::isnan(value)) {
return *isolate->factory()->nan_string();
}
- if (isinf(value)) {
+ if (std::isinf(value)) {
if (value < 0) {
return *isolate->factory()->minus_infinity_string();
}
@@ -6612,8 +6618,8 @@
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
CONVERT_DOUBLE_ARG_CHECKED(y, 1);
- if (isnan(x)) return Smi::FromInt(NOT_EQUAL);
- if (isnan(y)) return Smi::FromInt(NOT_EQUAL);
+ if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL);
+ if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL);
if (x == y) return Smi::FromInt(EQUAL);
Object* result;
if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) {
@@ -6649,7 +6655,7 @@
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
CONVERT_DOUBLE_ARG_CHECKED(y, 1);
- if (isnan(x) || isnan(y)) return args[2];
+ if (std::isnan(x) || std::isnan(y)) return args[2];
if (x == y) return Smi::FromInt(EQUAL);
if (isless(x, y)) return Smi::FromInt(LESS);
return Smi::FromInt(GREATER);
@@ -6872,7 +6878,7 @@
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
CONVERT_DOUBLE_ARG_CHECKED(y, 1);
double result;
- if (isinf(x) && isinf(y)) {
+ if (std::isinf(x) && std::isinf(y)) {
// Make sure that the result in case of two infinite arguments
// is a multiple of Pi / 4. The sign of the result is determined
// by the first argument (x) and the sign of the second argument
@@ -6955,7 +6961,7 @@
CONVERT_DOUBLE_ARG_CHECKED(y, 1);
double result = power_helper(x, y);
- if (isnan(result)) return isolate->heap()->nan_value();
+ if (std::isnan(result)) return isolate->heap()->nan_value();
return isolate->heap()->AllocateHeapNumber(result);
}
@@ -6972,7 +6978,7 @@
return Smi::FromInt(1);
} else {
double result = power_double_double(x, y);
- if (isnan(result)) return isolate->heap()->nan_value();
+ if (std::isnan(result)) return isolate->heap()->nan_value();
return isolate->heap()->AllocateHeapNumber(result);
}
}
@@ -7074,7 +7080,7 @@
Object* value = NULL;
bool is_value_nan = false;
- if (isnan(time)) {
+ if (std::isnan(time)) {
value = isolate->heap()->nan_value();
is_value_nan = true;
} else if (!is_utc &&
=======================================
--- /branches/bleeding_edge/src/strtod.cc Mon Mar 5 02:04:10 2012
+++ /branches/bleeding_edge/src/strtod.cc Fri Apr 19 06:26:47 2013
@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdarg.h>
-#include <math.h>
+#include <cmath>
#include "globals.h"
#include "utils.h"
=======================================
--- /branches/bleeding_edge/src/win32-math.cc Mon Sep 19 11:36:47 2011
+++ /branches/bleeding_edge/src/win32-math.cc Fri Apr 19 06:26:47 2013
@@ -35,21 +35,14 @@
#define V8_WIN32_HEADERS_FULL
#include "win32-headers.h"
#include <limits.h> // Required for INT_MAX etc.
-#include <math.h>
#include <float.h> // Required for DBL_MAX and on Win32 for
finite()
+#include <cmath>
#include "win32-math.h"
#include "checks.h"
-namespace v8 {
-// Test for finite value - usually defined in math.h
-int isfinite(double x) {
- return _finite(x);
-}
-
-} // namespace v8
-
+namespace std {
// Test for a NaN (not a number) value - usually defined in math.h
int isnan(double x) {
@@ -61,6 +54,12 @@
int isinf(double x) {
return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0;
}
+
+
+// Test for finite value - usually defined in math.h
+int isfinite(double x) {
+ return _finite(x);
+}
// Test if x is less than y and both nominal - usually defined in math.h
@@ -102,5 +101,7 @@
else
return x < 0;
}
+
+} // namespace std
#endif // _MSC_VER
=======================================
--- /branches/bleeding_edge/src/win32-math.h Mon Sep 19 11:36:47 2011
+++ /branches/bleeding_edge/src/win32-math.h Fri Apr 19 06:26:47 2013
@@ -45,17 +45,17 @@
FP_NORMAL
};
-namespace v8 {
-int isfinite(double x);
+namespace std {
-} // namespace v8
-
+int isfinite(double x);
+int isinf(double x);
int isnan(double x);
-int isinf(double x);
int isless(double x, double y);
int isgreater(double x, double y);
int fpclassify(double x);
int signbit(double x);
+} // namespace std
+
#endif // V8_WIN32_MATH_H_
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.