Bug 180970 - [JSC] Do not check isValid() in op_new_regexp
Summary: [JSC] Do not check isValid() in op_new_regexp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on: 180960 180966
Blocks:
  Show dependency treegraph
 
Reported: 2017-12-19 03:36 PST by Yusuke Suzuki
Modified: 2019-03-08 23:58 PST (History)
6 users (show)

See Also:


Attachments
Patch (8.50 KB, patch)
2017-12-19 12:11 PST, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2017-12-19 03:36:08 PST
If we have an invalid regexp, we should emit op_throw_xxx bytecode instead of op_new_regexp.
Comment 1 Yusuke Suzuki 2017-12-19 12:11:18 PST
Created attachment 329788 [details]
Patch
Comment 2 Saam Barati 2017-12-20 13:37:25 PST
Comment on attachment 329788 [details]
Patch

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

r=me with debug build fix.

> Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:149
> +    const Identifier& message = generator.parserArena().identifierArena().makeIdentifier(generator.vm(), bitwise_cast<const LChar*>(messageCharacters), strlen(messageCharacters));

bitwise_case -> static_cast?

> JSTests/stress/regexp-syntax-error-invalid-flags.js:18
> +    return /Hello/cocoa;

I vote for adding a few more invalid regrex tests
Comment 3 Yusuke Suzuki 2017-12-20 17:55:01 PST
Comment on attachment 329788 [details]
Patch

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

Thank you!

>> Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:149
>> +    const Identifier& message = generator.parserArena().identifierArena().makeIdentifier(generator.vm(), bitwise_cast<const LChar*>(messageCharacters), strlen(messageCharacters));
> 
> bitwise_case -> static_cast?

Since this is `const char*` to `const LChar*` cast, bitwise_cast is necessary. (LChar is uint8_t).

>> JSTests/stress/regexp-syntax-error-invalid-flags.js:18
>> +    return /Hello/cocoa;
> 
> I vote for adding a few more invalid regrex tests

The other invalid RegExp becomes early (parser phase) syntax error. We have relaxed rule for invalid flags, which raise runtime errors.
Comment 4 Yusuke Suzuki 2017-12-20 17:58:34 PST
Committed r226209: <https://trac.webkit.org/changeset/226209>
Comment 5 Radar WebKit Bug Importer 2017-12-20 18:00:37 PST
<rdar://problem/36169188>