<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>53598</bug_id>
          
          <creation_ts>2011-02-02 08:54:06 -0800</creation_ts>
          <short_desc>[V8] Incorrect behavior of NaNs in DataView (setting values, bit patterns)</short_desc>
          <delta_ts>2011-02-08 15:52:26 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGL</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 7</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joshua Bell">inexorabletash</reporter>
          <assigned_to name="Kenneth Russell">kbr</assigned_to>
          <cc>enne</cc>
    
    <cc>jianli</cc>
    
    <cc>kbr</cc>
    
    <cc>zmo</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>343992</commentid>
    <comment_count>0</comment_count>
    <who name="Joshua Bell">inexorabletash</who>
    <bug_when>2011-02-02 08:54:06 -0800</bug_when>
    <thetext>A handful of cases with NaNs in Typed Arrays.

var f32 = new Float32Array(1);

// Expected: 
f32[0] = NaN
f32[0]
&gt;&gt;&gt; NaN

// Unexpected: 
f32.set([NaN])
f32[0]
&gt;&gt;&gt; 0
// (expected NaN)

// Unexpected: 
f32 = new Float32Array([NaN]);
f32[0]
&gt;&gt;&gt; 0
// (expected NaN)

Additionally, NaN bit patterns don&apos;t match WebIDL draft:
http://www.w3.org/TR/WebIDL/#es-float
http://www.w3.org/TR/WebIDL/#es-double

var buf = new Uint8Array(8), dv = new DataView(buf.buffer);
dv.setFloat64(0, NaN);
dv.getUint32(0).toString(16);
&gt;&gt;&gt; &quot;fff80000&quot;
dv.getUint32(1).toString(16);
&gt;&gt;&gt; &quot;0&quot;

// Expected: 0x7ff8000000000000

dv.setFloat32(0, NaN);
dv.getUint32(0).toString(16);
&gt;&gt;&gt; &quot;ffc00000&quot;

// Expected: 0x7fc00000

Note that changing the WebIDL draft is an valid option as well if these values can be justified as making more sense. Alternately, the Typed Array specification could indicate that no explicit bit pattern for NaNs can be guaranteed - IEEE 754 defines a variety of NaN values, and for allowing variability among platforms may allow higher performance implementations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>343997</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Bell">inexorabletash</who>
    <bug_when>2011-02-02 09:10:28 -0800</bug_when>
    <thetext>Ooops - I previously reported the first issue as  https://bugs.webkit.org/show_bug.cgi?id=46990</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>344050</commentid>
    <comment_count>2</comment_count>
    <who name="Kenneth Russell">kbr</who>
    <bug_when>2011-02-02 10:37:33 -0800</bug_when>
    <thetext>To be clear:

 - Float32Array is working properly; the first few cases are working correctly in top of tree Chromium.

 - DataView seems to still have some corner case bugs around handling of NaNs.

Jian Li, do you have time to look into this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>346697</commentid>
    <comment_count>3</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-02-07 11:46:49 -0800</bug_when>
    <thetext>V8 bug filed: http://code.google.com/p/v8/issues/detail?id=1101</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>346815</commentid>
    <comment_count>4</comment_count>
    <who name="Kenneth Russell">kbr</who>
    <bug_when>2011-02-07 14:43:11 -0800</bug_when>
    <thetext>Please see the V8 bug http://code.google.com/p/chromium/issues/detail?id=71979 for some additional thoughts. I&apos;m inclined to relax the Typed Array spec in this area because if high-performance JavaScript engines like V8 avoid canonicalizing the NaN representation, it is strongly desirable to avoid impacting the performance of typed arrays in order to do so. Detecting and canonicalizing NaN would definitely negatively impact the performance of Float32Array&apos;s indexed setter.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>346933</commentid>
    <comment_count>5</comment_count>
    <who name="Joshua Bell">inexorabletash</who>
    <bug_when>2011-02-07 16:25:16 -0800</bug_when>
    <thetext>Relaxing the Typed Array spec is fine with me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>347759</commentid>
    <comment_count>6</comment_count>
    <who name="Kenneth Russell">kbr</who>
    <bug_when>2011-02-08 15:52:26 -0800</bug_when>
    <thetext>After discussion on the public_webgl list, this behavior is being left unspecified. Closing as Invalid.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>