Optimize global object access
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 431
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
IMO ejs shouldn't allow a writable global object, and all normal JS objects should be non-writable as well, at least by default. If we disable all writes (i.e. globals are frozen) then we can inline accesses for a ton of things at compile time.
I.e.
let a = Object.create (null);
This gets transformed to contain %getGlobal(Object) (which is itself a property lookup, just with implicit obj parameter) + a normal property lookup.
If everything is frozen, then we could directly invoke the function _ejs_Object_create (not even using _ejs_invoke_closure, since we can annotate the function such that the compiler knows it doesn't close over anything.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the EJS compiler/runtime, %getGlobal(Object), _ejs_Object_create, and _ejs_invoke_closure; start by tracing how these are currently used for Object.create(null). Done would require a decided design for non-writable globals and normal objects, plus compiler support for safe inlining and direct calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100