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

ES2017 review #775

Closed
wants to merge 77 commits into from
Closed

ES2017 review #775

wants to merge 77 commits into from

Conversation

anba
Copy link
Contributor

@anba anba commented Jan 23, 2017

I've kept the changes in small commits so it's easier to review them.

eval() and Function() are built-in functions, so per 9.3.1 the "current Realm Record" is the same realm as the [[Realm]] of the active function object.
Move the HostEnsureCanCompileStrings call into CreateDynamicFunction so it's also invoked for Generator and AsynFunction
All function Environment Records have a [[HomeObject]] field, use HasSuperBinding() to determine if it's a method.

Use [[FunctionKind]] to detect class constructors in PerformEval.
…cripts

And change "Constructors" to "Constructor methods" to avoid confusion with normal functions, because those are also constructors.
This error condition can no longer happen with the new early error checks for eval scripts.

It was previously needed to handle: (function(){ eval("super.p") })()
This error condition can no longer happen with the new early error checks for eval scripts.

It was previously needed to handle: (function(){ eval("super()") })()
Keep the entries in alphabetical order.
In addition to Script and Module, goal symbols for the grammar can also be FunctionBody, GeneratorBody, AsyncFunctionBody, and FormalParameters.
This is needed to avoid executing 9.1.6.3 ValidateAndApplyPropertyDescriptor, step 9, because exotic string objects don't use real properties for the string index properties.
The shorthand form is only valid for functional and method application styles per 5.2 Algorithm Conventions.
…s in typed array constructors

Prefer srcByteLength instead of srcLength to avoid confusion with [[ArrayLength]] of a typed array.
…pe.set

srcLength holds typedArray[[ArrayLength]], but we need typedArray[[ByteLengt]] when calling CloneArrayBuffer.
Similar to 'length' for %ArrayPrototype%.
Using <emu-clause> renders thisBooleanValue as property of Boolean.prototype. Alternatively we could use a nested <emu-clause> in Boolean.prototype.toString.
Change the length property back to 1 as defined in ECMA2016, implemented in all browsers, and also as tested in test262.
So it's properly linked in "Table 7: Well-known Intrinsic Objects".
…space exotic objects

ResolveExport isn't specified as infallible (consider the case when the module isn't a Source Text Module Record), so we need to handle abrupt completions.

Reverts tc39#507
@domenic
Copy link
Member

domenic commented Jan 23, 2017

Maybe we should move the HostEnsureCanCompileStrings check into CreateDynamicFunction?

@anba
Copy link
Contributor Author

anba commented Jan 23, 2017

Maybe we should move the HostEnsureCanCompileStrings check into CreateDynamicFunction?

That's fixed in the next commit 3f36151.

@domenic
Copy link
Member

domenic commented Jan 23, 2017

I see, I didn't expand the commit description; sorry for the noise!

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Most of the commits are either beyond my expertise or look fine - just a few questions.

@@ -8258,7 +8258,6 @@

<emu-clause id="sec-set-immutable-prototype">
<h1>SetImmutablePrototype ( _O_, _V_ )</h1>
<!-- This is used by host environment specs, even though it only has one consumer in this spec; don't inline it -->
Copy link
Member

Choose a reason for hiding this comment

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

How is this stale? I don't see anywhere else in the spec that references it (unless somewhere else in this PR references it?)

Either way, it seems prudent to leave it in, in case the other uses later get factored out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are now two callers of SetImmutablePrototype, so it's unlikely to get inlined.

Copy link
Member

Choose a reason for hiding this comment

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

Where are those two? I was unable to find them.

Copy link
Member

Choose a reason for hiding this comment

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

Either way tho, I think the comment is an important marker for the external dependency, and I'd expect every abstract operation that's referenced externally to be similarly noted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SetImmutablePrototype is used in 9.4.6.1 and 9.4.7.1. And we don't control which abstract operations are used by external parties, so we can't really mark every operation that's used externally. Allen's proposal in #398 seems more doable than having an incomplete coverage of operations which may or may not be used somewhere else.

@@ -33566,8 +33566,8 @@

<!-- es6num="24.1.2.1" -->
<emu-clause id="sec-arraybuffer-length">
<h1>ArrayBuffer ( [ _length_ ] )</h1>
<p>When the `ArrayBuffer` function is called with optional argument _length_, the following steps are taken:</p>
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this only need to be changed if it's web-incompatible to change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the length to zero is inconsistent with other functions, e.g. we could also change DataView.prototype.setInt32's length to zero because that function also "works" when called without any arguments, but the expectation is that setInt32 is called with at least two arguments. And the same applies for ArrayBuffer, where we expect it's called with a single length argument.

@@ -27139,7 +27139,7 @@
<!-- es6num="21.1.3" -->
<emu-clause id="sec-properties-of-the-string-prototype-object">
<h1>Properties of the String Prototype Object</h1>
<p>The String prototype object is the intrinsic object <dfn>%StringPrototype%</dfn>. The String prototype object is an ordinary object. The String prototype is itself a String object; it has a [[StringData]] internal slot with the value *""*.</p>
<p>The String prototype object is the intrinsic object <dfn>%StringPrototype%</dfn>. The String prototype object is an exotic String object and has the internal methods specified for such objects. It has a [[StringData]] internal slot with the value *""*.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Is it exotic solely because of the [[StringData]] internal slot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An object is only exotic if it uses a different implementation for any of the internal methods. And since String.prototype is a String object instance, and String objects are exotic String objects, String.prototype is also exotic.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha - and for my edification, why are String objects exotic (which internal methods does it differ for)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[[GetOwnProperty]], [[OwnPropertyKeys]], and (soon) [[DefineOwnProperty]] are overridden for exotic string objects in https://tc39.github.io/ecma262/#sec-string-exotic-objects. This is needed to support new String("test")[0] === "t", because the indexed properties aren't real properties but instead are defined as virtual properties, similar to how this is implemented in browsers.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense.

@bterlson
Copy link
Member

bterlson commented Feb 2, 2017

Reviewed most of these, working on thinking through a few of the normative-y ones. Any opinions on whether I should squash this monster or keep the individual commits?

@ljharb
Copy link
Member

ljharb commented Feb 2, 2017

The individual commits are super nice for review, and would also be nice for git blame.

@michaelficarra
Copy link
Member

Keep the individual commits. A lot of the spelling/typo commits can be merge though IMO.

@bterlson
Copy link
Member

bterlson commented Feb 2, 2017

I have a rebased branch with individual commits with updated commit messages. I'll do a rebase -i before I merge and join some like commits, but mostly leave them separate. Thanks for opinions :)

@bterlson
Copy link
Member

bterlson commented Feb 4, 2017

Pushed most of the commits individually (other than the ones I called out here). I guess I don't see a reason to collapse :)

In terms of release, none of the ones I left behind are bad to take during the RF opt-out period, so we will have some time to get them in before ES2017 is final-final.

@anba
Copy link
Contributor Author

anba commented Feb 6, 2017

Pushed most of the commits individually (other than the ones I called out here).

These five commits seem to be the ones left out:
65b2c27
81da5a0
88d70d7
72aa1de
0cd8543

The commit message for 65b2c27 should be changed, because it's incorrect (seems like I got confused by the current use of super restrictions in ch14). So basically the current spec text is correct w.r.t. the super-property restrictions, but applying 65b2c27 (with a corrected commit message!) makes the super-property restrictions more consistent with the ones in ch14.

@bterlson
Copy link
Member

bterlson commented Feb 6, 2017

65b2c27: IIUC, this has the effect of making SuperCall allowed in functions in eval. If this is correct, that doesn't align with clause 14 rules. Thoughts @anba?
81da5a0: I'm reluctant to take this change without hearing from some JSC folks (@msaboff)

88d70d7: Pulled (f608ef7)
72aa1de: Pulled (c934bf6)
0cd8543: Pulled (d88d05f)

@bterlson
Copy link
Member

bterlson commented Feb 6, 2017

Thinking again about 65b2c27, SuperCall is of course not allowed due to the "... outside constructors".  I'm just not sure I see the mapping to Clause 14.

I dislike this whole "... outside blah" notation after some experience with it.

@bterlson
Copy link
Member

bterlson commented Feb 8, 2017

Forgot to update to say:

65b2c27: Pulled (9c6e5b9)

@anba would you be open to making a PR for 81da5a0? I'll get to it later this week if you don't :)

@bakkot bakkot added the needs test262 tests The proposal should specify how to test an implementation. Ideally via github.com/tc39/test262 label Feb 8, 2017
@bakkot
Copy link
Contributor

bakkot commented Feb 8, 2017

Some of these changes are normative; test262 will need updates to match.

Normative changes which have gone in include at least the following, though not all of them make sense to test:

@anba
Copy link
Contributor Author

anba commented Feb 9, 2017

@anba would you be open to making a PR for 81da5a0? I'll get to it later this week if you don't :)

Filed #810.

@bterlson
Copy link
Member

This has all been merged! Thanks @anba.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs test262 tests The proposal should specify how to test an implementation. Ideally via github.com/tc39/test262
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants