OdinMonkey: fall back to baseline jit for enormous functions

ASSIGNED
Assigned to

Status

()

Core
JavaScript Engine
ASSIGNED
4 years ago
3 years ago

People

(Reporter: luke, Assigned: luke)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
Created attachment 753071 [details]
bad compile times 1

When functions get incredibly large, Ion starts to exhibit quadratic behavior in time and space usage.  This is fine normally, since these functions just get denied by the Ion compilation heuristics.  Odin, OTOH, currently Ion-compiles everything.  Fortunately, most codebases don't come anywhere close to the limit, but we are starting to find cases that do.  (One is the bison-generated yyparse (bug 864587), another is an Intel face-detection code, attached.)

A straightforward solution is to just fallback to the baseline jit in the case of these huge functions.  That's made a little difficult by the fact that we don't create bytecode for anything in an asm.js module.  However, we should be able to produce a JSScript on demand (for just the huge function) by reusing the lazy-bytecode work in bug 678037.
(Assignee)

Updated

4 years ago
Blocks: 881537

Comment 1

4 years ago
Will this mean there will be a max script size limit after which asm.js will not validate?
(Assignee)

Comment 2

4 years ago
Well, it'd "validate", but it'd just run in the baseline jit which is 2-20x slower.  This would be good for the case of huge cold functions, but still bad for hot ones (like say, big interpreter loops) so the developer would still need to cut the function into smaller pieces in that case.

Emscripten's outlining feature made this feature much less of a priority, btw.  A related feature I wish Emscripten could grow is to be able automatically move functions outside the asm.js module.  This could give developers another tool for managing the load-time of cold code.  In my wildest dreams, you could have Emscripten generate a profiling build that generates a list of cold functions which could then be moved outside of the asm.js module.  With asm.js caching, though, it's *still* possible that keeping these in the asm.js module would overall be faster.
You need to log in before you can comment on or make changes to this bug.