Bug 204555 - [JSC] Introduce IsoHeapCellType
Summary: [JSC] Introduce IsoHeapCellType
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: 2019-11-24 04:21 PST by Yusuke Suzuki
Modified: 2019-11-25 00:30 PST (History)
11 users (show)

See Also:


Attachments
Patch (43.26 KB, patch)
2019-11-24 04:24 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (46.88 KB, patch)
2019-11-24 04:30 PST, Yusuke Suzuki
mark.lam: 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 2019-11-24 04:21:30 PST
[JSC] Introduce IsoHeapCellType
Comment 1 Yusuke Suzuki 2019-11-24 04:24:26 PST
Created attachment 384251 [details]
Patch
Comment 2 Yusuke Suzuki 2019-11-24 04:30:19 PST
Created attachment 384252 [details]
Patch
Comment 3 Mark Lam 2019-11-24 09:49:59 PST
Comment on attachment 384252 [details]
Patch

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

Nice work.  r=me with suggestions.

> Source/JavaScriptCore/heap/IsoHeapCellType.h:35
> +class IsoHeapCellType final : public HeapCellType {
> +public:
> +    IsoHeapCellType()
> +        : HeapCellType(CellAttributes(CellType::needsDestruction ? NeedsDestruction : DoesNotNeedDestruction, HeapCell::JSCell))

If I understand you correctly, you intend to only use IsoHeapCellType for destructible types, yes?  Why not:
1. name it IsoHeapDestructibleCellType?
2. Always pass NeedsDestruction down to HeapCellType constructor here?
3. static_assert(CellType::needsDestruction)?

> Source/JavaScriptCore/heap/IsoHeapCellType.h:53
> +        DestroyFunc()(vm, cell);

Why not just go direct to CellType::destroy(cell) here?
Comment 4 Yusuke Suzuki 2019-11-24 14:37:37 PST
Comment on attachment 384252 [details]
Patch

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

Thanks!

>> Source/JavaScriptCore/heap/IsoHeapCellType.h:35
>> +        : HeapCellType(CellAttributes(CellType::needsDestruction ? NeedsDestruction : DoesNotNeedDestruction, HeapCell::JSCell))
> 
> If I understand you correctly, you intend to only use IsoHeapCellType for destructible types, yes?  Why not:
> 1. name it IsoHeapDestructibleCellType?
> 2. Always pass NeedsDestruction down to HeapCellType constructor here?
> 3. static_assert(CellType::needsDestruction)?

Currently, I'm considering using this for all IsoSubspace types (or, merging it into IsoSubspace if possible). So for now, I would like to make it usable for non destructible cell type too.

>> Source/JavaScriptCore/heap/IsoHeapCellType.h:53
>> +        DestroyFunc()(vm, cell);
> 
> Why not just go direct to CellType::destroy(cell) here?

It is OK too. Changed.
Comment 5 Yusuke Suzuki 2019-11-24 14:39:15 PST
Committed r252843: <https://trac.webkit.org/changeset/252843>
Comment 6 Radar WebKit Bug Importer 2019-11-24 14:40:19 PST
<rdar://problem/57461757>
Comment 7 Mark Lam 2019-11-24 15:09:42 PST
Comment on attachment 384252 [details]
Patch

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

>>> Source/JavaScriptCore/heap/IsoHeapCellType.h:35
>>> +        : HeapCellType(CellAttributes(CellType::needsDestruction ? NeedsDestruction : DoesNotNeedDestruction, HeapCell::JSCell))
>> 
>> If I understand you correctly, you intend to only use IsoHeapCellType for destructible types, yes?  Why not:
>> 1. name it IsoHeapDestructibleCellType?
>> 2. Always pass NeedsDestruction down to HeapCellType constructor here?
>> 3. static_assert(CellType::needsDestruction)?
> 
> Currently, I'm considering using this for all IsoSubspace types (or, merging it into IsoSubspace if possible). So for now, I would like to make it usable for non destructible cell type too.

How is it possible to use this class for non-destructible cell types too given that instantiation of this class requires that the underlying CellType has a destroy() function?  Or are you proposing to add no-op destroy() functions to all non-destructible cell types?
Comment 8 Yusuke Suzuki 2019-11-25 00:30:33 PST
Comment on attachment 384252 [details]
Patch

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

>>>> Source/JavaScriptCore/heap/IsoHeapCellType.h:35
>>>> +        : HeapCellType(CellAttributes(CellType::needsDestruction ? NeedsDestruction : DoesNotNeedDestruction, HeapCell::JSCell))
>>> 
>>> If I understand you correctly, you intend to only use IsoHeapCellType for destructible types, yes?  Why not:
>>> 1. name it IsoHeapDestructibleCellType?
>>> 2. Always pass NeedsDestruction down to HeapCellType constructor here?
>>> 3. static_assert(CellType::needsDestruction)?
>> 
>> Currently, I'm considering using this for all IsoSubspace types (or, merging it into IsoSubspace if possible). So for now, I would like to make it usable for non destructible cell type too.
> 
> How is it possible to use this class for non-destructible cell types too given that instantiation of this class requires that the underlying CellType has a destroy() function?  Or are you proposing to add no-op destroy() functions to all non-destructible cell types?

JSCell class has destroy() function, which has RELEASE_ASSERT. So instantiating this works. And it is not called since DoesNotNeedDestruction is specified. So, IsoHeapCellType<NonDestructibleCell> just works.