Open NightRa opened 8 years ago
@NightRa : nice catch, this one! Since you seem interested in maximum performance jison parsers, you may be interested in https://github.com/GerHobbelt/jison/commit/d2f8af7886ebda016b1e975fe94414b4134f6d5d (with some more performance-related work done in https://github.com/GerHobbelt/jison/commit/e44add313edf572f0c4f35f4862c08ab7aee41c8 ).
The thought there is that
bind()
is also rather costly (jsperf is down unfortunately, but old tests there indicated that .bind()
is not exactly the fastest kid on the block) parse()
API as these arguments are listed in the grammar file in the %parse-params
option line==> that made me wonder: "Why don't we take the %parse-params argument list and inject straight away into the code instead of messing with this arguments
semi-array at all?" and those two referenced commits above are the result.
Thanks you for your work; I had not realized the high cost of arguments
+slice
in the parser core yet. 👍
Using
arguments
in a dynamic way in a function leads to the JIT (v8) not optimizing the whole function, with the error: "Bad value context for argument value". See https://github.com/GoogleChrome/devtools-docs/issues/53#issuecomment-51941358 and Note gist.This commit wraps the parse function with handling of
arguments
, and calls into the regular function with theargs
array, and now it can be optimized.This fix improved performance almost 2x for me, from 17s to 9s. (for 500Kb of text so there's still room for improvement)