Bug 235720 - Reland StructureID overhaul
Summary: Reland StructureID overhaul
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: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-27 10:04 PST by Keith Miller
Modified: 2022-02-13 11:56 PST (History)
14 users (show)

See Also:


Attachments
Patch (272.29 KB, patch)
2022-01-27 10:38 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (272.68 KB, patch)
2022-01-31 07:03 PST, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2022-01-27 10:04:00 PST
Reland StructureID overhaul
Comment 1 Keith Miller 2022-01-27 10:38:12 PST
Created attachment 450155 [details]
Patch
Comment 2 Yusuke Suzuki 2022-01-27 10:47:22 PST
Comment on attachment 450155 [details]
Patch

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

r=me

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:105
> +        MarkedBlock* block = reinterpret_cast<MarkedBlock*>(g_jscConfig.startOfStructureHeap) + freeIndex * MarkedBlock::blockSize;
> +        constexpr bool writable = true;
> +        constexpr bool executable = false;
> +        OSAllocator::commit(block, MarkedBlock::blockSize, writable, executable);

Let's mprotect READ | WRITE in debug build.

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:111
> +        OSAllocator::decommit(blockPtr, MarkedBlock::blockSize);

Let's mprotect NONE in debug build.

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:149
> +void StructureAlignedMemoryAllocator::commitBlock(void* block)
> +{
> +    constexpr bool writable = true;
> +    constexpr bool executable = false;
> +    OSAllocator::commit(block, MarkedBlock::blockSize, writable, executable);
> +}

Let's mprotect READ | WRITE in debug build.

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:154
> +void StructureAlignedMemoryAllocator::decommitBlock(void* block)
> +{
> +    OSAllocator::decommit(block, MarkedBlock::blockSize);
> +}

Let's mprotect NONE in debug build.
Comment 3 Keith Miller 2022-01-31 07:03:33 PST
Created attachment 450407 [details]
Patch for landing
Comment 4 EWS 2022-01-31 08:06:42 PST
Committed r288815 (246591@main): <https://commits.webkit.org/246591@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450407 [details].
Comment 5 Radar WebKit Bug Importer 2022-01-31 08:07:18 PST
<rdar://problem/88270829>
Comment 6 Saam Barati 2022-02-13 11:43:23 PST
Comment on attachment 450407 [details]
Patch for landing

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

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:85
> +        ASSERT((g_jscConfig.startOfStructureHeap & ~structureIDMask) == g_jscConfig.startOfStructureHeap);

nits:
- Should be RELEASE_ASSERT
- And let's also RELEASE_ASSERT that startOfStructureHeap isn't null.

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:95
> +            ASSERT(freeIndex <= m_usedBlocks.bitCount());

This code is also quite subtle. You grow the bit vector by "not finding a bit", and having find return bitCount(). Might be worth a comment.

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:102
> +        MarkedBlock* block = reinterpret_cast<MarkedBlock*>(g_jscConfig.startOfStructureHeap) + freeIndex * MarkedBlock::blockSize;

same nit from last patch: use uint8_t* here instead of MarkedBlocked*
Comment 7 Saam Barati 2022-02-13 11:56:25 PST
Comment on attachment 450407 [details]
Patch for landing

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

> Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:92
> +            Locker locker(m_lock);

Not sure we need a lock here, given the IsoMemoryAllocatorBase already locks. We could pass around a locker if we wanted to indicate this.