Bug 21985 - Opcodes should use eax as their destination register whenever possible
Summary: Opcodes should use eax as their destination register whenever possible
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Cameron Zwarich (cpst)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-30 13:15 PDT by Cameron Zwarich (cpst)
Modified: 2008-10-30 14:27 PDT (History)
0 users

See Also:


Attachments
Proposed patch (3.33 KB, patch)
2008-10-30 13:46 PDT, Cameron Zwarich (cpst)
no flags Details | Formatted Diff | Diff
Revised proposed patch (3.33 KB, patch)
2008-10-30 13:50 PDT, Cameron Zwarich (cpst)
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Zwarich (cpst) 2008-10-30 13:15:43 PDT
Some opcodes pointlessly use something other than eax as their destination register or supply eax as an argument to emitPutResult rather than using the default. This potentially makes the sort of memory traffic elimination like in bug 21943 less of a win.
Comment 1 Cameron Zwarich (cpst) 2008-10-30 13:46:21 PDT
Created attachment 24778 [details]
Proposed patch
Comment 2 Cameron Zwarich (cpst) 2008-10-30 13:50:23 PDT
Created attachment 24779 [details]
Revised proposed patch

I forgot to remove one of the explicit uses of eax. Here is a new patch.
Comment 3 Sam Weinig 2008-10-30 13:53:47 PDT
Comment on attachment 24779 [details]
Revised proposed patch

r=me
Comment 4 Maciej Stachowiak 2008-10-30 13:56:40 PDT
Comment on attachment 24778 [details]
Proposed patch

r=me

> Index: ChangeLog
> ===================================================================
> --- ChangeLog	(revision 38005)
> +++ ChangeLog	(working copy)
> @@ -1,3 +1,17 @@
> +2008-10-30  Cameron Zwarich  <zwarich@apple.com>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        Bug 21985: Opcodes should use eax as their destination register whenever possible
> +        <https://bugs.webkit.org/show_bug.cgi?id=21985>
> +
> +        Change more opcodes to use eax as the register for their final result,
> +        and change calls to emitPutResult() that pass eax to rely on the default
> +        value of eax.
> +
> +        * VM/CTI.cpp:
> +        (JSC::CTI::privateCompileMainPass):
> +
>  2008-10-30  Alp Toker  <alp@nuanti.com>
>  
>          Build fix attempt for older gcc on the trunk-mac-intel build bot
> Index: VM/CTI.cpp
> ===================================================================
> --- VM/CTI.cpp	(revision 38001)
> +++ VM/CTI.cpp	(working copy)
> @@ -1011,10 +1011,10 @@ void CTI::privateCompileMainPass()
>          case op_mov: {
>              unsigned src = instruction[i + 2].u.operand;
>              if (isConstant(src))
> -                m_jit.movl_i32r(asInteger(getConstant(m_callFrame, src)), X86::edx);
> +                m_jit.movl_i32r(asInteger(getConstant(m_callFrame, src)), X86::eax);
>              else
> -                emitGetArg(src, X86::edx);
> -            emitPutResult(instruction[i + 1].u.operand, X86::edx);
> +                emitGetArg(src, X86::eax);
> +            emitPutResult(instruction[i + 1].u.operand);
>              i += 3;
>              break;
>          }
> @@ -1071,7 +1071,7 @@ void CTI::privateCompileMainPass()
>              emitJumpSlowCaseIfNotImmNum(X86::eax, i);
>              m_jit.addl_i8r(getDeTaggedConstantImmediate(JSImmediate::oneImmediate()), X86::eax);
>              m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i));
> -            emitPutResult(srcDst, X86::eax);
> +            emitPutResult(srcDst);
>              i += 2;
>              break;
>          }
> @@ -1305,7 +1305,7 @@ void CTI::privateCompileMainPass()
>              JSVariableObject* globalObject = static_cast<JSVariableObject*>(instruction[i + 2].u.jsCell);
>              m_jit.movl_i32r(asInteger(globalObject), X86::eax);
>              emitGetVariableObjectRegister(X86::eax, instruction[i + 3].u.operand, X86::eax);
> -            emitPutResult(instruction[i + 1].u.operand, X86::eax);
> +            emitPutResult(instruction[i + 1].u.operand);
>              i += 4;
>              break;
>          }
> @@ -1407,8 +1407,8 @@ void CTI::privateCompileMainPass()
>              X86Assembler::JmpSrc isObject = m_jit.emitUnlinkedJe();
>  
>              m_jit.link(isImmediate, m_jit.label());
> -            emitGetArg(instruction[i + 2].u.operand, X86::ecx);
> -            emitPutResult(instruction[i + 1].u.operand, X86::ecx);
> +            emitGetArg(instruction[i + 2].u.operand, X86::eax);
> +            emitPutResult(instruction[i + 1].u.operand, X86::eax);
>              m_jit.link(isObject, m_jit.label());
>  
>              i += 3;
> @@ -1603,7 +1603,7 @@ void CTI::privateCompileMainPass()
>              emitJumpSlowCaseIfNotImmNum(X86::eax, i);
>              m_jit.subl_i8r(getDeTaggedConstantImmediate(JSImmediate::oneImmediate()), X86::eax);
>              m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i));
> -            emitPutResult(srcDst, X86::eax);
> +            emitPutResult(srcDst);
>              i += 2;
>              break;
>          }
Comment 5 Cameron Zwarich (cpst) 2008-10-30 14:27:50 PDT
Landed in r38009. Don't review my old patches, Maciej. ;-)