Skip to content

Commit

Permalink
Update v8 version to 12.3.219.14 (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeirShpilraien authored Mar 28, 2024
1 parent daa1e3f commit d74c8b2
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "v8_rs"
version = "0.2.8"
version = "0.2.9"
edition = "2021"
license = "Redis Source Available License 2.0 (RSALv2) or the Server Side Public License v1 (SSPLv1)"

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lazy_static::lazy_static! {

static ref PROFILE: String = env::var("PROFILE").expect("PROFILE env var was not given");

static ref V8_DEFAULT_VERSION: &'static str = "12.2.281.21";
static ref V8_DEFAULT_VERSION: &'static str = "12.3.219.14";
static ref V8_VERSION: String = env::var("V8_VERSION").map(|v| if v == "default" {V8_DEFAULT_VERSION.to_string()} else {v}).unwrap_or(V8_DEFAULT_VERSION.to_string());
static ref V8_HEADERS_PATH: String = env::var("V8_HEADERS_PATH").unwrap_or("v8_c_api/libv8.include.zip".into());
static ref V8_HEADERS_URL: String = env::var("V8_HEADERS_URL").unwrap_or(format!("http://redismodules.s3.amazonaws.com/redisgears/dependencies/libv8.{}.include.zip", *V8_VERSION));
Expand Down
2 changes: 1 addition & 1 deletion v8_c_api/src/v8include/cppgc/internal/api-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};

static constexpr size_t kPageSize = size_t{1} << 17;

#if defined(V8_TARGET_ARCH_ARM64) && defined(V8_OS_DARWIN)
#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_DARWIN)
constexpr size_t kGuardPageSize = 0;
#else
constexpr size_t kGuardPageSize = 4096;
Expand Down
6 changes: 6 additions & 0 deletions v8_c_api/src/v8include/v8-array-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ class V8_EXPORT ArrayBuffer : public Object {
*/
std::shared_ptr<BackingStore> GetBackingStore();

/**
* More efficient shortcut for
* GetBackingStore()->IsResizableByUserJavaScript().
*/
bool IsResizableByUserJavaScript() const;

/**
* More efficient shortcut for GetBackingStore()->Data(). The returned pointer
* is valid as long as the ArrayBuffer is alive.
Expand Down
18 changes: 6 additions & 12 deletions v8_c_api/src/v8include/v8-callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ using WasmAsyncResolvePromiseCallback = void (*)(
using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
const char* name);

// --- Callback for checking if WebAssembly GC is enabled ---
// If the callback returns true, it will also enable Wasm stringrefs.
using WasmGCEnabledCallback = bool (*)(Local<Context> context);

// --- Callback for checking if WebAssembly imported strings are enabled ---
using WasmImportedStringsEnabledCallback = bool (*)(Local<Context> context);

Expand All @@ -342,6 +338,9 @@ using SharedArrayBufferConstructorEnabledCallback =
using JavaScriptCompileHintsMagicEnabledCallback =
bool (*)(Local<Context> context);

// --- Callback for checking if WebAssembly JSPI is enabled ---
using WasmJSPIEnabledCallback = bool (*)(Local<Context> context);

/**
* HostImportModuleDynamicallyCallback is called when we
* require the embedder to load a module. This is used as part of the dynamic
Expand All @@ -352,11 +351,11 @@ using JavaScriptCompileHintsMagicEnabledCallback =
*
* The specifier is the name of the module that should be imported.
*
* The import_assertions are import assertions for this request in the form:
* The import_attributes are import attributes for this request in the form:
* [key1, value1, key2, value2, ...] where the keys and values are of type
* v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
* returned from ModuleRequest::GetImportAssertions(), this array does not
* contain the source Locations of the assertions.
* contain the source Locations of the attributes.
*
* The embedder must compile, instantiate, evaluate the Module, and
* obtain its namespace object.
Expand All @@ -368,15 +367,10 @@ using JavaScriptCompileHintsMagicEnabledCallback =
* fails (e.g. due to stack overflow), the embedder must propagate
* that exception by returning an empty MaybeLocal.
*/
using HostImportModuleDynamicallyWithImportAssertionsCallback =
MaybeLocal<Promise> (*)(Local<Context> context,
Local<ScriptOrModule> referrer,
Local<String> specifier,
Local<FixedArray> import_assertions);
using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
Local<Context> context, Local<Data> host_defined_options,
Local<Value> resource_name, Local<String> specifier,
Local<FixedArray> import_assertions);
Local<FixedArray> import_attributes);

/**
* Callback for requesting a compile hint for a function from the embedder. The
Expand Down
6 changes: 3 additions & 3 deletions v8_c_api/src/v8include/v8-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,12 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {

template <class T>
MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
auto slot = GetDataFromSnapshotOnce(index);
if (slot) {
if (auto slot = GetDataFromSnapshotOnce(index); slot) {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<T, false>(slot));
return Local<T>::FromSlot(slot);
}
return Local<T>::FromSlot(slot);
return {};
}

Context* Context::Cast(v8::Data* data) {
Expand Down
1 change: 1 addition & 0 deletions v8_c_api/src/v8include/v8-forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Context;
class DataView;
class Data;
class Date;
class DictionaryTemplate;
class Extension;
class External;
class FixedArray;
Expand Down
3 changes: 2 additions & 1 deletion v8_c_api/src/v8include/v8-function-callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ Local<Value> ReturnValue<T>::Get() const {
#endif // V8_STATIC_ROOTS_BOOL
return Undefined(GetIsolate());
}
return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
return Local<Value>::New(GetIsolate(),
internal::ValueHelper::SlotAsValue<Value>(value_));
}

template <typename T>
Expand Down
4 changes: 0 additions & 4 deletions v8_c_api/src/v8include/v8-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@ constexpr bool kAllCodeObjectsLiveInTrustedSpace =
kRuntimeGeneratedCodeObjectsLiveInTrustedSpace &&
kBuiltinCodeObjectsLiveInTrustedSpace;

constexpr bool kInterpreterDataObjectsLiveInTrustedSpace = false;

// {obj} must be the raw tagged pointer representation of a HeapObject
// that's guaranteed to never be in ReadOnlySpace.
V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj);
Expand Down Expand Up @@ -781,8 +779,6 @@ class Internals {
static const int kNodeStateMask = 0x3;
static const int kNodeStateIsWeakValue = 2;

static const int kTracedNodeClassIdOffset = kApiSystemPointerSize;

static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0xcc;
Expand Down
15 changes: 5 additions & 10 deletions v8_c_api/src/v8include/v8-isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1579,19 +1579,14 @@ class V8_EXPORT Isolate {

void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);

/**
* Register callback to control whether Wasm GC is enabled.
* The callback overwrites the value of the flag.
* If the callback returns true, it will also enable Wasm stringrefs.
*/
void SetWasmGCEnabledCallback(WasmGCEnabledCallback callback);

void SetWasmImportedStringsEnabledCallback(
WasmImportedStringsEnabledCallback callback);

void SetSharedArrayBufferConstructorEnabledCallback(
SharedArrayBufferConstructorEnabledCallback callback);

void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);

/**
* Register callback to control whether compile hints magic comments are
* enabled.
Expand Down Expand Up @@ -1751,12 +1746,12 @@ uint32_t Isolate::GetNumberOfDataSlots() {

template <class T>
MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
auto slot = GetDataFromSnapshotOnce(index);
if (slot) {
if (auto slot = GetDataFromSnapshotOnce(index); slot) {
internal::PerformCastCheck(
internal::ValueHelper::SlotAsValue<T, false>(slot));
return Local<T>::FromSlot(slot);
}
return Local<T>::FromSlot(slot);
return {};
}

} // namespace v8
Expand Down
3 changes: 3 additions & 0 deletions v8_c_api/src/v8include/v8-local-handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ReturnValue;
class String;
template <class F>
class Traced;
class TypecheckWitness;
class Utils;

namespace debug {
Expand Down Expand Up @@ -405,6 +406,8 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
}

#ifdef V8_ENABLE_DIRECT_LOCAL
friend class TypecheckWitness;

V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
return Local<T>(LocalBase<T>(ptr));
}
Expand Down
13 changes: 9 additions & 4 deletions v8_c_api/src/v8include/v8-script.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,24 @@ class V8_EXPORT ModuleRequest : public Data {
int GetSourceOffset() const;

/**
* Contains the import assertions for this request in the form:
* Contains the import attributes for this request in the form:
* [key1, value1, source_offset1, key2, value2, source_offset2, ...].
* The keys and values are of type v8::String, and the source offsets are of
* type Int32. Use Module::SourceOffsetToLocation to convert the source
* offsets to Locations with line/column numbers.
*
* All assertions present in the module request will be supplied in this
* All attributes present in the module request will be supplied in this
* list, regardless of whether they are supported by the host. Per
* https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes,
* hosts are expected to throw for assertions that they do not support (as
* hosts are expected to throw for attributes that they do not support (as
* opposed to, for example, ignoring them).
*/
Local<FixedArray> GetImportAssertions() const;
Local<FixedArray> GetImportAttributes() const;

V8_DEPRECATE_SOON("Use GetImportAttributes instead")
Local<FixedArray> GetImportAssertions() const {
return GetImportAttributes();
}

