Changeset 250945 in webkit
- Timestamp:
- Oct 9, 2019 5:13:22 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r250943 r250945 1 2019-10-09 Daniel Bates <dabates@apple.com> 2 3 Add support for CompactPointerTuple<..., OptionSet<...>> 4 https://bugs.webkit.org/show_bug.cgi?id=201316 5 6 Reviewed by Yusuke Suzuki. 7 8 Support using an OptionSet<> for the byte value portion of a CompactPointerTuple so that 9 you can encode both a pointer and 8-bit bitmask in a type-safe way. Another benefit of 10 supporting OptionSet<> is that we have a LLDB pretty-printer for it so this makes it easy 11 to see the set flags in such a CompactPointerTuple. 12 13 * wtf/CompactPointerTuple.h: 14 1 15 2019-10-09 Russell Epstein <repstein@apple.com> 2 16 -
trunk/Source/WTF/wtf/CompactPointerTuple.h
r250943 r250945 1 1 /* 2 2 * Copyright (C) 2018 Yusuke Suzuki <utatane.tea@gmail.com>. 3 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 28 29 #include <type_traits> 30 #include <wtf/OptionSet.h> 29 31 #include <wtf/StdLibExtras.h> 30 32 31 33 namespace WTF { 34 35 template <typename T> 36 struct IsOptionSet : public std::integral_constant<bool, WTF::IsTemplate<std::decay_t<T>, OptionSet>::value> { }; 37 38 template<typename T> struct ByteValueTypeAdapter { 39 static constexpr uint8_t toByte(T value) { return value; } 40 static constexpr T fromByte(uint8_t value) { return static_cast<T>(value); } 41 }; 42 43 template<typename U> struct ByteValueTypeAdapter<OptionSet<U>> { 44 static constexpr uint8_t toByte(OptionSet<U> value) { return value.toRaw(); } 45 static constexpr OptionSet<U> fromByte(uint8_t value) { return OptionSet<U>::fromRaw(value); } 46 }; 32 47 33 48 // The goal of this class is folding a pointer and 1 byte value into 8 bytes in both 32bit and 64bit architectures. … … 35 50 // In 64bit, we use the upper 5 bits and lower 3 bits (zero due to alignment) since these bits are safe to use even 36 51 // with 5-level page tables where the effective pointer width is 57bits. 37 template<typename PointerType, typename Type >52 template<typename PointerType, typename Type, typename Adapter = ByteValueTypeAdapter<Type>> 38 53 class CompactPointerTuple final { 39 54 WTF_MAKE_FAST_ALLOCATED; … … 41 56 static_assert(sizeof(Type) == 1, ""); 42 57 static_assert(std::is_pointer<PointerType>::value, ""); 43 static_assert(std::is_integral<Type>::value || std::is_enum<Type>::value , "");58 static_assert(std::is_integral<Type>::value || std::is_enum<Type>::value || IsOptionSet<Type>::value, ""); 44 59 45 60 CompactPointerTuple() = default; … … 63 78 64 79 CompactPointerTuple(PointerType pointer, Type type) 65 : m_data (bitwise_cast<uint64_t>(pointer) | encodeType(static_cast<uint8_t>(type)))80 : m_data { bitwise_cast<uint64_t>(pointer) | encodeType(Adapter::toByte(type)) } 66 81 { 67 82 ASSERT((bitwise_cast<uint64_t>(pointer) & 0b111) == 0x0); … … 76 91 } 77 92 78 Type type() const { return static_cast<Type>(decodeType(m_data)); }93 Type type() const { return Adapter::fromByte(decodeType(m_data)); } 79 94 void setType(Type type) 80 95 { … … 99 114 private: 100 115 PointerType m_pointer { nullptr }; 101 Type m_type { 0};116 Type m_type { }; 102 117 #endif 103 118 }; -
trunk/Source/WebCore/ChangeLog
r250944 r250945 1 2019-10-09 Daniel Bates <dabates@apple.com> 2 3 Add support for CompactPointerTuple<..., OptionSet<...>> 4 https://bugs.webkit.org/show_bug.cgi?id=201316 5 6 Reviewed by Yusuke Suzuki. 7 8 Use the new CompactPointerTuple capability to replace CompactPointerTuple<RenderObject*, uint8_t> 9 with CompactPointerTuple<RenderObject*, OptionSet<ElementStyleFlag>> in Node.h. 10 11 * dom/Node.h: 12 (WebCore::Node::hasStyleFlag const): 13 (WebCore::Node::setStyleFlag): 14 (WebCore::Node::clearStyleFlags): 15 Update code now that we support CompactPointerTuple<..., OptionSet<...>>. 16 1 17 2019-10-09 John Wilander <wilander@apple.com> 2 18 -
trunk/Source/WebCore/dom/Node.h
r250943 r250945 37 37 #include <wtf/ListHashSet.h> 38 38 #include <wtf/MainThread.h> 39 #include <wtf/OptionSet.h> 39 40 #include <wtf/URLHash.h> 40 41 … … 616 617 }; 617 618 618 bool hasStyleFlag(ElementStyleFlag state) const { return m_rendererWithStyleFlags.type() & static_cast<uint8_t>(state); }619 void setStyleFlag(ElementStyleFlag state) { m_rendererWithStyleFlags.setType(m_rendererWithStyleFlags.type() | stat ic_cast<uint8_t>(state)); }620 void clearStyleFlags() { m_rendererWithStyleFlags.setType( 0); }619 bool hasStyleFlag(ElementStyleFlag state) const { return m_rendererWithStyleFlags.type().contains(state); } 620 void setStyleFlag(ElementStyleFlag state) { m_rendererWithStyleFlags.setType(m_rendererWithStyleFlags.type() | state); } 621 void clearStyleFlags() { m_rendererWithStyleFlags.setType({ }); } 621 622 622 623 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { } … … 676 677 Node* m_previous { nullptr }; 677 678 Node* m_next { nullptr }; 678 CompactPointerTuple<RenderObject*, uint8_t> m_rendererWithStyleFlags;679 CompactPointerTuple<RenderObject*, OptionSet<ElementStyleFlag>> m_rendererWithStyleFlags; 679 680 std::unique_ptr<NodeRareData, NodeRareDataDeleter> m_rareData; 680 681 }; -
trunk/Tools/ChangeLog
r250943 r250945 1 2019-10-09 Daniel Bates <dabates@apple.com> 2 3 Add support for CompactPointerTuple<..., OptionSet<...>> 4 https://bugs.webkit.org/show_bug.cgi?id=201316 5 6 Reviewed by Yusuke Suzuki. 7 8 Add a test to ensure we encode and decode a compact pointer tuple correctly when an uint8_t and 9 a OptionSet<> as the byte value portion of the tuple. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WTF/CompactPointerTuple.cpp: Added. 13 (TestWebKitAPI::TEST): 14 1 15 2019-10-09 Russell Epstein <repstein@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r250943 r250945 927 927 CE6E81A420A933D500E2C80F /* set-timeout-function.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE6E81A320A933B800E2C80F /* set-timeout-function.html */; }; 928 928 CE78705F2107AB980053AC67 /* MoveOnlyLifecycleLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE78705D2107AB8C0053AC67 /* MoveOnlyLifecycleLogger.cpp */; }; 929 CE9B07F2231889E300A09BC7 /* CompactPointerTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE9B07F1231889E300A09BC7 /* CompactPointerTuple.cpp */; }; 929 930 CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; }; 930 931 CEA7F57D2089624B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm in Sources */ = {isa = PBXBuildFile; fileRef = CEA7F57B20895F5B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm */; }; … … 2402 2403 CE78705C2107AB8C0053AC67 /* MoveOnlyLifecycleLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoveOnlyLifecycleLogger.h; sourceTree = "<group>"; }; 2403 2404 CE78705D2107AB8C0053AC67 /* MoveOnlyLifecycleLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MoveOnlyLifecycleLogger.cpp; sourceTree = "<group>"; }; 2405 CE9B07F1231889E300A09BC7 /* CompactPointerTuple.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompactPointerTuple.cpp; sourceTree = "<group>"; }; 2404 2406 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenAndCloseWindow.mm; sourceTree = "<group>"; }; 2405 2407 CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "open-and-close-window.html"; sourceTree = "<group>"; }; … … 3618 3620 E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */, 3619 3621 A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */, 3622 CE9B07F1231889E300A09BC7 /* CompactPointerTuple.cpp */, 3620 3623 0F30CB5B1FCE1792004B5323 /* ConcurrentPtrHashSet.cpp */, 3621 3624 0FEAE3671B7D19CB00CE17F2 /* Condition.cpp */, … … 4309 4312 7C83DE9C1D0A590C00FEBCF3 /* BloomFilter.cpp in Sources */, 4310 4313 7C83DEA01D0A590C00FEBCF3 /* CheckedArithmeticOperations.cpp in Sources */, 4314 CE9B07F2231889E300A09BC7 /* CompactPointerTuple.cpp in Sources */, 4311 4315 0F30CB5C1FCE1796004B5323 /* ConcurrentPtrHashSet.cpp in Sources */, 4312 4316 7C83DEC31D0A590C00FEBCF3 /* Condition.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.