Bug 189156

Summary: [JSC] Clean up StructureStubClearingWatchpoint
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch saam: review+

Description Yusuke Suzuki 2018-08-30 09:02:32 PDT
[JSC] Clean up StructureStubClearingWatchpoint
Comment 1 Yusuke Suzuki 2018-08-30 09:03:52 PDT
Created attachment 348502 [details]
Patch
Comment 2 Saam Barati 2018-08-30 13:23:57 PDT
Comment on attachment 348502 [details]
Patch

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

> Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h:-96
> -    std::unique_ptr<StructureStubClearingWatchpoint> m_head;

Was there a reason for the old code?
Comment 3 Yusuke Suzuki 2018-08-31 02:21:29 PDT
Comment on attachment 348502 [details]
Patch

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

>> Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h:-96
>> -    std::unique_ptr<StructureStubClearingWatchpoint> m_head;
> 
> Was there a reason for the old code?

I can't see any reason. Vector<StructureStubClearingWatchpoint> is bad since each StructureStubClearingWatchpoint address can be changed. But Vector<std::unique_ptr<StructureStubClearingWatchpoint>> is enough.
Comment 4 Saam Barati 2018-08-31 11:44:48 PDT
Comment on attachment 348502 [details]
Patch

Maybe the linked list uses less memory on average for common programs?
Comment 5 Yusuke Suzuki 2018-08-31 23:16:23 PDT
(In reply to Saam Barati from comment #4)
> Comment on attachment 348502 [details]
> Patch
> 
> Maybe the linked list uses less memory on average for common programs?

In the Vector<> case, we can drop a link in StructureStubClearingWatchpoint instead of allocating storage for Vector.
The memory consumption is so-so, larger in Vector case due to unused memory allocation for storages, or larger in linked-list case due to the representation of the enlarged objects in bmalloc (it depends on whether the given object size would fit to the bmalloc's segregated heap).
We can use Bag<> here, it does not change memory usage. Changed.
Comment 6 Yusuke Suzuki 2018-08-31 23:19:50 PDT
(In reply to Yusuke Suzuki from comment #5)
> (In reply to Saam Barati from comment #4)
> > Comment on attachment 348502 [details]
> > Patch
> > 
> > Maybe the linked list uses less memory on average for common programs?
> 
> In the Vector<> case, we can drop a link in StructureStubClearingWatchpoint
> instead of allocating storage for Vector.
> The memory consumption is so-so, larger in Vector case due to unused memory
> allocation for storages, or larger in linked-list case due to the
> representation of the enlarged objects in bmalloc (it depends on whether the
> given object size would fit to the bmalloc's segregated heap).
> We can use Bag<> here, it does not change memory usage. Changed.

If allocations of this watchpoint in this vector/bag is so many, SegmentedVector<> can improve memory usage more. In the meantime, I'll use bag.
Comment 7 Yusuke Suzuki 2018-08-31 23:20:12 PDT
Created attachment 348708 [details]
Patch
Comment 8 Yusuke Suzuki 2018-09-06 12:00:47 PDT
Ping?
Comment 9 Saam Barati 2018-09-06 12:50:21 PDT
Comment on attachment 348708 [details]
Patch

r=me
Comment 10 Yusuke Suzuki 2018-09-06 21:23:55 PDT
(In reply to Saam Barati from comment #9)
> Comment on attachment 348708 [details]
> Patch
> 
> r=me

Thanks!
Comment 11 Yusuke Suzuki 2018-09-06 21:24:24 PDT
Committed r235776: <https://trac.webkit.org/changeset/235776>
Comment 12 Radar WebKit Bug Importer 2018-09-06 21:25:32 PDT
<rdar://problem/44211170>