/*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2019 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
*
*/
-#ifndef WTF_Vector_h
-#define WTF_Vector_h
+#pragma once
#include <initializer_list>
#include <limits>
extern "C" void __sanitizer_annotate_contiguous_container(const void* begin, const void* end, const void* old_mid, const void* new_mid);
#endif
+namespace JSC {
+class LLIntOffsetsExtractor;
+}
+
namespace WTF {
template <bool needsDestruction, typename T>
using Base::m_size;
private:
+ friend class JSC::LLIntOffsetsExtractor;
using Base::m_buffer;
using Base::m_capacity;
};
#if ASAN_ENABLED
// ASan needs the buffer to begin and end on 8-byte boundaries for annotations to work.
// FIXME: Add a redzone before the buffer to catch off by one accesses. We don't need a guard after, because the buffer is the last member variable.
- static const size_t asanInlineBufferAlignment = std::alignment_of<T>::value >= 8 ? std::alignment_of<T>::value : 8;
- static const size_t asanAdjustedInlineCapacity = ((sizeof(T) * inlineCapacity + 7) & ~7) / sizeof(T);
+ static constexpr size_t asanInlineBufferAlignment = std::alignment_of<T>::value >= 8 ? std::alignment_of<T>::value : 8;
+ static constexpr size_t asanAdjustedInlineCapacity = ((sizeof(T) * inlineCapacity + 7) & ~7) / sizeof(T);
typename std::aligned_storage<sizeof(T), asanInlineBufferAlignment>::type m_inlineBuffer[asanAdjustedInlineCapacity];
#else
typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_inlineBuffer[inlineCapacity];
private:
typedef VectorBuffer<T, inlineCapacity> Base;
typedef VectorTypeOperations<T> TypeOperations;
+ friend class JSC::LLIntOffsetsExtractor;
public:
typedef T ValueType;
void uncheckedAppend(ValueType&& value) { uncheckedAppend<ValueType>(std::forward<ValueType>(value)); }
template<typename U> void uncheckedAppend(U&&);
+ template<typename... Args> void uncheckedConstructAndAppend(Args&&...);
template<typename U> void append(const U*, size_t);
template<typename U, size_t otherCapacity> void appendVector(const Vector<U, otherCapacity>&);
template<typename U> void insert(size_t position, const U*, size_t);
template<typename U> void insert(size_t position, U&&);
- template<typename U, size_t c> void insertVector(size_t position, const Vector<U, c>&);
+ template<typename U, size_t c, typename OH> void insertVector(size_t position, const Vector<U, c, OH>&);
void remove(size_t position);
void remove(size_t position, size_t length);
}
template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
+template<typename... Args>
+ALWAYS_INLINE void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::uncheckedConstructAndAppend(Args&&... args)
+{
+ ASSERT(size() < capacity());
+
+ asanBufferSizeWillChangeTo(m_size + 1);
+
+ new (NotNull, end()) T(std::forward<Args>(args)...);
+ ++m_size;
+}
+
+template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
template<typename U, size_t otherCapacity>
inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::appendVector(const Vector<U, otherCapacity>& val)
{
}
template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
-template<typename U, size_t c>
-inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::insertVector(size_t position, const Vector<U, c>& val)
+template<typename U, size_t c, typename OH>
+inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::insertVector(size_t position, const Vector<U, c, OH>& val)
{
insert(position, val.begin(), val.size());
}
using WTF::copyToVectorOf;
using WTF::copyToVectorSpecialization;
using WTF::removeRepeatedElements;
-
-#endif // WTF_Vector_h