Bug 154639 - [ES6] Arrow function. Some not used byte code is emited
Summary: [ES6] Arrow function. Some not used byte code is emited
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 140855
  Show dependency treegraph
 
Reported: 2016-02-24 04:10 PST by GSkachkov
Modified: 2016-03-01 13:28 PST (History)
5 users (show)

See Also:


Attachments
Patch (7.90 KB, patch)
2016-03-01 00:19 PST, GSkachkov
no flags Details | Formatted Diff | Diff
Patch (9.41 KB, patch)
2016-03-01 11:36 PST, 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 2016-02-24 04:10:51 PST
During checking arrow function I found that some unused byte code is emited:
for instance for:
var f2 = function () { return ()=>'test';}; 
f2()(); 
was generated:
....
f2#DrpDJu:[0x10de8f840->0x10de76f40, NoneFunctionCall, 20]: 20 m_instructions; 160 bytes; 1 parameter(s); 8 callee register(s); 7 variable(s)
[   0] enter             
[   1] get_scope         loc3
[   3] mov               loc4, loc3
[   6] create_lexical_environment loc5, loc3, Cell: 0x10de3bdd0 (0x10de27600:[SymbolTable, {}, NonArray, Leaf]), ID: 20(const0), Undefined(const1) // Not used create_lexical_environment byte code
[  11] mov               loc3, loc5
[  14] op_new_arrow_func_exp loc7, loc3, f0
[  18] ret               loc7

Constants:
   k0 = Cell: 0x10de3bdd0 (0x10de27600:[SymbolTable, {}, NonArray, Leaf]), ID: 20
   k1 = Undefined

#An0cos:[0x10de8f620->0x10de76e00, NoneFunctionCall, 10]: 10 m_instructions; 80 bytes; 1 parameter(s); 8 callee register(s); 6 variable(s)
[   0] enter             
[   1] get_scope         loc3
[   3] mov               loc4, loc3
[   6] ret               String (atomic) (identifier): test, ID: 4(const1)
[   8] ret               Undefined(const2) // Not used byte code
Comment 1 GSkachkov 2016-02-26 11:49:13 PST
Also TDZ is emited for 'this' in arrow function that is invoked in class method
Comment 2 GSkachkov 2016-03-01 00:19:18 PST
Created attachment 272552 [details]
Patch

Patch comming
Comment 3 GSkachkov 2016-03-01 09:17:25 PST
(In reply to comment #1)
> Also TDZ is emited for 'this' in arrow function that is invoked in class
> method

I've checked and seems that this TDZ is not related to the arrow function. It always add when we're accessing to the 'superProperty'
Comment 4 GSkachkov 2016-03-01 11:36:25 PST
Created attachment 272579 [details]
Patch

Fix typo
Comment 5 Saam Barati 2016-03-01 12:03:17 PST
Comment on attachment 272579 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:13
> +        1.create_lexical_environment not emited always for arrow function, only if some of 
> +        features(this/super/arguments/eval) is used inside of the arrow function. 
> +        2.load 'this' from arrow function scope in constructor is done only if super 
> +        contains in arrow function 

Nice!
Comment 6 WebKit Commit Bot 2016-03-01 13:28:38 PST
Comment on attachment 272579 [details]
Patch

Clearing flags on attachment: 272579

Committed r197410: <http://trac.webkit.org/changeset/197410>
Comment 7 WebKit Commit Bot 2016-03-01 13:28:42 PST
All reviewed patches have been landed.  Closing bug.