This repository has been archived by the owner on Feb 14, 2020. It is now read-only.
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.
Fixes #2
As reported by @XmiliaH at #2 code such as
fails to look up the value of "bad" on the endowment. This is due to conflicting assumptions in the code. Historically, we assumed that we were only optimizing optimizable own properties of the
safeGlobal
. Now that we're building optimizing code per evaluation, it makes sense to extend the optimization to include optimizable own properties of the endowments as well. The refactoring to extend this optimization missed a crucial step: passing the scopeProxy in as the object from which to extract the constant values, rather than passing in thesafeGlobal
.This way of repairing the refactoring does cause a proxy trap per optimizable global per evaluation. If this proves expensive, we could pass both the
safeGlobal
and theendowments
directly into the generated optimizer code, as long as we pass them in without introducing more names into scope.arguments[1]
andarguments[2]
would work.Note that either way of completing the refactoring introduces a hazard. Neither the
scopeProxy
(in the first technique) nor theendowments
object itself (in the second technique) may leak into user code. They both must be completely encapsulated by the shim. Making them available in the enclosing scope of the eval-ed code makes their encapsulation hard to verify. Such verification would need to reason about all the odd corners ofwith
and sloppy-mode declarations.