WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
207297
[JSC] Computed function properties compute their keys twice
https://bugs.webkit.org/show_bug.cgi?id=207297
Summary
[JSC] Computed function properties compute their keys twice
Ross Kirsling
Reported
2020-02-05 14:43:25 PST
Basic repro: ``` let count1 = 0; let key1 = { toString() { count1++; return 'foo'; } }; ({ [key1]: 'bar' }); let count2 = 0; let key2 = { toString() { count2++; return 'foo'; } }; ({ [key2]() { return 'bar'; } }); print(count1, count2); ``` λ eshost -s test.js #### ch, sm, v8, xs 1 1 #### jsc 1 2 Notes: - This also reproes if: - we write the function property as `[key]: function () { return 'bar'; }` or `[key]: () => 'bar'` instead - we set toString to null and use valueOf instead - Relevant test262 failures:
https://github.com/tc39/test262/blob/master/test/language/computed-property-names/to-name-side-effects/class.js
https://github.com/tc39/test262/blob/master/test/language/computed-property-names/to-name-side-effects/numbers-class.js
https://github.com/tc39/test262/blob/master/test/language/computed-property-names/to-name-side-effects/object.js
-
Bug 170934
seems related but separate.
Attachments
Patch
(8.19 KB, patch)
2020-02-08 16:10 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Patch
(13.87 KB, patch)
2020-02-10 13:53 PST
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Ross Kirsling
Comment 1
2020-02-08 16:10:42 PST
Created
attachment 390185
[details]
Patch
Ross Kirsling
Comment 2
2020-02-10 11:33:15 PST
Comment on
attachment 390185
[details]
Patch The current approach is very simple but incurs a ToPropertyKey instruction even for non-function computed properties. I suppose it would be better to split emitSetFunctionNameIfNeeded into needsSetFunctionName and emitSetFunctionName so that this can be avoided.
Ross Kirsling
Comment 3
2020-02-10 13:53:24 PST
Created
attachment 390291
[details]
Patch
Ross Kirsling
Comment 4
2020-02-18 10:28:54 PST
Ping?
Keith Miller
Comment 5
2020-02-18 11:11:11 PST
Comment on
attachment 390291
[details]
Patch r=me.
WebKit Commit Bot
Comment 6
2020-02-18 12:01:26 PST
Comment on
attachment 390291
[details]
Patch Clearing flags on attachment: 390291 Committed
r256846
: <
https://trac.webkit.org/changeset/256846
>
WebKit Commit Bot
Comment 7
2020-02-18 12:01:27 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 8
2020-02-18 12:02:21 PST
<
rdar://problem/59559881
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug