Bug 223231 - [WebIDL] Fix convertRecord() to throw on enumerable symbol |key|
Summary: [WebIDL] Fix convertRecord() to throw on enumerable symbol |key|
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Trivial
Assignee: Alexey Shvayka
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-15 18:17 PDT by Alexey Shvayka
Modified: 2021-03-17 09:02 PDT (History)
10 users (show)

See Also:


Attachments
Patch (10.55 KB, patch)
2021-03-15 18:25 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff
Patch (10.58 KB, patch)
2021-03-16 15:24 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Shvayka 2021-03-15 18:17:50 PDT
[WebIDL] Fix convertRecord() to throw on enumerable symbol |key|
Comment 1 Alexey Shvayka 2021-03-15 18:25:16 PDT
Created attachment 423276 [details]
Patch
Comment 2 Darin Adler 2021-03-16 14:30:22 PDT
Comment on attachment 423276 [details]
Patch

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

> Source/WebCore/bindings/js/JSDOMConvertStrings.cpp:38
> +    VM& vm = lexicalGlobalObject.vm();
> +    auto scope = DECLARE_THROW_SCOPE(vm);

Is there any performance benefit to moving this inside the if statement?

> Source/WebCore/bindings/js/JSDOMConvertStrings.cpp:103
> +    if (!string)
> +        return { };

This seems like an unimportant optimization. I would leave it out; the stringToUSVString function can handle the null string without causing any problems. Then this can just be a one-liner. Also, we generally write string.isNull() instead of !string. Not sure why.

    return stringToUSVString(identifierToString(lexicalGlobalObject, identifier));
Comment 3 Alexey Shvayka 2021-03-16 15:24:40 PDT
Created attachment 423404 [details]
Patch

Add UNLIKELY, move DECLARE_THROW_SCOPE into branch, and make identifierToUSVString() a one-liner.
Comment 4 Alexey Shvayka 2021-03-16 15:25:57 PDT
(In reply to Darin Adler from comment #2)

Thank you for reviewing convertRecord() changes!

> Is there any performance benefit to moving this inside the if statement?

I've found a few precedents of ThrowScope() created inside a branch, in hot inlined methods.
This won't break validation of exception checks.

Also, added an UNLIKELY, which is merely a compiler hint on how to emits jumps so common case is optimized.

> This seems like an unimportant optimization. I would leave it out; the
> stringToUSVString function can handle the null string without causing any
> problems. Then this can just be a one-liner. Also, we generally write
> string.isNull() instead of !string. Not sure why.
> 
>     return stringToUSVString(identifierToString(lexicalGlobalObject,
> identifier));

Nice, fixed.
Comment 5 EWS 2021-03-17 09:01:44 PDT
Committed r274561: <https://commits.webkit.org/r274561>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423404 [details].
Comment 6 Radar WebKit Bug Importer 2021-03-17 09:02:16 PDT
<rdar://problem/75528251>