Bug 124721 - ARM64: Implement push/pop equivalents in LLInt
Summary: ARM64: Implement push/pop equivalents in LLInt
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-21 09:07 PST by Michael Saboff
Modified: 2013-11-21 17:24 PST (History)
1 user (show)

See Also:


Attachments
Patch (5.57 KB, patch)
2013-11-21 16:56 PST, Michael Saboff
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2013-11-21 09:07:14 PST
ARM64 doesn't allow operation to the stack point that aren't 16 byte aligned.  Therefore push and pop need to be changed or abandoned.  One possibility is push and pop a pair of registers using the store pair (STP) and load pair (LDP) instructions.
Comment 1 Geoffrey Garen 2013-11-21 09:29:03 PST
Which push/pop instructions do you have in mind? 

Are you saying that the stack can't be misaligned even for a moment, such that two 8 byte pushes in a row would crash?
Comment 2 Michael Saboff 2013-11-21 09:41:02 PST
(In reply to comment #1)
> Which push/pop instructions do you have in mind? 
> 
> Are you saying that the stack can't be misaligned even for a moment, such that two 8 byte pushes in a row would crash?

ARM64 doesn't have push or pop instructions.  There are pre/post indexed memory ops.  The stack does need to be 16 byte aligned.  I don't know about whether temporary 8 byte alignment is fine.  There are load / store pair instructions which we use in the JSC macro assembler for pushToSave() and popToRestore().

There are LLInt push / pop macro ops.  They emit push and pop instructions, so I wondered if the clang assembler mapped those to the appropriate memory ops.  Turns out the it doesn't.  The current LLInt push / pop are currently unused, wrong and should result in a compile error.

When implementing the LLInt callToJavaScript(), I added {push,pop}CalleeSaves macro ops that does the right thing for each platform.  I followed after the push / pop macro op implementations.  Trying to work through the ARM64 compile issues I found there aren't ARM64 pseudo ops for push / pop.  I have reimplemented {push,pop}CalleeSaves using store / load pair and it appears to be working fine.
Comment 3 Michael Saboff 2013-11-21 16:56:59 PST
Created attachment 217628 [details]
Patch
Comment 4 Michael Saboff 2013-11-21 17:09:32 PST
Committed r159655: <http://trac.webkit.org/changeset/159655>
Comment 5 Michael Saboff 2013-11-21 17:10:03 PST
Reviewed in person by Phil Pizlo.
Comment 6 Geoffrey Garen 2013-11-21 17:11:02 PST
Does stp decrement the stack pointer register? Does ldp increment it? I'm worried that you're just storing/loading the same locations over and over again.
Comment 7 Michael Saboff 2013-11-21 17:24:04 PST
(In reply to comment #6)
> Does stp decrement the stack pointer register? Does ldp increment it? I'm worried that you're just storing/loading the same locations over and over again.

The stp is the pre-increment variety with an increment of -16.  That is what the "[sp, #-16]!" syntax means.
The ldp is the post-increment variety with an increment of 16.  The syntax for post increment has the increment amount after the closing ']': "[sp], #16".  A little confusing that's for sure.