From aa1a3ea998e895b57f69abd6b6c483b7cd1819fe Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 14 Sep 2017 17:01:13 +0200 Subject: [PATCH] deps: revert ABI breaking changes in V8 6.1 Below is the list of changes: deps: revert 70de12b73c150 from upstream V8 Original commit message: Remove deprecated ForceSet Also move the soon-to-be-deprecated version to deprecated BUG=none R=ulan@chromium.org Change-Id: I2252404f63e25ac35c7798daf66b36144bef6a7e Reviewed-on: https://chromium-review.googlesource.com/518162 Reviewed-by: Ulan Degenbaev Commit-Queue: Jochen Eisinger Cr-Commit-Position: refs/heads/master@{#45554} [squash] use renamed internal utilities v8: reorder V8_INTRINSICS_LIST for ABI compat Make `kErrorPrototype` added at the end of the `Intrinsic` for ABI compatibility. deps: revert 0089c786ed882 from V8 upstream Original commit message: Merged: Squashed multiple commits. Merged: [heap] Add API to set heap semi-space limits in KB. Revision: bb29f9a4d6fb5e32 Merged: [heap] Partially reland "Allow a minimum semi-space size of 512K." Revision: 7486dc3331 Merged: [heap] Set initial semi-space size to 512K. Revision: a5230d81d1f73c BUG=chromium:716032,chromium:735649 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true R=hablich@chromium.org Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Ia9946e28ce41dee6199fac571274aa196576385b Reviewed-on: https://chromium-review.googlesource.com/616283 Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/branch-heads/6.1@{#47} Cr-Branched-From: 1bf2e10ddb194d4c2871a87a4732613419de892d-refs/heads/6.1.534@{#1} Cr-Branched-From: e825c4318eb2065ffdf9044aa6a5278635c36427-refs/heads/master@{#46746} v8: work around callback typedef renaming Do some clever tricks to have an easy way around V8 renaming one of its typedef to a deprecated version and then introducing a new typedef with the same name. deps: revert 5ebd6fcd269de from V8 upstream Original commit message: [heap] Lower external allocation limit when external memory shrinks. BUG=chromium:728228 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng Review-Url: https://codereview.chromium.org/2921883002 Cr-Commit-Position: refs/heads/master@{#45726} deps: revert cf8f7bdc9d5ee from V8 upstream Original commit message: [heap] Increase memory reducer activation limit for external memory changes. BUG=chromium:729521 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng Review-Url: https://codereview.chromium.org/2923563006 Cr-Commit-Position: refs/heads/master@{#45763} deps: revert 11fc9fab94d48 from V8 upstream Original commit message: [heap] Guard against re-entering GC on external memory change. TBR=hpayer@chromium.org BUG=chromium:729868,chromium:729521 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng Review-Url: https://codereview.chromium.org/2929463002 Cr-Commit-Position: refs/heads/master@{#45745} deps: revert 502c6ae6a0397 from V8 upstream Original commit message: [heap] Activate memory reducer on external memory activity. BUG=chromium:728228,chromium:626082 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng Review-Url: https://codereview.chromium.org/2917853004 Cr-Commit-Position: refs/heads/master@{#45671} v8: revert changes to Contents structs The feature is disabled by default anyway,but we disable it completely. Backport-PR-URL: https://github.com/nodejs/node/pull/15393 PR-URL: https://github.com/nodejs/node/pull/15393 Author: Anna Henningsen Author: Peter Marshall Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann Reviewed-By: Matteo Collina --- deps/v8/include/v8.h | 127 ++++++------------- deps/v8/src/api.cc | 51 ++++---- deps/v8/src/heap/heap.cc | 34 ++--- deps/v8/src/heap/heap.h | 30 ++--- deps/v8/src/isolate.cc | 3 - deps/v8/src/trap-handler/handler-inside.cc | 2 +- deps/v8/src/trap-handler/trap-handler.h | 5 - deps/v8/test/cctest/heap/test-heap.cc | 2 +- deps/v8/test/cctest/test-api.cc | 63 +-------- deps/v8/test/cctest/test-strings.cc | 2 +- deps/v8/test/unittests/heap/heap-unittest.cc | 21 +-- 11 files changed, 102 insertions(+), 238 deletions(-) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index e37c549cb46b81..6bf0e1d7bf9bff 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -3097,9 +3097,12 @@ class V8_EXPORT Object : public Value { // // Note also that this only works for named properties. V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty", - Maybe ForceSet(Local context, Local key, - Local value, - PropertyAttribute attribs = None)); + bool ForceSet(Local key, Local value, + PropertyAttribute attribs = None)); + V8_DEPRECATE_SOON("Use CreateDataProperty / DefineOwnProperty", + Maybe ForceSet(Local context, + Local key, Local value, + PropertyAttribute attribs = None)); V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, @@ -4292,18 +4295,7 @@ class V8_EXPORT ArrayBuffer : public Object { */ class V8_EXPORT Contents { // NOLINT public: - Contents() - : data_(nullptr), - byte_length_(0), - allocation_base_(nullptr), - allocation_length_(0), - allocation_mode_(Allocator::AllocationMode::kNormal) {} - - void* AllocationBase() const { return allocation_base_; } - size_t AllocationLength() const { return allocation_length_; } - Allocator::AllocationMode AllocationMode() const { - return allocation_mode_; - } + Contents() : data_(NULL), byte_length_(0) {} void* Data() const { return data_; } size_t ByteLength() const { return byte_length_; } @@ -4311,9 +4303,6 @@ class V8_EXPORT ArrayBuffer : public Object { private: void* data_; size_t byte_length_; - void* allocation_base_; - size_t allocation_length_; - Allocator::AllocationMode allocation_mode_; friend class ArrayBuffer; }; @@ -4662,18 +4651,7 @@ class V8_EXPORT SharedArrayBuffer : public Object { */ class V8_EXPORT Contents { // NOLINT public: - Contents() - : data_(nullptr), - byte_length_(0), - allocation_base_(nullptr), - allocation_length_(0), - allocation_mode_(ArrayBuffer::Allocator::AllocationMode::kNormal) {} - - void* AllocationBase() const { return allocation_base_; } - size_t AllocationLength() const { return allocation_length_; } - ArrayBuffer::Allocator::AllocationMode AllocationMode() const { - return allocation_mode_; - } + Contents() : data_(NULL), byte_length_(0) {} void* Data() const { return data_; } size_t ByteLength() const { return byte_length_; } @@ -4681,9 +4659,6 @@ class V8_EXPORT SharedArrayBuffer : public Object { private: void* data_; size_t byte_length_; - void* allocation_base_; - size_t allocation_length_; - ArrayBuffer::Allocator::AllocationMode allocation_mode_; friend class SharedArrayBuffer; }; @@ -4930,8 +4905,8 @@ class V8_EXPORT External : public Value { F(ArrayProto_forEach, array_for_each_iterator) \ F(ArrayProto_keys, array_keys_iterator) \ F(ArrayProto_values, array_values_iterator) \ + F(IteratorPrototype, initial_iterator_prototype) \ F(ErrorPrototype, initial_error_prototype) \ - F(IteratorPrototype, initial_iterator_prototype) enum Intrinsic { #define V8_DECL_INTRINSIC(name, iname) k##name, @@ -5995,8 +5970,6 @@ V8_INLINE Local False(Isolate* isolate); * * The arguments for set_max_semi_space_size, set_max_old_space_size, * set_max_executable_size, set_code_range_size specify limits in MB. - * - * The argument for set_max_semi_space_size_in_kb is in KB. */ class V8_EXPORT ResourceConstraints { public: @@ -6014,28 +5987,10 @@ class V8_EXPORT ResourceConstraints { void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit); - // Returns the max semi-space size in MB. - V8_DEPRECATE_SOON("Use max_semi_space_size_in_kb()", - int max_semi_space_size()) { - return static_cast(max_semi_space_size_in_kb_ / 1024); - } - - // Sets the max semi-space size in MB. - V8_DEPRECATE_SOON("Use set_max_semi_space_size_in_kb(size_t limit_in_kb)", - void set_max_semi_space_size(int limit_in_mb)) { - max_semi_space_size_in_kb_ = limit_in_mb * 1024; + int max_semi_space_size() const { return max_semi_space_size_; } + void set_max_semi_space_size(int limit_in_mb) { + max_semi_space_size_ = limit_in_mb; } - - // Returns the max semi-space size in KB. - size_t max_semi_space_size_in_kb() const { - return max_semi_space_size_in_kb_; - } - - // Sets the max semi-space size in KB. - void set_max_semi_space_size_in_kb(size_t limit_in_kb) { - max_semi_space_size_in_kb_ = limit_in_kb; - } - int max_old_space_size() const { return max_old_space_size_; } void set_max_old_space_size(int limit_in_mb) { max_old_space_size_ = limit_in_mb; @@ -6061,10 +6016,7 @@ class V8_EXPORT ResourceConstraints { } private: - // max_semi_space_size_ is in KB - size_t max_semi_space_size_in_kb_; - - // The remaining limits are in MB + int max_semi_space_size_; int max_old_space_size_; int max_executable_size_; uint32_t* stack_limit_; @@ -6293,8 +6245,22 @@ typedef void (*FailedAccessCheckCallback)(Local target, */ typedef bool (*DeprecatedAllowCodeGenerationFromStringsCallback)( Local context); -typedef bool (*AllowCodeGenerationFromStringsCallback)(Local context, - Local source); +// The naming of this alias is for **Node v8.x releases only** +// plain V8 >= 6.1 just calls it AllowCodeGenerationFromStringsCallback +typedef bool (*FreshNewAllowCodeGenerationFromStringsCallback)( + Local context, Local source); + +// a) no addon uses this anyway +// b) this is sufficient because c++ type mangling takes care of resolving +// the typedefs +// c) doing it this way allows people to use the Fresh New variant +#ifdef USING_V8_SHARED +typedef DeprecatedAllowCodeGenerationFromStringsCallback + AllowCodeGenerationFromStringsCallback; +#else +typedef FreshNewAllowCodeGenerationFromStringsCallback + AllowCodeGenerationFromStringsCallback; +#endif // --- WebAssembly compilation callbacks --- typedef bool (*ExtensionCallback)(const FunctionCallbackInfo&); @@ -7570,7 +7536,7 @@ class V8_EXPORT Isolate { * strings should be allowed. */ void SetAllowCodeGenerationFromStringsCallback( - AllowCodeGenerationFromStringsCallback callback); + FreshNewAllowCodeGenerationFromStringsCallback callback); V8_DEPRECATED("Use callback with source parameter.", void SetAllowCodeGenerationFromStringsCallback( DeprecatedAllowCodeGenerationFromStringsCallback callback)); @@ -7691,7 +7657,6 @@ class V8_EXPORT Isolate { friend class PersistentValueMapBase; void ReportExternalAllocationLimitReached(); - void CheckMemoryPressure(); }; class V8_EXPORT StartupData { @@ -8052,7 +8017,7 @@ class V8_EXPORT V8 { */ static void ShutdownPlatform(); -#if V8_OS_POSIX +#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID /** * Give the V8 signal handler a chance to handle a fault. * @@ -8073,7 +8038,7 @@ class V8_EXPORT V8 { * points to a ucontext_t structure. */ static bool TryHandleSignal(int signal_number, void* info, void* context); -#endif // V8_OS_POSIX +#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID /** * Enable the default signal handler rather than using one provided by the @@ -8941,8 +8906,6 @@ class Internals { static const int kExternalMemoryOffset = 4 * kApiPointerSize; static const int kExternalMemoryLimitOffset = kExternalMemoryOffset + kApiInt64Size; - static const int kExternalMemoryAtLastMarkCompactOffset = - kExternalMemoryLimitOffset + kApiInt64Size; static const int kIsolateRootsOffset = kExternalMemoryLimitOffset + kApiInt64Size + kApiInt64Size + kApiPointerSize + kApiPointerSize; @@ -10161,32 +10124,13 @@ uint32_t Isolate::GetNumberOfDataSlots() { int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( int64_t change_in_bytes) { typedef internal::Internals I; - const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024; int64_t* external_memory = reinterpret_cast( reinterpret_cast(this) + I::kExternalMemoryOffset); - int64_t* external_memory_limit = reinterpret_cast( + const int64_t external_memory_limit = *reinterpret_cast( reinterpret_cast(this) + I::kExternalMemoryLimitOffset); - int64_t* external_memory_at_last_mc = - reinterpret_cast(reinterpret_cast(this) + - I::kExternalMemoryAtLastMarkCompactOffset); const int64_t amount = *external_memory + change_in_bytes; - *external_memory = amount; - - int64_t allocation_diff_since_last_mc = - *external_memory_at_last_mc - *external_memory; - allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0 - ? -allocation_diff_since_last_mc - : allocation_diff_since_last_mc; - if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) { - CheckMemoryPressure(); - } - - if (change_in_bytes < 0) { - *external_memory_limit += change_in_bytes; - } - - if (change_in_bytes > 0 && amount > *external_memory_limit) { + if (change_in_bytes > 0 && amount > external_memory_limit) { ReportExternalAllocationLimitReached(); } return *external_memory; @@ -10220,7 +10164,8 @@ void V8::SetAllowCodeGenerationFromStringsCallback( DeprecatedAllowCodeGenerationFromStringsCallback callback) { Isolate* isolate = Isolate::GetCurrent(); isolate->SetAllowCodeGenerationFromStringsCallback( - reinterpret_cast(callback)); + reinterpret_cast( + callback)); } diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 09da3ac8835266..4792a3e7ac38ba 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -878,7 +878,7 @@ Extension::Extension(const char* name, } ResourceConstraints::ResourceConstraints() - : max_semi_space_size_in_kb_(0), + : max_semi_space_size_(0), max_old_space_size_(0), stack_limit_(NULL), code_range_size_(0), @@ -886,8 +886,8 @@ ResourceConstraints::ResourceConstraints() void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit) { - set_max_semi_space_size_in_kb( - i::Heap::ComputeMaxSemiSpaceSize(physical_memory)); + set_max_semi_space_size( + static_cast(i::Heap::ComputeMaxSemiSpaceSize(physical_memory))); set_max_old_space_size( static_cast(i::Heap::ComputeMaxOldGenerationSize(physical_memory))); set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize); @@ -903,7 +903,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, void SetResourceConstraints(i::Isolate* isolate, const ResourceConstraints& constraints) { - size_t semi_space_size = constraints.max_semi_space_size_in_kb(); + int semi_space_size = constraints.max_semi_space_size(); int old_space_size = constraints.max_old_space_size(); size_t code_range_size = constraints.code_range_size(); size_t max_pool_size = constraints.max_zone_pool_size(); @@ -4505,6 +4505,24 @@ Maybe v8::Object::ForceSet(v8::Local context, } +bool v8::Object::ForceSet(v8::Local key, v8::Local value, + v8::PropertyAttribute attribs) { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + ENTER_V8_HELPER_DO_NOT_USE(isolate, Local(), Object, ForceSet, + false, i::HandleScope, false); + i::Handle self = + i::Handle::cast(Utils::OpenHandle(this)); + i::Handle key_obj = Utils::OpenHandle(*key); + i::Handle value_obj = Utils::OpenHandle(*value); + has_pending_exception = + DefineObjectProperty(self, key_obj, value_obj, + static_cast(attribs)) + .is_null(); + EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, false); + return true; +} + + Maybe v8::Object::SetPrivate(Local context, Local key, Local value) { auto isolate = reinterpret_cast(context->GetIsolate()); @@ -6331,16 +6349,11 @@ bool v8::V8::Initialize() { return true; } -#if V8_OS_POSIX -bool V8::TryHandleSignal(int signum, void* info, void* context) { #if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID - return v8::internal::trap_handler::TryHandleSignal( - signum, static_cast(info), static_cast(context)); -#else // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID +bool V8::TryHandleSignal(int signum, void* info, void* context) { return false; -#endif } -#endif +#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID bool V8::RegisterDefaultSignalHandler() { return v8::internal::trap_handler::RegisterDefaultSignalHandler(); @@ -7882,11 +7895,6 @@ v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { i::Handle self = Utils::OpenHandle(this); size_t byte_length = static_cast(self->byte_length()->Number()); Contents contents; - contents.allocation_base_ = self->allocation_base(); - contents.allocation_length_ = self->allocation_length(); - contents.allocation_mode_ = self->has_guard_region() - ? Allocator::AllocationMode::kReservation - : Allocator::AllocationMode::kNormal; contents.data_ = self->backing_store(); contents.byte_length_ = byte_length; return contents; @@ -8095,12 +8103,6 @@ v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { Contents contents; contents.data_ = self->backing_store(); contents.byte_length_ = byte_length; - // SharedArrayBuffers never have guard regions, so their allocation and data - // are equivalent. - contents.allocation_base_ = self->backing_store(); - contents.allocation_length_ = byte_length; - contents.allocation_mode_ = - ArrayBufferAllocator::Allocator::AllocationMode::kNormal; return contents; } @@ -8257,11 +8259,6 @@ void Isolate::ReportExternalAllocationLimitReached() { heap->ReportExternalMemoryPressure(); } -void Isolate::CheckMemoryPressure() { - i::Heap* heap = reinterpret_cast(this)->heap(); - if (heap->gc_state() != i::Heap::NOT_IN_GC) return; - heap->CheckMemoryPressure(); -} HeapProfiler* Isolate::GetHeapProfiler() { i::HeapProfiler* heap_profiler = diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index 6cc718840aa833..399117ca3220aa 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -85,7 +85,7 @@ Heap::Heap() // semispace_size_ should be a power of 2 and old_generation_size_ should // be a multiple of Page::kPageSize. max_semi_space_size_(8 * (kPointerSize / 4) * MB), - initial_semispace_size_(kMinSemiSpaceSizeInKB * KB), + initial_semispace_size_(MB), max_old_generation_size_(700ul * (kPointerSize / 4) * MB), initial_max_old_generation_size_(max_old_generation_size_), initial_old_generation_size_(max_old_generation_size_ / @@ -4573,12 +4573,10 @@ void Heap::CheckMemoryPressure() { GarbageCollectionReason::kMemoryPressure); } } - if (memory_reducer_) { - MemoryReducer::Event event; - event.type = MemoryReducer::kPossibleGarbage; - event.time_ms = MonotonicallyIncreasingTimeInMs(); - memory_reducer_->NotifyPossibleGarbage(event); - } + MemoryReducer::Event event; + event.type = MemoryReducer::kPossibleGarbage; + event.time_ms = MonotonicallyIncreasingTimeInMs(); + memory_reducer_->NotifyPossibleGarbage(event); } void Heap::CollectGarbageOnMemoryPressure() { @@ -5205,18 +5203,16 @@ void Heap::IterateStrongRoots(RootVisitor* v, VisitMode mode) { // TODO(1236194): Since the heap size is configurable on the command line // and through the API, we should gracefully handle the case that the heap // size is not big enough to fit all the initial objects. -bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb, - size_t max_old_generation_size_in_mb, - size_t code_range_size_in_mb) { +bool Heap::ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size, + size_t code_range_size) { if (HasBeenSetUp()) return false; // Overwrite default configuration. - if (max_semi_space_size_in_kb != 0) { - max_semi_space_size_ = - ROUND_UP(max_semi_space_size_in_kb * KB, Page::kPageSize); + if (max_semi_space_size != 0) { + max_semi_space_size_ = max_semi_space_size * MB; } - if (max_old_generation_size_in_mb != 0) { - max_old_generation_size_ = max_old_generation_size_in_mb * MB; + if (max_old_space_size != 0) { + max_old_generation_size_ = max_old_space_size * MB; } // If max space size flags are specified overwrite the configuration. @@ -5244,12 +5240,6 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb, max_semi_space_size_ = base::bits::RoundUpToPowerOfTwo32( static_cast(max_semi_space_size_)); - if (max_semi_space_size_ == kMaxSemiSpaceSizeInKB * KB) { - // Start with at least 1*MB semi-space on machines with a lot of memory. - initial_semispace_size_ = - Max(initial_semispace_size_, static_cast(1 * MB)); - } - if (FLAG_min_semi_space_size > 0) { size_t initial_semispace_size = static_cast(FLAG_min_semi_space_size) * MB; @@ -5293,7 +5283,7 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb, FixedArray::SizeFor(JSArray::kInitialMaxFastElementArray) + AllocationMemento::kSize)); - code_range_size_ = code_range_size_in_mb * MB; + code_range_size_ = code_range_size * MB; configured_ = true; return true; diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h index e90838e29538bb..9beea144eb9b21 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -573,11 +573,9 @@ class Heap { static const int kPointerMultiplier = i::kPointerSize / 4; #endif - // Semi-space size needs to be a multiple of page size. - static const int kMinSemiSpaceSizeInKB = - 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); - static const int kMaxSemiSpaceSizeInKB = - 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); + // The new space size has to be a power of 2. Sizes are in MB. + static const int kMinSemiSpaceSize = 1 * kPointerMultiplier; + static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier; // The old space size has to be a multiple of Page::kPageSize. // Sizes are in MB. @@ -927,14 +925,10 @@ class Heap { // Initialization. =========================================================== // =========================================================================== - // Configure heap sizes - // max_semi_space_size_in_kb: maximum semi-space size in KB - // max_old_generation_size_in_mb: maximum old generation size in MB - // code_range_size_in_mb: code range size in MB - // Return false if the heap has been set up already. - bool ConfigureHeap(size_t max_semi_space_size_in_kb, - size_t max_old_generation_size_in_mb, - size_t code_range_size_in_mb); + // Configure heap size in MB before setup. Return false if the heap has been + // set up already. + bool ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size, + size_t code_range_size); bool ConfigureHeapDefault(); // Prepares the heap, setting up memory areas that are needed in the isolate @@ -1310,12 +1304,10 @@ class Heap { uint64_t capped_physical_memory = Max(Min(physical_memory, max_physical_memory), min_physical_memory); // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C - int semi_space_size_in_kb = - static_cast(((capped_physical_memory - min_physical_memory) * - (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / - (max_physical_memory - min_physical_memory) + - kMinSemiSpaceSizeInKB); - return RoundUp(semi_space_size_in_kb, (1 << kPageSizeBits) / KB); + return static_cast(((capped_physical_memory - min_physical_memory) * + (kMaxSemiSpaceSize - kMinSemiSpaceSize)) / + (max_physical_memory - min_physical_memory) + + kMinSemiSpaceSize); } // Returns the capacity of the heap in bytes w/o growing. Heap grows when diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index 48f5b30bd2f9f1..8e517982ace663 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -2840,9 +2840,6 @@ bool Isolate::Init(Deserializer* des) { Internals::kExternalMemoryOffset); CHECK_EQ(static_cast(OFFSET_OF(Isolate, heap_.external_memory_limit_)), Internals::kExternalMemoryLimitOffset); - CHECK_EQ(static_cast( - OFFSET_OF(Isolate, heap_.external_memory_at_last_mark_compact_)), - Internals::kExternalMemoryAtLastMarkCompactOffset); time_millis_at_init_ = heap_.MonotonicallyIncreasingTimeInMs(); diff --git a/deps/v8/src/trap-handler/handler-inside.cc b/deps/v8/src/trap-handler/handler-inside.cc index a51bd9427f0c95..4a748b817527f7 100644 --- a/deps/v8/src/trap-handler/handler-inside.cc +++ b/deps/v8/src/trap-handler/handler-inside.cc @@ -36,13 +36,13 @@ namespace trap_handler { namespace { +#if V8_TRAP_HANDLER_SUPPORTED bool IsKernelGeneratedSignal(siginfo_t* info) { return info->si_code > 0 && info->si_code != SI_USER && info->si_code != SI_QUEUE && info->si_code != SI_TIMER && info->si_code != SI_ASYNCIO && info->si_code != SI_MESGQ; } -#if V8_TRAP_HANDLER_SUPPORTED class SigUnmaskStack { public: explicit SigUnmaskStack(sigset_t sigs) { diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h index ed9459918b7b36..73a147f0cb2863 100644 --- a/deps/v8/src/trap-handler/trap-handler.h +++ b/deps/v8/src/trap-handler/trap-handler.h @@ -21,12 +21,7 @@ namespace v8 { namespace internal { namespace trap_handler { -// TODO(eholk): Support trap handlers on other platforms. -#if V8_TARGET_ARCH_X64 && V8_OS_LINUX && !V8_OS_ANDROID -#define V8_TRAP_HANDLER_SUPPORTED 1 -#else #define V8_TRAP_HANDLER_SUPPORTED 0 -#endif struct ProtectedInstructionData { // The offset of this instruction from the start of its code object. diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index 6781d3de6a3e26..d9608292e8c0ed 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -4806,7 +4806,7 @@ HEAP_TEST(Regress538257) { FLAG_manual_evacuation_candidates_selection = true; v8::Isolate::CreateParams create_params; // Set heap limits. - create_params.constraints.set_max_semi_space_size_in_kb(1024); + create_params.constraints.set_max_semi_space_size(1); create_params.constraints.set_max_old_space_size(6); create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 2d64279bf80dc6..aa4cba5a602d89 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -3453,16 +3453,10 @@ class ScopedArrayBufferContents { public: explicit ScopedArrayBufferContents(const v8::ArrayBuffer::Contents& contents) : contents_(contents) {} - ~ScopedArrayBufferContents() { free(contents_.AllocationBase()); } + ~ScopedArrayBufferContents() { free(contents_.Data()); } void* Data() const { return contents_.Data(); } size_t ByteLength() const { return contents_.ByteLength(); } - void* AllocationBase() const { return contents_.AllocationBase(); } - size_t AllocationLength() const { return contents_.AllocationLength(); } - v8::ArrayBuffer::Allocator::AllocationMode AllocationMode() const { - return contents_.AllocationMode(); - } - private: const v8::ArrayBuffer::Contents contents_; }; @@ -3738,43 +3732,15 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) { CheckDataViewIsNeutered(dv); } -THREADED_TEST(ArrayBuffer_AllocationInformation) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope handle_scope(isolate); - - const size_t ab_size = 1024; - Local ab = v8::ArrayBuffer::New(isolate, ab_size); - ScopedArrayBufferContents contents(ab->Externalize()); - - // Array buffers should have normal allocation mode. - CHECK(contents.AllocationMode() == - v8::ArrayBuffer::Allocator::AllocationMode::kNormal); - // The allocation must contain the buffer (normally they will be equal, but - // this is not required by the contract). - CHECK_NOT_NULL(contents.AllocationBase()); - const uintptr_t alloc = - reinterpret_cast(contents.AllocationBase()); - const uintptr_t data = reinterpret_cast(contents.Data()); - CHECK_LE(alloc, data); - CHECK_LE(data + contents.ByteLength(), alloc + contents.AllocationLength()); -} - class ScopedSharedArrayBufferContents { public: explicit ScopedSharedArrayBufferContents( const v8::SharedArrayBuffer::Contents& contents) : contents_(contents) {} - ~ScopedSharedArrayBufferContents() { free(contents_.AllocationBase()); } + ~ScopedSharedArrayBufferContents() { free(contents_.Data()); } void* Data() const { return contents_.Data(); } size_t ByteLength() const { return contents_.ByteLength(); } - void* AllocationBase() const { return contents_.AllocationBase(); } - size_t AllocationLength() const { return contents_.AllocationLength(); } - v8::ArrayBuffer::Allocator::AllocationMode AllocationMode() const { - return contents_.AllocationMode(); - } - private: const v8::SharedArrayBuffer::Contents contents_; }; @@ -20361,7 +20327,7 @@ class InitDefaultIsolateThread : public v8::base::Thread { create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); switch (testCase_) { case SetResourceConstraints: { - create_params.constraints.set_max_semi_space_size_in_kb(1024); + create_params.constraints.set_max_semi_space_size(1); create_params.constraints.set_max_old_space_size(6); break; } @@ -26057,29 +26023,6 @@ TEST(FutexInterruption) { timeout_thread.Join(); } -THREADED_TEST(SharedArrayBuffer_AllocationInformation) { - i::FLAG_harmony_sharedarraybuffer = true; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope handle_scope(isolate); - - const size_t ab_size = 1024; - Local ab = - v8::SharedArrayBuffer::New(isolate, ab_size); - ScopedSharedArrayBufferContents contents(ab->Externalize()); - - // Array buffers should have normal allocation mode. - CHECK(contents.AllocationMode() == - v8::ArrayBuffer::Allocator::AllocationMode::kNormal); - // The allocation must contain the buffer (normally they will be equal, but - // this is not required by the contract). - CHECK_NOT_NULL(contents.AllocationBase()); - const uintptr_t alloc = - reinterpret_cast(contents.AllocationBase()); - const uintptr_t data = reinterpret_cast(contents.Data()); - CHECK_LE(alloc, data); - CHECK_LE(data + contents.ByteLength(), alloc + contents.AllocationLength()); -} static int nb_uncaught_exception_callback_calls = 0; diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 73e9c58596e1b0..d98a4819b5cd08 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -1301,7 +1301,7 @@ TEST(SliceFromSlice) { UNINITIALIZED_TEST(OneByteArrayJoin) { v8::Isolate::CreateParams create_params; // Set heap limits. - create_params.constraints.set_max_semi_space_size_in_kb(1024); + create_params.constraints.set_max_semi_space_size(1); create_params.constraints.set_max_old_space_size(7); create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); diff --git a/deps/v8/test/unittests/heap/heap-unittest.cc b/deps/v8/test/unittests/heap/heap-unittest.cc index 6262eff210a99f..8dab181ca7e822 100644 --- a/deps/v8/test/unittests/heap/heap-unittest.cc +++ b/deps/v8/test/unittests/heap/heap-unittest.cc @@ -63,14 +63,19 @@ TEST(Heap, MaxHeapGrowingFactor) { } TEST(Heap, SemiSpaceSize) { - const size_t KB = static_cast(i::KB); - const size_t MB = static_cast(i::MB); - const size_t pm = i::Heap::kPointerMultiplier; - ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(0u) * KB); - ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(512u * MB) * KB); - ASSERT_EQ(3u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(1024u * MB) * KB); - ASSERT_EQ(8u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(2024u * MB) * KB); - ASSERT_EQ(8u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(4095u * MB) * KB); + uint64_t configurations[][2] = { + {0, 1 * i::Heap::kPointerMultiplier}, + {512 * i::MB, 1 * i::Heap::kPointerMultiplier}, + {1 * i::GB, 3 * i::Heap::kPointerMultiplier}, + {2 * static_cast(i::GB), i::Heap::kMaxSemiSpaceSize}, + {4 * static_cast(i::GB), i::Heap::kMaxSemiSpaceSize}, + {8 * static_cast(i::GB), i::Heap::kMaxSemiSpaceSize}}; + + for (auto configuration : configurations) { + ASSERT_EQ(configuration[1], + static_cast( + i::Heap::ComputeMaxSemiSpaceSize(configuration[0]))); + } } TEST(Heap, OldGenerationSize) {