Bug 140139 - Investigate the character type of repeated string instead of checking is8Bit flag
Summary: Investigate the character type of repeated string instead of checking is8Bit ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-06 11:53 PST by Yusuke Suzuki
Modified: 2015-01-08 08:33 PST (History)
2 users (show)

See Also:


Attachments
Patch (3.02 KB, patch)
2015-01-06 11:57 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.02 KB, patch)
2015-01-06 12:07 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (2.95 KB, patch)
2015-01-07 06:34 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2015-01-06 11:53:54 PST
Investigate the character type of repeated string instead of checking is8Bit flag
Comment 1 Yusuke Suzuki 2015-01-06 11:57:59 PST
Created attachment 244082 [details]
Patch
Comment 2 Yusuke Suzuki 2015-01-06 12:02:39 PST
Comment on attachment 244082 [details]
Patch

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

In this patch, I've fixed the issue pointed at [1].

1: https://bugs.webkit.org/show_bug.cgi?id=140047#c22

> Source/JavaScriptCore/runtime/StringPrototype.cpp:679
> +static inline JSValue repeatCharacter(ExecState* exec, CharacterType character, unsigned repeatCount)

Change name to `repeatCharacter`.

> Source/JavaScriptCore/runtime/StringPrototype.cpp:725
> +        if (!(character & ~0xff))

Checking character is 8bit or not. This check is the same to the guart which is used in the StringImpl / StringBuiler[1].

1: http://trac.webkit.org/browser/trunk/Source/WTF/wtf/text/StringImpl.h#L1135
Comment 3 Yusuke Suzuki 2015-01-06 12:07:51 PST
Created attachment 244087 [details]
Patch
Comment 4 Darin Adler 2015-01-06 14:12:01 PST
Comment on attachment 244087 [details]
Patch

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

> Source/JavaScriptCore/runtime/StringPrototype.cpp:727
> +            return JSValue::encode(repeatCharacter<LChar>(exec, static_cast<LChar>(character), repeatCount));
> +        return JSValue::encode(repeatCharacter<UChar>(exec, character, repeatCount));

I don’t think the <LChar> and <UChar> are needed after repeatCharacter; I think template type deduction will take care of this.
Comment 5 Yusuke Suzuki 2015-01-07 06:33:06 PST
Comment on attachment 244087 [details]
Patch

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

Thanks for your review :)

>> Source/JavaScriptCore/runtime/StringPrototype.cpp:727
>> +        return JSValue::encode(repeatCharacter<UChar>(exec, character, repeatCount));
> 
> I don’t think the <LChar> and <UChar> are needed after repeatCharacter; I think template type deduction will take care of this.

Agreed. `static_cast` ensures the instantiated result of the template function.
I'll fix it and update the patch.
Comment 6 Yusuke Suzuki 2015-01-07 06:34:24 PST
Created attachment 244154 [details]
Patch
Comment 7 WebKit Commit Bot 2015-01-07 21:09:27 PST
Comment on attachment 244154 [details]
Patch

Clearing flags on attachment: 244154

Committed r178098: <http://trac.webkit.org/changeset/178098>
Comment 8 WebKit Commit Bot 2015-01-07 21:09:30 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Yusuke Suzuki 2015-01-08 08:33:20 PST
Thank you for your r+ and cq+ :D