Closed Bug 672490 Opened 8 years ago Closed Last year

Implicit coercion is a little faster than using "as" but they should be the same

Categories

(Tamarin Graveyard :: Virtual Machine, defect, P3)

x86
All
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: treilly, Unassigned)

Details

Attachments

(1 file, 3 obsolete files)

Attached file test diff (obsolete) —

Thomas-Reillys-Mac-Pro:~ treilly$ ~/builds/tamarin-redux/release/shell/avmshell cast.abc
as: 63
impl: 170
Thomas-Reillys-Mac-Pro:~ treilly$ ~/builds/tamarin-redux/release64/shell/avmshell cast.abc
as: 60
impl: 158
Thomas-Reillys-Mac-Pro:~ treilly$ ~/builds/tamarin-redux/release64/shell/avmshell cast.abc
as: 59
impl: 157
Summary: astype_late beats coerceobj_atom by a lot → Using "as" instead of implicit coercion is much faster
Attached file test case 2, not skewed by DCE (obsolete) —
results with test 2

$ ~/builds/tamarin-redux/release/shell/avmshell cast.abc
as: 314
impl: 513
$ ~/builds/tamarin-redux/release/shell/avmshell cast.abc
as: 312
impl: 510
$ ~/builds/tamarin-redux/release-debugger/shell/avmshell cast.abc
as: 344
impl: 589
$ ~/builds/tamarin-redux/release64/shell/avmshell cast.abc
as: 239
impl: 399
$ ~/builds/tamarin-redux/release64/shell/avmshell cast.abc
as: 240
impl: 402
Attached file vector is even worse (obsolete) —
Okay so the executive summary is that you have to be careful about DCE eliding the astype_late if you never use the value (see test 2).   Werner surmises this is due to astype_late being pure.  

coerceobj_atom takes a Traits and doesn't have to call toClassITraits but it seems possibly branchier.   AvmCore::astype doesn't some nitfy stuff if Traits is a builtin type but the JIT knows that isn't the case so the as case could be even faster.   

Both operations could arguably do the atom testing in the JIT'd code and make a direct call to subtypeof for kObjectType atoms.   A good first step would be to try to make coerceobj_atom as fast as astype_late.  

And then for true glory the fast path of subtypeof could be inlined into the JIT'd code too.
previous tests/comments were bogus, as operator is slower than implicit cast, vector is even faster, and atom to atom is the fastest.  so no really big surprises here really.
Attachment #546778 - Attachment is obsolete: true
Attachment #546835 - Attachment is obsolete: true
Attachment #546856 - Attachment is obsolete: true
Summary: Using "as" instead of implicit coercion is much faster → Implicit coercion is a little faster than using "as" but they should be the same
OS: Mac OS X → All
Priority: -- → P3
New results with fixed test.   So there is a bug that as operator probably slows things down more than it needs to, a specialization of astype for when we know the right hand side is a valid class is probably in order.   

$ ~/builds/tamarin-redux/release64/shell/avmshell cast.abc
as: 239
impl: 161
vec: 157
obj: 144
Flags: flashplayer-qrb+
Tamarin isn't maintained anymore. WONTFIX remaining bugs.
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.