<?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>150412</bug_id>
          
          <creation_ts>2015-10-21 13:46:28 -0700</creation_ts>
          <short_desc>[MIPS] &quot;(-1) % NaN&quot; returns -1 instead of NaN with LLInt</short_desc>
          <delta_ts>2016-01-18 18:26:43 -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>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>108664</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Guillaume Emont">guijemont</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annulen</cc>
    
    <cc>fpizlo</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1135364</commentid>
    <comment_count>0</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2015-10-21 13:46:28 -0700</bug_when>
    <thetext>The spec[1] says it should return NaN. It doesn&apos;t because fmod() on MIPS returns an impure NaN.

[1]http://www.ecma-international.org/ecma-262/6.0/#sec-applying-the-mod-operator</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1135367</commentid>
    <comment_count>1</comment_count>
      <attachid>263727</attachid>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2015-10-21 13:51:37 -0700</bug_when>
    <thetext>Created attachment 263727
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1151636</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2015-12-30 15:20:17 -0800</bug_when>
    <thetext>My preference is to approve this patch, since it&apos;s such a small #ifdef.

But I will defer for a few days to Filip, as he wants to drop support for MIPS; he might not want to add this since it is a cross-platform file that otherwise has no arch-specific #ifdefs, and this smells like a workaround for a bug in glibc and ulibc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1151996</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-02 10:43:03 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; But I will defer for a few days to Filip, as he wants to drop support for
&gt; MIPS; he might not want to add this since it is a cross-platform file that
&gt; otherwise has no arch-specific #ifdefs, and this smells like a workaround
&gt; for a bug in glibc and ulibc.

Just please wait a week before committing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1152016</commentid>
    <comment_count>4</comment_count>
      <attachid>263727</attachid>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2016-01-02 12:53:49 -0800</bug_when>
    <thetext>Comment on attachment 263727
Patch

I think that this is the wrong approach. You should create a new header (JSMathExtras.h maybe) that provides an abstraction for fmod, and probably other things in the future. Then inside that abstraction you can do the purifyNaN based on some condition, like maybe a global switch like MATH_PURIFIES_NAN, which can be false on MIPS. This is a better approach because there will be other callers of fmod and there will be other math functions that have the same issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1156315</commentid>
    <comment_count>5</comment_count>
    <who name="Konstantin Tokarev">annulen</who>
    <bug_when>2016-01-17 12:47:50 -0800</bug_when>
    <thetext>Is there a test case which can reliably reproduce this bug? Seems to work fine here with glibc 2.18 without this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1156372</commentid>
    <comment_count>6</comment_count>
    <who name="Konstantin Tokarev">annulen</who>
    <bug_when>2016-01-18 02:38:18 -0800</bug_when>
    <thetext>By chance, isn&apos;t it softfp-only issue? In your similar patch[1] you mention sotfp, and I&apos;m testiong on hardfp.

https://github.com/Metrological/WebKitForWayland/commit/bcb5650161a0e93db180663d909b2c10f5c81c12</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1156502</commentid>
    <comment_count>7</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2016-01-18 18:26:43 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; By chance, isn&apos;t it softfp-only issue? In your similar patch[1] you mention
&gt; sotfp, and I&apos;m testiong on hardfp.
&gt; 
&gt; https://github.com/Metrological/WebKitForWayland/commit/
&gt; bcb5650161a0e93db180663d909b2c10f5c81c12

Yes, I don&apos;t have a softfp build right now to test the theory, but I think you are right and that I encountered the issue when using glibc&apos;s softfp implementation. I will try to cook a patch following Filip&apos;s recommendation, though it&apos;s not the highest priority for me right now as I switched to a hardfp build.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>263727</attachid>
            <date>2015-10-21 13:51:37 -0700</date>
            <delta_ts>2016-01-02 12:53:49 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-150412-20151021155105.patch</filename>
            <type>text/plain</type>
            <size>1550</size>
            <attacher name="Guillaume Emont">guijemont</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTkxMzk5CmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBk
ZjZjOTI3YTVhMWI2YWJjZjJiYmU3MzlkYWFiMDg1YmFiZTVmMWVjLi41YjFiYzlmNjczZTZmODI2
OTZlY2Q3NDk5OTIwZGRhOGExZTg1YTg0IDEwMDY0NAotLS0gYS9Tb3VyY2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XZhU2NyaXB0Q29y
ZS9ydW50aW1lL0NvbW1vblNsb3dQYXRocy5jcHAKKysrIGIvU291cmNlL0phdmFTY3JpcHRDb3Jl
L3J1bnRpbWUvQ29tbW9uU2xvd1BhdGhzLmNwcApAQCAtNDAyLDcgKzQwMiwxMyBAQCBTTE9XX1BB
VEhfREVDTChzbG93X3BhdGhfbW9kKQogICAgIEJFR0lOKCk7CiAgICAgZG91YmxlIGEgPSBPUF9D
KDIpLmpzVmFsdWUoKS50b051bWJlcihleGVjKTsKICAgICBkb3VibGUgYiA9IE9QX0MoMykuanNW
YWx1ZSgpLnRvTnVtYmVyKGV4ZWMpOworI2lmIENQVShNSVBTKQorICAgIC8vIFdoZW4gcGFzc2Vk
IGEgTmFOIGFzIHBhcmFtZXRlciwgZm1vZCgpIHRlbmRzIHRvIHJldHVybiBhbiBpbXB1cmUgTmFO
IG9uCisgICAgLy8gTUlQUyAoYm90aCB3aXRoIHVjbGliYyBhbmQgZ2xpYmMpLgorICAgIFJFVFVS
Tihqc051bWJlcihwdXJpZnlOYU4oZm1vZChhLCBiKSkpKTsKKyNlbHNlCiAgICAgUkVUVVJOKGpz
TnVtYmVyKGZtb2QoYSwgYikpKTsKKyNlbmRpZgogfQogCiBTTE9XX1BBVEhfREVDTChzbG93X3Bh
dGhfbHNoaWZ0KQo=
</data>
<flag name="review"
          id="288843"
          type_id="1"
          status="-"
          setter="fpizlo"
    />
          </attachment>
      

    </bug>

</bugzilla>