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

Optimize global object access #10

Open
toshok opened this issue Dec 31, 2013 · 0 comments
Open

Optimize global object access #10

toshok opened this issue Dec 31, 2013 · 0 comments

Comments

@toshok
Copy link
Owner

toshok commented Dec 31, 2013

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.)

toshok added a commit that referenced this issue Jan 3, 2014
when --frozen-global is present on the command line, it becomes a syntax error to
set a property on the global object (i.e. every lhs of an assignment has to be an
in-scope variable declaration.)

Also, since we know the global object is frozen we can inline loads from the C globals
instead of calling _ejs_global_getprop at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant