Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8: patch API to be compatible with v8 6.0 #13217

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions deps/v8/include/v8-debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "v8.h" // NOLINT(build/include)

/**
* Debugger support for the V8 JavaScript engine.
* ATTENTION: The debugger API exposed by this file is deprecated and will be
* removed by the end of 2017. Please use the V8 inspector declared
* in include/v8-inspector.h instead.
*/
namespace v8 {

Expand Down Expand Up @@ -140,21 +142,19 @@ class V8_EXPORT Debug {
*/
typedef void (*MessageHandler)(const Message& message);

/**
* This is now a no-op.
*/
typedef void (*DebugMessageDispatchHandler)();

static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>()));

// Schedule a debugger break to happen when JavaScript code is run
// in the given isolate.
static void DebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void DebugBreak(Isolate* isolate));

// Remove scheduled debugger break in given isolate if it has not
// happened yet.
static void CancelDebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void CancelDebugBreak(Isolate* isolate));

// Check if a debugger break is scheduled in the given isolate.
V8_DEPRECATED("No longer supported",
Expand Down Expand Up @@ -189,10 +189,10 @@ class V8_EXPORT Debug {
* }
* \endcode
*/
// TODO(dcarney): data arg should be a MaybeLocal
static MaybeLocal<Value> Call(Local<Context> context,
v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported",
static MaybeLocal<Value> Call(
Local<Context> context, v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>()));

// This is now a no-op.
V8_DEPRECATED("No longer supported",
Expand Down Expand Up @@ -221,23 +221,28 @@ class V8_EXPORT Debug {
* (default Isolate if not provided). V8 will abort if LiveEdit is
* unexpectedly used. LiveEdit is enabled by default.
*/
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
V8_DEPRECATED("No longer supported",
static void SetLiveEditEnabled(Isolate* isolate, bool enable));

/**
* Returns array of internal properties specific to the value type. Result has
* the following format: [<name>, <value>,...,<name>, <value>]. Result array
* will be allocated in the current context.
*/
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
Local<Value> value);
V8_DEPRECATED("No longer supported",
static MaybeLocal<Array> GetInternalProperties(
Isolate* isolate, Local<Value> value));

/**
* Defines if the ES2015 tail call elimination feature is enabled or not.
* The change of this flag triggers deoptimization of all functions that
* contain calls at tail position.
*/
static bool IsTailCallEliminationEnabled(Isolate* isolate);
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
V8_DEPRECATED("No longer supported",
static bool IsTailCallEliminationEnabled(Isolate* isolate));
V8_DEPRECATED("No longer supported",
static void SetTailCallEliminationEnabled(Isolate* isolate,
bool enabled));
};


Expand Down
2 changes: 0 additions & 2 deletions deps/v8/include/v8-inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ class V8_EXPORT V8Inspector {
virtual void resetContextGroup(int contextGroupId) = 0;

// Various instrumentation.
virtual void willExecuteScript(v8::Local<v8::Context>, int scriptId) = 0;
virtual void didExecuteScript(v8::Local<v8::Context>) = 0;
virtual void idleStarted() = 0;
virtual void idleFinished() = 0;

Expand Down
25 changes: 20 additions & 5 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -2973,12 +2973,12 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<Value> key);

/**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
* Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6.
*/
V8_DEPRECATED("Use maybe version",
Local<Value> GetOwnPropertyDescriptor(Local<String> key));
Local<Value> GetOwnPropertyDescriptor(Local<Name> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
Local<Context> context, Local<String> key);
Local<Context> context, Local<Name> key);

V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key));
/**
Expand Down Expand Up @@ -4008,12 +4008,20 @@ class V8_EXPORT ArrayBuffer : public Object {
*/
virtual void* AllocateUninitialized(size_t length) = 0;

virtual void* Reserve(size_t length);

/**
* Free the memory block of size |length|, pointed to by |data|.
* That memory is guaranteed to be previously allocated by |Allocate|.
*/
virtual void Free(void* data, size_t length) = 0;

enum class AllocationMode { kNormal, kReservation };
virtual void Free(void* data, size_t length, AllocationMode mode);
enum class Protection { kNoAccess, kReadWrite };
virtual void SetProtection(void* data, size_t length,
Protection protection);

/**
* malloc/free based convenience allocator.
*
Expand Down Expand Up @@ -5723,8 +5731,12 @@ class V8_EXPORT ResourceConstraints {
void set_max_old_space_size(int limit_in_mb) {
max_old_space_size_ = limit_in_mb;
}
int max_executable_size() const { return max_executable_size_; }
void set_max_executable_size(int limit_in_mb) {
V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
int max_executable_size() const) {
return max_executable_size_;
}
V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
void set_max_executable_size(int limit_in_mb)) {
max_executable_size_ = limit_in_mb;
}
uint32_t* stack_limit() const { return stack_limit_; }
Expand Down Expand Up @@ -6011,6 +6023,8 @@ enum GCType {
* - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called
* in a phase where V8 is trying to collect all available garbage
* (e.g., handling a low memory notification).
* - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to
* trigger an idle garbage collection.
*/
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
Expand All @@ -6019,6 +6033,7 @@ enum GCCallbackFlags {
kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
kGCCallbackFlagCollectAllExternalMemory = 1 << 5,
kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
};

typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
Expand Down
101 changes: 50 additions & 51 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) {
i::V8::SetSnapshotBlob(snapshot_blob);
}

void* v8::ArrayBuffer::Allocator::Reserve(size_t length) { UNIMPLEMENTED(); }

void v8::ArrayBuffer::Allocator::Free(void* data, size_t length,
AllocationMode mode) {
UNIMPLEMENTED();
}

void v8::ArrayBuffer::Allocator::SetProtection(
void* data, size_t length,
v8::ArrayBuffer::Allocator::Protection protection) {
UNIMPLEMENTED();
}

namespace {

class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
Expand Down Expand Up @@ -798,7 +811,6 @@ Extension::Extension(const char* name,
ResourceConstraints::ResourceConstraints()
: max_semi_space_size_(0),
max_old_space_size_(0),
max_executable_size_(0),
stack_limit_(NULL),
code_range_size_(0),
max_zone_pool_size_(0) {}
Expand All @@ -820,24 +832,20 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
if (physical_memory <= low_limit) {
set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice);
set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice);
set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice);
set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSizeLowMemoryDevice);
} else if (physical_memory <= medium_limit) {
set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice);
set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice);
set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice);
set_max_zone_pool_size(
i::AccountingAllocator::kMaxPoolSizeMediumMemoryDevice);
} else if (physical_memory <= high_limit) {
set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice);
set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice);
set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice);
set_max_zone_pool_size(
i::AccountingAllocator::kMaxPoolSizeHighMemoryDevice);
} else {
set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice);
set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice);
set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice);
set_max_zone_pool_size(
i::AccountingAllocator::kMaxPoolSizeHugeMemoryDevice);
}
Expand All @@ -856,13 +864,11 @@ void SetResourceConstraints(i::Isolate* isolate,
const ResourceConstraints& constraints) {
int semi_space_size = constraints.max_semi_space_size();
int old_space_size = constraints.max_old_space_size();
int max_executable_size = constraints.max_executable_size();
size_t code_range_size = constraints.code_range_size();
size_t max_pool_size = constraints.max_zone_pool_size();
if (semi_space_size != 0 || old_space_size != 0 ||
max_executable_size != 0 || code_range_size != 0) {
if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) {
isolate->heap()->ConfigureHeap(semi_space_size, old_space_size,
max_executable_size, code_range_size);
0 /*max_executable_size*/, code_range_size);
}
isolate->allocator()->ConfigureSegmentPool(max_pool_size);

Expand Down Expand Up @@ -4443,12 +4449,11 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) {
.FromMaybe(static_cast<PropertyAttribute>(i::NONE));
}


MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
Local<String> key) {
Local<Name> key) {
PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyDescriptor, Value);
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
i::Handle<i::String> key_name = Utils::OpenHandle(*key);
i::Handle<i::Name> key_name = Utils::OpenHandle(*key);

i::PropertyDescriptor desc;
Maybe<bool> found =
Expand All @@ -4461,8 +4466,7 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
RETURN_ESCAPED(Utils::ToLocal(desc.ToObject(isolate)));
}


Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) {
Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<Name> key) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value);
}
Expand Down Expand Up @@ -8940,17 +8944,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that,
return true;
}

void Debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}

void Debug::DebugBreak(Isolate* isolate) { debug::DebugBreak(isolate); }

void Debug::CancelDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
debug::CancelDebugBreak(isolate);
}


bool Debug::CheckDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
return internal_isolate->stack_guard()->CheckDebugBreak();
Expand All @@ -8965,29 +8964,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length,
MaybeLocal<Value> Debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj),
&result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
return debug::Call(context, fun, data);
}


void Debug::ProcessDebugMessages(Isolate* isolate) {}

Local<Context> Debug::GetDebugContext(Isolate* isolate) {
return debug::GetDebugContext(isolate);
}


MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8(i_isolate);
Expand All @@ -8998,8 +8983,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
}

void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
debug::SetLiveEditEnabled(isolate, enable);
}

bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) {
Expand All @@ -9014,13 +8998,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) {

MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
return debug::GetInternalProperties(v8_isolate, value);
}

Local<Context> debug::GetDebugContext(Isolate* isolate) {
Expand All @@ -9032,22 +9010,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) {
MaybeLocal<Value> debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
return Debug::Call(context, fun, data);
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception = !ToLocal<Value>(
isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}

void debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
Debug::SetLiveEditEnabled(isolate, enable);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
}

void debug::DebugBreak(Isolate* isolate) { Debug::DebugBreak(isolate); }
void debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}

void debug::CancelDebugBreak(Isolate* isolate) {
Debug::CancelDebugBreak(isolate);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
}

MaybeLocal<Array> debug::GetInternalProperties(Isolate* isolate,
MaybeLocal<Array> debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
return Debug::GetInternalProperties(isolate, value);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
}

void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {
Expand Down
1 change: 0 additions & 1 deletion deps/v8/src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
"of their absolute value.")
DEFINE_INT(max_old_space_size, 0, "max size of the old space (in Mbytes)")
DEFINE_INT(initial_old_space_size, 0, "initial old space size (in Mbytes)")
DEFINE_INT(max_executable_size, 0, "max size of executable memory (in Mbytes)")
DEFINE_BOOL(gc_global, false, "always perform global GCs")
DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
DEFINE_INT(retain_maps_for_n_gc, 2,
Expand Down
Loading