V8_INLINE static ModuleRequest* Cast(Data* data);

Expand Down
7 changes: 6 additions & 1 deletion v8_c_api/src/v8include/v8-snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace v8 {

class Object;

namespace internal {
class SnapshotCreatorImpl;
} // namespace internal

class V8_EXPORT StartupData {
public:
/**
Expand Down Expand Up @@ -206,7 +210,8 @@ class V8_EXPORT SnapshotCreator {
size_t AddData(Local<Context> context, internal::Address object);
size_t AddData(internal::Address object);

void* data_;
internal::SnapshotCreatorImpl* impl_;
friend class internal::SnapshotCreatorImpl;
};

template <class T>
Expand Down
51 changes: 50 additions & 1 deletion v8_c_api/src/v8include/v8-template.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#ifndef INCLUDE_V8_TEMPLATE_H_
#define INCLUDE_V8_TEMPLATE_H_

#include <cstddef>
#include <string_view>

#include "v8-data.h" // NOLINT(build/include_directory)
#include "v8-function-callback.h" // NOLINT(build/include_directory)
#include "v8-local-handle.h" // NOLINT(build/include_directory)
Expand Down Expand Up @@ -778,7 +781,11 @@ class V8_EXPORT ObjectTemplate : public Template {
Isolate* isolate,
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());

/** Creates a new instance of this template.*/
/**
* Creates a new instance of this template.
*
* \param context The context in which the instance is created.
*/
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);

/**
Expand Down Expand Up @@ -950,6 +957,41 @@ class V8_EXPORT ObjectTemplate : public Template {
friend class FunctionTemplate;
};

/**
* A template to create dictionary objects at runtime.
*/
class V8_EXPORT DictionaryTemplate final {
public:
/** Creates a new template. Also declares data properties that can be passed
* on instantiation of the template. Properties can only be declared on
* construction and are then immutable. The values are passed on creating the
* object via `NewInstance()`.
*
* \param names the keys that can be passed on instantiation.
*/
static Local<DictionaryTemplate> New(
Isolate* isolate, MemorySpan<const std::string_view> names);

/**
* Creates a new instance of this template.
*
* \param context The context used to create the dictionary object.
* \param property_values Values of properties that were declared using
* `DeclareDataProperties()`. The span only passes values and expectes the
* order to match the declaration. Non-existent properties are signaled via
* empty `MaybeLocal`s.
*/
V8_WARN_UNUSED_RESULT Local<Object> NewInstance(
Local<Context> context, MemorySpan<MaybeLocal<Value>> property_values);

V8_INLINE static DictionaryTemplate* Cast(Data* data);

private:
static void CheckCast(Data* that);

DictionaryTemplate();
};

/**
* A Signature specifies which receiver is valid for a function.
*
Expand Down Expand Up @@ -995,6 +1037,13 @@ ObjectTemplate* ObjectTemplate::Cast(Data* data) {
return reinterpret_cast<ObjectTemplate*>(data);
}

DictionaryTemplate* DictionaryTemplate::Cast(Data* data) {
#ifdef V8_ENABLE_CHECKS
CheckCast(data);
#endif
return reinterpret_cast<DictionaryTemplate*>(data);
}

Signature* Signature::Cast(Data* data) {
#ifdef V8_ENABLE_CHECKS
CheckCast(data);
Expand Down
29 changes: 0 additions & 29 deletions v8_c_api/src/v8include/v8-traced-handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase {
return this->GetSlotThreadSafe() == nullptr;
}

/**
* Assigns a wrapper class ID to the handle.
*/
V8_DEPRECATED("Embedders need to maintain state for references themselves.")
V8_INLINE void SetWrapperClassId(uint16_t class_id);

/**
* Returns the class ID previously assigned to this handle or 0 if no class ID
* was previously assigned.
*/
V8_DEPRECATED("Embedders need to maintain state for references themselves.")
V8_INLINE uint16_t WrapperClassId() const;

protected:
V8_INLINE TracedReferenceBase() = default;

Expand Down Expand Up @@ -440,22 +427,6 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
return *this;
}

void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
using I = internal::Internals;
if (IsEmpty()) return;
uint8_t* addr =
reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
*reinterpret_cast<uint16_t*>(addr) = class_id;
}

uint16_t TracedReferenceBase::WrapperClassId() const {
using I = internal::Internals;
if (IsEmpty()) return 0;
uint8_t* addr =
reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr);
}

} // namespace v8

#endif // INCLUDE_V8_TRACED_HANDLE_H_
Loading

0 comments on commit d74c8b2

Please sign in to comment.