summaryrefslogtreecommitdiff
path: root/chromium/v8/src/utils/pointer-with-payload.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/utils/pointer-with-payload.h
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/utils/pointer-with-payload.h')
-rw-r--r--chromium/v8/src/utils/pointer-with-payload.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/chromium/v8/src/utils/pointer-with-payload.h b/chromium/v8/src/utils/pointer-with-payload.h
index 3dbd6acac05..6200f410775 100644
--- a/chromium/v8/src/utils/pointer-with-payload.h
+++ b/chromium/v8/src/utils/pointer-with-payload.h
@@ -20,6 +20,12 @@ struct PointerWithPayloadTraits {
alignof(PointerType) >= 8 ? 3 : alignof(PointerType) >= 4 ? 2 : 1;
};
+// Assume void* has the same payloads as void**, under the assumption that it's
+// used for classes that contain at least one pointer.
+template <>
+struct PointerWithPayloadTraits<void> : public PointerWithPayloadTraits<void*> {
+};
+
// PointerWithPayload combines a PointerType* an a small PayloadType into
// one. The bits of the storage type get packed into the lower bits of the
// pointer that are free due to alignment. The user needs to specify how many
@@ -42,7 +48,8 @@ class PointerWithPayload {
"Ptr does not have sufficient alignment for the selected amount of "
"storage bits.");
- static constexpr uintptr_t kPayloadMask = (uintptr_t{1} << kAvailBits) - 1;
+ static constexpr uintptr_t kPayloadMask =
+ (uintptr_t{1} << NumPayloadBits) - 1;
static constexpr uintptr_t kPointerMask = ~kPayloadMask;
public:
@@ -68,6 +75,13 @@ class PointerWithPayload {
return reinterpret_cast<PointerType*>(pointer_ & kPointerMask);
}
+ // An optimized version of GetPointer for when we know the payload value.
+ V8_INLINE PointerType* GetPointerWithKnownPayload(PayloadType payload) const {
+ DCHECK_EQ(GetPayload(), payload);
+ return reinterpret_cast<PointerType*>(pointer_ -
+ static_cast<uintptr_t>(payload));
+ }
+
V8_INLINE PointerType* operator->() const { return GetPointer(); }
V8_INLINE void update(PointerType* new_pointer, PayloadType new_payload) {