Closed Bug 861785 Opened 11 years ago Closed 11 years ago

Odinmonkey (ARM): use the hard-float ABI for inter-asm.js calls, even when the system is using the soft-float ABI.

Categories

(Core :: JavaScript Engine, defect)

ARM
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: dougc, Assigned: dougc)

References

Details

Attachments

(1 file, 1 obsolete file)

The soft-float ABI used on Android, and presumably B2G, passes floating point arguments and results in general purpose registers and on the stack which is generally slower than passing them in floating point registers.  Ion can optimize inter-asm.js function calls on the ARM by using the hard-float ABI internally, irrespective of the system ABI.  This is some low hanging fruit that should give a useful performance gain for ARM asm.js code.

It might be worth exploring if B2G could use the hard-float ABI by default?  Break away from the Android legacy.
Initial patch that passes some minimal testing.
Assignee: general → dtc-moz
Status: NEW → ASSIGNED
Great to see you looking into this!  It's definitely on the list of things to do after initial landing (https://wiki.mozilla.org/Javascript:SpiderMonkey:OdinMonkey#Potential_backend_optimizations).  What I was thinking we could do is have ABIArgIter take an enum parameter { Internal, External } describing whether this was an asm-to-asm call or external-to-asm/asm-to-external call and that this dynamic parameter would determine the ABI.  (The same goes for x86, where External can't use xmm registers.)
(In reply to Luke Wagner [:luke] from comment #2)
> Great to see you looking into this!  It's definitely on the list of things
> to do after initial landing
> (https://wiki.mozilla.org/Javascript:SpiderMonkey:
> OdinMonkey#Potential_backend_optimizations).  What I was thinking we could
> do is have ABIArgIter take an enum parameter { Internal, External }
> describing whether this was an asm-to-asm call or
> external-to-asm/asm-to-external call and that this dynamic parameter would
> determine the ABI.  (The same goes for x86, where External can't use xmm
> registers.)

That's a good list, thanks.  I've taken a quick look at using the
fastcall ABI for the x86 and will work on adding this along with
the ARM hardfp ABI support.
Summary: Optimize inter-asm.js function calls for the ARM arch by allow the use of hard-float ABI even when the system is using the soft-float ABI. → Odinmonkey (ARM): use the hard-float ABI for inter-asm.js calls, even when the system is using the soft-float ABI.
Blocks: 904918
Comment on attachment 8343688 [details] [diff] [review]
Use the hard-float ABI for inter-asm.js function calls irrespective of the system ABI.

Nice!
Attachment #8343688 - Flags: review?(luke) → review+
This will block the landing of bug 904918.  It has been tested for months, and just re-passed a good deal of the jit-tests locally, so will hopefully stick.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9e1a644eb6f3
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Any numbers on this?
(In reply to Alon Zakai (:azakai) from comment #9)
> Any numbers on this?

function test (glob, env, b) {
    'use asm';
    function f1(x, y) {
	x = +x; y = +y;
	return +(x+y);
    };
    function f2(x,y,n) {
	x = +x; y = +y; n = n|0;
	var i = 0; var s = 0.0;
	for (;(i|0)<1000000000;i=(i+1)|0) s = s + +f1(x,y);
	return +s;
    };
    return f2;
};
var asm = test(this);
asm(1.0, 2.0, 1000000);


ARM using the soft-float ABI for inter-asm.js calls: 40.5 s

ARM using the hard-float ABI for inter-asm.js calls: 18.0 s

ARM using --no-asmjs: 129.6 s
Nice!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: