-
Notifications
You must be signed in to change notification settings - Fork 74
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
Use Compartment.p.evaluate instead of eight magic lines on XS #730
Comments
@erights - We'd like to see xsnap switch over to the XS implementation of Compartments. It should be more efficient and it would let us get some experience together on Compartments. However, recall that thee snapshot capability of xsnap and Compartments are mutually exclusive at the moment. There's a non-trivial investigation needed to see if/how those can be used together. The |
How about as a compartment.evaluate(src, { sourceURL: 'file:stuff' }); Attn @kriskowal @dckc |
Interesting. I had certainly forgotten that, if I ever knew it. |
@dckc - FWIW, email from September 30, 2020:
@erights - Another options bag! If @kriskowal and @dckc are OK with that approach too, we can take a look later this week. |
Adding |
OK. So then we should not spend time on the sourceURL until snapshots and Compartments can work together. |
Yes, that makes sense to me. |
Looks like this is a dup of Agoric/agoric-sdk#2480 ; I was pretty sure we already had an issue for this. Maybe I'll close the one in agoric-sdk in favor of this... |
Agreed. This is the repository where the integration work will have to land. |
Actually, I was just having second thoughts; the most recent xsnap work is in agoric-sdk, so it seems likely to land there, unless / until we move it (#681 ). What suggests that the integration has to land here, @kriskowal ? |
We’ll need a follow-up change in SES to feature-detect the suitable XS Compartment and switch the behavior of |
We currently depend on the 8 magic lines proxy for two features that we can't emulate using
In addition, there is another potential gotcha with the live binding transformation. Currently we consider an exported variable to be a live binding if there are any statically visible assignments to that variable. However, the direct eval expression enables assignments that are not statically visible. Fortunately, a direct eval expression is itself statically visible. Under the 8 magic lines, we did not need to worry about this because we could not support direct eval anyway. If we switch to |
For the "sloppy globals" issue, we could painlessly add a dirt simple translator to our repl, replacing a first line matching /^(\s*)(\w*\s*=)/ with `${m[1]}globalThis.${m[2])` |
If the price of moving to |
Noting that there is yet another bug under 8 magic lines that would be fixed by moving to
Moving to |
See also Agoric/agoric-sdk#2480 which is dup-ish, but we're keeping both open for now. |
Currently, even on xsnap, we're building SES essentially the same way we do on normal JS, by running the full SES shim including the eight magic lines built on direct
eval
. Currently, XSeval
does not understand the sourceURL directive, so all SES code runs in XS without any tie to a filename. Also, using the eight magic lines, we cannot fix #31Instead, we could switch to using the XS builtin
Compartment.prototype.evaluate
as our safe evaluator, replacing the eight magic lines, while still building the rest of SES using code from the SES shim. This should immediately fix #31 .In addition, perhaps it is easier to get XS to accept a filename via
Compartment.prototype.evaluate
rather than the sourceURL directive in aneval
? Attn @phoddieThe text was updated successfully, but these errors were encountered: