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

Patch V8 API to be ABI compatible with v5.9. #12878

Closed
wants to merge 1 commit 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
5 changes: 0 additions & 5 deletions deps/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,6 @@ v8_source_set("v8_base") {

### gcmole(all) ###
"include/v8-debug.h",
"include/v8-experimental.h",
"include/v8-platform.h",
"include/v8-profiler.h",
"include/v8-testing.h",
Expand All @@ -905,8 +904,6 @@ v8_source_set("v8_base") {
"src/api-arguments-inl.h",
"src/api-arguments.cc",
"src/api-arguments.h",
"src/api-experimental.cc",
"src/api-experimental.h",
"src/api-natives.cc",
"src/api-natives.h",
"src/api.cc",
Expand Down Expand Up @@ -1386,8 +1383,6 @@ v8_source_set("v8_base") {
"src/external-reference-table.h",
"src/factory.cc",
"src/factory.h",
"src/fast-accessor-assembler.cc",
"src/fast-accessor-assembler.h",
"src/fast-dtoa.cc",
"src/fast-dtoa.h",
"src/feedback-vector-inl.h",
Expand Down
5 changes: 4 additions & 1 deletion deps/v8/include/libplatform/libplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace v8 {
namespace platform {

enum class IdleTaskSupport { kDisabled, kEnabled };

/**
* Returns a new instance of the default v8::Platform implementation.
*
Expand All @@ -21,7 +23,8 @@ namespace platform {
* processors online will be chosen.
*/
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0);
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled);

/**
* Pumps the message loop for the given isolate.
Expand Down
58 changes: 0 additions & 58 deletions deps/v8/include/v8-experimental.h

This file was deleted.

5 changes: 0 additions & 5 deletions deps/v8/include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,6 @@ class V8_EXPORT HeapProfiler {
/** Returns memory used for profiler internal data and snapshots. */
size_t GetProfilerMemorySize();

/**
* Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId).
*/
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);

private:
HeapProfiler();
~HeapProfiler();
Expand Down
159 changes: 19 additions & 140 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ template<class V, class T> class PersistentValueVector;
template<class T, class P> class WeakCallbackObject;
class FunctionTemplate;
class ObjectTemplate;
class Data;
template<typename T> class FunctionCallbackInfo;
template<typename T> class PropertyCallbackInfo;
class StackTrace;
Expand All @@ -137,10 +136,6 @@ class CallHandlerHelper;
class EscapableHandleScope;
template<typename T> class ReturnValue;

namespace experimental {
class FastAccessorBuilder;
} // namespace experimental

namespace internal {
class Arguments;
class Heap;
Expand All @@ -155,30 +150,6 @@ class GlobalHandles;
} // namespace internal


/**
* General purpose unique identifier.
*/
class UniqueId {
public:
explicit UniqueId(intptr_t data)
: data_(data) {}

bool operator==(const UniqueId& other) const {
return data_ == other.data_;
}

bool operator!=(const UniqueId& other) const {
return data_ != other.data_;
}

bool operator<(const UniqueId& other) const {
return data_ < other.data_;
}

private:
intptr_t data_;
};

// --- Handles ---

#define TYPE_CHECK(T, S) \
Expand Down Expand Up @@ -388,19 +359,18 @@ class MaybeLocal {
// Eternal handles are set-once handles that live for the life of the isolate.
template <class T> class Eternal {
public:
V8_INLINE Eternal() : index_(kInitialValue) { }
template<class S>
V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
V8_INLINE Eternal() : val_(nullptr) {}
template <class S>
V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) {
Set(isolate, handle);
}
// Can only be safely called if already set.
V8_INLINE Local<T> Get(Isolate* isolate);
V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
V8_INLINE Local<T> Get(Isolate* isolate) const;
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);

private:
static const int kInitialValue = -1;
int index_;
T* val_;
};


Expand Down Expand Up @@ -1922,7 +1892,7 @@ class V8_EXPORT NativeWeakMap : public Data {
public:
static Local<NativeWeakMap> New(Isolate* isolate);
void Set(Local<Value> key, Local<Value> value);
Local<Value> Get(Local<Value> key);
Local<Value> Get(Local<Value> key) const;
bool Has(Local<Value> key);
bool Delete(Local<Value> key);
};
Expand Down Expand Up @@ -5122,16 +5092,6 @@ class V8_EXPORT FunctionTemplate : public Template {
static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
size_t index);

/**
* Creates a function template with a fast handler. If a fast handler is set,
* the callback cannot be null.
*/
static Local<FunctionTemplate> NewWithFastHandler(
Isolate* isolate, FunctionCallback callback,
experimental::FastAccessorBuilder* fast_handler = nullptr,
Local<Value> data = Local<Value>(),
Local<Signature> signature = Local<Signature>(), int length = 0);

/**
* Creates a function template backed/cached by a private property.
*/
Expand Down Expand Up @@ -5159,9 +5119,8 @@ class V8_EXPORT FunctionTemplate : public Template {
* callback is called whenever the function created from this
* FunctionTemplate is called.
*/
void SetCallHandler(
FunctionCallback callback, Local<Value> data = Local<Value>(),
experimental::FastAccessorBuilder* fast_handler = nullptr);
void SetCallHandler(FunctionCallback callback,
Local<Value> data = Local<Value>());

/** Set the predefined length property for the FunctionTemplate. */
void SetLength(int length);
Expand Down Expand Up @@ -6824,45 +6783,6 @@ class V8_EXPORT Isolate {
*/
Local<Value> ThrowException(Local<Value> exception);

/**
* Allows the host application to group objects together. If one
* object in the group is alive, all objects in the group are alive.
* After each garbage collection, object groups are removed. It is
* intended to be used in the before-garbage-collection callback
* function, for instance to simulate DOM tree connections among JS
* wrapper objects. Object groups for all dependent handles need to
* be provided for kGCTypeMarkSweepCompact collections, for all other
* garbage collection types it is sufficient to provide object groups
* for partially dependent handles only.
*/
template <typename T>
V8_DEPRECATED("Use EmbedderHeapTracer",
void SetObjectGroupId(const Persistent<T>& object,
UniqueId id));

/**
* Allows the host application to declare implicit references from an object
* group to an object. If the objects of the object group are alive, the child
* object is alive too. After each garbage collection, all implicit references
* are removed. It is intended to be used in the before-garbage-collection
* callback function.
*/
template <typename T>
V8_DEPRECATED("Use EmbedderHeapTracer",
void SetReferenceFromGroup(UniqueId id,
const Persistent<T>& child));

/**
* Allows the host application to declare implicit references from an object
* to another object. If the parent object is alive, the child object is alive
* too. After each garbage collection, all implicit references are removed. It
* is intended to be used in the before-garbage-collection callback function.
*/
template <typename T, typename S>
V8_DEPRECATED("Use EmbedderHeapTracer",
void SetReference(const Persistent<T>& parent,
const Persistent<S>& child));

typedef void (*GCCallback)(Isolate* isolate, GCType type,
GCCallbackFlags flags);

Expand Down Expand Up @@ -7223,16 +7143,6 @@ class V8_EXPORT Isolate {
void SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback callback);

/**
* Set the callback to invoke to check if wasm compilation from
* the specified object is allowed. By default, wasm compilation
* is allowed.
*
* Similar for instantiate.
*/
void SetAllowWasmCompileCallback(AllowWasmCompileCallback callback);
void SetAllowWasmInstantiateCallback(AllowWasmInstantiateCallback callback);

/**
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
Expand Down Expand Up @@ -7328,9 +7238,6 @@ class V8_EXPORT Isolate {
template <class K, class V, class Traits>
friend class PersistentValueMapBase;

void SetObjectGroupId(internal::Object** object, UniqueId id);
void SetReferenceFromGroup(UniqueId id, internal::Object** object);
void SetReference(internal::Object** parent, internal::Object** child);
void ReportExternalAllocationLimitReached();
};

Expand Down Expand Up @@ -7709,10 +7616,7 @@ class V8_EXPORT V8 {
WeakCallbackInfo<void>::Callback weak_callback);
static void MakeWeak(internal::Object*** location_addr);
static void* ClearWeak(internal::Object** location);
static void Eternalize(Isolate* isolate,
Value* handle,
int* index);
static Local<Value> GetEternal(Isolate* isolate, int index);
static Value* Eternalize(Isolate* isolate, Value* handle);

static void RegisterExternallyReferencedObject(internal::Object** object,
internal::Isolate* isolate);
Expand Down Expand Up @@ -8531,8 +8435,8 @@ class Internals {
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsActiveShift = 4;

static const int kJSApiObjectType = 0xb9;
static const int kJSObjectType = 0xba;
static const int kJSApiObjectType = 0xbb;
static const int kJSObjectType = 0xbc;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x82;
static const int kForeignType = 0x86;
Expand Down Expand Up @@ -8677,13 +8581,15 @@ template<class T>
template<class S>
void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
TYPE_CHECK(T, S);
V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
val_ = reinterpret_cast<T*>(
V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
}


template<class T>
Local<T> Eternal<T>::Get(Isolate* isolate) {
return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
template <class T>
Local<T> Eternal<T>::Get(Isolate* isolate) const {
// The eternal handle will never go away, so as with the roots, we don't even
// need to open a handle.
return Local<T>(val_);
}


Expand Down Expand Up @@ -9740,33 +9646,6 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
return *external_memory;
}


template<typename T>
void Isolate::SetObjectGroupId(const Persistent<T>& object,
UniqueId id) {
TYPE_CHECK(Value, T);
SetObjectGroupId(reinterpret_cast<internal::Object**>(object.val_), id);
}


template<typename T>
void Isolate::SetReferenceFromGroup(UniqueId id,
const Persistent<T>& object) {
TYPE_CHECK(Value, T);
SetReferenceFromGroup(id, reinterpret_cast<internal::Object**>(object.val_));
}


template<typename T, typename S>
void Isolate::SetReference(const Persistent<T>& parent,
const Persistent<S>& child) {
TYPE_CHECK(Object, T);
TYPE_CHECK(Value, S);
SetReference(reinterpret_cast<internal::Object**>(parent.val_),
reinterpret_cast<internal::Object**>(child.val_));
}


Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
Expand Down
Loading