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

Auto update version to 12.4.254.15 #111

Merged
merged 1 commit into from
May 1, 2024
Merged
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
2 changes: 1 addition & 1 deletion V8_DEFAULT_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.3.219.15
12.4.254.15
90 changes: 48 additions & 42 deletions v8_c_api/src/v8include/v8-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,39 @@ class V8_EXPORT Context : public Data {
* created by a previous call to Context::New with the same global
* template. The state of the global object will be completely reset
* and only object identify will remain.
*
* \param internal_fields_deserializer An optional callback used
* to deserialize fields set by
* v8::Object::SetAlignedPointerInInternalField() in wrapper objects
* from the default context snapshot. It should match the
* SerializeInternalFieldsCallback() used by
* v8::SnapshotCreator::SetDefaultContext() when the default context
* snapshot is created. It does not need to be configured if the default
* context snapshot contains no wrapper objects with pointer internal
* fields, or if no custom startup snapshot is configured
* in the v8::CreateParams used to create the isolate.
*
* \param microtask_queue An optional microtask queue used to manage
* the microtasks created in this context. If not set the per-isolate
* default microtask queue would be used.
*
* \param context_data_deserializer An optional callback used
* to deserialize embedder data set by
* v8::Context::SetAlignedPointerInEmbedderData() in the default
* context from the default context snapshot. It does not need to be
* configured if the default context snapshot contains no pointer embedder
* data, or if no custom startup snapshot is configured in the
* v8::CreateParams used to create the isolate.
*/
static Local<Context> New(
Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
DeserializeInternalFieldsCallback internal_fields_deserializer =
DeserializeInternalFieldsCallback(),
MicrotaskQueue* microtask_queue = nullptr);
MicrotaskQueue* microtask_queue = nullptr,
DeserializeContextDataCallback context_data_deserializer =
DeserializeContextDataCallback());

/**
* Create a new context from a (non-default) context snapshot. There
Expand All @@ -103,21 +128,37 @@ class V8_EXPORT Context : public Data {
* \param context_snapshot_index The index of the context snapshot to
* deserialize from. Use v8::Context::New for the default snapshot.
*
* \param embedder_fields_deserializer Optional callback to deserialize
* internal fields. It should match the SerializeInternalFieldCallback used
* to serialize.
* \param internal_fields_deserializer An optional callback used
* to deserialize fields set by
* v8::Object::SetAlignedPointerInInternalField() in wrapper objects
* from the default context snapshot. It does not need to be
* configured if there are no wrapper objects with no internal
* pointer fields in the default context snapshot or if no startup
* snapshot is configured when the isolate is created.
*
* \param extensions See v8::Context::New.
*
* \param global_object See v8::Context::New.
*
* \param internal_fields_deserializer Similar to
* internal_fields_deserializer in v8::Context::New but applies to
* the context specified by the context_snapshot_index.
*
* \param microtask_queue See v8::Context::New.
*
* \param context_data_deserializer Similar to
* context_data_deserializer in v8::Context::New but applies to
* the context specified by the context_snapshot_index.
*/
static MaybeLocal<Context> FromSnapshot(
Isolate* isolate, size_t context_snapshot_index,
DeserializeInternalFieldsCallback embedder_fields_deserializer =
DeserializeInternalFieldsCallback internal_fields_deserializer =
DeserializeInternalFieldsCallback(),
ExtensionConfiguration* extensions = nullptr,
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
MicrotaskQueue* microtask_queue = nullptr);
MicrotaskQueue* microtask_queue = nullptr,
DeserializeContextDataCallback context_data_deserializer =
DeserializeContextDataCallback());

/**
* Returns an global object that isn't backed by an actual context.
Expand Down Expand Up @@ -181,27 +222,8 @@ class V8_EXPORT Context : public Data {
* also be considered for freezing should be added to the children_out
* parameter. Returns true if the operation completed successfully.
*/
V8_DEPRECATED("Please use the version that takes a LocalVector&")
virtual bool FreezeEmbedderObjectAndGetChildren(
Local<Object> obj, std::vector<Local<Object>>& children_out) {
// TODO(chromium:1454114): This method is temporarily defined in order to
// smoothen the transition to the version that follows.
return true;
}
virtual bool FreezeEmbedderObjectAndGetChildren(
Local<Object> obj, LocalVector<Object>& children_out) {
// TODO(chromium:1454114): This method is temporarily defined and
// calls the previous version, soon to be deprecated, in order to
// smoothen the transition. When deprecation is completed, this
// will become an abstract method.
std::vector<Local<Object>> children;
START_ALLOW_USE_DEPRECATED()
// Temporarily use the old callback.
bool result = FreezeEmbedderObjectAndGetChildren(obj, children);
END_ALLOW_USE_DEPRECATED()
children_out.insert(children_out.end(), children.begin(), children.end());
return result;
}
Local<Object> obj, LocalVector<Object>& children_out) = 0;
};

