Bug 214914 - Update some JSArrayBufferView comments and add some assertions.
Summary: Update some JSArrayBufferView comments and add some assertions.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-29 01:49 PDT by Mark Lam
Modified: 2020-07-29 09:56 PDT (History)
8 users (show)

See Also:


Attachments
proposed patch. (5.75 KB, patch)
2020-07-29 01:53 PDT, Mark Lam
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2020-07-29 01:49:43 PDT
...
Comment 1 Mark Lam 2020-07-29 01:53:09 PDT
Created attachment 405444 [details]
proposed patch.
Comment 2 Darin Adler 2020-07-29 09:39:44 PDT
Comment on attachment 405444 [details]
proposed patch.

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

> Source/JavaScriptCore/runtime/ArrayBuffer.cpp:213
> +    ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(data) && Gigacage::contains(bitwise_cast<const uint8_t*>(data) + byteLength - 1)));

Converting from const void* to const uint8_t* requires only a static_cast, not a bitwise_cast. We should reserve bitwise_cast for the cases where it’s needed.

> Source/JavaScriptCore/runtime/JSArrayBufferView.cpp:51
> +    ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(vector) && Gigacage::contains(bitwise_cast<const uint8_t*>(vector) + length - 1)));

Ditto. Also, I suggest casting to uint8_t* for brevity rather than adding const. That can still be passed to a function that expects const uint8_t.
Comment 3 Mark Lam 2020-07-29 09:50:54 PDT
Comment on attachment 405444 [details]
proposed patch.

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

Thanks for the review.

>> Source/JavaScriptCore/runtime/ArrayBuffer.cpp:213
>> +    ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(data) && Gigacage::contains(bitwise_cast<const uint8_t*>(data) + byteLength - 1)));
> 
> Converting from const void* to const uint8_t* requires only a static_cast, not a bitwise_cast. We should reserve bitwise_cast for the cases where it’s needed.

I'll switch static_cast.  const is still needed.  Otherwise Clang will complain about: error: static_cast from 'const void *' to 'uint8_t *' (aka 'unsigned char *') casts away qualifiers.

>> Source/JavaScriptCore/runtime/JSArrayBufferView.cpp:51
>> +    ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(vector) && Gigacage::contains(bitwise_cast<const uint8_t*>(vector) + length - 1)));
> 
> Ditto. Also, I suggest casting to uint8_t* for brevity rather than adding const. That can still be passed to a function that expects const uint8_t.

Ditto.
Comment 4 Mark Lam 2020-07-29 09:55:37 PDT
Landed in r265045: <http://trac.webkit.org/r265045>.
Comment 5 Radar WebKit Bug Importer 2020-07-29 09:56:19 PDT
<rdar://problem/66278689>