Skip to content
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 README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rusty V8 Binding

V8 Version: 14.5.201.5
V8 Version: 14.6.202.2

[![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/rusty_v8/actions)
[![crates](https://img.shields.io/crates/v/v8.svg)](https://crates.io/crates/v8)
Expand Down
2 changes: 1 addition & 1 deletion build
Submodule build updated 79 files
+9 −11 android/gyp/compile_resources.py
+37 −35 android/gyp/create_app_bundle.py
+24 −26 android/gyp/proguard.py
+5 −3 android/gyp/util/resource_utils.py
+4 −3 android/java/src/org/chromium/build/NullUtil.java
+21 −24 android/pylib/constants/__init__.py
+13 −2 android/pylib/gtest/gtest_test_instance.py
+9 −0 android/pylib/instrumentation/instrumentation_test_instance.py
+10 −0 android/pylib/junit/junit_test_instance.py
+2 −1 android/pylib/local/device/local_device_environment.py
+26 −4 android/pylib/local/machine/local_machine_junit_test_run.py
+15 −22 android/pylib/results/report_results.py
+27 −13 android/pylib/utils/logging_utils.py
+10 −3 android/stacktrace/java/org/chromium/build/FlushingReTrace.java
+ android/stacktrace/java_deobfuscate_java.jar
+26 −18 android/test_runner.py
+41 −0 apple/tweak_info_plist.py
+74 −23 buildflag_header.gni
+1 −4 config/BUILDCONFIG.gn
+3 −14 config/android/BUILD.gn
+3 −3 config/android/config.gni
+1 −1 config/android/internal_rules.gni
+20 −6 config/android/rules.gni
+22 −0 config/apple/group.modulemap.jinja
+36 −0 config/apple/group_modulemap_helper.py
+221 −24 config/apple/swift_source_set.gni
+1 −1 config/chromeos/rules.gni
+4 −0 config/clang/BUILD.gn
+2 −2 config/compiler/BUILD.gn
+10 −8 config/compiler/compiler.gni
+1 −6 config/fuchsia/BUILD.gn
+8 −3 config/ios/BUILD.gn
+15 −2 config/rust.gni
+91 −1 config/sanitizers/BUILD.gn
+6 −0 config/sanitizers/ignorelist_stdlib_and_absl.txt
+22 −0 config/sanitizers/sanitizers.gni
+1 −0 config/siso/blink_all.star
+17 −10 config/siso/clang_all.star
+28 −0 config/siso/grit.star
+2 −20 config/siso/main.star
+4 −0 config/siso/mojo.star
+1 −0 config/unsafe_buffers_paths.txt
+1 −0 fuchsia/test/run_test.py
+37 −0 linux/chrome.map
+3 −1 print_python_deps.py
+1 −1 private_code_test/private_code_test.gni
+8 −0 rust/BUILD.gn
+3 −6 rust/allocator/BUILD.gn
+4 −4 rust/allocator/lib.rs
+1 −0 rust/cargo_crate.gni
+179 −0 rust/gni_impl/cpp_api_from_rust.gni
+45 −0 rust/gni_impl/cpp_api_from_rust_wrapper.py
+74 −31 rust/gni_impl/rust_target.gni
+44 −6 rust/gni_impl/rustc_wrapper.py
+14 −0 rust/rust_static_library.gni
+3 −6 rust/rust_unit_test.gni
+0 −2 rust/std/fake_root/Cargo.toml.template
+359 −247 rust/std/rules/BUILD.gn
+33 −0 rust/tests/test_buildflag_header/BUILD.gn
+43 −0 rust/tests/test_buildflag_header/lib.rs
+25 −0 rust/tests/test_cpp_api_from_rust/BUILD.gn
+10 −0 rust/tests/test_cpp_api_from_rust/lib.rs
+12 −0 rust/tests/test_cpp_api_from_rust/unittests.cc
+7 −2 rust/tests/test_cpp_including_rust/BUILD.gn
+0 −0 rust/tests/test_cpp_including_rust/shared_unittest.cc
+0 −0 rust/tests/test_cpp_including_rust/static_unittest.cc
+13 −1 rust/tests/test_cxx_cfg/BUILD.gn
+16 −0 rust/tests/test_cxx_cfg/cxx_cfg_lib.rs
+11 −1 rust/tests/test_cxx_cfg/cxx_cfg_unittest.cc
+15 −10 toolchain/apple/toolchain.gni
+15 −10 toolchain/gcc_toolchain.gni
+4 −0 toolchain/kythe.gni
+1 −1 toolchain/toolchain.gni
+15 −10 toolchain/win/toolchain.gni
+11 −8 util/lib/proto/metric.py
+2 −3 util/lib/proto/metric_unittests.py
+6 −0 util/lib/proto/test_script_metrics.proto
+6 −6 util/lib/proto/test_script_metrics_pb2.py
+7 −3 vs_toolchain.py
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ fn build_binding() {
.generate_cstr(true)
.rustified_enum(".*UseCounterFeature")
.rustified_enum(".*ModuleImportPhase")
.rustified_enum(".*Intercepted")
.bitfield_enum(".*GCType")
.bitfield_enum(".*GCCallbackFlags")
.allowlist_item("v8__.*")
.allowlist_item("cppgc__.*")
.allowlist_item("RustObj")
.allowlist_item("memory_span_t")
.allowlist_item("const_memory_span_t")
.allowlist_item("ExternalConstOneByteStringResource")
.generate()
.expect("Unable to generate bindings");
Expand Down
2 changes: 1 addition & 1 deletion buildtools
Submodule buildtools updated from 4dc32b to 6a1868
4 changes: 2 additions & 2 deletions examples/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ impl<'scope, 'obj, 'isolate> JsHttpRequestProcessor<'scope, 'obj, 'isolate> {
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue,
) {
let this = args.this();
let external = Self::unwrap_request(scope, this);
let holder = args.holder();
let external = Self::unwrap_request(scope, holder);

assert!(
!external.is_null(),
Expand Down
54 changes: 36 additions & 18 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,8 @@ const v8::Boolean* v8__Boolean__New(v8::Isolate* isolate, bool value) {

int v8__FixedArray__Length(const v8::FixedArray& self) { return self.Length(); }

const v8::Data* v8__FixedArray__Get(const v8::FixedArray& self,
const v8::Context& context, int index) {
return local_to_ptr(ptr_to_local(&self)->Get(ptr_to_local(&context), index));
const v8::Data* v8__FixedArray__Get(const v8::FixedArray& self, int index) {
return local_to_ptr(ptr_to_local(&self)->Get(index));
}

const v8::PrimitiveArray* v8__PrimitiveArray__New(v8::Isolate* isolate,
Expand Down Expand Up @@ -1456,14 +1455,15 @@ const v8::Value* v8__Object__GetIndex(const v8::Object& self,
ptr_to_local(&self)->Get(ptr_to_local(&context), index));
}

void* v8__Object__GetAlignedPointerFromInternalField(const v8::Object& self,
int index) {
return ptr_to_local(&self)->GetAlignedPointerFromInternalField(index);
void* v8__Object__GetAlignedPointerFromInternalField(
const v8::Object& self, int index, v8::EmbedderDataTypeTag tag) {
return ptr_to_local(&self)->GetAlignedPointerFromInternalField(index, tag);
}

void v8__Object__SetAlignedPointerInInternalField(const v8::Object& self,
int index, void* value) {
ptr_to_local(&self)->SetAlignedPointerInInternalField(index, value);
int index, void* value,
v8::EmbedderDataTypeTag tag) {
ptr_to_local(&self)->SetAlignedPointerInInternalField(index, value, tag);
}

bool v8__Object__IsApiWrapper(const v8::Object& self) {
Expand Down Expand Up @@ -1997,12 +1997,14 @@ void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
v8::StartupData payload, void* data) {
assert(data == nullptr);
if (payload.raw_size == 0) {
holder->SetAlignedPointerInInternalField(index, nullptr);
holder->SetAlignedPointerInInternalField(index, nullptr,
v8::kEmbedderDataTypeTagDefault);
return;
}
InternalFieldData* embedder_field = new InternalFieldData{0};
memcpy(embedder_field, payload.data, payload.raw_size);
holder->SetAlignedPointerInInternalField(index, embedder_field);
holder->SetAlignedPointerInInternalField(index, embedder_field,
v8::kEmbedderDataTypeTagDefault);
deserialized_data.push_back(embedder_field);
}

Expand Down Expand Up @@ -2406,11 +2408,6 @@ const v8::Value* v8__PropertyCallbackInfo__Data(
return local_to_ptr(self.Data());
}

const v8::Object* v8__PropertyCallbackInfo__This(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.This());
}

const v8::Object* v8__PropertyCallbackInfo__Holder(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.HolderV2());
Expand Down Expand Up @@ -2907,7 +2904,8 @@ v8::StartupData SerializeInternalFields(v8::Local<v8::Object> holder, int index,
void* data) {
assert(data == nullptr);
InternalFieldData* embedder_field = static_cast<InternalFieldData*>(
holder->GetAlignedPointerFromInternalField(index));
holder->GetAlignedPointerFromInternalField(
index, v8::kEmbedderDataTypeTagDefault));
if (embedder_field == nullptr) return {nullptr, 0};
int size = sizeof(*embedder_field);
char* payload = new char[size];
Expand Down Expand Up @@ -3438,13 +3436,20 @@ void v8__WasmStreaming__shared_ptr_DESTRUCT(WasmStreamingSharedPtr* self) {
self->~WasmStreamingSharedPtr();
}

void v8__WasmStreaming__SetHasCompiledModuleBytes(
WasmStreamingSharedPtr* self) {
self->inner->SetHasCompiledModuleBytes();
}

void v8__WasmStreaming__OnBytesReceived(WasmStreamingSharedPtr* self,
const uint8_t* data, size_t len) {
self->inner->OnBytesReceived(data, len);
}

void v8__WasmStreaming__Finish(WasmStreamingSharedPtr* self) {
self->inner->Finish();
void v8__WasmStreaming__Finish(
WasmStreamingSharedPtr* self,
void (*callback)(v8::WasmStreaming::ModuleCachingInterface&)) {
self->inner->Finish(callback);
}

void v8__WasmStreaming__Abort(WasmStreamingSharedPtr* self,
Expand All @@ -3457,6 +3462,19 @@ void v8__WasmStreaming__SetUrl(WasmStreamingSharedPtr* self, const char* url,
self->inner->SetUrl(url, len);
}

const_memory_span_t v8__ModuleCachingInterface__GetWireBytes(
const v8::WasmStreaming::ModuleCachingInterface& self) {
v8::MemorySpan<const uint8_t> span = self.GetWireBytes();
return {span.data(), span.size()};
}

bool v8__ModuleCachingInterface__SetCachedCompiledModuleBytes(
v8::WasmStreaming::ModuleCachingInterface& self,
const_memory_span_t bytes) {
v8::MemorySpan<const uint8_t> bytes_span{bytes.data, bytes.size};
return self.SetCachedCompiledModuleBytes(bytes_span);
}

const v8::ArrayBuffer* v8__WasmMemoryObject__Buffer(
const v8::WasmMemoryObject& self) {
return local_to_ptr(ptr_to_local(&self)->Buffer());
Expand Down
1 change: 1 addition & 0 deletions src/binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ using v8__HeapStatistics = v8::HeapStatistics;
using v8__HeapSpaceStatistics = v8::HeapSpaceStatistics;
using v8__GCType = v8::GCType;
using v8__GCCallbackFlags = v8::GCCallbackFlags;
using v8__Intercepted = v8::Intercepted;

static uint32_t v8__MAJOR_VERSION = V8_MAJOR_VERSION;
static uint32_t v8__MINOR_VERSION = V8_MINOR_VERSION;
Expand Down
16 changes: 4 additions & 12 deletions src/fixed_array.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use crate::scope::PinScope;
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
use crate::Context;

use crate::Data;
use crate::FixedArray;
use crate::Local;
use crate::scope::PinScope;
use crate::support::int;

unsafe extern "C" {
fn v8__FixedArray__Length(this: *const FixedArray) -> int;

fn v8__FixedArray__Get(
this: *const FixedArray,
context: *const Context,
index: int,
) -> *const Data;
fn v8__FixedArray__Get(this: *const FixedArray, index: int) -> *const Data;
}

impl FixedArray {
Expand All @@ -32,10 +28,6 @@ impl FixedArray {
return None;
}

unsafe {
scope.cast_local(|sd| {
v8__FixedArray__Get(self, &*sd.get_current_context(), index as int)
})
}
unsafe { scope.cast_local(|_| v8__FixedArray__Get(self, index as int)) }
}
}
49 changes: 0 additions & 49 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ unsafe extern "C" {
fn v8__PropertyCallbackInfo__Data(
this: *const RawPropertyCallbackInfo,
) -> *const Value;
fn v8__PropertyCallbackInfo__This(
this: *const RawPropertyCallbackInfo,
) -> *const Object;
fn v8__PropertyCallbackInfo__Holder(
this: *const RawPropertyCallbackInfo,
) -> *const Object;
Expand Down Expand Up @@ -406,52 +403,6 @@ impl<'s> PropertyCallbackArguments<'s> {
}
}

/// Returns the receiver. In many cases, this is the object on which the
/// property access was intercepted. When using
/// `Reflect.get`, `Function.prototype.call`, or similar functions, it is the
/// object passed in as receiver or thisArg.
///
/// ```c++
/// void GetterCallback(Local<Name> name,
/// const v8::PropertyCallbackInfo<v8::Value>& info) {
/// auto context = info.GetIsolate()->GetCurrentContext();
///
/// v8::Local<v8::Value> a_this =
/// info.This()
/// ->GetRealNamedProperty(context, v8_str("a"))
/// .ToLocalChecked();
/// v8::Local<v8::Value> a_holder =
/// info.Holder()
/// ->GetRealNamedProperty(context, v8_str("a"))
/// .ToLocalChecked();
///
/// CHECK(v8_str("r")->Equals(context, a_this).FromJust());
/// CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());
///
/// info.GetReturnValue().Set(name);
/// }
///
/// v8::Local<v8::FunctionTemplate> templ =
/// v8::FunctionTemplate::New(isolate);
/// templ->InstanceTemplate()->SetHandler(
/// v8::NamedPropertyHandlerConfiguration(GetterCallback));
/// LocalContext env;
/// env->Global()
/// ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
/// .ToLocalChecked()
/// ->NewInstance(env.local())
/// .ToLocalChecked())
/// .FromJust();
///
/// CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
/// ```
#[inline(always)]
pub fn this(&self) -> Local<'s, Object> {
unsafe {
Local::from_raw(v8__PropertyCallbackInfo__This(self.0)).unwrap_unchecked()
}
}

/// Returns the data set in the configuration, i.e., in
/// `NamedPropertyHandlerConfiguration` or
/// `IndexedPropertyHandlerConfiguration.`
Expand Down
2 changes: 1 addition & 1 deletion src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ impl Isolate {
+ for<'a, 'b, 'c> Fn(
&'c mut PinScope<'a, 'b>,
Local<'a, Value>,
WasmStreaming,
WasmStreaming<false>,
),
{
unsafe {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub use value_serializer::ValueSerializer;
pub use value_serializer::ValueSerializerHelper;
pub use value_serializer::ValueSerializerImpl;
pub use wasm::CompiledWasmModule;
pub use wasm::ModuleCachingInterface;
pub use wasm::WasmStreaming;

/// https://v8.dev/docs/version-numbers
Expand Down
10 changes: 8 additions & 2 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ unsafe extern "C" {
fn v8__Object__GetAlignedPointerFromInternalField(
this: *const Object,
index: int,
tag: u16,
) -> *const c_void;
fn v8__Object__SetAlignedPointerInInternalField(
this: *const Object,
index: int,
value: *const c_void,
tag: u16,
);
fn v8__Object__SetIntegrityLevel(
this: *const Object,
Expand Down Expand Up @@ -747,8 +749,9 @@ impl Object {
pub unsafe fn get_aligned_pointer_from_internal_field(
&self,
index: i32,
tag: u16,
) -> *const c_void {
unsafe { v8__Object__GetAlignedPointerFromInternalField(self, index) }
unsafe { v8__Object__GetAlignedPointerFromInternalField(self, index, tag) }
}

/// Sets a 2-byte-aligned native pointer in an internal field.
Expand All @@ -759,8 +762,11 @@ impl Object {
&self,
index: i32,
value: *const c_void,
tag: u16,
) {
unsafe { v8__Object__SetAlignedPointerInInternalField(self, index, value) }
unsafe {
v8__Object__SetAlignedPointerInInternalField(self, index, value, tag)
}
}

/// Wraps a JS wrapper with a C++ instance.
Expand Down
5 changes: 5 additions & 0 deletions src/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ struct memory_span_t {
size_t size;
};

struct const_memory_span_t {
const uint8_t* data;
size_t size;
};

#define EACH_TYPED_ARRAY(V) \
V(Uint8Array) \
V(Uint8ClampedArray) \
Expand Down
9 changes: 1 addition & 8 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::SideEffectType;
use crate::Signature;
use crate::String;
use crate::Value;
pub use crate::binding::v8__Intercepted as Intercepted;
use crate::data::Data;
use crate::data::FunctionTemplate;
use crate::data::Name;
Expand Down Expand Up @@ -146,14 +147,6 @@ unsafe extern "C" {
fn v8__ObjectTemplate__SetImmutableProto(this: *const ObjectTemplate);
}

/// Interceptor callbacks use this value to indicate whether the request was
/// intercepted or not.
#[repr(u8)]
pub enum Intercepted {
No,
Yes,
}

pub type AccessorNameGetterCallback = NamedGetterCallbackForAccessor;

/// Note: [ReturnValue] is ignored for accessors.
Expand Down
Loading