Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8 Inlining limitations #1

Open
PlNG opened this issue Feb 22, 2015 · 2 comments
Open

V8 Inlining limitations #1

PlNG opened this issue Feb 22, 2015 · 2 comments

Comments

@PlNG
Copy link

PlNG commented Feb 22, 2015

I read somewhere that in order for the function to be eligible for inlining, the function body character limit (including white space) needs to be less than 600 characters and 196 AST nodes.

I see two ways to aid the user there: suggesting whitespace reduction if that is enough and suggesting minification if whitespace removal isn't enough.

@marten-de-vries
Copy link
Owner

I searched for this a bit, a possible source for that info is here. The idea seems interesting. Some practical problems:

  • Mozilla AST (which acorn/esprima use internally) != V8 AST. The count will probably be off, although they seem reasonably similar on first look so counting mozilla ast nodes is probably a good enough heuristic.
  • when to activate this. Not every function will be inlined at runtime, and not every function needs to. There are multiple ways around this. A CLI flag, opt-in using a comment, opt-out using a comment.

@PlNG
Copy link
Author

PlNG commented Mar 4, 2015

Here's a man page I found for 10.25 exposing the option and its default, so it's definitely real. Someone I asked in IRC commented that it's an awful metric, but that's the way it is. I agree that not every function is going to be inlined, but to even be considered, it has to meet the source limit: 600 characters, so warnings / suggestions when it's close to the number and a bit of work could bring it under the limit would work. I dislike noisy lints myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants