Skip to content

Commit

Permalink
deps: revert ABI breaking changes in V8 6.1
Browse files Browse the repository at this point in the history
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.

Backport-PR-URL: #15393
PR-URL: #15393
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>
  • Loading branch information
addaleax authored and MylesBorins committed Oct 3, 2017
1 parent 8471747 commit aa1a3ea
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 238 deletions.
127 changes: 36 additions & 91 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<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,
Expand Down Expand Up @@ -4292,28 +4295,14 @@ 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_; }

private:
void* data_;
size_t byte_length_;
void* allocation_base_;
size_t allocation_length_;
Allocator::AllocationMode allocation_mode_;

friend class ArrayBuffer;
};
Expand Down Expand Up @@ -4662,28 +4651,14 @@ 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_; }

private:
void* data_;
size_t byte_length_;
void* allocation_base_;
size_t allocation_length_;
ArrayBuffer::Allocator::AllocationMode allocation_mode_;

friend class SharedArrayBuffer;
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -5995,8 +5970,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:
Expand All @@ -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<int>(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;
Expand All @@ -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_;
Expand Down Expand Up @@ -6293,8 +6245,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>&);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -7691,7 +7657,6 @@ class V8_EXPORT Isolate {
friend class PersistentValueMapBase;

void ReportExternalAllocationLimitReached();
void CheckMemoryPressure();
};

class V8_EXPORT StartupData {
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<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;
Expand Down Expand Up @@ -10220,7 +10164,8 @@ void V8::SetAllowCodeGenerationFromStringsCallback(
DeprecatedAllowCodeGenerationFromStringsCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
isolate->SetAllowCodeGenerationFromStringsCallback(
reinterpret_cast<AllowCodeGenerationFromStringsCallback>(callback));
reinterpret_cast<FreshNewAllowCodeGenerationFromStringsCallback>(
callback));
}


Expand Down
51 changes: 24 additions & 27 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,16 +878,16 @@ 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),
max_zone_pool_size_(0) {}

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);
Expand All @@ -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();
Expand Down Expand Up @@ -4505,6 +4505,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());
Expand Down Expand Up @@ -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<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();
Expand Down Expand Up @@ -7882,11 +7895,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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -8257,11 +8259,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 =
Expand Down
Loading

0 comments on commit aa1a3ea

Please sign in to comment.