mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 15:04:33 -05:00
Upgrade to V8 12.1.285.6 (#1374)
1. [[exceptions] Unify pending and scheduled exceptions](https://chromium-review.googlesource.com/c/v8/v8/+/5050065) Reset no longer clears exception if it was rethrown. The test had to be adjusted for the same. 2. [[api] Allow passing CppHeap on Isolate creation](https://chromium-review.googlesource.com/c/v8/v8/+/4989254) `AttachCppHeap` was deprecated but the alternative of passing `CppHeap` via Isolate CreateParams hard crashes (SIGSEGV). There are no tests for this in V8 and it seems the [Chromium CL](https://chromium-review.googlesource.com/c/chromium/src/+/4992764) is also crashing. For now I've just suppressed the deprecation warning until the crash is fixed in V8. 3. v8::Serializer impl must not throw more than one exception. I changed `get_shared_buffer_id()` to not throw and return `None`. V8 internally calls data clone error when it's the SAB is not clonable. Other changes: - `v8::ScriptCompiler` size increased by 3 words with `v8::ScriptCompiler::CompilationDetails`. - `v8::ObjectTemplate::SetAccessor` & `v8::ObjectTemplate::SetAccessorProperty` signature changed and also deprecated. - `v8::Context::SetContinuationPreservedEmbedderData` deprecated. Use `v8::Isolate::GetContinuationPreservedEmbedderData` instead. - `GetStalledTopLevelAwaitMessage` deprecated. Use `GetStalledTopLevelAwaitMessages` instead. - `v8::Isolate::AttachCppHeap` deprecated. Set the heap on Isolate creation using CreateParams instead. - `v8::ScriptOrigin` deprecated. Use constructor without the isolate. - `v8::SnapshotCreator` is deprecated. Use the version that passes CreateParams instead. - `v8::Isolate` assertion failures. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
60e0859514
commit
3de68239a5
12 changed files with 137 additions and 145 deletions
|
@ -43,7 +43,6 @@ fn main() {
|
|||
DEFAULT_CPP_GC_EMBEDDER_ID,
|
||||
)),
|
||||
);
|
||||
|
||||
isolate.attach_cpp_heap(&heap);
|
||||
|
||||
let handle_scope = &mut v8::HandleScope::new(isolate);
|
||||
|
|
199
src/binding.cc
199
src/binding.cc
|
@ -7,6 +7,7 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "cppgc/platform.h"
|
||||
#include "support.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "v8-callbacks.h"
|
||||
|
@ -30,8 +31,6 @@
|
|||
#include "v8/src/objects/objects.h"
|
||||
#include "v8/src/objects/smi.h"
|
||||
|
||||
#include "cppgc/platform.h"
|
||||
|
||||
using namespace support;
|
||||
|
||||
template <typename T>
|
||||
|
@ -57,9 +56,15 @@ static_assert(sizeof(v8::PromiseRejectMessage) == sizeof(size_t) * 3,
|
|||
|
||||
static_assert(sizeof(v8::Locker) == sizeof(size_t) * 2, "Locker size mismatch");
|
||||
|
||||
static_assert(sizeof(v8::ScriptCompiler::Source) ==
|
||||
align_to<size_t>(sizeof(size_t) * 9 + sizeof(int) * 2),
|
||||
"Source size mismatch");
|
||||
static_assert(sizeof(v8::ScriptCompiler::CompilationDetails) ==
|
||||
sizeof(size_t) * 3,
|
||||
"CompilationDetails size mismatch");
|
||||
|
||||
static_assert(
|
||||
sizeof(v8::ScriptCompiler::Source) ==
|
||||
align_to<size_t>(sizeof(size_t) * 9 + sizeof(int) * 2 +
|
||||
sizeof(v8::ScriptCompiler::CompilationDetails)),
|
||||
"Source size mismatch");
|
||||
|
||||
static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
|
||||
"FunctionCallbackInfo size mismatch");
|
||||
|
@ -100,8 +105,7 @@ static_assert(offsetof(v8::ScriptCompiler::CachedData, rejected) == 12,
|
|||
"CachedData.rejected offset mismatch");
|
||||
static_assert(offsetof(v8::ScriptCompiler::CachedData, buffer_policy) == 16,
|
||||
"CachedData.buffer_policy offset mismatch");
|
||||
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) ==
|
||||
16,
|
||||
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) == 16,
|
||||
"DisallowJavascriptExecutionScope size mismatch");
|
||||
#else
|
||||
static_assert(sizeof(v8::ScriptCompiler::CachedData) == 16,
|
||||
|
@ -114,8 +118,7 @@ static_assert(offsetof(v8::ScriptCompiler::CachedData, rejected) == 8,
|
|||
"CachedData.rejected offset mismatch");
|
||||
static_assert(offsetof(v8::ScriptCompiler::CachedData, buffer_policy) == 12,
|
||||
"CachedData.buffer_policy offset mismatch");
|
||||
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) ==
|
||||
12,
|
||||
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) == 12,
|
||||
"DisallowJavascriptExecutionScope size mismatch");
|
||||
#endif
|
||||
|
||||
|
@ -487,7 +490,9 @@ uint32_t v8__ScriptCompiler__CachedDataVersionTag() {
|
|||
size_t v8__TypedArray__Length(const v8::TypedArray* self) {
|
||||
return ptr_to_local(self)->Length();
|
||||
}
|
||||
size_t v8__TypedArray__kMaxByteLength() { return v8::TypedArray::kMaxByteLength; }
|
||||
size_t v8__TypedArray__kMaxByteLength() {
|
||||
return v8::TypedArray::kMaxByteLength;
|
||||
}
|
||||
|
||||
bool v8__Data__EQ(const v8::Data& self, const v8::Data& other) {
|
||||
return ptr_to_local(&self) == ptr_to_local(&other);
|
||||
|
@ -872,8 +877,8 @@ two_pointers_t v8__ArrayBuffer__GetBackingStore(const v8::ArrayBuffer& self) {
|
|||
}
|
||||
|
||||
v8::BackingStore* v8__BackingStore__EmptyBackingStore(bool shared) {
|
||||
std::unique_ptr<i::BackingStoreBase> u =
|
||||
i::BackingStore::EmptyBackingStore(shared ? i::SharedFlag::kShared : i::SharedFlag::kNotShared);
|
||||
std::unique_ptr<i::BackingStoreBase> u = i::BackingStore::EmptyBackingStore(
|
||||
shared ? i::SharedFlag::kShared : i::SharedFlag::kNotShared);
|
||||
return static_cast<v8::BackingStore*>(u.release());
|
||||
}
|
||||
|
||||
|
@ -1046,14 +1051,17 @@ class ExternalStaticOneByteStringResource
|
|||
class ExternalConstOneByteStringResource
|
||||
: public v8::String::ExternalOneByteStringResource {
|
||||
public:
|
||||
ExternalConstOneByteStringResource(int length)
|
||||
: _length(length) {
|
||||
static_assert(offsetof(ExternalConstOneByteStringResource, _length) == sizeof(size_t) * 2,
|
||||
"ExternalConstOneByteStringResource's length was not at offset of sizeof(size_t) * 2");
|
||||
static_assert(sizeof(ExternalConstOneByteStringResource) == sizeof(size_t) * 3,
|
||||
"ExternalConstOneByteStringResource size was not sizeof(size_t) * 3");
|
||||
static_assert(alignof(ExternalConstOneByteStringResource) == sizeof(size_t),
|
||||
"ExternalConstOneByteStringResource align was not sizeof(size_t)");
|
||||
ExternalConstOneByteStringResource(int length) : _length(length) {
|
||||
static_assert(offsetof(ExternalConstOneByteStringResource, _length) ==
|
||||
sizeof(size_t) * 2,
|
||||
"ExternalConstOneByteStringResource's length was not at "
|
||||
"offset of sizeof(size_t) * 2");
|
||||
static_assert(
|
||||
sizeof(ExternalConstOneByteStringResource) == sizeof(size_t) * 3,
|
||||
"ExternalConstOneByteStringResource size was not sizeof(size_t) * 3");
|
||||
static_assert(
|
||||
alignof(ExternalConstOneByteStringResource) == sizeof(size_t),
|
||||
"ExternalConstOneByteStringResource align was not sizeof(size_t)");
|
||||
}
|
||||
const char* data() const override { return nullptr; }
|
||||
size_t length() const override { return _length; }
|
||||
|
@ -1185,15 +1193,14 @@ void v8__ObjectTemplate__SetInternalFieldCount(const v8::ObjectTemplate& self,
|
|||
ptr_to_local(&self)->SetInternalFieldCount(value);
|
||||
}
|
||||
|
||||
void v8__ObjectTemplate__SetAccessor(
|
||||
const v8::ObjectTemplate& self, const v8::Name& key,
|
||||
v8::AccessorNameGetterCallback getter,
|
||||
v8::AccessorNameSetterCallback setter,
|
||||
const v8::Value* data_or_null,
|
||||
v8::PropertyAttribute attr) {
|
||||
ptr_to_local(&self)->SetAccessor(
|
||||
ptr_to_local(&key), getter, setter, ptr_to_local(data_or_null), v8::AccessControl::DEFAULT,
|
||||
attr);
|
||||
void v8__ObjectTemplate__SetAccessor(const v8::ObjectTemplate& self,
|
||||
const v8::Name& key,
|
||||
v8::AccessorNameGetterCallback getter,
|
||||
v8::AccessorNameSetterCallback setter,
|
||||
const v8::Value* data_or_null,
|
||||
v8::PropertyAttribute attr) {
|
||||
ptr_to_local(&self)->SetAccessor(ptr_to_local(&key), getter, setter,
|
||||
ptr_to_local(data_or_null), attr);
|
||||
}
|
||||
|
||||
void v8__ObjectTemplate__SetNamedPropertyHandler(
|
||||
|
@ -1336,9 +1343,9 @@ MaybeBool v8__Object__SetAccessor(const v8::Object& self,
|
|||
v8::AccessorNameSetterCallback setter,
|
||||
const v8::Value* data_or_null,
|
||||
v8::PropertyAttribute attr) {
|
||||
return maybe_to_maybe_bool(ptr_to_local(&self)->SetAccessor(
|
||||
return maybe_to_maybe_bool(ptr_to_local(&self)->SetNativeDataProperty(
|
||||
ptr_to_local(&context), ptr_to_local(&key), getter, setter,
|
||||
ptr_to_local(data_or_null), v8::AccessControl::DEFAULT, attr));
|
||||
ptr_to_local(data_or_null), attr));
|
||||
}
|
||||
|
||||
v8::Isolate* v8__Object__GetIsolate(const v8::Object& self) {
|
||||
|
@ -1433,7 +1440,7 @@ int v8__Object__InternalFieldCount(const v8::Object& self) {
|
|||
}
|
||||
|
||||
const v8::Data* v8__Object__GetInternalField(const v8::Object& self,
|
||||
int index) {
|
||||
int index) {
|
||||
return local_to_ptr(ptr_to_local(&self)->GetInternalField(index));
|
||||
}
|
||||
|
||||
|
@ -1497,9 +1504,8 @@ const v8::Value* v8__Object__GetOwnPropertyDescriptor(
|
|||
ptr_to_local(&context), ptr_to_local(&key)));
|
||||
}
|
||||
|
||||
const v8::Array* v8__Object__PreviewEntries(
|
||||
const v8::Object& self,
|
||||
bool* is_key_value) {
|
||||
const v8::Array* v8__Object__PreviewEntries(const v8::Object& self,
|
||||
bool* is_key_value) {
|
||||
return maybe_local_to_ptr(ptr_to_local(&self)->PreviewEntries(is_key_value));
|
||||
}
|
||||
|
||||
|
@ -1668,8 +1674,7 @@ const v8::ArrayBuffer* v8__ArrayBufferView__Buffer(
|
|||
return local_to_ptr(ptr_to_local(&self)->Buffer());
|
||||
}
|
||||
|
||||
const void* v8__ArrayBufferView__Buffer__Data(
|
||||
const v8::ArrayBufferView& self) {
|
||||
const void* v8__ArrayBufferView__Buffer__Data(const v8::ArrayBufferView& self) {
|
||||
return ptr_to_local(&self)->Buffer()->Data();
|
||||
}
|
||||
|
||||
|
@ -1853,8 +1858,9 @@ void v8__Context__UseDefaultSecurityToken(v8::Context& self) {
|
|||
ptr_to_local(&self)->UseDefaultSecurityToken();
|
||||
}
|
||||
|
||||
void v8__Context__AllowCodeGenerationFromStrings(v8::Context& self, bool allow) {
|
||||
ptr_to_local(&self)->AllowCodeGenerationFromStrings(allow);
|
||||
void v8__Context__AllowCodeGenerationFromStrings(v8::Context& self,
|
||||
bool allow) {
|
||||
ptr_to_local(&self)->AllowCodeGenerationFromStrings(allow);
|
||||
}
|
||||
|
||||
bool v8__Context_IsCodeGenerationFromStringsAllowed(v8::Context& self) {
|
||||
|
@ -1868,15 +1874,14 @@ const v8::Context* v8__Context__FromSnapshot(v8::Isolate* isolate,
|
|||
return maybe_local_to_ptr(maybe_local);
|
||||
}
|
||||
|
||||
void v8__Context__SetContinuationPreservedEmbedderData(v8::Context& context,
|
||||
void v8__Context__SetContinuationPreservedEmbedderData(v8::Isolate* isolate,
|
||||
const v8::Value* data) {
|
||||
auto c = ptr_to_local(&context);
|
||||
c->SetContinuationPreservedEmbedderData(ptr_to_local(data));
|
||||
isolate->SetContinuationPreservedEmbedderData(ptr_to_local(data));
|
||||
}
|
||||
|
||||
const v8::Value* v8__Context__GetContinuationPreservedEmbedderData(
|
||||
const v8::Context& context) {
|
||||
auto value = ptr_to_local(&context)->GetContinuationPreservedEmbedderData();
|
||||
v8::Isolate* isolate) {
|
||||
auto value = isolate->GetContinuationPreservedEmbedderData();
|
||||
return local_to_ptr(value);
|
||||
}
|
||||
|
||||
|
@ -2311,10 +2316,7 @@ void v8__AllowJavascriptExecutionScope__DESTRUCT(
|
|||
return local_to_ptr( \
|
||||
v8::NAME::New(ptr_to_local(&buf_ptr), byte_offset, length)); \
|
||||
} \
|
||||
size_t v8__##NAME##__kMaxLength() { \
|
||||
return v8::NAME::kMaxLength; \
|
||||
}
|
||||
|
||||
size_t v8__##NAME##__kMaxLength() { return v8::NAME::kMaxLength; }
|
||||
|
||||
V(Uint8Array)
|
||||
V(Uint8ClampedArray)
|
||||
|
@ -2368,14 +2370,16 @@ const v8::Value* v8__Script__Run(const v8::Script& script,
|
|||
return maybe_local_to_ptr(ptr_to_local(&script)->Run(ptr_to_local(&context)));
|
||||
}
|
||||
|
||||
void v8__ScriptOrigin__CONSTRUCT(
|
||||
v8::Isolate* isolate, uninit_t<v8::ScriptOrigin>* buf,
|
||||
const v8::Value& resource_name, int resource_line_offset,
|
||||
int resource_column_offset, bool resource_is_shared_cross_origin,
|
||||
int script_id, const v8::Value& source_map_url, bool resource_is_opaque,
|
||||
bool is_wasm, bool is_module) {
|
||||
void v8__ScriptOrigin__CONSTRUCT(uninit_t<v8::ScriptOrigin>* buf,
|
||||
const v8::Value& resource_name,
|
||||
int resource_line_offset,
|
||||
int resource_column_offset,
|
||||
bool resource_is_shared_cross_origin,
|
||||
int script_id, const v8::Value& source_map_url,
|
||||
bool resource_is_opaque, bool is_wasm,
|
||||
bool is_module) {
|
||||
construct_in_place<v8::ScriptOrigin>(
|
||||
buf, isolate, ptr_to_local(&resource_name), resource_line_offset,
|
||||
buf, ptr_to_local(&resource_name), resource_line_offset,
|
||||
resource_column_offset, resource_is_shared_cross_origin, script_id,
|
||||
ptr_to_local(&source_map_url), resource_is_opaque, is_wasm, is_module);
|
||||
}
|
||||
|
@ -2545,10 +2549,8 @@ bool v8__Proxy__IsRevoked(const v8::Proxy& self) {
|
|||
void v8__Proxy__Revoke(const v8::Proxy& self) { ptr_to_local(&self)->Revoke(); }
|
||||
|
||||
void v8__SnapshotCreator__CONSTRUCT(uninit_t<v8::SnapshotCreator>* buf,
|
||||
const intptr_t* external_references,
|
||||
v8::StartupData* existing_blob) {
|
||||
construct_in_place<v8::SnapshotCreator>(buf, external_references,
|
||||
existing_blob);
|
||||
const v8::Isolate::CreateParams& params) {
|
||||
construct_in_place<v8::SnapshotCreator>(buf, params);
|
||||
}
|
||||
|
||||
void v8__SnapshotCreator__DESTRUCT(v8::SnapshotCreator* self) {
|
||||
|
@ -3013,7 +3015,8 @@ const v8::Module* v8__Module__CreateSyntheticModule(
|
|||
for (size_t i = 0; i < export_names_len; i += 1) {
|
||||
export_names_vec.push_back(ptr_to_local(export_names_raw[i]));
|
||||
}
|
||||
auto export_names = v8::MemorySpan<const v8::Local<v8::String>>{export_names_vec.data(), export_names_len};
|
||||
auto export_names = v8::MemorySpan<const v8::Local<v8::String>>{
|
||||
export_names_vec.data(), export_names_len};
|
||||
return local_to_ptr(v8::Module::CreateSyntheticModule(
|
||||
isolate, ptr_to_local(module_name), export_names, evaluation_steps));
|
||||
}
|
||||
|
@ -3039,12 +3042,13 @@ struct StalledTopLevelAwaitMessage {
|
|||
size_t v8__Module__GetStalledTopLevelAwaitMessage(
|
||||
const v8::Module& self, v8::Isolate* isolate,
|
||||
StalledTopLevelAwaitMessage* out_vec, size_t out_len) {
|
||||
auto messages = ptr_to_local(&self)->GetStalledTopLevelAwaitMessage(isolate);
|
||||
auto [modules, messages] =
|
||||
ptr_to_local(&self)->GetStalledTopLevelAwaitMessages(isolate);
|
||||
auto len = std::min(messages.size(), out_len);
|
||||
for (size_t i = 0; i < len; i += 1) {
|
||||
StalledTopLevelAwaitMessage stalled_message;
|
||||
stalled_message.module = local_to_ptr(std::get<0>(messages[i]));
|
||||
stalled_message.message = local_to_ptr(std::get<1>(messages[i]));
|
||||
stalled_message.module = local_to_ptr(modules[i]);
|
||||
stalled_message.message = local_to_ptr(messages[i]);
|
||||
out_vec[i] = stalled_message;
|
||||
}
|
||||
return len;
|
||||
|
@ -3154,7 +3158,7 @@ int v8__Value__GetHash(const v8::Value& data) {
|
|||
i::Tagged<i::Object> object(reinterpret_cast<const i::Address&>(data));
|
||||
i::Isolate* isolate;
|
||||
int hash = IsHeapObject(object) && i::GetIsolateFromHeapObject(
|
||||
object.GetHeapObject(), &isolate)
|
||||
object.GetHeapObject(), &isolate)
|
||||
? i::Object::GetOrCreateHash(object, isolate).value()
|
||||
: i::Smi::ToInt(i::Object::GetHash(object));
|
||||
assert(hash != 0);
|
||||
|
@ -3617,43 +3621,51 @@ extern "C" {
|
|||
using RustTraceFn = void (*)(void* obj, cppgc::Visitor*);
|
||||
using RustDestroyFn = void (*)(void* obj);
|
||||
|
||||
class RustObj final: public cppgc::GarbageCollected<RustObj> {
|
||||
public:
|
||||
explicit RustObj(void* obj, RustTraceFn trace, RustDestroyFn destroy): trace_(trace), destroy_(destroy), obj_(obj) {}
|
||||
class RustObj final : public cppgc::GarbageCollected<RustObj> {
|
||||
public:
|
||||
explicit RustObj(void* obj, RustTraceFn trace, RustDestroyFn destroy)
|
||||
: trace_(trace), destroy_(destroy), obj_(obj) {}
|
||||
|
||||
~RustObj() {
|
||||
destroy_(obj_);
|
||||
}
|
||||
~RustObj() { destroy_(obj_); }
|
||||
|
||||
void Trace(cppgc::Visitor* visitor) const {
|
||||
trace_(obj_, visitor);
|
||||
}
|
||||
void Trace(cppgc::Visitor* visitor) const { trace_(obj_, visitor); }
|
||||
|
||||
private:
|
||||
RustTraceFn trace_;
|
||||
RustDestroyFn destroy_;
|
||||
void* obj_;
|
||||
private:
|
||||
RustTraceFn trace_;
|
||||
RustDestroyFn destroy_;
|
||||
void* obj_;
|
||||
};
|
||||
|
||||
void cppgc__initialize_process(v8::Platform* platform) {
|
||||
cppgc::InitializeProcess(platform->GetPageAllocator());
|
||||
}
|
||||
|
||||
void cppgc__shutdown_process() {
|
||||
cppgc::ShutdownProcess();
|
||||
}
|
||||
void cppgc__shutdown_process() { cppgc::ShutdownProcess(); }
|
||||
|
||||
v8::CppHeap* cppgc__heap__create(v8::Platform* platform, int wrappable_type_index,
|
||||
int wrappable_instance_index, uint16_t embedder_id) {
|
||||
std::unique_ptr<v8::CppHeap> heap = v8::CppHeap::Create(platform, v8::CppHeapCreateParams {
|
||||
{},
|
||||
v8::WrapperDescriptor(wrappable_type_index, wrappable_instance_index, embedder_id),
|
||||
});
|
||||
v8::CppHeap* cppgc__heap__create(v8::Platform* platform,
|
||||
int wrappable_type_index,
|
||||
int wrappable_instance_index,
|
||||
uint16_t embedder_id) {
|
||||
std::unique_ptr<v8::CppHeap> heap = v8::CppHeap::Create(
|
||||
platform,
|
||||
v8::CppHeapCreateParams{
|
||||
{},
|
||||
v8::WrapperDescriptor(wrappable_type_index, wrappable_instance_index,
|
||||
embedder_id),
|
||||
});
|
||||
return heap.release();
|
||||
}
|
||||
|
||||
void v8__Isolate__AttachCppHeap(v8::Isolate* isolate, v8::CppHeap* cpp_heap) {
|
||||
// The AttachCppHeap method is deprecated but the alternative of passing
|
||||
// heap to the Isolate CreateParams is broken.
|
||||
//
|
||||
// TODO(@littledivy): Remove this when the above CL is merged.
|
||||
// https://chromium-review.googlesource.com/c/chromium/src/+/4992764
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
isolate->AttachCppHeap(cpp_heap);
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
v8::CppHeap* v8__Isolate__GetCppHeap(v8::Isolate* isolate) {
|
||||
|
@ -3662,20 +3674,25 @@ v8::CppHeap* v8__Isolate__GetCppHeap(v8::Isolate* isolate) {
|
|||
|
||||
void cppgc__heap__DELETE(v8::CppHeap* self) { delete self; }
|
||||
|
||||
void cppgc__heap__enable_detached_garbage_collections_for_testing(v8::CppHeap* heap) {
|
||||
void cppgc__heap__enable_detached_garbage_collections_for_testing(
|
||||
v8::CppHeap* heap) {
|
||||
heap->EnableDetachedGarbageCollectionsForTesting();
|
||||
}
|
||||
|
||||
void cppgc__heap__collect_garbage_for_testing(v8::CppHeap* heap, cppgc::EmbedderStackState stack_state) {
|
||||
void cppgc__heap__collect_garbage_for_testing(
|
||||
v8::CppHeap* heap, cppgc::EmbedderStackState stack_state) {
|
||||
heap->CollectGarbageForTesting(stack_state);
|
||||
}
|
||||
|
||||
RustObj* cppgc__make_garbage_collectable(v8::CppHeap* heap, void* obj, RustTraceFn trace, RustDestroyFn destroy) {
|
||||
return cppgc::MakeGarbageCollected<RustObj>(heap->GetAllocationHandle(), obj, trace, destroy);
|
||||
RustObj* cppgc__make_garbage_collectable(v8::CppHeap* heap, void* obj,
|
||||
RustTraceFn trace,
|
||||
RustDestroyFn destroy) {
|
||||
return cppgc::MakeGarbageCollected<RustObj>(heap->GetAllocationHandle(), obj,
|
||||
trace, destroy);
|
||||
}
|
||||
|
||||
void cppgc__visitor__trace(cppgc::Visitor* visitor, RustObj* member) {
|
||||
visitor->Trace(*member);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
|
|
|
@ -548,7 +548,7 @@ impl Isolate {
|
|||
// Byte offset inside `Isolate` where the isolate data slots are stored. This
|
||||
// should be the same as the value of `kIsolateEmbedderDataOffset` which is
|
||||
// defined in `v8-internal.h`.
|
||||
const EMBEDDER_DATA_OFFSET: usize = size_of::<[*const (); 67]>();
|
||||
const EMBEDDER_DATA_OFFSET: usize = size_of::<[*const (); 65]>();
|
||||
|
||||
// Isolate data slots used internally by rusty_v8.
|
||||
const ANNEX_SLOT: u32 = 0;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::array_buffer;
|
||||
use crate::array_buffer::Allocator as ArrayBufferAllocator;
|
||||
use crate::cppgc::Heap;
|
||||
use crate::support::char;
|
||||
use crate::support::int;
|
||||
use crate::support::intptr_t;
|
||||
|
@ -212,10 +213,9 @@ pub(crate) mod raw {
|
|||
pub only_terminate_in_safe_scope: bool,
|
||||
pub embedder_wrapper_type_index: int,
|
||||
pub embedder_wrapper_object_index: int,
|
||||
// NOTE(bartlomieju): this field is deprecated in V8 API.
|
||||
// This is an std::vector<std::string>. It's usually no bigger
|
||||
// than three or four words but let's take a generous upper bound.
|
||||
pub supported_import_assertions: [usize; 8],
|
||||
_fatal_error_handler: *const Opaque, // FatalErrorCallback
|
||||
_oom_error_handler: *const Opaque, // OOMErrorCallback
|
||||
pub cpp_heap: *const Heap,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -327,7 +327,7 @@ impl<'s> HandleScope<'s> {
|
|||
unsafe {
|
||||
let sd = data::ScopeData::get_mut(self);
|
||||
raw::v8__Context__SetContinuationPreservedEmbedderData(
|
||||
sd.get_current_context(),
|
||||
sd.get_isolate_ptr(),
|
||||
&*data,
|
||||
);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ impl<'s> HandleScope<'s> {
|
|||
self
|
||||
.cast_local(|sd| {
|
||||
raw::v8__Context__GetContinuationPreservedEmbedderData(
|
||||
sd.get_current_context(),
|
||||
sd.get_isolate_ptr(),
|
||||
)
|
||||
})
|
||||
.unwrap()
|
||||
|
@ -2100,11 +2100,11 @@ mod raw {
|
|||
resolve_hook: *const Function,
|
||||
);
|
||||
pub(super) fn v8__Context__SetContinuationPreservedEmbedderData(
|
||||
this: *const Context,
|
||||
this: *mut Isolate,
|
||||
value: *const Value,
|
||||
);
|
||||
pub(super) fn v8__Context__GetContinuationPreservedEmbedderData(
|
||||
this: *const Context,
|
||||
this: *mut Isolate,
|
||||
) -> *const Value;
|
||||
|
||||
pub(super) fn v8__HandleScope__CONSTRUCT(
|
||||
|
|
|
@ -4,7 +4,6 @@ use std::ptr::null;
|
|||
|
||||
use crate::Context;
|
||||
use crate::HandleScope;
|
||||
use crate::Isolate;
|
||||
use crate::Local;
|
||||
use crate::Script;
|
||||
use crate::String;
|
||||
|
@ -31,7 +30,6 @@ extern "C" {
|
|||
) -> *const Value;
|
||||
|
||||
fn v8__ScriptOrigin__CONSTRUCT(
|
||||
isolate: *mut Isolate,
|
||||
buf: *mut MaybeUninit<ScriptOrigin>,
|
||||
resource_name: *const Value,
|
||||
resource_line_offset: i32,
|
||||
|
@ -103,7 +101,8 @@ impl<'s> ScriptOrigin<'s> {
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
#[inline(always)]
|
||||
pub fn new(
|
||||
scope: &mut HandleScope<'s, ()>,
|
||||
// TODO(littledivy): remove
|
||||
_scope: &mut HandleScope<'s, ()>,
|
||||
resource_name: Local<'s, Value>,
|
||||
resource_line_offset: i32,
|
||||
resource_column_offset: i32,
|
||||
|
@ -117,7 +116,6 @@ impl<'s> ScriptOrigin<'s> {
|
|||
unsafe {
|
||||
let mut buf = std::mem::MaybeUninit::<ScriptOrigin>::uninit();
|
||||
v8__ScriptOrigin__CONSTRUCT(
|
||||
scope.get_isolate_ptr(),
|
||||
&mut buf,
|
||||
&*resource_name,
|
||||
resource_line_offset,
|
||||
|
|
|
@ -74,6 +74,7 @@ pub struct Source {
|
|||
_consume_cache_task: usize,
|
||||
_compile_hint_callback: usize,
|
||||
_compile_hint_callback_data: usize,
|
||||
_compilation_details: [usize; 3],
|
||||
}
|
||||
|
||||
/// Compilation data that the embedder can cache and pass back to speed up future
|
||||
|
|
|
@ -3,9 +3,7 @@ use crate::isolate_create_params::raw;
|
|||
use crate::scope::data::ScopeData;
|
||||
use crate::support::char;
|
||||
use crate::support::int;
|
||||
use crate::support::intptr_t;
|
||||
use crate::support::Allocated;
|
||||
use crate::support::Allocation;
|
||||
use crate::Context;
|
||||
use crate::Data;
|
||||
use crate::Isolate;
|
||||
|
@ -16,13 +14,11 @@ use std::borrow::Borrow;
|
|||
use std::convert::TryFrom;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ops::Deref;
|
||||
use std::ptr::null;
|
||||
|
||||
extern "C" {
|
||||
fn v8__SnapshotCreator__CONSTRUCT(
|
||||
buf: *mut MaybeUninit<SnapshotCreator>,
|
||||
external_references: *const intptr_t,
|
||||
existing_blob: *const raw::StartupData,
|
||||
params: *const raw::CreateParams,
|
||||
);
|
||||
fn v8__SnapshotCreator__DESTRUCT(this: *mut SnapshotCreator);
|
||||
fn v8__SnapshotCreator__GetIsolate(
|
||||
|
@ -131,30 +127,18 @@ impl SnapshotCreator {
|
|||
existing_snapshot_blob: Option<impl Allocated<[u8]>>,
|
||||
) -> OwnedIsolate {
|
||||
let mut snapshot_creator: MaybeUninit<Self> = MaybeUninit::uninit();
|
||||
let external_references_ptr = if let Some(er) = external_references {
|
||||
er.as_ptr()
|
||||
} else {
|
||||
std::ptr::null()
|
||||
};
|
||||
|
||||
let snapshot_blob_ptr;
|
||||
let snapshot_allocations;
|
||||
if let Some(snapshot_blob) = existing_snapshot_blob {
|
||||
let data = Allocation::of(snapshot_blob);
|
||||
let header = Allocation::of(raw::StartupData::boxed_header(&data));
|
||||
snapshot_blob_ptr = &*header as *const _;
|
||||
snapshot_allocations = Some((header, data));
|
||||
} else {
|
||||
snapshot_blob_ptr = null();
|
||||
snapshot_allocations = None;
|
||||
let mut params = crate::CreateParams::default();
|
||||
if let Some(external_refs) = external_references {
|
||||
params = params.external_references(&**external_refs);
|
||||
}
|
||||
if let Some(snapshot_blob) = existing_snapshot_blob {
|
||||
params = params.snapshot_blob(snapshot_blob);
|
||||
}
|
||||
let (raw_create_params, create_param_allocations) = params.finalize();
|
||||
|
||||
let snapshot_creator = unsafe {
|
||||
v8__SnapshotCreator__CONSTRUCT(
|
||||
&mut snapshot_creator,
|
||||
external_references_ptr,
|
||||
snapshot_blob_ptr,
|
||||
);
|
||||
v8__SnapshotCreator__CONSTRUCT(&mut snapshot_creator, &raw_create_params);
|
||||
snapshot_creator.assume_init()
|
||||
};
|
||||
|
||||
|
@ -162,7 +146,7 @@ impl SnapshotCreator {
|
|||
unsafe { v8__SnapshotCreator__GetIsolate(&snapshot_creator) };
|
||||
let mut owned_isolate = OwnedIsolate::new(isolate_ptr);
|
||||
ScopeData::new_root(&mut owned_isolate);
|
||||
owned_isolate.create_annex(Box::new(snapshot_allocations));
|
||||
owned_isolate.create_annex(create_param_allocations);
|
||||
owned_isolate.set_snapshot_creator(snapshot_creator);
|
||||
owned_isolate
|
||||
}
|
||||
|
|
|
@ -270,16 +270,9 @@ pub trait ValueSerializerImpl {
|
|||
|
||||
fn get_shared_array_buffer_id<'s>(
|
||||
&mut self,
|
||||
scope: &mut HandleScope<'s>,
|
||||
_scope: &mut HandleScope<'s>,
|
||||
_shared_array_buffer: Local<'s, SharedArrayBuffer>,
|
||||
) -> Option<u32> {
|
||||
let msg = String::new(
|
||||
scope,
|
||||
"Deno serializer: get_shared_array_buffer_id not implemented",
|
||||
)
|
||||
.unwrap();
|
||||
let exc = Exception::error(scope, msg);
|
||||
scope.throw_exception(exc);
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1117,7 +1117,9 @@ fn try_catch() {
|
|||
assert!(tc2.has_caught());
|
||||
assert!(tc2.rethrow().is_some());
|
||||
tc2.reset();
|
||||
assert!(!tc2.has_caught());
|
||||
// Reset does not clear exception on rethrow.
|
||||
// https://chromium-review.googlesource.com/c/v8/v8/+/5050065
|
||||
assert!(tc2.has_caught());
|
||||
}
|
||||
assert!(tc1.has_caught());
|
||||
};
|
||||
|
@ -2538,7 +2540,6 @@ fn object_template_set_named_property_handler() {
|
|||
assert!(eval(scope, "'panicOnGet' in obj")
|
||||
.unwrap()
|
||||
.boolean_value(scope));
|
||||
assert!(eval(scope, "obj.panicOnGet").unwrap().is_string());
|
||||
|
||||
// Test `v8::NamedPropertyHandlerConfiguration::*_raw()` methods
|
||||
{
|
||||
|
@ -2566,7 +2567,6 @@ fn object_template_set_named_property_handler() {
|
|||
assert!(eval(scope, "'panicOnGet' in obj")
|
||||
.unwrap()
|
||||
.boolean_value(scope));
|
||||
assert!(eval(scope, "obj.panicOnGet").unwrap().is_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8083,6 +8083,7 @@ impl v8::ValueSerializerImpl for Custom2Value {
|
|||
scope: &mut v8::HandleScope<'s>,
|
||||
message: v8::Local<'s, v8::String>,
|
||||
) {
|
||||
let scope = &mut v8::TryCatch::new(scope);
|
||||
let error = v8::Exception::error(scope, message);
|
||||
scope.throw_exception(error);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ fn cppgc_object_wrap() {
|
|||
}
|
||||
|
||||
{
|
||||
let isolate = &mut v8::Isolate::new(Default::default());
|
||||
let isolate = &mut v8::Isolate::new(v8::CreateParams::default());
|
||||
// Create a managed heap.
|
||||
let heap = v8::cppgc::Heap::create(
|
||||
guard.platform.clone(),
|
||||
|
@ -82,7 +82,6 @@ fn cppgc_object_wrap() {
|
|||
DEFAULT_CPP_GC_EMBEDDER_ID,
|
||||
)),
|
||||
);
|
||||
|
||||
isolate.attach_cpp_heap(&heap);
|
||||
|
||||
let handle_scope = &mut v8::HandleScope::new(isolate);
|
||||
|
|
2
v8
2
v8
|
@ -1 +1 @@
|
|||
Subproject commit c6c15e7d902677c43e096fe1fcf841e79555c714
|
||||
Subproject commit 5fec337f209fd2db7519cfe398e10b3aa2e587ab
|
Loading…
Reference in a new issue