toshok / toshok/echojs

Optimize global object access

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement performance
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.