<?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>180653</bug_id>
          
          <creation_ts>2017-12-11 10:00:52 -0800</creation_ts>
          <short_desc>LLInt: reserve 16 bytes of stack on MIPS for native calls</short_desc>
          <delta_ts>2017-12-12 11:03:39 -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>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Guillaume Emont">guijemont</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aperez</cc>
    
    <cc>clopez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1380254</commentid>
    <comment_count>0</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-12-11 10:00:52 -0800</bug_when>
    <thetext>The calling convention on MIPS is that the caller reserves 16 bytes (4 words) of stack space for all calls (regardless of the number of arguments). The callee can use that space. in LLInt&apos;s nativeCallTrampoline (which is only used if JIT is disabled), we effectively only save 8 bytes when adjusting the alignment. This crashes many date-related tests when running in llint-only mode when compiling in -Os.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380256</commentid>
    <comment_count>1</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-12-11 10:02:41 -0800</bug_when>
    <thetext>Note that it does not crash when the JIT is enabled, because it seems we use the thunk generated by JSC::nativeForGenerator() even when calling from llint. This thunk correctly allocates the 16 bytes of stack.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380265</commentid>
    <comment_count>2</comment_count>
      <attachid>328994</attachid>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-12-11 10:07:09 -0800</bug_when>
    <thetext>Created attachment 328994
Patch

Patch fixing the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380342</commentid>
    <comment_count>3</comment_count>
      <attachid>328994</attachid>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-12-11 12:23:23 -0800</bug_when>
    <thetext>Comment on attachment 328994
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328994&amp;action=review

Informal review: r+, with a comment. Please check it before landing.

&gt; Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:2086
&gt; +        # calling convention says to save stack space for 4 first registers in

Wow, good find. A similar scheme is used in the
“internalFunctionCallTrampoline()” macro but this patch does NOT
modify it accordingly. Is that intended?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380350</commentid>
    <comment_count>4</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-12-11 12:48:53 -0800</bug_when>
    <thetext>&gt; 
&gt; Wow, good find. A similar scheme is used in the
&gt; “internalFunctionCallTrampoline()” macro but this patch does NOT
&gt; modify it accordingly. Is that intended?

