<?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>116306</bug_id>
          
          <creation_ts>2013-05-17 05:02:36 -0700</creation_ts>
          <short_desc>MacroAssemblerARM should use xor to swap registers instead of move</short_desc>
          <delta_ts>2013-06-26 07:09:49 -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>Unspecified</rep_platform>
          <op_sys>Unspecified</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>
          
          <blocked>108645</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Gabor Rapcsanyi">rgabor</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ossy</cc>
    
    <cc>scerveau</cc>
    
    <cc>zherczeg</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>890294</commentid>
    <comment_count>0</comment_count>
    <who name="Gabor Rapcsanyi">rgabor</who>
    <bug_when>2013-05-17 05:02:36 -0700</bug_when>
    <thetext>On ARM Traditional and Thumb2 we are using a temporary register to swap two register value.
ARM Traditional using the r3 register for that purpose.

MacroAssemblerARM.h:540
     void swap(RegisterID reg1, RegisterID reg2)
     {
        move(reg1, ARMRegisters::S0);
        move(reg2, reg1);
        move(ARMRegisters::S0, reg2);
     }

That causing a problem because there is a case when we set up the function parameters in DFGCCallHelpers.h we put the third parameter to r3 then in setupTwoStubArgs() we swap r1 and r2 using r3 as temporary register. 

DFGCCallHelpers.h:460
        if (arg1 != GPRInfo::argumentGPR3 &amp;&amp; arg2 != GPRInfo::argumentGPR3) {
            move(arg3, GPRInfo::argumentGPR3);
            setupTwoStubArgs&lt;GPRInfo::argumentGPR1, GPRInfo::argumentGPR2&gt;(arg1, arg2);
            return;
        }

This generates the following code which is not correct:
  =&gt; 0x40022a3c:  mov     r3, r4
  =&gt; 0x40022a40:  mov     r3, r1
  =&gt; 0x40022a44:  mov     r1, r2
  =&gt; 0x40022a48:  mov     r2, r3

ARM Thumb2 is using the r12 register so this bug doesn&apos;t affect it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>890298</commentid>
    <comment_count>1</comment_count>
      <attachid>202065</attachid>
    <who name="Gabor Rapcsanyi">rgabor</who>
    <bug_when>2013-05-17 05:15:19 -0700</bug_when>
    <thetext>Created attachment 202065
proposed fix

Maybe we should consider to make this change on ARMv7 as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>893900</commentid>
    <comment_count>2</comment_count>
      <attachid>202065</attachid>
    <who name="Zoltan Herczeg">zherczeg</who>
    <bug_when>2013-05-27 00:05:40 -0700</bug_when>
    <thetext>Comment on attachment 202065
proposed fix

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>893985</commentid>
    <comment_count>3</comment_count>
      <attachid>202065</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-05-27 05:22:56 -0700</bug_when>
    <thetext>Comment on attachment 202065
proposed fix

Clearing flags on attachment: 202065

Committed r150748: &lt;http://trac.webkit.org/changeset/150748&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>893986</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-05-27 05:22:58 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>894212</commentid>
    <comment_count>5</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2013-05-27 20:55:38 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; Maybe we should consider to make this change on ARMv7 as well.

I think we should not.
ARMv7 has register aliasing, making &quot;mov&quot; essentially free in most situation.

Does the bug exist on ARMv7 though?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>894214</commentid>
    <comment_count>6</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2013-05-27 20:56:05 -0700</bug_when>
    <thetext>Well, let&apos;s say, some ARMv7 have register aliasing... :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>894216</commentid>
    <comment_count>7</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2013-05-27 21:07:44 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #1)
&gt; &gt; Maybe we should consider to make this change on ARMv7 as well.
&gt; 
&gt; I think we should not.
&gt; ARMv7 has register aliasing, making &quot;mov&quot; essentially free in most situation.
&gt; 
&gt; Does the bug exist on ARMv7 though?

Yeah this doesn&apos;t feel right for the ARMv7 assembler. There we have scratch registers for doing this. So long as there is a spare register the moves will be faster.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>894282</commentid>
    <comment_count>8</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2013-05-28 03:24:03 -0700</bug_when>
    <thetext>*** Bug 112697 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>894283</commentid>
    <comment_count>9</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2013-05-28 03:25:15 -0700</bug_when>
    <thetext>This bug also fixed many failing tests reported in https://bugs.webkit.org/show_bug.cgi?id=105304</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>896878</commentid>
    <comment_count>10</comment_count>
    <who name="Gabor Rapcsanyi">rgabor</who>
    <bug_when>2013-06-04 07:00:16 -0700</bug_when>
    <thetext>*** Bug 113774 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>903694</commentid>
    <comment_count>11</comment_count>
    <who name="Stephane Cerveau">scerveau</who>
    <bug_when>2013-06-26 07:09:49 -0700</bug_when>
    <thetext>*** Bug 117349 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>202065</attachid>
            <date>2013-05-17 05:15:19 -0700</date>
            <delta_ts>2013-05-27 05:22:56 -0700</delta_ts>
            <desc>proposed fix</desc>
            <filename>swap.patch</filename>
            <type>text/plain</type>
            <size>1346</size>
            <attacher name="Gabor Rapcsanyi">rgabor</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cgYi9Tb3VyY2UvSmF2
YVNjcmlwdENvcmUvQ2hhbmdlTG9nCmluZGV4IDRlOWFhN2IuLjE2MDg4MjYgMTAwNjQ0Ci0tLSBh
L1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL0phdmFTY3JpcHRD
b3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDEzLTA1LTE3ICBHYWJvciBSYXBjc2Fu
eWkgIDxyZ2Fib3JAd2Via2l0Lm9yZz4KKworICAgICAgICBNYWNyb0Fzc2VtYmxlckFSTSBzaG91
bGQgdXNlIHhvciB0byBzd2FwIHJlZ2lzdGVycyBpbnN0ZWFkIG9mIG1vdmUKKyAgICAgICAgaHR0
cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTExNjMwNgorCisgICAgICAgIFJl
dmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIENoYW5nZSByZ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