/**
Expand Down Expand Up @@ -328,22 +350,6 @@ class V8_EXPORT Context : public Data {
Local<Context> context);
void SetAbortScriptExecution(AbortScriptExecutionCallback callback);

/**
* Returns the value that was set or restored by
* SetContinuationPreservedEmbedderData(), if any.
*/
V8_DEPRECATE_SOON(
"Use v8::Isolate::GetContinuationPreservedEmbedderData instead")
Local<Value> GetContinuationPreservedEmbedderData() const;

/**
* Sets a value that will be stored on continuations and reset while the
* continuation runs.
*/
V8_DEPRECATE_SOON(
"Use v8::Isolate::SetContinuationPreservedEmbedderData instead")
void SetContinuationPreservedEmbedderData(Local<Value> context);

/**
* Set or clear hooks to be invoked for promise lifecycle operations.
* To clear a hook, set it to an empty v8::Function. Each function will
Expand Down
83 changes: 52 additions & 31 deletions v8_c_api/src/v8include/v8-function-callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ class ReturnValue {
friend class PropertyCallbackInfo;
template <class F, class G, class H>
friend class PersistentValueMapBase;
V8_INLINE void SetInternal(internal::Address value) { *value_ = value; }
V8_INLINE internal::Address GetDefaultValue();
V8_INLINE void SetInternal(internal::Address value);
// Setting the hole value has different meanings depending on the usage:
// - for function template callbacks it means that the callback returns
// the undefined value,
// - for property getter callbacks is means that the callback returns
// the undefined value (for property setter callbacks the value returned
// is ignored),
// - for interceptor callbacks it means that the request was not handled.
V8_INLINE void SetTheHole();
V8_INLINE explicit ReturnValue(internal::Address* slot);

// See FunctionCallbackInfo.
Expand Down Expand Up @@ -286,14 +293,28 @@ using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
template <typename T>
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}

template <typename T>
void ReturnValue<T>::SetInternal(internal::Address value) {
#if V8_STATIC_ROOTS_BOOL
using I = internal::Internals;
// Ensure that the upper 32-bits are not modified. Compiler should be
// able to optimize this to a store of a lower 32-bits of the value.
// This is fine since the callback can return only JavaScript values which
// are either Smis or heap objects allocated in the main cage.
*value_ = I::DecompressTaggedField(*value_, I::CompressTagged(value));
#else
*value_ = value;
#endif // V8_STATIC_ROOTS_BOOL
}

template <typename T>
template <typename S>
void ReturnValue<T>::Set(const Global<S>& handle) {
static_assert(std::is_base_of<T, S>::value, "type check");
if (V8_UNLIKELY(handle.IsEmpty())) {
*value_ = GetDefaultValue();
SetTheHole();
} else {
*value_ = handle.ptr();
SetInternal(handle.ptr());
}
}

Expand All @@ -304,17 +325,17 @@ void ReturnValue<T>::SetNonEmpty(const Global<S>& handle) {
#ifdef V8_ENABLE_CHECKS
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
#endif // V8_ENABLE_CHECKS
*value_ = handle.ptr();
SetInternal(handle.ptr());
}

template <typename T>
template <typename S>
void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
static_assert(std::is_base_of<T, S>::value, "type check");
if (V8_UNLIKELY(handle.IsEmpty())) {
*value_ = GetDefaultValue();
SetTheHole();
} else {
*value_ = handle.ptr();
SetInternal(handle.ptr());
}
}

Expand All @@ -325,7 +346,7 @@ void ReturnValue<T>::SetNonEmpty(const BasicTracedReference<S>& handle) {
#ifdef V8_ENABLE_CHECKS
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
#endif // V8_ENABLE_CHECKS
*value_ = handle.ptr();
SetInternal(handle.ptr());
}

template <typename T>
Expand All @@ -334,9 +355,9 @@ void ReturnValue<T>::Set(const Local<S> handle) {
static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
"type check");
if (V8_UNLIKELY(handle.IsEmpty())) {
*value_ = GetDefaultValue();
SetTheHole();
} else {
*value_ = handle.ptr();
SetInternal(handle.ptr());
}
}

Expand All @@ -348,24 +369,24 @@ void ReturnValue<T>::SetNonEmpty(const Local<S> handle) {
#ifdef V8_ENABLE_CHECKS
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
#endif // V8_ENABLE_CHECKS
*value_ = handle.ptr();
SetInternal(handle.ptr());
}

template <typename T>
void ReturnValue<T>::Set(double i) {
static_assert(std::is_base_of<T, Number>::value, "type check");
Set(Number::New(GetIsolate(), i));
SetNonEmpty(Number::New(GetIsolate(), i));
}

template <typename T>
void ReturnValue<T>::Set(int32_t i) {
static_assert(std::is_base_of<T, Integer>::value, "type check");
using I = internal::Internals;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
SetInternal(I::IntToSmi(i));
return;
}
Set(Integer::New(GetIsolate(), i));
SetNonEmpty(Integer::New(GetIsolate(), i));
}

template <typename T>
Expand All @@ -377,7 +398,7 @@ void ReturnValue<T>::Set(uint32_t i) {
Set(static_cast<int32_t>(i));
return;
}
Set(Integer::NewFromUnsigned(GetIsolate(), i));
SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i));
}

template <typename T>
Expand All @@ -386,7 +407,7 @@ void ReturnValue<T>::Set(uint16_t i) {
using I = internal::Internals;
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::min()));
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::max()));
*value_ = I::IntToSmi(i);
SetInternal(I::IntToSmi(i));
}

template <typename T>
Expand All @@ -398,9 +419,8 @@ void ReturnValue<T>::Set(bool value) {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<Value, true>(value_));
#endif // V8_ENABLE_CHECKS
*value_ = I::DecompressTaggedField(
*value_, value ? I::StaticReadOnlyRoot::kTrueValue
: I::StaticReadOnlyRoot::kFalseValue);
SetInternal(value ? I::StaticReadOnlyRoot::kTrueValue
: I::StaticReadOnlyRoot::kFalseValue);
#else
int root_index;
if (value) {
Expand All @@ -412,6 +432,16 @@ void ReturnValue<T>::Set(bool value) {
#endif // V8_STATIC_ROOTS_BOOL
}

template <typename T>
void ReturnValue<T>::SetTheHole() {
using I = internal::Internals;
#if V8_STATIC_ROOTS_BOOL
SetInternal(I::StaticReadOnlyRoot::kTheHoleValue);
#else
*value_ = I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
#endif // V8_STATIC_ROOTS_BOOL
}

template <typename T>
void ReturnValue<T>::SetNull() {
static_assert(std::is_base_of<T, Primitive>::value, "type check");
Expand All @@ -421,8 +451,7 @@ void ReturnValue<T>::SetNull() {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<Value, true>(value_));
#endif // V8_ENABLE_CHECKS
*value_ =
I::DecompressTaggedField(*value_, I::StaticReadOnlyRoot::kNullValue);
SetInternal(I::StaticReadOnlyRoot::kNullValue);
#else
*value_ = I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
#endif // V8_STATIC_ROOTS_BOOL
Expand All @@ -437,8 +466,7 @@ void ReturnValue<T>::SetUndefined() {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<Value, true>(value_));
#endif // V8_ENABLE_CHECKS
*value_ =
I::DecompressTaggedField(*value_, I::StaticReadOnlyRoot::kUndefinedValue);
SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
#else
*value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
#endif // V8_STATIC_ROOTS_BOOL
Expand All @@ -453,8 +481,7 @@ void ReturnValue<T>::SetEmptyString() {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<Value, true>(value_));
#endif // V8_ENABLE_CHECKS
*value_ =
I::DecompressTaggedField(*value_, I::StaticReadOnlyRoot::kEmptyString);
SetInternal(I::StaticReadOnlyRoot::kEmptyString);
#else
*value_ = I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
#endif // V8_STATIC_ROOTS_BOOL
Expand Down Expand Up @@ -485,12 +512,6 @@ void ReturnValue<T>::Set(S* whatever) {
static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
}

template <typename T>
internal::Address ReturnValue<T>::GetDefaultValue() {
using I = internal::Internals;
return I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
}

template <typename T>
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
internal::Address* values,
Expand Down
Loading
Loading