WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
180916
[JSC] Use IsoSpace for JSWeakMap and JSWeakSet to use finalizeUnconditionally
https://bugs.webkit.org/show_bug.cgi?id=180916
Summary
[JSC] Use IsoSpace for JSWeakMap and JSWeakSet to use finalizeUnconditionally
Yusuke Suzuki
Reported
2017-12-17 09:49:47 PST
[JSC] Use IsoSpace for JSWeakMap and JSWeakSet to use finalizeUnconditionally
Attachments
Patch
(11.65 KB, patch)
2017-12-17 09:56 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(23.44 KB, patch)
2017-12-17 11:56 PST
,
Yusuke Suzuki
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2017-12-17 09:56:25 PST
Created
attachment 329604
[details]
Patch
Yusuke Suzuki
Comment 2
2017-12-17 11:56:47 PST
Created
attachment 329615
[details]
Patch
Darin Adler
Comment 3
2017-12-17 12:17:52 PST
Comment on
attachment 329615
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=329615&action=review
I see the performance benefit of this. What is the performance cost? Will this use more memory or reduce locality of reference in a way that will affect speed of execution? Is there a security benefit or a security cost?
> Source/JavaScriptCore/ChangeLog:12 > + Currently we still have WeakReferenceHaverster in JSWeakMap and JSWeakSet. We should
typo: "harvester" rather than "haverster"
> Source/JavaScriptCore/runtime/WeakMapImplInlines.h:33 > +template <typename WeakMapBucket>
No space after "template" to match the style we prefer elsewhere.
> Source/JavaScriptCore/runtime/WeakMapImplInlines.h:34 > +inline void WeakMapImpl<WeakMapBucket>::finalizeUnconditionally(VM&)
Do we really need to mark this inline? Since it’s a function template we don’t need it for correctness, so I presume it’s needed here only because it actually convinces some particular compiler to do the inlining.
Filip Pizlo
Comment 4
2017-12-17 13:37:47 PST
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 329615
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=329615&action=review
> > I see the performance benefit of this. > > What is the performance cost? Will this use more memory or reduce locality > of reference in a way that will affect speed of execution?
I previously found that if you have to iterate a bag of objects during GC then it’s up to 5x faster to have those objects allocated next to each other. This was an extreme case that happened in Dromaeo. Most other measurements show it to be neutral.
> > Is there a security benefit or a security cost?
Security benefit. Allocating objects in isoheaps neutralizes their value for UAF-based RCE attacks.
> > > Source/JavaScriptCore/ChangeLog:12 > > + Currently we still have WeakReferenceHaverster in JSWeakMap and JSWeakSet. We should > > typo: "harvester" rather than "haverster" > > > Source/JavaScriptCore/runtime/WeakMapImplInlines.h:33 > > +template <typename WeakMapBucket> > > No space after "template" to match the style we prefer elsewhere. > > > Source/JavaScriptCore/runtime/WeakMapImplInlines.h:34 > > +inline void WeakMapImpl<WeakMapBucket>::finalizeUnconditionally(VM&) > > Do we really need to mark this inline? Since it’s a function template we > don’t need it for correctness, so I presume it’s needed here only because it > actually convinces some particular compiler to do the inlining.
We put these in the same translation unit as their caller by having them be in an Inlines easer included from Heap.cpp. It would be ugly to define this knowing heap.cpp. I don’t know how profitable inlining is here, but we usually err on the side of giving the compiler an option to do it for GC critical paths.
Darin Adler
Comment 5
2017-12-17 19:44:54 PST
(In reply to Filip Pizlo from
comment #4
)
> (In reply to Darin Adler from
comment #3
) > > Do we really need to mark this inline? Since it’s a function template we > > don’t need it for correctness, so I presume it’s needed here only because it > > actually convinces some particular compiler to do the inlining. > > We put these in the same translation unit as their caller by having them be > in an Inlines easer included from Heap.cpp. It would be ugly to define this > knowing heap.cpp. I don’t know how profitable inlining is here, but we > usually err on the side of giving the compiler an option to do it for GC > critical paths.
My proposal is: leave this in a WeakMapImplInlines.h header and let the compiler inline it when compiling Heap.cpp. But do not explicitly mark it with the inline keyword because it’s a template and so we don’t need to. I’m not sure my proposal is right, but it doesn’t necessarily interfere with anything you mentioned above.
Filip Pizlo
Comment 6
2017-12-17 19:56:37 PST
(In reply to Darin Adler from
comment #5
)
> (In reply to Filip Pizlo from
comment #4
) > > (In reply to Darin Adler from
comment #3
) > > > Do we really need to mark this inline? Since it’s a function template we > > > don’t need it for correctness, so I presume it’s needed here only because it > > > actually convinces some particular compiler to do the inlining. > > > > We put these in the same translation unit as their caller by having them be > > in an Inlines easer included from Heap.cpp. It would be ugly to define this > > knowing heap.cpp. I don’t know how profitable inlining is here, but we > > usually err on the side of giving the compiler an option to do it for GC > > critical paths. > > My proposal is: leave this in a WeakMapImplInlines.h header and let the > compiler inline it when compiling Heap.cpp. But do not explicitly mark it > with the inline keyword because it’s a template and so we don’t need to. > > I’m not sure my proposal is right, but it doesn’t necessarily interfere with > anything you mentioned above.
Oh! Yes, you're right. I missed the part about it being a template.
Yusuke Suzuki
Comment 7
2017-12-17 21:21:37 PST
Comment on
attachment 329615
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=329615&action=review
Thanks!
>>> Source/JavaScriptCore/ChangeLog:12 >>> + Currently we still have WeakReferenceHaverster in JSWeakMap and JSWeakSet. We should >> >> typo: "harvester" rather than "haverster" > > We put these in the same translation unit as their caller by having them be in an Inlines easer included from Heap.cpp. It would be ugly to define this knowing heap.cpp. I don’t know how profitable inlining is here, but we usually err on the side of giving the compiler an option to do it for GC critical paths.
Oops, fixed.
>> Source/JavaScriptCore/runtime/WeakMapImplInlines.h:33 >> +template <typename WeakMapBucket> > > No space after "template" to match the style we prefer elsewhere.
Fixed.
>> Source/JavaScriptCore/runtime/WeakMapImplInlines.h:34 >> +inline void WeakMapImpl<WeakMapBucket>::finalizeUnconditionally(VM&) > > Do we really need to mark this inline? Since it’s a function template we don’t need it for correctness, so I presume it’s needed here only because it actually convinces some particular compiler to do the inlining.
OK, drop this "inline" keyword, and let compiler decide inlining.
Yusuke Suzuki
Comment 8
2017-12-17 21:24:12 PST
Committed
r226017
: <
https://trac.webkit.org/changeset/226017
>
Radar WebKit Bug Importer
Comment 9
2017-12-17 21:27:14 PST
<
rdar://problem/36099376
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug