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

realm.js: don't freeze globals #104

Merged
merged 3 commits into from
Jun 18, 2018
Merged

Conversation

warner
Copy link
Collaborator

@warner warner commented Jun 6, 2018

The spec says the initial Realm state should have writable+configurable
global properties (except for three).

We'll want this to happen for frozen/SES realms, eventually, but not here. We
need to be able to run a shim that replaces Realm, or others.

@warner
Copy link
Collaborator Author

warner commented Jun 6, 2018

My apologies for not yet adding a test: I need to get a node-10 environment installed so I can run the test suite locally. We need something which creates a new realm and then attempts to replace one of the existing globals, i.e. let r = new Realm(); r.global.Realm = "foo";. I'll see what I can get done tomorrow.

@ljharb
Copy link
Member

ljharb commented Jun 6, 2018

@warner
Copy link
Collaborator Author

warner commented Jun 6, 2018

@ljharb thanks! I'll give that a try.

@warner
Copy link
Collaborator Author

warner commented Jun 6, 2018

Ah, it looks like current master doesn't pass tests on node7/8/9 (probably due to a function* somewhere). Not my fault :). I'll file a separate issue about that, it looks like @jfparadis 's last patch to the shim is the culprit.

@warner
Copy link
Collaborator Author

warner commented Jun 7, 2018

I pushed a new commit that adds tests, which revealed that I had the exclusion logic wrong, so that's been fixed too.

I ran the tests successfully on a different branch, which omitted the most recent commit (3ccc45a). This PR will fail CI until that gets fixed.

@@ -89,7 +89,7 @@ function setDefaultBindings(realmRec) {
const intrinsics = realmRec[Intrinsics];
const descs = getStdLib(intrinsics);
for (const name of Object.getOwnPropertyNames(descs)) {
if (name !== 'Infinity' || name !== 'NaN' || name !== 'undefined') {
if (!(name in { Infinity, NaN, undefined })) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous check was better; this will incorrectly pass for toString, for example.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! (My bad)

In any case, the previous code had a deMorgan confusion. It needed to use && rather than ||. That's what we should return to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, good catch

@warner warner changed the title realm.js: don't freeze primordials realm.js: don't freeze globals Jun 7, 2018
@warner
Copy link
Collaborator Author

warner commented Jun 8, 2018

I'm going to rebase this onto current master, to provoke travis into doing a new build.

@warner
Copy link
Collaborator Author

warner commented Jun 8, 2018

Ah, good, it's passing now.

Let me know if you'd prefer the writable+configurable settings to live in stdlib.js rather than being applied to everything (minus the three exceptions) in setDefaultBindings.

@warner
Copy link
Collaborator Author

warner commented Jun 12, 2018

BTW, https://github.com/agoric/proposal-realms/tree/unfreeze-globals-2 has an extra commit to move the settings to stdlib.js, if you'd like to see how that looks.

@warner
Copy link
Collaborator Author

warner commented Jun 15, 2018

This patch uses the list-of-names approach, as @jfparadis suggested today. There's one outstanding question: should eval be configurable? The current patch makes it so, but previously it was writable but not configurable.

The spec says the initial Realm state should have writable+configurable
global properties (except for three).

We'll want this to happen for frozen/SES realms, eventually, but not here. We
need to be able to run a shim that replaces Realm, or others.
@jfparadis jfparadis merged commit 0e44e87 into tc39:master Jun 18, 2018
@warner warner deleted the unfreeze-globals branch June 19, 2018 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants