<?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>113146</bug_id>
          
          <creation_ts>2013-03-23 20:38:29 -0700</creation_ts>
          <short_desc>Offlineasm cloop backend compiles op+branch incorrectly</short_desc>
          <delta_ts>2013-03-25 18:11:33 -0700</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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Filip Pizlo">fpizlo</reporter>
          <assigned_to name="Mark Lam">mark.lam</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>jbriance</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>862301</commentid>
    <comment_count>0</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2013-03-23 20:38:29 -0700</bug_when>
    <thetext>This is almost certainly a benign bug but it would be worth fixing. 

Quoth Julien:

sc.rb unless there is a strong reason not to.
&gt; I started to look at risc.rb and there are some things that I don&apos;t understand.
&gt; 
&gt; For instance the riscLowerSimpleBranchOps, where we have something like this:
&gt;   # baddiz foo, bar, baz
&gt;   #
&gt;   # will become:
&gt;   #
&gt;   # addi foo, bar
&gt;   # bz baz
&gt; 
&gt; As I see in the C loop impl, I thought it would be something like:
&gt;   # baddiz foo, bar, baz
&gt;   #
&gt;   # will become:
&gt;   #
&gt;   # addi foo, bar, tmp
&gt;   # bz baz
&gt;   # move tmp, bar
&gt; 
&gt; Am I missing something here ?

I confirmed by inspection that this is indeed what cloop does, in which case it&apos;s wrong. I expect this to be asymptommatic for now since if the LLInt uses those ops, it will be branching to a place where &apos;bar&apos; is dead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863189</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-03-25 17:11:58 -0700</bug_when>
    <thetext>I asked and Filip answered:

Me: I take it that the bug reported here is that the result should be applied before the branch, and is not conditional on the branch.
Filip: Yup. 
Me:   I presume that this should be true of the following opcodes also? baddio, bsubio, bmulio, baddis, baddinz, baddqs, baddqz, baddqnz, baddps, baddpz, baddpnz, bsubis, bsubiz, bsubinz, borris, borriz, borrinz.
Filip: Yup.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863195</commentid>
    <comment_count>2</comment_count>
      <attachid>194958</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-03-25 17:17:03 -0700</bug_when>
    <thetext>Created attachment 194958
the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863210</commentid>
    <comment_count>3</comment_count>
      <attachid>194958</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2013-03-25 17:26:36 -0700</bug_when>
    <thetext>Comment on attachment 194958
the patch.

r=me

Is there a way to regression test for this, when the c loop happens to be enabled?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863222</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-03-25 17:39:03 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Is there a way to regression test for this, when the c loop happens to be enabled?

I&apos;ll think about it and file a bug to do this later if it&apos;s possible (with reasonable effort).

Thanks for the review.  Landed in r146831: &lt;http://trac.webkit.org/changeset/146831&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863240</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2013-03-25 18:11:33 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; Is there a way to regression test for this, when the c loop happens to be enabled?
&gt; 
&gt; I&apos;ll think about it and file a bug to do this later if it&apos;s possible (with reasonable effort).

After inspecting the llint asm code, I don&apos;t think there is any JS level test that can check to ensure that the operations is done before the branch checks (at least at this time).  This is because the only existing uses of these instructions are &quot;baddis&quot; which is only when JIT_ENABLED (hence, not applicable to the cloop), and the branch on integer overflow cases.  In the integer overflow cases, the overflow condition will result in a branch to slow code which redo the operation using doubles.  Hence, we won&apos;t be able to observe that the instruction did not store the result of the integer operation.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>194958</attachid>
            <date>2013-03-25 17:17:03 -0700</date>
            <delta_ts>2013-03-25 17:26:35 -0700</delta_ts>
            <desc>the patch.</desc>
            <filename>bug-113146.patch</filename>
            <type>text/plain</type>
            <size>3669</size>
            <attacher name="Mark Lam">mark.lam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMTQ2ODI3KQorKysgU291cmNl
L0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDIzIEBA
CisyMDEzLTAzLTI1ICBNYXJrIExhbSAgPG1hcmsubGFtQGFwcGxlLmNvbT4KKworICAgICAgICBP
ZmZsaW5lYXNtIGNsb29wIGJhY2tlbmQgY29tcGlsZXMgb3ArYnJhbmNoIGluY29ycmV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cmZsb3cpIgor
ICAgICRhc20ucHV0YyAiICAgICAgICBnb3RvICN7b3BlcmFuZHNbMl0uY0xhYmVsfTsiCiAgICAg
JGFzbS5wdXRjICJ9IgogZW5kCiAK
</data>
<flag name="review"
          id="216766"
          type_id="1"
          status="+"
          setter="ggaren"
    />
          </attachment>
      

    </bug>

</bugzilla>