Bug 113662

Summary: Regions should be allocated from the same contiguous segment of virtual memory
Product: WebKit Reporter: Mark Hahnenberg <mhahnenberg>
Component: JavaScriptCoreAssignee: Mark Hahnenberg <mhahnenberg>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, ojan.autocc, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch fpizlo: review+, eflews.bot: commit-queue-

Description Mark Hahnenberg 2013-03-31 09:20:03 PDT
Instead of letting the OS spread our Regions all over the place, we should allocate them all within some range of each other. This change will open the door to some other optimizations, e.g. doing simple range checks for our write barriers and compressing JSCell pointers to 32-bits.

We can do this by having a SuperRegion for each BlockAllocator (i.e. per-VM) which subclasses MetaAllocator along the lines of the FixedVMPoolExecutableAllocator we use for the JIT.
Comment 1 Mark Hahnenberg 2013-03-31 20:49:43 PDT
Created attachment 195921 [details]
Patch
Comment 2 Mark Hahnenberg 2013-03-31 20:51:47 PDT
(In reply to comment #1)
> Created an attachment (id=195921) [details]
> Patch

This patch is actually a slight speedup on some benchmarks.
Comment 3 Mark Hahnenberg 2013-03-31 21:13:39 PDT
Created attachment 195922 [details]
Patch
Comment 4 Mark Hahnenberg 2013-03-31 21:14:28 PDT
(In reply to comment #3)
> Created an attachment (id=195922) [details]
> Patch

Had to add more ifdefs.
Comment 5 Filip Pizlo 2013-03-31 21:16:59 PDT
Comment on attachment 195922 [details]
Patch

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

Other than the one comment, looks good!

> Source/WTF/wtf/MetaAllocator.h:67
> +    WTF_EXPORT_PRIVATE MetaAllocator(size_t allocationGranule, size_t pageSize = 0);

Why not say pageSize = WTF::pageSize() and then get rid of the pageSize initialization conditional inside MetaAllocator::MetaAllocator?
Comment 6 Mark Hahnenberg 2013-03-31 21:19:05 PDT
(In reply to comment #5)
> (From update of attachment 195922 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=195922&action=review
> 
> Other than the one comment, looks good!
> 
> > Source/WTF/wtf/MetaAllocator.h:67
> > +    WTF_EXPORT_PRIVATE MetaAllocator(size_t allocationGranule, size_t pageSize = 0);
> 
> Why not say pageSize = WTF::pageSize() and then get rid of the pageSize initialization conditional inside MetaAllocator::MetaAllocator?

Good call.
Comment 7 EFL EWS Bot 2013-03-31 21:57:45 PDT
Comment on attachment 195922 [details]
Patch

Attachment 195922 [details] did not pass efl-ews (efl):
Output: http://webkit-commit-queue.appspot.com/results/17392062
Comment 8 Mark Hahnenberg 2013-04-01 08:22:11 PDT
Committed r147324: <http://trac.webkit.org/changeset/147324>
Comment 10 Geoffrey Garen 2013-04-01 11:45:58 PDT
Comment on attachment 195922 [details]
Patch

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

> Source/JavaScriptCore/heap/SuperRegion.cpp:34
> +const size_t SuperRegion::s_fixedHeapMemoryPoolSize = 4 * 1024 * MB;

This seems a bit excessive, compared to most heaps. If the only cost of going over is a bit of performance, maybe we should make this smaller, like 1GB or 2GB.