New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JSC] Add VectorTraits for WriteBarrier #2492
[JSC] Add VectorTraits for WriteBarrier #2492
Conversation
|
||
template<typename T> struct VectorTraits<JSC::WriteBarrier<T>> : public SimpleClassVectorTraits { | ||
static_assert(std::is_trivially_destructible<JSC::WriteBarrier<T>>::value); | ||
static const bool canInitializeWithMemset = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since canInitializeWithMemset
is already true
in the base class, I think we should omit this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Fixed.
template<> struct VectorTraits<JSC::WriteBarrier<JSC::Unknown>> : public SimpleClassVectorTraits { | ||
static_assert(std::is_trivially_destructible<JSC::WriteBarrier<JSC::Unknown>>::value); | ||
#if USE(JSVALUE64) | ||
// We can memset only in JSVALUE64 since empty value is zero. On the other hand, JSVALUE32_64's empty value is not zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is great but code should be #if !USE(JSVALUE64)
and only include setting to false
, rely on inheritance for the true case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, fixed.
static const bool canInitializeWithMemset = false; | ||
#endif | ||
static const bool canCopyWithMemcpy = true; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also set canCompareWithMemcmp
to true
? Also seems like operator==
for two WriteBarrier<Unknown>
should not decode the two values, just compare them still encoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rigt, changed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, canCompareWithMemcmp
was true since SimpleClassVectorTraits
is setting it to true :)
b96371f
to
61499f2
Compare
https://bugs.webkit.org/show_bug.cgi?id=196242 Reviewed by Darin Adler. WriteBarrier<> is one of the most frequently used class for Vector etc. in JSC. Let's add VectorTraits for that. * Source/JavaScriptCore/runtime/WriteBarrier.h: Canonical link: https://commits.webkit.org/252556@main
61499f2
to
1eb3c9f
Compare
Committed 252556@main (1eb3c9f): https://commits.webkit.org/252556@main Reviewed commits have been landed. Closing PR #2492 and removing active labels. |
|
||
template<typename T> struct VectorTraits<JSC::WriteBarrier<T>> : public SimpleClassVectorTraits { | ||
static_assert(std::is_trivially_destructible<JSC::WriteBarrier<T>>::value); | ||
static constexpr bool canCopyWithMemcpy = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Constellation Isn't this wrong? My understanding is that memcpy is free to use load/store instructions with fewer than 8 bytes, which would cause GC tearing. I know we do something special for some copies, what is the current state of that?
1eb3c9f