Bug 147742 - [ES6] Implement ES6 arrow function syntax. Prototype of arrow function should be undefined
Summary: [ES6] Implement ES6 arrow function syntax. Prototype of arrow function should...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 140855
  Show dependency treegraph
 
Reported: 2015-08-06 13:02 PDT by GSkachkov
Modified: 2015-09-04 22:20 PDT (History)
6 users (show)

See Also:


Attachments
Patch (11.23 KB, patch)
2015-08-19 08:43 PDT, GSkachkov
no flags Details | Formatted Diff | Diff
Patch (11.23 KB, patch)
2015-08-19 08:59 PDT, GSkachkov
no flags Details | Formatted Diff | Diff
Patch (11.28 KB, patch)
2015-08-20 01:03 PDT, GSkachkov
no flags Details | Formatted Diff | Diff
Patch (9.33 KB, patch)
2015-08-26 03:58 PDT, GSkachkov
no flags Details | Formatted Diff | Diff
Patch (8.54 KB, patch)
2015-09-03 15:38 PDT, GSkachkov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description GSkachkov 2015-08-06 13:02:08 PDT
Arrow function should support following condition:
var af = ()=>{}; 
typeof af.prototype === 'undefined';
Comment 1 GSkachkov 2015-08-19 08:43:07 PDT
Created attachment 259371 [details]
Patch

Implemented feature
Comment 2 GSkachkov 2015-08-19 08:59:25 PDT
Created attachment 259372 [details]
Patch

Upload after rebase
Comment 3 GSkachkov 2015-08-20 01:03:28 PDT
Created attachment 259456 [details]
Patch

Fix build
Comment 4 Filip Pizlo 2015-08-25 14:13:13 PDT
Comment on attachment 259456 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259456&action=review

> Source/JavaScriptCore/runtime/JSArrowFunction.cpp:70
> +    removeDirect(vm, vm.propertyNames->prototype);

This is not necessary, and it's also quite wrong.  It's quite bad to remove properties; it puts the object into a conservative (i.e. slow) mode.  Also, there is no way for the object to have a "prototype" property at this point, since it's added lazily.
Comment 5 GSkachkov 2015-08-26 03:58:13 PDT
Created attachment 259943 [details]
Patch

Fix comments
Comment 6 GSkachkov 2015-08-26 06:39:06 PDT
(In reply to comment #4)
> Comment on attachment 259456 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=259456&action=review
> 
> > Source/JavaScriptCore/runtime/JSArrowFunction.cpp:70
> > +    removeDirect(vm, vm.propertyNames->prototype);
> 
> This is not necessary, and it's also quite wrong.  It's quite bad to remove
> properties; it puts the object into a conservative (i.e. slow) mode.  Also,
> there is no way for the object to have a "prototype" property at this point,
> since it's added lazily.

Hmm, it is really unnecessary. I've removed this code. Could you please make review one more time? 

Also something wrong with tests during build, because tests don't pass without my patch.
Comment 7 Saam Barati 2015-09-01 16:49:38 PDT
Comment on attachment 259943 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259943&action=review

> Source/JavaScriptCore/runtime/JSFunction.cpp:481
> +            || (propertyName == exec->propertyNames().prototype && !executable->isArrowFunction())

Why the isArrowFunction check here?
If we're an arrow function, don't we want to prevent deletion here?
Comment 8 GSkachkov 2015-09-02 02:51:03 PDT
How I understand this rule:
If an arrow function doesn't have own prototype so it can be initialized by custom js code. And if it possible to init this property so there has to be way to delete it. 
Does it make sense? 
Possible I need add this to task description or ChangeLog
Comment 9 Saam Barati 2015-09-02 22:39:01 PDT
Comment on attachment 259943 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259943&action=review

r=me with comment.
If you upload again I'll cq+

> Source/JavaScriptCore/runtime/JSFunction.cpp:361
>      if (propertyName == exec->propertyNames().prototype) {

I think this code is more clear if we just check !executable->isArrowFunction()
here instead of doing it twice below.
Comment 10 Saam Barati 2015-09-02 22:40:18 PDT
(In reply to comment #8)
> How I understand this rule:
> If an arrow function doesn't have own prototype so it can be initialized by
> custom js code. And if it possible to init this property so there has to be
> way to delete it. 
> Does it make sense? 
> Possible I need add this to task description or ChangeLog

Okay. I see. So for normal functions, we're definitely
not allowed to delete "prototype", but for arrow functions,
we start with no prototype, but we're allowed to define
one and delete one?
Comment 11 GSkachkov 2015-09-03 15:36:43 PDT
(In reply to comment #10)
> (In reply to comment #8)
> > How I understand this rule:
> > If an arrow function doesn't have own prototype so it can be initialized by
> > custom js code. And if it possible to init this property so there has to be
> > way to delete it. 
> > Does it make sense? 
> > Possible I need add this to task description or ChangeLog
> 
> Okay. I see. So for normal functions, we're definitely
> not allowed to delete "prototype", but for arrow functions,
> we start with no prototype, but we're allowed to define
> one and delete one?

Yes, that is correct.
I've double checked the es6 spec, and did not find any mention that related to 'prototype' property in arrow function section(14.2), only in "usual" function section(14.1.20 Note 2) http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function-definitions-runtime-semantics-evaluation, so I expect that 'prototype' property of arrow function should behave as ordinary property, in contrast with 'prototype' property of "usual" function that automatically created, can be changed, but can't be deleted.
Comment 12 GSkachkov 2015-09-03 15:38:36 PDT
Created attachment 260532 [details]
Patch

Increate code readability
Comment 13 Saam Barati 2015-09-03 23:12:27 PDT
Comment on attachment 260532 [details]
Patch

LGTM
Comment 14 WebKit Commit Bot 2015-09-03 23:58:46 PDT
Comment on attachment 260532 [details]
Patch

Clearing flags on attachment: 260532

Committed r189341: <http://trac.webkit.org/changeset/189341>
Comment 15 WebKit Commit Bot 2015-09-03 23:58:51 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Csaba Osztrogonác 2015-09-04 02:32:03 PDT
(In reply to comment #14)
> Comment on attachment 260532 [details]
> Patch
> 
> Clearing flags on attachment: 260532
> 
> Committed r189341: <http://trac.webkit.org/changeset/189341>

es6.yaml/es6/arrow_functions_no_prototype_property.js.default 
fails on all JSC tester bot, please check what happened.

Don't you run JSC tests before commiting a patch?
Comment 17 Alexey Proskuryakov 2015-09-04 09:09:37 PDT
Is anyone available to fix this soon? If not, I'm going to roll out the patch.
Comment 18 Basile Clement 2015-09-04 09:33:33 PDT
This patch actually made the test pass, but it is marked as "must fail" in the harness. r189350 <http://trac.webkit.org/changeset/189350> marks the test as "must succeed".
Comment 19 Alexey Proskuryakov 2015-09-04 10:18:47 PDT
Thank you Basile!
Comment 20 GSkachkov 2015-09-04 22:20:57 PDT
Basile Clemen Thank you for the fix. I'll try to avoid such think in future!(Run all tests on the lastest jsc version)