Bug 23624 - Expose a cross-platform NaN in MathExtras.h
Summary: Expose a cross-platform NaN in MathExtras.h
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-29 11:27 PST by Simon Fraser (smfr)
Modified: 2009-01-30 09:12 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2009-01-29 11:27:33 PST
MathExtras.h should expose a NaN that works everywhere.
Comment 1 Simon Fraser (smfr) 2009-01-29 11:54:40 PST
Ugh, std::numeric_limits<double>::quiet_NaN() is marked as throw(), which throws the JIT into a tizzy if I put it in a header.
Comment 2 Darin Adler 2009-01-29 12:14:15 PST
(In reply to comment #1)
> Ugh, std::numeric_limits<double>::quiet_NaN() is marked as throw(), which
> throws the JIT into a tizzy if I put it in a header.

Thows the JIT into a tizzy? Could you be more specific?

I've used quiet_NaN() in many cases without having any problems. I don't think we need it in MathExtras.h -- I think we should just use it directly.
Comment 3 Simon Fraser (smfr) 2009-01-29 13:11:17 PST
Sorry to be vague. With this patch:

diff --git a/JavaScriptCore/wtf/MathExtras.h b/JavaScriptCore/wtf/MathExtras.h
index 76488b4..9638b35 100644
--- a/JavaScriptCore/wtf/MathExtras.h
+++ b/JavaScriptCore/wtf/MathExtras.h
@@ -28,6 +28,7 @@
 
 #include <math.h>
 #include <stdlib.h>
+#include <limits>
 
 #if PLATFORM(SOLARIS)
 #include <ieeefp.h>
@@ -44,7 +45,6 @@
 #else
 #include <xmath.h>
 #endif
-#include <limits>
 
 #if HAVE(FLOAT_H)
 #include <float.h>
@@ -68,6 +68,8 @@ const double piOverFourDouble = M_PI_4;
 const float piOverFourFloat = static_cast<float>(M_PI_4);
 #endif
 
+const double nanDouble = std::numeric_limits<double>::quiet_NaN();
+
 #if PLATFORM(DARWIN)
 
 // Work around a bug in the Mac OS X libc where ceil(-0.1) return +0.

I get link errors:

ld warning: symbol _ctiVMThrowTrampoline found in unsupported section in /Volumes/InternalData/Development/WebKit/WebKit.git/WebKitBuild/JavaScriptCore.build/Debug/JavaScriptCore.build/Objects-normal/i386/JIT.o
ld warning: symbol _ctiTrampoline found in unsupported section in /Volumes/InternalData/Development/WebKit/WebKit.git/WebKitBuild/JavaScriptCore.build/Debug/JavaScriptCore.build/Objects-normal/i386/JIT.o
Undefined symbols:
  "_ctiTrampoline", referenced from:
      __ZN3JSC3JIT7executeEPvPNS_12RegisterFileEPNS_9ExecStateEPNS_12JSGlobalDataEPNS_10JSValuePtrE in Interpreter.o
  "_ctiVMThrowTrampoline", referenced from:
      _ctiVMThrowTrampoline$non_lazy_ptr in Interpreter.o
ld: symbol(s) not found

I think this is because quiet_NaN() is declared as 
  double quiet_NaN() throw()
.
Comment 4 Alexey Proskuryakov 2009-01-30 07:32:04 PST
FWIW, we also have "extern const double NaN", which is used in several places.
Comment 5 Darin Adler 2009-01-30 09:09:53 PST
(In reply to comment #3)
> I think this is because quiet_NaN() is declared as 
>   double quiet_NaN() throw()

I don't think that's why. The CTI throw code has nothing to do with C++ exceptions; it's about JavaScript exceptions.

I don't think we should define a new named NAN constant in MathExtras.h. I think we should change our C++ code to use the standard quiet_NaN() directly.
Comment 6 Simon Fraser (smfr) 2009-01-30 09:12:52 PST
OK, this is a WONTFIX then.