My understanding is that nativeCallTrampoline() is used to call C++ (native) functions, and internalFunctionCallTrampoline() is used to call js (internal) functions. Neither LLInt nor the JIT use that extra space, so we can save some memory by not allocating it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380382</commentid>
    <comment_count>5</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2017-12-11 13:54:41 -0800</bug_when>
    <thetext>(In reply to Guillaume Emont from comment #4)
&gt; &gt; 
&gt; &gt; Wow, good find. A similar scheme is used in the
&gt; &gt; “internalFunctionCallTrampoline()” macro but this patch does NOT
&gt; &gt; modify it accordingly. Is that intended?
&gt; 
&gt; My understanding is that nativeCallTrampoline() is used to call C++ (native)
&gt; functions, and internalFunctionCallTrampoline() is used to call js
&gt; (internal) functions. Neither LLInt nor the JIT use that extra space, so we
&gt; can save some memory by not allocating it.

That was also my suspicion, okay then!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380663</commentid>
    <comment_count>6</comment_count>
      <attachid>328994</attachid>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2017-12-12 08:48:39 -0800</bug_when>
    <thetext>Comment on attachment 328994
Patch

r=me (trusting Adrian review)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380709</commentid>
    <comment_count>7</comment_count>
      <attachid>328994</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-12-12 10:40:33 -0800</bug_when>
    <thetext>Comment on attachment 328994
Patch

Clearing flags on attachment: 328994

Committed r225788: &lt;https://trac.webkit.org/changeset/225788&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380710</commentid>
    <comment_count>8</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-12-12 10:40:35 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1380726</commentid>
    <comment_count>9</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-12-12 11:03:39 -0800</bug_when>
    <thetext>&lt;rdar://problem/35998684&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>328994</attachid>
            <date>2017-12-11 10:07:09 -0800</date>
            <delta_ts>2017-12-12 10:40:33 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-180653-20171211120708.patch</filename>
            <type>text/plain</type>
            <size>2186</size>
            <attacher name="Guillaume Emont">guijemont</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI1NzQyCmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBl
MGM2MmFkY2E2ZmI3YjA5YmZmNWMyMTY0NzQyYWUzYTdiMTM5NTNhLi4wNDg0Yzk0NTZhZjQxNDg5
ZjRmNGY2ZWNmNTA0ZmE4NjY4YTZlNTllIDEwMDY0NAotLS0gYS9Tb3VyY2UvSmF2YVNjcmlwdENv
cmUvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxNSBAQAorMjAxNy0xMi0xMSAgR3VpbGxhdW1lIEVtb250ICA8Z3VpamVtb250QGlnYWxp
YS5jb20+CisKKyAgICAgICAgTExJbnQ6IHJlc2VydmUgMTYgYnl0ZXMgb2Ygc3RhY2sgb24gTUlQ
UyBmb3IgbmF0aXZlIGNhbGxzCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3df
YnVnLmNnaT9pZD0xODA2NTMKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4K
KworICAgICAgICAqIGxsaW50L0xvd0xldmVsSW50ZXJwcmV0ZXIzMl82NC5hc206CisgICAgICAg
IE9uIE1JUFMsIHN1YnN0cmFjdCAyNCBmcm9tIHRoZSBzdGFjayBwb2ludGVyICgxNiBmb3IgY2Fs
bGluZworICAgICAgICBjb252ZW50aW9uICsgOCB0byBiZSAxNi1hbGlnbmVkKSBpbnN0ZWFkIG9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HNh
dmUgc3RhY2sgc3BhY2UgZm9yIDQgZmlyc3QgcmVnaXN0ZXJzIGluCisgICAgICAgICMgYWxsIGNh
c2VzLiBUbyBtYXRjaCBvdXIgMTYtYnl0ZSBhbGlnbm1lbnQsIHRoYXQgbWVhbnMgd2UgbmVlZCB0
bworICAgICAgICAjIHRha2UgMjQgYnl0ZXMKKyAgICAgICAgICAgIHN1YnAgMjQsIHNwCisgICAg
ICAgIGVsc2UKKyAgICAgICAgICAgIHN1YnAgOCwgc3AgIyBhbGlnbiBzdGFjayBwb2ludGVyCisg
ICAgICAgIGVuZAogICAgICAgICAjIHQxIGFscmVhZHkgY29udGFpbnMgdGhlIENhbGxlZS4KICAg
ICAgICAgYW5kcCBNYXJrZWRCbG9ja01hc2ssIHQxCiAgICAgICAgIGxvYWRwIE1hcmtlZEJsb2Nr
OjptX3ZtW3QxXSwgdDEKQEAgLTIwOTksNyArMjEwNiwxMSBAQCBtYWNybyBuYXRpdmVDYWxsVHJh
bXBvbGluZShleGVjdXRhYmxlT2Zmc2V0VG9GdW5jdGlvbikKICAgICAgICAgbG9hZHAgQ2FsbGVl
ICsgUGF5bG9hZE9mZnNldFtjZnJdLCB0MwogICAgICAgICBhbmRwIE1hcmtlZEJsb2NrTWFzaywg
dDMKICAgICAgICAgbG9hZHAgTWFya2VkQmxvY2s6Om1fdm1bdDNdLCB0MwotICAgICAgICBhZGRw
IDgsIHNwCisgICAgICAgIGlmIE1JUFMKKyAgICAgICAgICAgIGFkZHAgMjQsIHNwCisgICAgICAg
IGVsc2UKKyAgICAgICAgICAgIGFkZHAgOCwgc3AKKyAgICAgICAgZW5kCiAgICAgZWxzZQogICAg
ICAgICBlcnJvcgogICAgIGVuZAo=
</data>

          </attachment>
      

    </bug>

</bugzilla>