Bug 201316

Summary: Add support for CompactPointerTuple<..., OptionSet<...>>
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Web Template FrameworkAssignee: Daniel Bates <dbates>
Status: REOPENED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, esprehn+autocc, ews-watchlist, jbedard, kangil.han, repstein, sam, tsavell, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch and test
none
Patch and test
none
Patch and test
none
Patch and test
none
Patch
none
Patch
none
Patch
none
Patch
none
Updated patch
none
To land
none
Take 2: To Land none

Daniel Bates
Reported 2019-08-29 16:00:06 PDT
Came across code in Node.h <https://trac.webkit.org/browser/trunk/Source/WebCore/dom/Node.h?rev=249287#L619> that uses CompactPointerTuple to store a bitmask and does raw bitmask manipulation. We have a type safe convenience class called OptionSet<> that represents a bitmask that can abstract such operations away plus it is pretty printable. We should support CompactPointerTuple<..., OptionSet<...>>.
Attachments
Patch and test (11.14 KB, patch)
2019-08-29 16:10 PDT, Daniel Bates
no flags
Patch and test (11.14 KB, patch)
2019-08-29 16:14 PDT, Daniel Bates
no flags
Patch and test (14.21 KB, patch)
2019-08-29 17:35 PDT, Daniel Bates
no flags
Patch and test (14.22 KB, patch)
2019-08-30 11:12 PDT, Daniel Bates
no flags
Patch (14.25 KB, patch)
2019-09-03 16:15 PDT, Daniel Bates
no flags
Patch (15.70 KB, patch)
2019-09-09 12:03 PDT, Daniel Bates
no flags
Patch (14.33 KB, patch)
2019-09-13 11:55 PDT, Daniel Bates
no flags
Patch (15.76 KB, patch)
2019-09-13 11:57 PDT, Daniel Bates
no flags
Updated patch (14.30 KB, patch)
2019-10-09 10:30 PDT, Daniel Bates
no flags
To land (14.26 KB, patch)
2019-10-09 14:01 PDT, Daniel Bates
no flags
Take 2: To Land (14.33 KB, patch)
2019-10-09 17:12 PDT, Daniel Bates
no flags
Daniel Bates
Comment 1 2019-08-29 16:10:03 PDT
Created attachment 377647 [details] Patch and test
Daniel Bates
Comment 2 2019-08-29 16:11:22 PDT
Comment on attachment 377647 [details] Patch and test View in context: https://bugs.webkit.org/attachment.cgi?id=377647&action=review > Source/WTF/wtf/CompactPointerTuple.h:71 > + static constexpr uint8_t toRaw(T value) { return value; } > + static constexpr T fromRaw(uint8_t value) { return static_cast<T>(value); } Just had a thought, maybe toByte() and fromByte() would be better names. Thoughts?
Daniel Bates
Comment 3 2019-08-29 16:14:21 PDT
Created attachment 377648 [details] Patch and test
Daniel Bates
Comment 4 2019-08-29 16:21:35 PDT
Another thought.... should update code to use std::byte.
Daniel Bates
Comment 5 2019-08-29 16:24:11 PDT
(In reply to Daniel Bates from comment #4) > Another thought.... should update code to use std::byte. Not in this bug though assuming it is even feasible.
Sam Weinig
Comment 6 2019-08-29 17:20:06 PDT
Comment on attachment 377648 [details] Patch and test View in context: https://bugs.webkit.org/attachment.cgi?id=377648&action=review > Tools/ChangeLog:11 > + * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Did you forget to svn add the new test?
Daniel Bates
Comment 7 2019-08-29 17:31:38 PDT
(In reply to Sam Weinig from comment #6) > Comment on attachment 377648 [details] > Patch and test > > View in context: > https://bugs.webkit.org/attachment.cgi?id=377648&action=review > > > Tools/ChangeLog:11 > > + * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: > > Did you forget to svn add the new test? Yep
Daniel Bates
Comment 8 2019-08-29 17:35:16 PDT
Created attachment 377659 [details] Patch and test
Daniel Bates
Comment 9 2019-08-29 17:38:06 PDT
Could make tests more comprehensive. Anyway this is a start as no tests for CompactPointerTuple were originally added
Daniel Bates
Comment 10 2019-08-30 11:12:14 PDT
Created attachment 377734 [details] Patch and test
Daniel Bates
Comment 11 2019-09-03 16:15:49 PDT
Daniel Bates
Comment 12 2019-09-09 12:03:51 PDT
Daniel Bates
Comment 13 2019-09-09 12:07:04 PDT
I didn't specialize std::is_integral because of: [[ None of the templates defined in <type_traits> may be specialized for a program-defined type, except for std::common_type. This includes the type traits and the class template std::integral_constant. ]] <https://unixpapa.com/js/testkey.html>
Daniel Bates
Comment 14 2019-09-09 12:07:20 PDT
(In reply to Daniel Bates from comment #13) > I didn't specialize std::is_integral because of: > > [[ > None of the templates defined in <type_traits> may be specialized for a > program-defined type, except for std::common_type. This includes the type > traits and the class template std::integral_constant. > ]] > <https://unixpapa.com/js/testkey.html> * <https://en.cppreference.com/w/cpp/language/extending_std>
Daniel Bates
Comment 15 2019-09-13 11:55:50 PDT
Daniel Bates
Comment 16 2019-09-13 11:57:48 PDT
Yusuke Suzuki
Comment 17 2019-09-25 13:32:31 PDT
Comment on attachment 378741 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378741&action=review r=me with comment. > Source/WTF/wtf/CompactPointerTuple.h:77 > + template<typename T> struct ByteValueTypeAdapter { > + static constexpr uint8_t toByte(T value) { return value; } > + static constexpr T fromByte(uint8_t value) { return static_cast<T>(value); } > + }; > + > + template<typename U> struct ByteValueTypeAdapter<OptionSet<U>> { > + static constexpr uint8_t toByte(OptionSet<U> value) { return value.toRaw(); } > + static constexpr OptionSet<U> fromByte(uint8_t value) { return OptionSet<U>::fromRaw(value); } > + }; How about taking this as a template parameter of `CompactPointerTuple`? Like, template<typename PointerType, typename Type, typename Adaptor = ByteValueTypeAdapter<Type>> class CompactPointerTuple;
Daniel Bates
Comment 18 2019-09-25 13:35:10 PDT
Comment on attachment 378741 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378741&action=review >> Source/WTF/wtf/CompactPointerTuple.h:77 >> + }; > > How about taking this as a template parameter of `CompactPointerTuple`? Like, > > template<typename PointerType, typename Type, typename Adaptor = ByteValueTypeAdapter<Type>> > class CompactPointerTuple; I can do this. Only reason not to is to avoid exposing ByteValueTypeAdapter in the WTF namespace....
Daniel Bates
Comment 19 2019-09-25 13:36:29 PDT
Comment on attachment 378741 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378741&action=review >>> Source/WTF/wtf/CompactPointerTuple.h:77 >>> + }; >> >> How about taking this as a template parameter of `CompactPointerTuple`? Like, >> >> template<typename PointerType, typename Type, typename Adaptor = ByteValueTypeAdapter<Type>> >> class CompactPointerTuple; > > I can do this. Only reason not to is to avoid exposing ByteValueTypeAdapter in the WTF namespace.... Haha, I was trying to avoid exposing this struct, but accidentally put in public section. So, your suggestion is no different except for qualification.
Daniel Bates
Comment 20 2019-10-09 10:30:03 PDT
Created attachment 380541 [details] Updated patch
Daniel Bates
Comment 21 2019-10-09 14:01:25 PDT
Daniel Bates
Comment 22 2019-10-09 14:03:01 PDT
Radar WebKit Bug Importer
Comment 23 2019-10-09 14:03:17 PDT
Russell Epstein
Comment 24 2019-10-09 16:50:23 PDT
Reverted r250930 for reason: Broke watchOS Builds Committed r250943: <https://trac.webkit.org/changeset/250943>
Daniel Bates
Comment 25 2019-10-09 17:12:26 PDT
Created attachment 380589 [details] Take 2: To Land
Daniel Bates
Comment 26 2019-10-09 17:13:30 PDT
Truitt Savell
Comment 27 2019-10-10 07:55:52 PDT
It looks like this change, as well as the previous one that was rolled out, has broken 18 API tests on Debug for Mac and iOS. Build: https://build.webkit.org/builders/Apple%20Mojave%20Debug%20WK1%20%28Tests%29/builds/6157 They are crashing with this: ASSERTION FAILED: Enumerator is not a positive power of two. hasOneBitSet(static_cast<StorageType>(option)) /Volumes/Data/slave/mojave-debug/build
Jonathan Bedard
Comment 28 2019-10-11 07:30:25 PDT
Reverted r250945 for reason: Broke 18 Debug API tests Committed r251008: <https://trac.webkit.org/changeset/251008>
Note You need to log in before you can comment on or make changes to this bug.