Bug 211029 - [JSC] Add fast path for BigInt32 left-shift
Summary: [JSC] Add fast path for BigInt32 left-shift
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-25 13:53 PDT by Yusuke Suzuki
Modified: 2020-04-25 16:57 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.03 KB, patch)
2020-04-25 13:56 PDT, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff
Patch for landing (3.71 KB, patch)
2020-04-25 14:24 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch for landing (8.87 KB, patch)
2020-04-25 14:28 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch for landing (8.56 KB, patch)
2020-04-25 14:30 PDT, 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 2020-04-25 13:53:58 PDT
[JSC] Add fast path for BigInt32 left-shift
Comment 1 Yusuke Suzuki 2020-04-25 13:56:03 PDT
Created attachment 397581 [details]
Patch
Comment 2 Saam Barati 2020-04-25 13:59:25 PDT
Comment on attachment 397581 [details]
Patch

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

> Source/JavaScriptCore/runtime/Operations.h:776
> +            int64_t result64 = static_cast<int64_t>(leftInt32) << rightInt32;

you need to check if this is a left shift, right?
Comment 3 Saam Barati 2020-04-25 14:01:54 PDT
Comment on attachment 397581 [details]
Patch

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

Nice. r=me

>> Source/JavaScriptCore/runtime/Operations.h:776
>> +            int64_t result64 = static_cast<int64_t>(leftInt32) << rightInt32;
> 
> you need to check if this is a left shift, right?

sorry, I missed the above !isLeft branch
Comment 4 Yusuke Suzuki 2020-04-25 14:18:53 PDT
Comment on attachment 397581 [details]
Patch

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

> Source/JavaScriptCore/runtime/Operations.h:765
>              rightInt32 = -rightInt32;

BTW, while this is completely separate issue from this, is this right? What happens if rightInt32 is INT32_MIN?
Comment 5 Yusuke Suzuki 2020-04-25 14:22:42 PDT
Comment on attachment 397581 [details]
Patch

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

> Source/JavaScriptCore/runtime/Operations.h:-770
> -            return jsBigInt32(leftInt32 >> std::min(rightInt32, 31));

I thought this is right in terms of int32 spec, but it seems that BigInt is not using rounding. So this is wrong. Will just use std::min.
Comment 6 Yusuke Suzuki 2020-04-25 14:24:48 PDT
Created attachment 397582 [details]
Patch for landing
Comment 7 Yusuke Suzuki 2020-04-25 14:28:07 PDT
Created attachment 397583 [details]
Patch for landing
Comment 8 Yusuke Suzuki 2020-04-25 14:30:32 PDT
Created attachment 397584 [details]
Patch for landing
Comment 9 Yusuke Suzuki 2020-04-25 16:56:46 PDT
Committed r260711: <https://trac.webkit.org/changeset/260711>
Comment 10 Radar WebKit Bug Importer 2020-04-25 16:57:16 PDT
<rdar://problem/62377699>