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

RESOLVED FIXED in mozilla28

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dougc, Assigned: dougc)

Tracking

(Blocks: 1 bug)

Trunk
mozilla28
ARM
All
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
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.
(Assignee)

Comment 1

5 years ago
Created attachment 737395 [details] [diff] [review]
All the choice of the inter-asm.js hard/soft float ABI irrespective of the system ABI.

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.)
(Assignee)

Comment 3

5 years ago
(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.
Blocks: 896808
(Assignee)

Updated

5 years ago
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.
(Assignee)

Comment 4

5 years ago
Created attachment 8343688 [details] [diff] [review]
Use the hard-float ABI for inter-asm.js function calls irrespective of the system ABI.
Attachment #737395 - Attachment is obsolete: true
Attachment #8343688 - Flags: review?(luke)
(Assignee)

Updated

5 years ago
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+
(Assignee)

Comment 6

5 years ago
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
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28

Comment 9

5 years ago
Any numbers on this?
(Assignee)

Comment 10

5 years ago
(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.