Add initial support for storing function source and getting it from func .toString() #1147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Placeholder for now.
Basic idea is to store
_Source
in the compiler when source support is enabled. Then, inFunction.prototype.toString()
, if source is available, use it as the toString() result directly.So it's up to the compiler to come up with a useful
_Source
that matches ES6 requirements.Later on it'd make sense to use some form of compression on the source code, e.g. bit packing optimized for ASCII and RLE compressing white space.
Or maybe an actual compression algorithm: for example, a 1kB footprint for a compression/decompression algorithm would be worth it if the ~3kB strings and built-ins init data was reduced to 2kB. Also, the more strings and built-ins are present (which increases over time), the better this trade-off would be.