summaryrefslogtreecommitdiff
path: root/deps/v8/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/utils')
-rw-r--r--deps/v8/src/utils/OWNERS2
-rw-r--r--deps/v8/src/utils/allocation.cc19
-rw-r--r--deps/v8/src/utils/allocation.h9
-rw-r--r--deps/v8/src/utils/utils.h23
4 files changed, 23 insertions, 30 deletions
diff --git a/deps/v8/src/utils/OWNERS b/deps/v8/src/utils/OWNERS
index 3f9de7e204..4750620072 100644
--- a/deps/v8/src/utils/OWNERS
+++ b/deps/v8/src/utils/OWNERS
@@ -1,3 +1,3 @@
-file://COMMON_OWNERS
+file:../../COMMON_OWNERS
# COMPONENT: Blink>JavaScript
diff --git a/deps/v8/src/utils/allocation.cc b/deps/v8/src/utils/allocation.cc
index af32e90088..f44b3c42ea 100644
--- a/deps/v8/src/utils/allocation.cc
+++ b/deps/v8/src/utils/allocation.cc
@@ -161,15 +161,14 @@ void* GetRandomMmapAddr() {
return GetPlatformPageAllocator()->GetRandomMmapAddr();
}
-void* AllocatePages(v8::PageAllocator* page_allocator, void* address,
- size_t size, size_t alignment,
- PageAllocator::Permission access) {
+void* AllocatePages(v8::PageAllocator* page_allocator, void* hint, size_t size,
+ size_t alignment, PageAllocator::Permission access) {
DCHECK_NOT_NULL(page_allocator);
- DCHECK_EQ(address, AlignedAddress(address, alignment));
+ DCHECK_EQ(hint, AlignedAddress(hint, alignment));
DCHECK(IsAligned(size, page_allocator->AllocatePageSize()));
void* result = nullptr;
for (int i = 0; i < kAllocationTries; ++i) {
- result = page_allocator->AllocatePages(address, size, alignment, access);
+ result = page_allocator->AllocatePages(hint, size, alignment, access);
if (result != nullptr) break;
size_t request_size = size + alignment - page_allocator->AllocatePageSize();
if (!OnCriticalMemoryPressure(request_size)) break;
@@ -198,16 +197,6 @@ bool SetPermissions(v8::PageAllocator* page_allocator, void* address,
return page_allocator->SetPermissions(address, size, access);
}
-byte* AllocatePage(v8::PageAllocator* page_allocator, void* address,
- size_t* allocated) {
- DCHECK_NOT_NULL(page_allocator);
- size_t page_size = page_allocator->AllocatePageSize();
- void* result = AllocatePages(page_allocator, address, page_size, page_size,
- PageAllocator::kReadWrite);
- if (result != nullptr) *allocated = page_size;
- return static_cast<byte*>(result);
-}
-
bool OnCriticalMemoryPressure(size_t length) {
// TODO(bbudge) Rework retry logic once embedders implement the more
// informative overload.
diff --git a/deps/v8/src/utils/allocation.h b/deps/v8/src/utils/allocation.h
index 2f7074acb0..4cb244172c 100644
--- a/deps/v8/src/utils/allocation.h
+++ b/deps/v8/src/utils/allocation.h
@@ -89,7 +89,7 @@ V8_EXPORT_PRIVATE v8::PageAllocator* SetPlatformPageAllocatorForTesting(
v8::PageAllocator* page_allocator);
// Gets the page granularity for AllocatePages and FreePages. Addresses returned
-// by AllocatePages and AllocatePage are aligned to this size.
+// by AllocatePages are aligned to this size.
V8_EXPORT_PRIVATE size_t AllocatePageSize();
// Gets the granularity at which the permissions and release calls can be made.
@@ -142,13 +142,6 @@ inline bool SetPermissions(v8::PageAllocator* page_allocator, Address address,
access);
}
-// Convenience function that allocates a single system page with read and write
-// permissions. |address| is a hint. Returns the base address of the memory and
-// the page size via |allocated| on success. Returns nullptr on failure.
-V8_EXPORT_PRIVATE
-V8_WARN_UNUSED_RESULT byte* AllocatePage(v8::PageAllocator* page_allocator,
- void* address, size_t* allocated);
-
// Function that may release reserved memory regions to allow failed allocations
// to succeed. |length| is the amount of memory needed. Returns |true| if memory
// could be released, false otherwise.
diff --git a/deps/v8/src/utils/utils.h b/deps/v8/src/utils/utils.h
index 20d85aae10..27d3d5ef21 100644
--- a/deps/v8/src/utils/utils.h
+++ b/deps/v8/src/utils/utils.h
@@ -20,10 +20,13 @@
#include "src/base/platform/platform.h"
#include "src/base/v8-fallthrough.h"
#include "src/common/globals.h"
-#include "src/third_party/siphash/halfsiphash.h"
#include "src/utils/allocation.h"
#include "src/utils/vector.h"
+#if defined(V8_USE_SIPHASH)
+#include "src/third_party/siphash/halfsiphash.h"
+#endif
+
#if defined(V8_OS_AIX)
#include <fenv.h> // NOLINT(build/c++11)
#endif
@@ -302,29 +305,36 @@ T SaturateSub(T a, T b) {
// ----------------------------------------------------------------------------
// BitField is a help template for encoding and decode bitfield with
// unsigned content.
+// Instantiate them via 'using', which is cheaper than deriving a new class:
+// using MyBitField = BitField<int, 4, 2, MyEnum>;
+// The BitField class is final to enforce this style over derivation.
template <class T, int shift, int size, class U = uint32_t>
-class BitField {
+class BitField final {
public:
STATIC_ASSERT(std::is_unsigned<U>::value);
STATIC_ASSERT(shift < 8 * sizeof(U)); // Otherwise shifts by {shift} are UB.
STATIC_ASSERT(size < 8 * sizeof(U)); // Otherwise shifts by {size} are UB.
STATIC_ASSERT(shift + size <= 8 * sizeof(U));
+ STATIC_ASSERT(size > 0);
using FieldType = T;
// A type U mask of bit field. To use all bits of a type U of x bits
// in a bitfield without compiler warnings we have to compute 2^x
// without using a shift count of x in the computation.
- static constexpr U kShift = shift;
- static constexpr U kSize = size;
+ static constexpr int kShift = shift;
+ static constexpr int kSize = size;
static constexpr U kMask = ((U{1} << kShift) << kSize) - (U{1} << kShift);
- static constexpr U kNext = kShift + kSize;
+ static constexpr int kLastUsedBit = kShift + kSize - 1;
static constexpr U kNumValues = U{1} << kSize;
// Value for the field with all bits set.
static constexpr T kMax = static_cast<T>(kNumValues - 1);
+ template <class T2, int size2>
+ using Next = BitField<T2, kShift + kSize, size2, U>;
+
// Tells whether the provided value fits into the bit field.
static constexpr bool is_valid(T value) {
return (static_cast<U>(value) & ~static_cast<U>(kMax)) == 0;
@@ -892,7 +902,8 @@ class BailoutId {
// Our version of printf().
V8_EXPORT_PRIVATE void PRINTF_FORMAT(1, 2) PrintF(const char* format, ...);
-void PRINTF_FORMAT(2, 3) PrintF(FILE* out, const char* format, ...);
+V8_EXPORT_PRIVATE void PRINTF_FORMAT(2, 3)
+ PrintF(FILE* out, const char* format, ...);
// Prepends the current process ID to the output.
void PRINTF_FORMAT(1, 2) PrintPID(const char* format, ...);