diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/utils | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-c30a6232df03e1efbd9f3b226777b07e087a1122.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')
-rw-r--r-- | chromium/v8/src/utils/ostreams.cc | 4 | ||||
-rw-r--r-- | chromium/v8/src/utils/ostreams.h | 9 | ||||
-rw-r--r-- | chromium/v8/src/utils/pointer-with-payload.h | 16 | ||||
-rw-r--r-- | chromium/v8/src/utils/vector.h | 29 |
4 files changed, 50 insertions, 8 deletions
diff --git a/chromium/v8/src/utils/ostreams.cc b/chromium/v8/src/utils/ostreams.cc index c43f01be563..b58f51159b8 100644 --- a/chromium/v8/src/utils/ostreams.cc +++ b/chromium/v8/src/utils/ostreams.cc @@ -6,6 +6,7 @@ #include <cinttypes> +#include "src/base/lazy-instance.h" #include "src/objects/objects.h" #include "src/objects/string.h" @@ -114,6 +115,9 @@ std::streamsize AndroidLogStream::xsputn(const char* s, std::streamsize n) { } #endif +DEFINE_LAZY_LEAKY_OBJECT_GETTER(base::RecursiveMutex, + StdoutStream::GetStdoutMutex) + namespace { // Locale-independent predicates. diff --git a/chromium/v8/src/utils/ostreams.h b/chromium/v8/src/utils/ostreams.h index 118dfc282af..899c85fd94c 100644 --- a/chromium/v8/src/utils/ostreams.h +++ b/chromium/v8/src/utils/ostreams.h @@ -13,6 +13,7 @@ #include "include/v8config.h" #include "src/base/macros.h" +#include "src/base/platform/mutex.h" #include "src/common/globals.h" namespace v8 { @@ -80,12 +81,20 @@ class StdoutStream : public std::ostream { StdoutStream() : std::ostream(&stream_) {} private: + static V8_EXPORT_PRIVATE base::RecursiveMutex* GetStdoutMutex(); + AndroidLogStream stream_; + base::RecursiveMutexGuard mutex_guard_{GetStdoutMutex()}; }; #else class StdoutStream : public OFStream { public: StdoutStream() : OFStream(stdout) {} + + private: + static V8_EXPORT_PRIVATE base::RecursiveMutex* GetStdoutMutex(); + + base::RecursiveMutexGuard mutex_guard_{GetStdoutMutex()}; }; #endif 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) { diff --git a/chromium/v8/src/utils/vector.h b/chromium/v8/src/utils/vector.h index 38202d804fd..50622174844 100644 --- a/chromium/v8/src/utils/vector.h +++ b/chromium/v8/src/utils/vector.h @@ -28,9 +28,7 @@ class Vector { constexpr Vector() : start_(nullptr), length_(0) {} constexpr Vector(T* data, size_t length) : start_(data), length_(length) { -#if V8_HAS_CXX14_CONSTEXPR - DCHECK(length == 0 || data != nullptr); -#endif + CONSTEXPR_DCHECK(length == 0 || data != nullptr); } static Vector<T> New(size_t length) { @@ -115,9 +113,7 @@ class Vector { } // Implicit conversion from Vector<T> to Vector<const T>. - inline operator Vector<const T>() const { - return Vector<const T>::cast(*this); - } + operator Vector<const T>() const { return {start_, length_}; } template <typename S> static Vector<T> cast(Vector<S> input) { @@ -163,6 +159,7 @@ class OwnedVector { : data_(std::move(data)), length_(length) { DCHECK_IMPLIES(length_ > 0, data_ != nullptr); } + // Implicit conversion from {OwnedVector<U>} to {OwnedVector<T>}, instantiable // if {std::unique_ptr<U>} can be converted to {std::unique_ptr<T>}. // Can be used to convert {OwnedVector<T>} to {OwnedVector<const T>}. @@ -207,11 +204,20 @@ class OwnedVector { } // Allocates a new vector of the specified size via the default allocator. + // Elements in the new vector are value-initialized. static OwnedVector<T> New(size_t size) { if (size == 0) return {}; return OwnedVector<T>(std::make_unique<T[]>(size), size); } + // Allocates a new vector of the specified size via the default allocator. + // Elements in the new vector are default-initialized. + static OwnedVector<T> NewForOverwrite(size_t size) { + if (size == 0) return {}; + // TODO(v8): Use {std::make_unique_for_overwrite} once we allow C++20. + return OwnedVector<T>(std::unique_ptr<T[]>(new T[size]), size); + } + // Allocates a new vector containing the specified collection of values. // {Iterator} is the common type of {std::begin} and {std::end} called on a // {const U&}. This function is only instantiable if that type exists. @@ -222,7 +228,8 @@ class OwnedVector { Iterator begin = std::begin(collection); Iterator end = std::end(collection); using non_const_t = typename std::remove_const<T>::type; - auto vec = OwnedVector<non_const_t>::New(std::distance(begin, end)); + auto vec = + OwnedVector<non_const_t>::NewForOverwrite(std::distance(begin, end)); std::copy(begin, end, vec.start()); return vec; } @@ -289,6 +296,14 @@ inline constexpr auto VectorOf(Container&& c) return VectorOf(c.data(), c.size()); } +// Construct a Vector from an initializer list. The vector can obviously only be +// used as long as the initializer list is live. Valid uses include direct use +// in parameter lists: F(VectorOf({1, 2, 3})); +template <typename T> +inline constexpr Vector<const T> VectorOf(std::initializer_list<T> list) { + return VectorOf(list.begin(), list.size()); +} + template <typename T, size_t kSize> class EmbeddedVector : public Vector<T> { public: |