mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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 <ulan@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
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 <mlippautz@chromium.org>
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.
Refs: https://github.com/nodejs/node/pull/15393
PR-URL: https://github.com/nodejs/node/pull/15393
Backport-PR-URL: https://github.com/nodejs/node/pull/16413
Author: Anna Henningsen <anna@addaleax.net>
Author: Peter Marshall <p.s.marshall0@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
758b730139
commit
1e316826ff
11 files changed
+102
-238
No files matched your search
Vendored
+36
-91
@@ -3112,9 +3112,12 @@ class V8_EXPORT Object : public Value {
|
||||
//
|
||||
// Note also that this only works for named properties.
|
||||
V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
|
||||
Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
|
||||
Local<Value> value,
|
||||
PropertyAttribute attribs = None));
|
||||
bool ForceSet(Local<Value> key, Local<Value> value,
|
||||
PropertyAttribute attribs = None));
|
||||
V8_DEPRECATE_SOON("Use CreateDataProperty / DefineOwnProperty",
|
||||
Maybe<bool> ForceSet(Local<Context> context,
|
||||
Local<Value> key, Local<Value> value,
|
||||
PropertyAttribute attribs = None));
|
||||
|
||||
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
|
||||
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
|
||||
@@ -4343,18 +4346,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_; }
|
||||
@@ -4362,9 +4354,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;
|
||||
};
|
||||
@@ -4719,18 +4708,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_; }
|
||||
@@ -4738,9 +4716,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;
|
||||
};
|
||||
@@ -4987,8 +4962,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,
|
||||
@@ -6050,8 +6025,6 @@ V8_INLINE Local<Boolean> 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:
|
||||
@@ -6069,28 +6042,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<int>(max_semi_space_size_in_kb_ / 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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
@@ -6116,10 +6071,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_;
|
||||
@@ -6350,8 +6302,22 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
|
||||
*/
|
||||
typedef bool (*DeprecatedAllowCodeGenerationFromStringsCallback)(
|
||||
Local<Context> context);
|
||||
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
|
||||
Local<String> 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> context, Local<String> 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<Value>&);
|
||||
@@ -7637,7 +7603,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));
|
||||
@@ -7758,7 +7724,6 @@ class V8_EXPORT Isolate {
|
||||
friend class PersistentValueMapBase;
|
||||
|
||||
void ReportExternalAllocationLimitReached();
|
||||
void CheckMemoryPressure();
|
||||
};
|
||||
|
||||
class V8_EXPORT StartupData {
|
||||
@@ -8119,7 +8084,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.
|
||||
*
|
||||
@@ -8140,7 +8105,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
|
||||
@@ -9008,8 +8973,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;
|
||||
@@ -10228,32 +10191,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<int64_t*>(
|
||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
||||
int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
|
||||
const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
|
||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
||||
int64_t* external_memory_at_last_mc =
|
||||
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(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;
|
||||
@@ -10287,7 +10231,8 @@ void V8::SetAllowCodeGenerationFromStringsCallback(
|
||||
DeprecatedAllowCodeGenerationFromStringsCallback callback) {
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
isolate->SetAllowCodeGenerationFromStringsCallback(
|
||||
reinterpret_cast<AllowCodeGenerationFromStringsCallback>(callback));
|
||||
reinterpret_cast<FreshNewAllowCodeGenerationFromStringsCallback>(
|
||||
callback));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+24
-27
@@ -874,7 +874,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),
|
||||
@@ -882,8 +882,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<int>(i::Heap::ComputeMaxSemiSpaceSize(physical_memory)));
|
||||
set_max_old_space_size(
|
||||
static_cast<int>(i::Heap::ComputeMaxOldGenerationSize(physical_memory)));
|
||||
set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize);
|
||||
@@ -899,7 +899,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();
|
||||
@@ -4492,6 +4492,24 @@ Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
|
||||
}
|
||||
|
||||
|
||||
bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value,
|
||||
v8::PropertyAttribute attribs) {
|
||||
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
|
||||
ENTER_V8_HELPER_DO_NOT_USE(isolate, Local<Context>(), Object, ForceSet,
|
||||
false, i::HandleScope, false);
|
||||
i::Handle<i::JSObject> self =
|
||||
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
|
||||
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
|
||||
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
|
||||
has_pending_exception =
|
||||
DefineObjectProperty(self, key_obj, value_obj,
|
||||
static_cast<i::PropertyAttributes>(attribs))
|
||||
.is_null();
|
||||
EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key,
|
||||
Local<Value> value) {
|
||||
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
|
||||
@@ -6318,16 +6336,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<siginfo_t*>(info), static_cast<ucontext_t*>(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();
|
||||
@@ -7912,11 +7925,6 @@ v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() {
|
||||
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
|
||||
size_t byte_length = static_cast<size_t>(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;
|
||||
@@ -8128,12 +8136,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;
|
||||
}
|
||||
|
||||
@@ -8290,11 +8292,6 @@ void Isolate::ReportExternalAllocationLimitReached() {
|
||||
heap->ReportExternalMemoryPressure();
|
||||
}
|
||||
|
||||
void Isolate::CheckMemoryPressure() {
|
||||
i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
|
||||
if (heap->gc_state() != i::Heap::NOT_IN_GC) return;
|
||||
heap->CheckMemoryPressure();
|
||||
}
|
||||
|
||||
HeapProfiler* Isolate::GetHeapProfiler() {
|
||||
i::HeapProfiler* heap_profiler =
|
||||
|
||||
Vendored
+12
-22
@@ -99,7 +99,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_ /
|
||||
@@ -4816,12 +4816,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() {
|
||||
@@ -5427,18 +5425,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.
|
||||
@@ -5466,12 +5462,6 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb,
|
||||
max_semi_space_size_ = base::bits::RoundUpToPowerOfTwo32(
|
||||
static_cast<uint32_t>(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<size_t>(1 * MB));
|
||||
}
|
||||
|
||||
if (FLAG_min_semi_space_size > 0) {
|
||||
size_t initial_semispace_size =
|
||||
static_cast<size_t>(FLAG_min_semi_space_size) * MB;
|
||||
@@ -5515,7 +5505,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;
|
||||
|
||||
Vendored
+11
-19
@@ -583,11 +583,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.
|
||||
@@ -916,14 +914,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
|
||||
@@ -1308,12 +1302,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<int>(((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<int>(((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
|
||||
|
||||
Vendored
-3
@@ -2837,9 +2837,6 @@ bool Isolate::Init(StartupDeserializer* des) {
|
||||
Internals::kExternalMemoryOffset);
|
||||
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.external_memory_limit_)),
|
||||
Internals::kExternalMemoryLimitOffset);
|
||||
CHECK_EQ(static_cast<int>(
|
||||
OFFSET_OF(Isolate, heap_.external_memory_at_last_mark_compact_)),
|
||||
Internals::kExternalMemoryAtLastMarkCompactOffset);
|
||||
|
||||
time_millis_at_init_ = heap_.MonotonicallyIncreasingTimeInMs();
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
-5
@@ -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.
|
||||
|
||||
+1
-1
@@ -4564,7 +4564,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);
|
||||
|
||||
Vendored
+3
-60
@@ -3487,16 +3487,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_;
|
||||
};
|
||||
@@ -3772,43 +3766,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<v8::ArrayBuffer> 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<uintptr_t>(contents.AllocationBase());
|
||||
const uintptr_t data = reinterpret_cast<uintptr_t>(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_;
|
||||
};
|
||||
@@ -20480,7 +20446,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;
|
||||
}
|
||||
@@ -26192,29 +26158,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<v8::SharedArrayBuffer> 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<uintptr_t>(contents.AllocationBase());
|
||||
const uintptr_t data = reinterpret_cast<uintptr_t>(contents.Data());
|
||||
CHECK_LE(alloc, data);
|
||||
CHECK_LE(data + contents.ByteLength(), alloc + contents.AllocationLength());
|
||||
}
|
||||
|
||||
static int nb_uncaught_exception_callback_calls = 0;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -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);
|
||||
|
||||
+13
-8
@@ -63,14 +63,19 @@ TEST(Heap, MaxHeapGrowingFactor) {
|
||||
}
|
||||
|
||||
TEST(Heap, SemiSpaceSize) {
|
||||
const size_t KB = static_cast<size_t>(i::KB);
|
||||
const size_t MB = static_cast<size_t>(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(2u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(1024u * MB) * KB);
|
||||
ASSERT_EQ(5u * 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<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
|
||||
{4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
|
||||
{8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}};
|
||||
|
||||
for (auto configuration : configurations) {
|
||||
ASSERT_EQ(configuration[1],
|
||||
static_cast<uint64_t>(
|
||||
i::Heap::ComputeMaxSemiSpaceSize(configuration[0])));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Heap, OldGenerationSize) {
|
||||
|
||||
Reference in new issue
Block a user