diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a42c2987ac..ae95ef4ffc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ permissions: write-all jobs: build: - name: ${{ matrix.config.variant }} ${{ matrix.config.target }} ${{ matrix.config.v8_enable_pointer_compression && 'ptrcomp' || '' }} ${{ matrix.config.simdutf && 'simdutf' || '' }} + name: ${{ matrix.config.variant }} ${{ matrix.config.target }} ${{ matrix.config.v8_enable_pointer_compression && 'ptrcomp' || '' }} ${{ matrix.config.simdutf && 'simdutf' || '' }} ${{ matrix.config.no_icu && 'noicu' || '' }} runs-on: ${{ matrix.config.os }} timeout-minutes: 180 strategy: @@ -181,13 +181,56 @@ jobs: simdutf: true cargo: cargo + # no_icu builds (i18n/ICU disabled). Built with simdutf to match the + # feature set the Deno CLI consumes, producing `_simdutf_noicu` + # archives. Release-only across the targets the CLI ships. + - os: macos-15-large + target: x86_64-apple-darwin + variant: release + v8_enable_pointer_compression: false + simdutf: true + no_icu: true + cargo: cargo + + - os: macos-15 + target: aarch64-apple-darwin + variant: release + v8_enable_pointer_compression: false + simdutf: true + no_icu: true + cargo: cargo + + - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }} + target: x86_64-unknown-linux-gnu + variant: release + v8_enable_pointer_compression: false + simdutf: true + no_icu: true + cargo: cargo + + - os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }} + target: aarch64-unknown-linux-gnu + variant: release + v8_enable_pointer_compression: false + simdutf: true + no_icu: true + cargo: cargo + + - os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2022-xxl' || 'windows-2022' }} + target: x86_64-pc-windows-msvc + variant: release # Note: we do not support windows debug builds. + v8_enable_pointer_compression: false + simdutf: true + no_icu: true + cargo: cargo + env: V8_FROM_SOURCE: true CARGO_VARIANT_FLAG: ${{ matrix.config.variant == 'release' && '--release' || '' }} - CARGO_FEATURE_FLAGS: ${{ format('{0} {1}', matrix.config.v8_enable_pointer_compression && '--features v8_enable_pointer_compression' || '', matrix.config.simdutf && '--features simdutf' || '') }} + CARGO_FEATURE_FLAGS: ${{ format('{0} {1} {2}', matrix.config.v8_enable_pointer_compression && '--features v8_enable_pointer_compression' || '', matrix.config.simdutf && '--features simdutf' || '', matrix.config.no_icu && '--features no_icu' || '') }} LIB_NAME: ${{ contains(matrix.config.target, 'windows') && 'rusty_v8' || 'librusty_v8' }} LIB_EXT: ${{ contains(matrix.config.target, 'windows') && 'lib' || 'a' }} - FEATURES_SUFFIX: ${{ format('{0}{1}', matrix.config.v8_enable_pointer_compression && '_ptrcomp' || '', matrix.config.simdutf && '_simdutf' || '') }} + FEATURES_SUFFIX: ${{ format('{0}{1}{2}', matrix.config.v8_enable_pointer_compression && '_ptrcomp' || '', matrix.config.simdutf && '_simdutf' || '', matrix.config.no_icu && '_noicu' || '') }} RUSTFLAGS: -D warnings steps: @@ -251,7 +294,7 @@ jobs: target/*/.* target/*/build target/*/deps - key: cargo1-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ matrix.config.v8_enable_pointer_compression }}-${{ matrix.config.simdutf }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }} + key: cargo1-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ matrix.config.v8_enable_pointer_compression }}-${{ matrix.config.simdutf }}-${{ matrix.config.no_icu }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }} restore-keys: cargo1-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ matrix.config.v8_enable_pointer_compression }}- - name: Install and start sccache @@ -611,6 +654,99 @@ jobs: name: src_binding_simdutf_release_aarch64-pc-windows-msvc.rs path: target/src_binding_simdutf_release_aarch64-pc-windows-msvc.rs + build-windows-arm64-simdutf-noicu: + name: release aarch64-pc-windows-msvc simdutf noicu + runs-on: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2022-xxl' || 'windows-2022' }} + timeout-minutes: 180 + env: + CARGO_VARIANT_FLAG: --release + V8_FROM_SOURCE: true + CCACHE: ccache + LIB_NAME: rusty_v8 + LIB_EXT: lib + FEATURES_SUFFIX: '_simdutf_noicu' + steps: + - name: Configure git + run: git config --global core.symlinks true + + - name: Clone repository + uses: actions/checkout@v4 + with: + fetch-depth: 10 + submodules: recursive + + - uses: dsherret/rust-toolchain-file@v1 + + - name: Install Windows ARM64 target + run: rustup target add aarch64-pc-windows-msvc + + - name: Install nextest + uses: taiki-e/install-action@nextest + + - name: Write git_submodule_status.txt + run: git submodule status --recursive > git_submodule_status.txt + + - name: Cache + uses: actions/cache@v4 + with: + path: |- + target/sccache + target/aarch64-pc-windows-msvc/release/gn_out + key: cargo1-aarch64-pc-windows-msvc-release-simdutf-noicu-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }} + restore-keys: cargo1-aarch64-pc-windows-msvc-release-simdutf-noicu- + + - name: Install and start sccache + shell: pwsh + env: + SCCACHE_DIR: ${{ github.workspace }}/target/sccache + SCCACHE_CACHE_SIZE: 256M + SCCACHE_IDLE_TIMEOUT: 0 + run: | + $version = "v0.8.2" + $platform = "x86_64-pc-windows-msvc" + $basename = "sccache-$version-$platform" + $url = "https://github.com/mozilla/sccache/releases/download/$version/$basename.tar.gz" + cd ~ + curl -LO $url + tar -xzvf "$basename.tar.gz" + . $basename/sccache --start-server + echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Install Clang + run: python3 tools/clang/scripts/update.py + + - name: Build (cross-compile, no tests) + env: + SCCACHE_IDLE_TIMEOUT: 0 + run: cargo build --all-targets --locked --target aarch64-pc-windows-msvc --release --features simdutf --features no_icu + + - name: Clippy + run: cargo clippy --all-targets --locked --target aarch64-pc-windows-msvc --release --features simdutf --features no_icu -- -D clippy::all + + - name: Prepare binary publish + run: | + gzip -9c target/aarch64-pc-windows-msvc/release/gn_out/obj/rusty_v8.lib > target/rusty_v8_simdutf_noicu_release_aarch64-pc-windows-msvc.lib.gz + ls -l target/rusty_v8_simdutf_noicu_release_aarch64-pc-windows-msvc.lib.gz + + cp target/aarch64-pc-windows-msvc/release/gn_out/src_binding.rs target/src_binding_simdutf_noicu_release_aarch64-pc-windows-msvc.rs + ls -l target/src_binding_simdutf_noicu_release_aarch64-pc-windows-msvc.rs + + - name: Binary publish + uses: softprops/action-gh-release@v0.1.15 + if: github.repository == 'denoland/rusty_v8' && startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + target/rusty_v8_simdutf_noicu_release_aarch64-pc-windows-msvc.lib.gz + target/src_binding_simdutf_noicu_release_aarch64-pc-windows-msvc.rs + + - name: Upload CI artifacts + uses: actions/upload-artifact@v4 + with: + name: src_binding_simdutf_noicu_release_aarch64-pc-windows-msvc.rs + path: target/src_binding_simdutf_noicu_release_aarch64-pc-windows-msvc.rs + test-windows-arm64: name: test aarch64-pc-windows-msvc needs: build-windows-arm64 @@ -643,7 +779,7 @@ jobs: run: cargo nextest run -v --all-targets --locked --target aarch64-pc-windows-msvc --release --no-fail-fast publish: - needs: [build, build-windows-arm64, build-windows-arm64-simdutf] + needs: [build, build-windows-arm64, build-windows-arm64-simdutf, build-windows-arm64-simdutf-noicu] runs-on: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }} if: github.repository == 'denoland/rusty_v8' && startsWith(github.ref, 'refs/tags/') steps: diff --git a/BUILD.gn b/BUILD.gn index 5d7b05e915..2f34c674bd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -3,6 +3,11 @@ import("//build/config/host_byteorder.gni") declare_args() { rusty_v8_enable_simdutf = false + + # Gates the ICU bindings in src/binding.cc. Set to false (via the `no_icu` + # cargo feature) when V8 is built with v8_enable_i18n_support=false, so the + # static library still links without ICU. + rusty_v8_enable_i18n = true } static_library("rusty_v8") { @@ -63,6 +68,10 @@ config("rusty_v8_config") { defines += [ "RUSTY_V8_ENABLE_SIMDUTF" ] } + if (rusty_v8_enable_i18n) { + defines += [ "RUSTY_V8_ENABLE_I18N" ] + } + if (is_clang) { cflags += [ "-fcolor-diagnostics", diff --git a/Cargo.toml b/Cargo.toml index b077313df0..7f2a5c9ee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,6 +104,11 @@ opt-level = 1 default = ["use_custom_libcxx"] use_custom_libcxx = [] simdutf = [] +# Opt-out feature that builds V8 without i18n/ICU support. Enabling it drops the +# embedded ICU data (~10MB) and the `Intl` API from the resulting static +# library. It is modelled as an opt-out so that existing consumers (including +# those that set `default-features = false`) keep ICU without any changes. +no_icu = [] v8_enable_pointer_compression = [] v8_enable_sandbox = ["v8_enable_pointer_compression"] v8_enable_v8_checks = [] diff --git a/benches/string.rs b/benches/string.rs new file mode 100644 index 0000000000..2d6aa02590 --- /dev/null +++ b/benches/string.rs @@ -0,0 +1,142 @@ +fn main() { + if cfg!(debug_assertions) || std::env::var("CI").is_ok() { + return; + } + + let platform = v8::new_default_platform(0, false).make_shared(); + v8::V8::initialize_platform(platform); + v8::V8::initialize(); + let isolate = &mut v8::Isolate::new(v8::CreateParams::default()); + v8::scope!(let scope, isolate); + let context = v8::Context::new(scope, Default::default()); + let scope = &mut v8::ContextScope::new(scope, context); + + println!( + "simdutf feature: {}", + if cfg!(feature = "simdutf") { + "ENABLED" + } else { + "DISABLED" + } + ); + println!(); + + // --- Build test strings of various sizes --- + let sizes: &[usize] = &[16, 64, 256, 1024, 4096, 16384]; + + for &size in sizes { + println!("=== String length: {size} ==="); + + // 1) Pure ASCII one-byte string + { + let ascii_data: String = + (0..size).map(|i| (b'A' + (i % 26) as u8) as char).collect(); + let v8_str = v8::String::new(scope, &ascii_data).unwrap(); + bench_to_rust_string_lossy(scope, v8_str, "ascii_to_rust_string_lossy"); + bench_write_utf8_into(scope, v8_str, "ascii_write_utf8_into"); + bench_to_rust_cow_lossy(scope, v8_str, "ascii_to_rust_cow_lossy"); + } + + // 2) Latin-1 string (non-ASCII one-byte) + // Create via new_from_one_byte with bytes in 0x80..0xFF range + { + let latin1_data: Vec = + (0..size).map(|i| 0xC0 + (i % 64) as u8).collect(); + let v8_str = v8::String::new_from_one_byte( + scope, + &latin1_data, + v8::NewStringType::Normal, + ) + .unwrap(); + bench_to_rust_string_lossy(scope, v8_str, "latin1_to_rust_string_lossy"); + bench_write_utf8_into(scope, v8_str, "latin1_write_utf8_into"); + bench_to_rust_cow_lossy(scope, v8_str, "latin1_to_rust_cow_lossy"); + } + + // 3) Two-byte string (UTF-16 with characters outside Latin-1) + // Use codepoints like U+0400..U+04FF (Cyrillic) to force two-byte representation + { + let utf16_data: Vec = + (0..size).map(|i| 0x0400 + (i % 256) as u16).collect(); + let v8_str = v8::String::new_from_two_byte( + scope, + &utf16_data, + v8::NewStringType::Normal, + ) + .unwrap(); + bench_to_rust_string_lossy(scope, v8_str, "twobyte_to_rust_string_lossy"); + bench_write_utf8_into(scope, v8_str, "twobyte_write_utf8_into"); + bench_to_rust_cow_lossy(scope, v8_str, "twobyte_to_rust_cow_lossy"); + } + + println!(); + } +} + +fn bench_to_rust_string_lossy( + scope: &mut v8::PinScope<'_, '_>, + s: v8::Local<'_, v8::String>, + label: &str, +) { + let iterations = iterations_for_length(s.length()); + let start = std::time::Instant::now(); + for _ in 0..iterations { + let _ = std::hint::black_box(s.to_rust_string_lossy(scope)); + } + let elapsed = start.elapsed(); + print_result(label, elapsed, iterations, s.length()); +} + +fn bench_write_utf8_into( + scope: &mut v8::PinScope<'_, '_>, + s: v8::Local<'_, v8::String>, + label: &str, +) { + let iterations = iterations_for_length(s.length()); + let mut buf = String::new(); + let start = std::time::Instant::now(); + for _ in 0..iterations { + s.write_utf8_into(scope, &mut buf); + std::hint::black_box(&buf); + } + let elapsed = start.elapsed(); + print_result(label, elapsed, iterations, s.length()); +} + +fn bench_to_rust_cow_lossy( + scope: &mut v8::PinScope<'_, '_>, + s: v8::Local<'_, v8::String>, + label: &str, +) { + let iterations = iterations_for_length(s.length()); + let start = std::time::Instant::now(); + for _ in 0..iterations { + let mut buffer = [std::mem::MaybeUninit::uninit(); 2048]; + let _ = std::hint::black_box(s.to_rust_cow_lossy(scope, &mut buffer)); + } + let elapsed = start.elapsed(); + print_result(label, elapsed, iterations, s.length()); +} + +fn iterations_for_length(len: usize) -> u64 { + // More iterations for shorter strings to get stable timings + match len { + 0..=64 => 5_000_000, + 65..=512 => 2_000_000, + 513..=4096 => 500_000, + _ => 100_000, + } +} + +fn print_result( + label: &str, + elapsed: std::time::Duration, + iterations: u64, + length: usize, +) { + let total_ns = elapsed.as_nanos() as f64; + let ns_per_iter = total_ns / iterations as f64; + let throughput_mb = + (length as f64 * iterations as f64) / (elapsed.as_secs_f64() * 1e6); + println!(" {ns_per_iter:8.1} ns/iter {throughput_mb:8.1} MB/s {label}",); +} diff --git a/build.rs b/build.rs index a2a2e4596f..30b69f0205 100644 --- a/build.rs +++ b/build.rs @@ -318,6 +318,14 @@ fn build_v8(is_asan: bool) { env::var("CARGO_FEATURE_SIMDUTF").is_ok() )); + // When the `no_icu` feature is enabled, build V8 without i18n/ICU support. + // `v8_enable_i18n_support=false` drops the embedded ICU data and the `Intl` + // API, while `rusty_v8_enable_i18n` gates the ICU bindings in + // `src/binding.cc` so the static library still links without ICU. + let enable_i18n = env::var("CARGO_FEATURE_NO_ICU").is_err(); + gn_args.push(format!("v8_enable_i18n_support={enable_i18n}")); + gn_args.push(format!("rusty_v8_enable_i18n={enable_i18n}")); + // Fix GN's host_cpu detection when using x86_64 bins on Apple Silicon if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") { gn_args.push("host_cpu=\"arm64\"".to_string()); @@ -571,6 +579,9 @@ fn prebuilt_features_suffix() -> String { if env::var("CARGO_FEATURE_SIMDUTF").is_ok() { features.push_str("_simdutf"); } + if env::var("CARGO_FEATURE_NO_ICU").is_ok() { + features.push_str("_noicu"); + } features } diff --git a/empty.js b/empty.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gen/src_binding_release_aarch64-apple-darwin.rs b/gen/src_binding_release_aarch64-apple-darwin.rs new file mode 100644 index 0000000000..0c3f2f4548 --- /dev/null +++ b/gen/src_binding_release_aarch64-apple-darwin.rs @@ -0,0 +1,946 @@ +/* automatically generated by rust-bindgen 0.72.0 */ + +#[doc = " Base class for managed objects. Only descendent types of `GarbageCollected`\n can be constructed using `MakeGarbageCollected()`. Must be inherited from as\n left-most base class.\n\n Types inheriting from GarbageCollected must provide a method of\n signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed\n pointers to the visitor and delegates to garbage-collected base classes.\n The method must be virtual if the type is not directly a child of\n GarbageCollected and marked as final.\n\n \\code\n // Example using final class.\n class FinalType final : public GarbageCollected {\n public:\n void Trace(cppgc::Visitor* visitor) const {\n // Dispatch using visitor->Trace(...);\n }\n };\n\n // Example using non-final base class.\n class NonFinalBase : public GarbageCollected {\n public:\n virtual void Trace(cppgc::Visitor*) const {}\n };\n\n class FinalChild final : public NonFinalBase {\n public:\n void Trace(cppgc::Visitor* visitor) const final {\n // Dispatch using visitor->Trace(...);\n NonFinalBase::Trace(visitor);\n }\n };\n \\endcode"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct cppgc_GarbageCollected { + pub _address: u8, +} +pub type cppgc_GarbageCollected_IsGarbageCollectedTypeMarker = + ::std::os::raw::c_void; +pub type cppgc_GarbageCollected_ParentMostGarbageCollectedType = T; +#[repr(C)] +pub struct cppgc_Visitor__bindgen_vtable(::std::os::raw::c_void); +#[doc = " Visitor passed to trace methods. All managed pointers must have called the\n Visitor's trace method on them.\n\n \\code\n class Foo final : public GarbageCollected {\n public:\n void Trace(Visitor* visitor) const {\n visitor->Trace(foo_);\n visitor->Trace(weak_foo_);\n }\n private:\n Member foo_;\n WeakMember weak_foo_;\n };\n \\endcode"] +#[repr(C)] +#[derive(Debug)] +pub struct cppgc_Visitor { + pub vtable_: *const cppgc_Visitor__bindgen_vtable, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct cppgc_Visitor_Key { + pub _address: u8, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of cppgc_Visitor_Key"] + [::std::mem::size_of::() - 1usize]; + ["Alignment of cppgc_Visitor_Key"] + [::std::mem::align_of::() - 1usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of cppgc_Visitor"][::std::mem::size_of::() - 8usize]; + ["Alignment of cppgc_Visitor"] + [::std::mem::align_of::() - 8usize]; +}; +#[repr(C)] +pub struct cppgc_NameProvider__bindgen_vtable(::std::os::raw::c_void); +#[doc = " NameProvider allows for providing a human-readable name for garbage-collected\n objects.\n\n There's two cases of names to distinguish:\n a. Explicitly specified names via using NameProvider. Such names are always\n preserved in the system.\n b. Internal names that Oilpan infers from a C++ type on the class hierarchy\n of the object. This is not necessarily the type of the actually\n instantiated object.\n\n Depending on the build configuration, Oilpan may hide names, i.e., represent\n them with kHiddenName, of case b. to avoid exposing internal details."] +#[repr(C)] +#[derive(Debug)] +pub struct cppgc_NameProvider { + pub vtable_: *const cppgc_NameProvider__bindgen_vtable, +} +#[doc = " Name that is used when hiding internals."] +pub const cppgc_NameProvider_kHiddenName: &::std::ffi::CStr = c"InternalNode"; +#[doc = " Name that is used in case compiler support is missing for composing a name\n from C++ types."] +pub const cppgc_NameProvider_kNoNameDeducible: &::std::ffi::CStr = c""; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of cppgc_NameProvider"] + [::std::mem::size_of::() - 8usize]; + ["Alignment of cppgc_NameProvider"] + [::std::mem::align_of::() - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_String_WriteFlags { + pub _address: u8, +} +pub const v8_String_WriteFlags_kNone: v8_String_WriteFlags__bindgen_ty_1 = 0; +pub const v8_String_WriteFlags_kNullTerminate: + v8_String_WriteFlags__bindgen_ty_1 = 1; +pub const v8_String_WriteFlags_kReplaceInvalidUtf8: + v8_String_WriteFlags__bindgen_ty_1 = 2; +pub type v8_String_WriteFlags__bindgen_ty_1 = ::std::os::raw::c_uint; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_String_WriteFlags"] + [::std::mem::size_of::() - 1usize]; + ["Alignment of v8_String_WriteFlags"] + [::std::mem::align_of::() - 1usize]; +}; +#[repr(C)] +pub struct v8_String_ExternalStringResourceBase__bindgen_vtable( + ::std::os::raw::c_void, +); +#[repr(C)] +#[derive(Debug)] +pub struct v8_String_ExternalStringResourceBase { + pub vtable_: *const v8_String_ExternalStringResourceBase__bindgen_vtable, +} +#[repr(C)] +pub struct v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder__bindgen_vtable( + ::std::os::raw::c_void, +); +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder { pub vtable_ : * const v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder__bindgen_vtable , } +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder"] + [::std::mem::size_of::< + v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder, + >() + - 8usize]; + [ + "Alignment of v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder", + ][::std::mem::align_of::< + v8_String_ExternalStringResourceBase_SharedMemoryUsageRecorder, + >() + - 8usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v86String26ExternalStringResourceBase22kDefaultMemoryEstimateE"] + pub static v8_String_ExternalStringResourceBase_kDefaultMemoryEstimate: usize; +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_String_ExternalStringResourceBase"] + [::std::mem::size_of::() - 8usize]; + ["Alignment of v8_String_ExternalStringResourceBase"] + [::std::mem::align_of::() - 8usize]; +}; +#[doc = " An ExternalOneByteStringResource is a wrapper around an one-byte\n string buffer that resides outside V8's heap. Implement an\n ExternalOneByteStringResource to manage the life cycle of the\n underlying buffer. Note that the string data must be immutable\n and that the data must be Latin-1 and not UTF-8, which would require\n special treatment internally in the engine and do not allow efficient\n indexing. Use String::New or convert to 16 bit data for non-Latin1."] +#[repr(C)] +#[derive(Debug)] +pub struct v8_String_ExternalOneByteStringResource { + pub _base: v8_String_ExternalStringResourceBase, + pub cached_data_: *const ::std::os::raw::c_char, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_String_ExternalOneByteStringResource"][::std::mem::size_of::< + v8_String_ExternalOneByteStringResource, + >() + - 16usize]; + ["Alignment of v8_String_ExternalOneByteStringResource"][::std::mem::align_of::< + v8_String_ExternalOneByteStringResource, + >() - 8usize]; + ["Offset of field: v8_String_ExternalOneByteStringResource::cached_data_"][::std::mem::offset_of!( + v8_String_ExternalOneByteStringResource, + cached_data_ + ) + - 8usize]; +}; +unsafe extern "C" { + #[doc = " Update {cached_data_} with the data from the underlying buffer. This can\n be called only for cacheable resources."] + #[link_name = "\u{1}__ZN2v86String29ExternalOneByteStringResource15UpdateDataCacheEv"] + pub fn v8_String_ExternalOneByteStringResource_UpdateDataCache( + this: *mut v8_String_ExternalOneByteStringResource, + ); +} +impl v8_String_ExternalOneByteStringResource { + #[inline] + pub unsafe fn UpdateDataCache(&mut self) { + v8_String_ExternalOneByteStringResource_UpdateDataCache(self) + } +} +#[repr(C)] +#[derive(Debug)] +pub struct v8_Object_Wrappable { + pub _base_1: cppgc_NameProvider, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_Object_Wrappable"] + [::std::mem::size_of::() - 8usize]; + ["Alignment of v8_Object_Wrappable"] + [::std::mem::align_of::() - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_CTypeInfo { + pub type_: v8_CTypeInfo_Type, + pub flags_: v8_CTypeInfo_Flags, +} +pub const v8_CTypeInfo_Type_kVoid: v8_CTypeInfo_Type = 0; +pub const v8_CTypeInfo_Type_kBool: v8_CTypeInfo_Type = 1; +pub const v8_CTypeInfo_Type_kUint8: v8_CTypeInfo_Type = 2; +pub const v8_CTypeInfo_Type_kInt32: v8_CTypeInfo_Type = 3; +pub const v8_CTypeInfo_Type_kUint32: v8_CTypeInfo_Type = 4; +pub const v8_CTypeInfo_Type_kInt64: v8_CTypeInfo_Type = 5; +pub const v8_CTypeInfo_Type_kUint64: v8_CTypeInfo_Type = 6; +pub const v8_CTypeInfo_Type_kFloat32: v8_CTypeInfo_Type = 7; +pub const v8_CTypeInfo_Type_kFloat64: v8_CTypeInfo_Type = 8; +pub const v8_CTypeInfo_Type_kPointer: v8_CTypeInfo_Type = 9; +pub const v8_CTypeInfo_Type_kV8Value: v8_CTypeInfo_Type = 10; +pub const v8_CTypeInfo_Type_kSeqOneByteString: v8_CTypeInfo_Type = 11; +pub const v8_CTypeInfo_Type_kApiObject: v8_CTypeInfo_Type = 12; +pub const v8_CTypeInfo_Type_kAny: v8_CTypeInfo_Type = 13; +pub type v8_CTypeInfo_Type = u8; +pub const v8_CTypeInfo_Flags_kNone: v8_CTypeInfo_Flags = 0; +pub const v8_CTypeInfo_Flags_kAllowSharedBit: v8_CTypeInfo_Flags = 1; +pub const v8_CTypeInfo_Flags_kEnforceRangeBit: v8_CTypeInfo_Flags = 2; +pub const v8_CTypeInfo_Flags_kClampBit: v8_CTypeInfo_Flags = 4; +pub const v8_CTypeInfo_Flags_kIsRestrictedBit: v8_CTypeInfo_Flags = 8; +pub type v8_CTypeInfo_Flags = u8; +pub type v8_CTypeInfo_Identifier = u32; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v89CTypeInfo20kCallbackOptionsTypeE"] + pub static v8_CTypeInfo_kCallbackOptionsType: v8_CTypeInfo_Type; +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_CTypeInfo"][::std::mem::size_of::() - 2usize]; + ["Alignment of v8_CTypeInfo"] + [::std::mem::align_of::() - 1usize]; + ["Offset of field: v8_CTypeInfo::type_"] + [::std::mem::offset_of!(v8_CTypeInfo, type_) - 0usize]; + ["Offset of field: v8_CTypeInfo::flags_"] + [::std::mem::offset_of!(v8_CTypeInfo, flags_) - 1usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_FastOneByteString { + pub data: *const ::std::os::raw::c_char, + pub length: u32, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_FastOneByteString"] + [::std::mem::size_of::() - 16usize]; + ["Alignment of v8_FastOneByteString"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_FastOneByteString::data"] + [::std::mem::offset_of!(v8_FastOneByteString, data) - 0usize]; + ["Offset of field: v8_FastOneByteString::length"] + [::std::mem::offset_of!(v8_FastOneByteString, length) - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_CFunctionInfo { + pub return_info_: v8_CTypeInfo, + pub repr_: v8_CFunctionInfo_Int64Representation, + pub arg_count_: ::std::os::raw::c_uint, + pub arg_info_: *const v8_CTypeInfo, +} +pub const v8_CFunctionInfo_Int64Representation_kNumber: + v8_CFunctionInfo_Int64Representation = 0; +pub const v8_CFunctionInfo_Int64Representation_kBigInt: + v8_CFunctionInfo_Int64Representation = 1; +pub type v8_CFunctionInfo_Int64Representation = u8; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_CFunctionInfo"] + [::std::mem::size_of::() - 16usize]; + ["Alignment of v8_CFunctionInfo"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_CFunctionInfo::return_info_"] + [::std::mem::offset_of!(v8_CFunctionInfo, return_info_) - 0usize]; + ["Offset of field: v8_CFunctionInfo::repr_"] + [::std::mem::offset_of!(v8_CFunctionInfo, repr_) - 2usize]; + ["Offset of field: v8_CFunctionInfo::arg_count_"] + [::std::mem::offset_of!(v8_CFunctionInfo, arg_count_) - 4usize]; + ["Offset of field: v8_CFunctionInfo::arg_info_"] + [::std::mem::offset_of!(v8_CFunctionInfo, arg_info_) - 8usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZNK2v813CFunctionInfo12ArgumentInfoEj"] + pub fn v8_CFunctionInfo_ArgumentInfo( + this: *const v8_CFunctionInfo, + index: ::std::os::raw::c_uint, + ) -> *const v8_CTypeInfo; +} +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v813CFunctionInfoC1ERKNS_9CTypeInfoEjPS2_NS0_19Int64RepresentationE"] + pub fn v8_CFunctionInfo_CFunctionInfo( + this: *mut v8_CFunctionInfo, + return_info: *const v8_CTypeInfo, + arg_count: ::std::os::raw::c_uint, + arg_info: *const v8_CTypeInfo, + repr: v8_CFunctionInfo_Int64Representation, + ); +} +impl v8_CFunctionInfo { + #[inline] + pub unsafe fn ArgumentInfo( + &self, + index: ::std::os::raw::c_uint, + ) -> *const v8_CTypeInfo { + v8_CFunctionInfo_ArgumentInfo(self, index) + } + #[inline] + pub unsafe fn new( + return_info: *const v8_CTypeInfo, + arg_count: ::std::os::raw::c_uint, + arg_info: *const v8_CTypeInfo, + repr: v8_CFunctionInfo_Int64Representation, + ) -> Self { + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + v8_CFunctionInfo_CFunctionInfo( + __bindgen_tmp.as_mut_ptr(), + return_info, + arg_count, + arg_info, + repr, + ); + __bindgen_tmp.assume_init() + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_CFunction { + pub address_: *const ::std::os::raw::c_void, + pub type_info_: *const v8_CFunctionInfo, +} +pub const v8_CFunction_OverloadResolution_kImpossible: + v8_CFunction_OverloadResolution = 0; +pub const v8_CFunction_OverloadResolution_kAtRuntime: + v8_CFunction_OverloadResolution = 1; +pub const v8_CFunction_OverloadResolution_kAtCompileTime: + v8_CFunction_OverloadResolution = 2; +pub type v8_CFunction_OverloadResolution = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_CFunction_ArgUnwrap { + pub _address: u8, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_CFunction"][::std::mem::size_of::() - 16usize]; + ["Alignment of v8_CFunction"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_CFunction::address_"] + [::std::mem::offset_of!(v8_CFunction, address_) - 0usize]; + ["Offset of field: v8_CFunction::type_info_"] + [::std::mem::offset_of!(v8_CFunction, type_info_) - 8usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v89CFunctionC1EPKvPKNS_13CFunctionInfoE"] + pub fn v8_CFunction_CFunction( + this: *mut v8_CFunction, + address: *const ::std::os::raw::c_void, + type_info: *const v8_CFunctionInfo, + ); +} +impl v8_CFunction { + #[inline] + pub unsafe fn new( + address: *const ::std::os::raw::c_void, + type_info: *const v8_CFunctionInfo, + ) -> Self { + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + v8_CFunction_CFunction(__bindgen_tmp.as_mut_ptr(), address, type_info); + __bindgen_tmp.assume_init() + } +} +impl v8_GCType { + pub const kGCTypeScavenge: v8_GCType = v8_GCType(1); + pub const kGCTypeMinorMarkSweep: v8_GCType = v8_GCType(2); + pub const kGCTypeMarkSweepCompact: v8_GCType = v8_GCType(4); + pub const kGCTypeIncrementalMarking: v8_GCType = v8_GCType(8); + pub const kGCTypeProcessWeakCallbacks: v8_GCType = v8_GCType(16); + pub const kGCTypeAll: v8_GCType = v8_GCType(31); +} +impl ::std::ops::BitOr for v8_GCType { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + v8_GCType(self.0 | other.0) + } +} +impl ::std::ops::BitOrAssign for v8_GCType { + #[inline] + fn bitor_assign(&mut self, rhs: v8_GCType) { + self.0 |= rhs.0; + } +} +impl ::std::ops::BitAnd for v8_GCType { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + v8_GCType(self.0 & other.0) + } +} +impl ::std::ops::BitAndAssign for v8_GCType { + #[inline] + fn bitand_assign(&mut self, rhs: v8_GCType) { + self.0 &= rhs.0; + } +} +#[repr(transparent)] +#[doc = " Applications can register callback functions which will be called before and\n after certain garbage collection operations. Allocations are not allowed in\n the callback functions, you therefore cannot manipulate objects (set or\n delete properties for example) since it is possible such operations will\n result in the allocation of objects.\n TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct v8_GCType(pub ::std::os::raw::c_uint); +impl v8_GCCallbackFlags { + pub const kNoGCCallbackFlags: v8_GCCallbackFlags = v8_GCCallbackFlags(0); + pub const kGCCallbackFlagConstructRetainedObjectInfos: v8_GCCallbackFlags = + v8_GCCallbackFlags(2); + pub const kGCCallbackFlagForced: v8_GCCallbackFlags = v8_GCCallbackFlags(4); + pub const kGCCallbackFlagSynchronousPhantomCallbackProcessing: + v8_GCCallbackFlags = v8_GCCallbackFlags(8); + pub const kGCCallbackFlagCollectAllAvailableGarbage: v8_GCCallbackFlags = + v8_GCCallbackFlags(16); + pub const kGCCallbackFlagCollectAllExternalMemory: v8_GCCallbackFlags = + v8_GCCallbackFlags(32); + pub const kGCCallbackScheduleIdleGarbageCollection: v8_GCCallbackFlags = + v8_GCCallbackFlags(64); + pub const kGCCallbackFlagLastResort: v8_GCCallbackFlags = + v8_GCCallbackFlags(128); +} +impl ::std::ops::BitOr for v8_GCCallbackFlags { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + v8_GCCallbackFlags(self.0 | other.0) + } +} +impl ::std::ops::BitOrAssign for v8_GCCallbackFlags { + #[inline] + fn bitor_assign(&mut self, rhs: v8_GCCallbackFlags) { + self.0 |= rhs.0; + } +} +impl ::std::ops::BitAnd for v8_GCCallbackFlags { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + v8_GCCallbackFlags(self.0 & other.0) + } +} +impl ::std::ops::BitAndAssign for v8_GCCallbackFlags { + #[inline] + fn bitand_assign(&mut self, rhs: v8_GCCallbackFlags) { + self.0 &= rhs.0; + } +} +#[repr(transparent)] +#[doc = " GCCallbackFlags is used to notify additional information about the GC\n callback.\n - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for\n constructing retained object infos.\n - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.\n - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback\n is called synchronously without getting posted to an idle task.\n - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called\n in a phase where V8 is trying to collect all available garbage\n (e.g., handling a low memory notification).\n - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to\n trigger an idle garbage collection."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct v8_GCCallbackFlags(pub ::std::os::raw::c_uint); +#[repr(i32)] +#[doc = " Import phases in import requests."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum v8_ModuleImportPhase { + kSource = 0, + kDefer = 1, + kEvaluation = 2, +} +#[doc = " Collection of V8 heap information.\n\n Instances of this class can be passed to v8::Isolate::GetHeapStatistics to\n get heap statistics from V8."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_HeapStatistics { + pub total_heap_size_: usize, + pub total_heap_size_executable_: usize, + pub total_physical_size_: usize, + pub total_available_size_: usize, + pub used_heap_size_: usize, + pub heap_size_limit_: usize, + pub malloced_memory_: usize, + pub external_memory_: usize, + pub peak_malloced_memory_: usize, + pub does_zap_garbage_: bool, + pub number_of_native_contexts_: usize, + pub number_of_detached_contexts_: usize, + pub total_global_handles_size_: usize, + pub used_global_handles_size_: usize, + pub total_allocated_bytes_: u64, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_HeapStatistics"] + [::std::mem::size_of::() - 120usize]; + ["Alignment of v8_HeapStatistics"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_HeapStatistics::total_heap_size_"] + [::std::mem::offset_of!(v8_HeapStatistics, total_heap_size_) - 0usize]; + ["Offset of field: v8_HeapStatistics::total_heap_size_executable_"][::std::mem::offset_of!( + v8_HeapStatistics, + total_heap_size_executable_ + ) + - 8usize]; + ["Offset of field: v8_HeapStatistics::total_physical_size_"] + [::std::mem::offset_of!(v8_HeapStatistics, total_physical_size_) - 16usize]; + ["Offset of field: v8_HeapStatistics::total_available_size_"][::std::mem::offset_of!( + v8_HeapStatistics, + total_available_size_ + ) - 24usize]; + ["Offset of field: v8_HeapStatistics::used_heap_size_"] + [::std::mem::offset_of!(v8_HeapStatistics, used_heap_size_) - 32usize]; + ["Offset of field: v8_HeapStatistics::heap_size_limit_"] + [::std::mem::offset_of!(v8_HeapStatistics, heap_size_limit_) - 40usize]; + ["Offset of field: v8_HeapStatistics::malloced_memory_"] + [::std::mem::offset_of!(v8_HeapStatistics, malloced_memory_) - 48usize]; + ["Offset of field: v8_HeapStatistics::external_memory_"] + [::std::mem::offset_of!(v8_HeapStatistics, external_memory_) - 56usize]; + ["Offset of field: v8_HeapStatistics::peak_malloced_memory_"][::std::mem::offset_of!( + v8_HeapStatistics, + peak_malloced_memory_ + ) - 64usize]; + ["Offset of field: v8_HeapStatistics::does_zap_garbage_"] + [::std::mem::offset_of!(v8_HeapStatistics, does_zap_garbage_) - 72usize]; + ["Offset of field: v8_HeapStatistics::number_of_native_contexts_"][::std::mem::offset_of!( + v8_HeapStatistics, + number_of_native_contexts_ + ) + - 80usize]; + ["Offset of field: v8_HeapStatistics::number_of_detached_contexts_"][::std::mem::offset_of!( + v8_HeapStatistics, + number_of_detached_contexts_ + ) + - 88usize]; + ["Offset of field: v8_HeapStatistics::total_global_handles_size_"][::std::mem::offset_of!( + v8_HeapStatistics, + total_global_handles_size_ + ) + - 96usize]; + ["Offset of field: v8_HeapStatistics::used_global_handles_size_"][::std::mem::offset_of!( + v8_HeapStatistics, + used_global_handles_size_ + ) + - 104usize]; + ["Offset of field: v8_HeapStatistics::total_allocated_bytes_"][::std::mem::offset_of!( + v8_HeapStatistics, + total_allocated_bytes_ + ) - 112usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v814HeapStatisticsC1Ev"] + pub fn v8_HeapStatistics_HeapStatistics(this: *mut v8_HeapStatistics); +} +impl v8_HeapStatistics { + #[inline] + pub unsafe fn new() -> Self { + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + v8_HeapStatistics_HeapStatistics(__bindgen_tmp.as_mut_ptr()); + __bindgen_tmp.assume_init() + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_HeapSpaceStatistics { + pub space_name_: *const ::std::os::raw::c_char, + pub space_size_: usize, + pub space_used_size_: usize, + pub space_available_size_: usize, + pub physical_space_size_: usize, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_HeapSpaceStatistics"] + [::std::mem::size_of::() - 40usize]; + ["Alignment of v8_HeapSpaceStatistics"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_HeapSpaceStatistics::space_name_"] + [::std::mem::offset_of!(v8_HeapSpaceStatistics, space_name_) - 0usize]; + ["Offset of field: v8_HeapSpaceStatistics::space_size_"] + [::std::mem::offset_of!(v8_HeapSpaceStatistics, space_size_) - 8usize]; + ["Offset of field: v8_HeapSpaceStatistics::space_used_size_"][::std::mem::offset_of!( + v8_HeapSpaceStatistics, + space_used_size_ + ) - 16usize]; + ["Offset of field: v8_HeapSpaceStatistics::space_available_size_"][::std::mem::offset_of!( + v8_HeapSpaceStatistics, + space_available_size_ + ) + - 24usize]; + ["Offset of field: v8_HeapSpaceStatistics::physical_space_size_"][::std::mem::offset_of!( + v8_HeapSpaceStatistics, + physical_space_size_ + ) + - 32usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v819HeapSpaceStatisticsC1Ev"] + pub fn v8_HeapSpaceStatistics_HeapSpaceStatistics( + this: *mut v8_HeapSpaceStatistics, + ); +} +impl v8_HeapSpaceStatistics { + #[inline] + pub unsafe fn new() -> Self { + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + v8_HeapSpaceStatistics_HeapSpaceStatistics(__bindgen_tmp.as_mut_ptr()); + __bindgen_tmp.assume_init() + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct v8_HeapCodeStatistics { + pub code_and_metadata_size_: usize, + pub bytecode_and_metadata_size_: usize, + pub external_script_source_size_: usize, + pub cpu_profiler_metadata_size_: usize, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of v8_HeapCodeStatistics"] + [::std::mem::size_of::() - 32usize]; + ["Alignment of v8_HeapCodeStatistics"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: v8_HeapCodeStatistics::code_and_metadata_size_"][::std::mem::offset_of!( + v8_HeapCodeStatistics, + code_and_metadata_size_ + ) + - 0usize]; + ["Offset of field: v8_HeapCodeStatistics::bytecode_and_metadata_size_"][::std::mem::offset_of!( + v8_HeapCodeStatistics, + bytecode_and_metadata_size_ + ) + - 8usize]; + ["Offset of field: v8_HeapCodeStatistics::external_script_source_size_"][::std::mem::offset_of!( + v8_HeapCodeStatistics, + external_script_source_size_ + ) + - 16usize]; + ["Offset of field: v8_HeapCodeStatistics::cpu_profiler_metadata_size_"][::std::mem::offset_of!( + v8_HeapCodeStatistics, + cpu_profiler_metadata_size_ + ) + - 24usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN2v818HeapCodeStatisticsC1Ev"] + pub fn v8_HeapCodeStatistics_HeapCodeStatistics( + this: *mut v8_HeapCodeStatistics, + ); +} +impl v8_HeapCodeStatistics { + #[inline] + pub unsafe fn new() -> Self { + let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); + v8_HeapCodeStatistics_HeapCodeStatistics(__bindgen_tmp.as_mut_ptr()); + __bindgen_tmp.assume_init() + } +} +#[repr(u32)] +#[doc = " Features reported via the SetUseCounterCallback callback. Do not change\n assigned numbers of existing items; add new features to the end of this\n list.\n Dead features can be marked `V8_DEPRECATE_SOON`, then `V8_DEPRECATED`, and\n then finally be renamed to `kOBSOLETE_...` to stop embedders from using\n them."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum v8_Isolate_UseCounterFeature { + kUseAsm = 0, + kBreakIterator = 1, + kOBSOLETE_LegacyConst = 2, + kOBSOLETE_MarkDequeOverflow = 3, + kOBSOLETE_StoreBufferOverflow = 4, + kOBSOLETE_SlotsBufferOverflow = 5, + kOBSOLETE_ObjectObserve = 6, + kForcedGC = 7, + kSloppyMode = 8, + kStrictMode = 9, + kOBSOLETE_StrongMode = 10, + kRegExpPrototypeStickyGetter = 11, + kRegExpPrototypeToString = 12, + kRegExpPrototypeUnicodeGetter = 13, + kOBSOLETE_IntlV8Parse = 14, + kOBSOLETE_IntlPattern = 15, + kOBSOLETE_IntlResolved = 16, + kOBSOLETE_PromiseChain = 17, + kOBSOLETE_PromiseAccept = 18, + kOBSOLETE_PromiseDefer = 19, + kHtmlCommentInExternalScript = 20, + kHtmlComment = 21, + kSloppyModeBlockScopedFunctionRedefinition = 22, + kForInInitializer = 23, + kOBSOLETE_ArrayProtectorDirtied = 24, + kArraySpeciesModified = 25, + kArrayPrototypeConstructorModified = 26, + kOBSOLETE_ArrayInstanceProtoModified = 27, + kArrayInstanceConstructorModified = 28, + kOBSOLETE_LegacyFunctionDeclaration = 29, + kOBSOLETE_RegExpPrototypeSourceGetter = 30, + kOBSOLETE_RegExpPrototypeOldFlagGetter = 31, + kDecimalWithLeadingZeroInStrictMode = 32, + kLegacyDateParser = 33, + kDefineGetterOrSetterWouldThrow = 34, + kFunctionConstructorReturnedUndefined = 35, + kAssigmentExpressionLHSIsCallInSloppy = 36, + kAssigmentExpressionLHSIsCallInStrict = 37, + kPromiseConstructorReturnedUndefined = 38, + kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn = 39, + kOBSOLETE_LabeledExpressionStatement = 40, + kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator = 41, + kIndexAccessor = 42, + kErrorCaptureStackTrace = 43, + kErrorPrepareStackTrace = 44, + kErrorStackTraceLimit = 45, + kWebAssemblyInstantiation = 46, + kDeoptimizerDisableSpeculation = 47, + kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype = 48, + kFunctionTokenOffsetTooLongForToString = 49, + kWasmSharedMemory = 50, + kWasmThreadOpcodes = 51, + kOBSOLETE_AtomicsNotify = 52, + kOBSOLETE_AtomicsWake = 53, + kCollator = 54, + kNumberFormat = 55, + kDateTimeFormat = 56, + kPluralRules = 57, + kRelativeTimeFormat = 58, + kLocale = 59, + kListFormat = 60, + kSegmenter = 61, + kStringLocaleCompare = 62, + kOBSOLETE_StringToLocaleUpperCase = 63, + kStringToLocaleLowerCase = 64, + kNumberToLocaleString = 65, + kDateToLocaleString = 66, + kDateToLocaleDateString = 67, + kDateToLocaleTimeString = 68, + kAttemptOverrideReadOnlyOnPrototypeSloppy = 69, + kAttemptOverrideReadOnlyOnPrototypeStrict = 70, + kOBSOLETE_OptimizedFunctionWithOneShotBytecode = 71, + kRegExpMatchIsTrueishOnNonJSRegExp = 72, + kRegExpMatchIsFalseishOnJSRegExp = 73, + kOBSOLETE_DateGetTimezoneOffset = 74, + kStringNormalize = 75, + kCallSiteAPIGetFunctionSloppyCall = 76, + kCallSiteAPIGetThisSloppyCall = 77, + kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp = 78, + kRegExpExecCalledOnSlowRegExp = 79, + kRegExpReplaceCalledOnSlowRegExp = 80, + kDisplayNames = 81, + kSharedArrayBufferConstructed = 82, + kArrayPrototypeHasElements = 83, + kObjectPrototypeHasElements = 84, + kNumberFormatStyleUnit = 85, + kDateTimeFormatRange = 86, + kDateTimeFormatDateTimeStyle = 87, + kBreakIteratorTypeWord = 88, + kBreakIteratorTypeLine = 89, + kInvalidatedArrayBufferDetachingProtector = 90, + kInvalidatedArrayConstructorProtector = 91, + kInvalidatedArrayIteratorLookupChainProtector = 92, + kInvalidatedArraySpeciesLookupChainProtector = 93, + kInvalidatedIsConcatSpreadableLookupChainProtector = 94, + kInvalidatedMapIteratorLookupChainProtector = 95, + kInvalidatedNoElementsProtector = 96, + kInvalidatedPromiseHookProtector = 97, + kInvalidatedPromiseResolveLookupChainProtector = 98, + kInvalidatedPromiseSpeciesLookupChainProtector = 99, + kInvalidatedPromiseThenLookupChainProtector = 100, + kInvalidatedRegExpSpeciesLookupChainProtector = 101, + kInvalidatedSetIteratorLookupChainProtector = 102, + kInvalidatedStringIteratorLookupChainProtector = 103, + kInvalidatedStringLengthOverflowLookupChainProtector = 104, + kInvalidatedTypedArraySpeciesLookupChainProtector = 105, + kWasmSimdOpcodes = 106, + kVarRedeclaredCatchBinding = 107, + kWasmRefTypes = 108, + kWasmBulkMemory = 109, + kWasmMultiValue = 110, + kWasmExceptionHandling = 111, + kInvalidatedMegaDOMProtector = 112, + kFunctionPrototypeArguments = 113, + kFunctionPrototypeCaller = 114, + kTurboFanOsrCompileStarted = 115, + kAsyncStackTaggingCreateTaskCall = 116, + kDurationFormat = 117, + kInvalidatedNumberStringNotRegexpLikeProtector = 118, + kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119, + kOBSOLETE_ImportAssertionDeprecatedSyntax = 120, + kLocaleInfoObsoletedGetters = 121, + kLocaleInfoFunctions = 122, + kCompileHintsMagicAll = 123, + kInvalidatedNoProfilingProtector = 124, + kWasmMemory64 = 125, + kWasmMultiMemory = 126, + kWasmGC = 127, + kWasmImportedStrings = 128, + kSourceMappingUrlMagicCommentAtSign = 129, + kTemporalObject = 130, + kWasmModuleCompilation = 131, + kInvalidatedNoUndetectableObjectsProtector = 132, + kWasmJavaScriptPromiseIntegration = 133, + kWasmReturnCall = 134, + kWasmExtendedConst = 135, + kWasmRelaxedSimd = 136, + kWasmTypeReflection = 137, + kWasmExnRef = 138, + kWasmTypedFuncRef = 139, + kInvalidatedStringWrapperToPrimitiveProtector = 140, + kDocumentAllLegacyCall = 141, + kDocumentAllLegacyConstruct = 142, + kConsoleContext = 143, + kWasmImportedStringsUtf8 = 144, + kResizableArrayBuffer = 145, + kGrowableSharedArrayBuffer = 146, + kArrayByCopy = 147, + kArrayFromAsync = 148, + kIteratorMethods = 149, + kPromiseAny = 150, + kSetMethods = 151, + kArrayFindLast = 152, + kArrayGroup = 153, + kArrayBufferTransfer = 154, + kPromiseWithResolvers = 155, + kAtomicsWaitAsync = 156, + kExtendingNonExtensibleWithPrivate = 157, + kPromiseTry = 158, + kStringReplaceAll = 159, + kStringWellFormed = 160, + kWeakReferences = 161, + kErrorIsError = 162, + kInvalidatedTypedArrayLengthLookupChainProtector = 163, + kRegExpEscape = 164, + kFloat16Array = 165, + kExplicitResourceManagement = 166, + kWasmBranchHinting = 167, + kWasmMutableGlobals = 168, + kUint8ArrayToFromBase64AndHex = 169, + kAtomicsPause = 170, + kTopLevelAwait = 171, + kLogicalAssignment = 172, + kNullishCoalescing = 173, + kInvalidatedNoDateTimeConfigurationChangeProtector = 174, + kWasmNonTrappingFloatToInt = 175, + kWasmSignExtensionOps = 176, + kRegExpCompile = 177, + kRegExpStaticProperties = 178, + kRegExpStaticPropertiesWithLastMatch = 179, + kWithStatement = 180, + kHtmlWrapperMethods = 181, + kWasmCustomDescriptors = 182, + kWasmResizableBuffers = 183, + kUseCounterFeatureCount = 184, +} +#[repr(u32)] +#[doc = " Interceptor callbacks use this value to indicate whether the request was\n intercepted or not.\n\n The values for constants and type are chosen this way for better\n performance."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum v8_Intercepted { + kNo = 1, + kYes = 0, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct memory_span_t { + pub data: *mut u8, + pub size: usize, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of memory_span_t"][::std::mem::size_of::() - 16usize]; + ["Alignment of memory_span_t"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: memory_span_t::data"] + [::std::mem::offset_of!(memory_span_t, data) - 0usize]; + ["Offset of field: memory_span_t::size"] + [::std::mem::offset_of!(memory_span_t, size) - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct const_memory_span_t { + pub data: *const u8, + pub size: usize, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of const_memory_span_t"] + [::std::mem::size_of::() - 16usize]; + ["Alignment of const_memory_span_t"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: const_memory_span_t::data"] + [::std::mem::offset_of!(const_memory_span_t, data) - 0usize]; + ["Offset of field: const_memory_span_t::size"] + [::std::mem::offset_of!(const_memory_span_t, size) - 8usize]; +}; +#[repr(C)] +#[derive(Debug)] +pub struct RustObj { + pub _base: v8_Object_Wrappable, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of RustObj"][::std::mem::size_of::() - 8usize]; + ["Alignment of RustObj"][::std::mem::align_of::() - 8usize]; +}; +unsafe extern "C" { + #[link_name = "\u{1}__ZN7RustObjD1Ev"] + pub fn RustObj_RustObj_destructor(this: *mut RustObj); +} +unsafe extern "C" { + #[link_name = "\u{1}__ZNK7RustObj5TraceEPN5cppgc7VisitorE"] + pub fn RustObj_Trace( + this: *mut ::std::os::raw::c_void, + visitor: *mut cppgc_Visitor, + ); +} +unsafe extern "C" { + #[link_name = "\u{1}__ZNK7RustObj20GetHumanReadableNameEv"] + pub fn RustObj_GetHumanReadableName( + this: *mut ::std::os::raw::c_void, + ) -> *const ::std::os::raw::c_char; +} +#[doc = " Types defined here will be compiled with bindgen\n and made available in `crate::binding` in rust."] +pub const v8__ScriptOrigin_SIZE: usize = 40; +pub const cppgc__Member_SIZE: usize = 4; +pub const cppgc__WeakMember_SIZE: usize = 4; +pub const v8__TracedReference_SIZE: usize = 8; +pub const v8__Eternal_SIZE: usize = 8; +pub const v8__String__ValueView_SIZE: usize = 32; +pub const v8__String__kMaxLength: ::std::os::raw::c_int = 536870888; +pub const v8__TypedArray__kMaxByteLength: usize = 9007199254740991; +pub const v8__TYPED_ARRAY_MAX_SIZE_IN_HEAP: usize = 0; +pub const v8__Uint8Array__kMaxLength: usize = 9007199254740991; +pub const v8__Uint8ClampedArray__kMaxLength: usize = 9007199254740991; +pub const v8__Int8Array__kMaxLength: usize = 9007199254740991; +pub const v8__Uint16Array__kMaxLength: usize = 4503599627370495; +pub const v8__Int16Array__kMaxLength: usize = 4503599627370495; +pub const v8__Uint32Array__kMaxLength: usize = 2251799813685247; +pub const v8__Int32Array__kMaxLength: usize = 2251799813685247; +pub const v8__Float16Array__kMaxLength: usize = 4503599627370495; +pub const v8__Float32Array__kMaxLength: usize = 2251799813685247; +pub const v8__Float64Array__kMaxLength: usize = 1125899906842623; +pub const v8__BigUint64Array__kMaxLength: usize = 1125899906842623; +pub const v8__BigInt64Array__kMaxLength: usize = 1125899906842623; +pub type v8__CFunction = v8_CFunction; +pub type v8__CFunctionInfo = v8_CFunctionInfo; +pub type v8__FastOneByteString = v8_FastOneByteString; +#[doc = " Features reported via the SetUseCounterCallback callback. Do not change\n assigned numbers of existing items; add new features to the end of this\n list.\n Dead features can be marked `V8_DEPRECATE_SOON`, then `V8_DEPRECATED`, and\n then finally be renamed to `kOBSOLETE_...` to stop embedders from using\n them."] +pub use self::v8_Isolate_UseCounterFeature as v8__Isolate__UseCounterFeature; +pub type v8__String__WriteFlags = v8_String_WriteFlags; +#[doc = " Import phases in import requests."] +pub use self::v8_ModuleImportPhase as v8__ModuleImportPhase; +#[doc = " Collection of V8 heap information.\n\n Instances of this class can be passed to v8::Isolate::GetHeapStatistics to\n get heap statistics from V8."] +pub type v8__HeapStatistics = v8_HeapStatistics; +pub type v8__HeapSpaceStatistics = v8_HeapSpaceStatistics; +pub type v8__HeapCodeStatistics = v8_HeapCodeStatistics; +#[doc = " GCCallbackFlags is used to notify additional information about the GC\n callback.\n - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for\n constructing retained object infos.\n - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.\n - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback\n is called synchronously without getting posted to an idle task.\n - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called\n in a phase where V8 is trying to collect all available garbage\n (e.g., handling a low memory notification).\n - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to\n trigger an idle garbage collection."] +pub use self::v8_GCCallbackFlags as v8__GCCallbackFlags; +#[doc = " Applications can register callback functions which will be called before and\n after certain garbage collection operations. Allocations are not allowed in\n the callback functions, you therefore cannot manipulate objects (set or\n delete properties for example) since it is possible such operations will\n result in the allocation of objects.\n TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink."] +pub use self::v8_GCType as v8__GCType; +#[doc = " Interceptor callbacks use this value to indicate whether the request was\n intercepted or not.\n\n The values for constants and type are chosen this way for better\n performance."] +pub use self::v8_Intercepted as v8__Intercepted; +pub const v8__MAJOR_VERSION: u32 = 14; +pub const v8__MINOR_VERSION: u32 = 6; +pub const v8__BUILD_NUMBER: u32 = 202; +pub const v8__PATCH_LEVEL: u32 = 9; +pub const v8__VERSION_STRING: &::std::ffi::CStr = c"14.6.202.9-rusty"; +#[repr(C)] +#[derive(Debug)] +pub struct ExternalConstOneByteStringResource { + pub _base: v8_String_ExternalOneByteStringResource, + pub _length: ::std::os::raw::c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of ExternalConstOneByteStringResource"] + [::std::mem::size_of::() - 24usize]; + ["Alignment of ExternalConstOneByteStringResource"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: ExternalConstOneByteStringResource::_length"][::std::mem::offset_of!( + ExternalConstOneByteStringResource, + _length + ) - 16usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + [ + "Size of template specialization: cppgc_GarbageCollected_open0_v8_Object_Wrappable_close0", + ][::std::mem::size_of::() - 1usize]; + [ + "Align of template specialization: cppgc_GarbageCollected_open0_v8_Object_Wrappable_close0", + ][::std::mem::align_of::() - 1usize]; +}; diff --git a/gen/src_binding_release_aarch64-apple-darwin.tmp b/gen/src_binding_release_aarch64-apple-darwin.tmp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/binding.cc b/src/binding.cc index 3bc6e87985..06d721a4a5 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -13,7 +13,9 @@ #include "cppgc/platform.h" #include "libplatform/libplatform.h" #include "support.h" +#ifdef RUSTY_V8_ENABLE_I18N #include "unicode/locid.h" +#endif #include "v8-callbacks.h" #include "v8-cppgc.h" #include "v8-fast-api-calls.h" @@ -4271,6 +4273,8 @@ void v8__CompiledWasmModule__DELETE(v8::CompiledWasmModule* self) { extern "C" { +#ifdef RUSTY_V8_ENABLE_I18N + size_t icu_get_default_locale(char* output, size_t output_len) { const icu_77::Locale& default_locale = icu::Locale::getDefault(); icu_77::CheckedArrayByteSink sink(output, static_cast(output_len)); @@ -4286,6 +4290,27 @@ void icu_set_default_locale(const char* locale) { icu::Locale::setDefault(icu::Locale(locale), status); } +#else // RUSTY_V8_ENABLE_I18N + +// When V8 is built without i18n/ICU support these symbols still need to exist +// so consumers of the crate keep linking. Report a fixed BCP47 language tag and +// ignore attempts to change the default locale. +size_t icu_get_default_locale(char* output, size_t output_len) { + static const char kDefaultLocale[] = "en-US"; + size_t len = sizeof(kDefaultLocale) - 1; + if (len > output_len) { + len = output_len; + } + for (size_t i = 0; i < len; i++) { + output[i] = kDefaultLocale[i]; + } + return len; +} + +void icu_set_default_locale(const char*) {} + +#endif // RUSTY_V8_ENABLE_I18N + } // extern "C" // v8::PropertyDescriptor diff --git a/src/icu.rs b/src/icu.rs index 7737f1aaca..18eb22f301 100644 --- a/src/icu.rs +++ b/src/icu.rs @@ -5,6 +5,9 @@ use std::ffi::CString; unsafe extern "C" { fn icu_get_default_locale(output: *mut char, output_len: usize) -> usize; fn icu_set_default_locale(locale: *const char); + // Only available when V8 is built with i18n/ICU support (i.e. without the + // `no_icu` feature). The symbol is provided by ICU itself. + #[cfg(not(feature = "no_icu"))] fn udata_setCommonData_77(this: *const u8, error_code: *mut i32); } @@ -41,6 +44,10 @@ unsafe extern "C" { /// This function has no effect on application (non ICU) data. See udata_setAppData() for similar /// functionality for application data. // TODO(ry) Map error code to something useful. +// +// Not available when V8 is built without i18n/ICU support (the `no_icu` +// feature), since there is no ICU to hand the data to. +#[cfg(not(feature = "no_icu"))] #[inline(always)] pub fn set_common_data_77(data: &'static [u8]) -> Result<(), i32> { let mut error_code = 0i32; diff --git a/tests/test_api.rs b/tests/test_api.rs index bb3ae8d3ea..501d54cb52 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -46,6 +46,7 @@ mod setup { fn initialize_once() { static START: Once = Once::new(); START.call_once(|| { + #[cfg(not(feature = "no_icu"))] assert!(v8::icu::set_common_data_77(align_data::include_aligned!( align_data::Align16, "../third_party/icu/common/icudtl.dat" @@ -9781,6 +9782,7 @@ fn prepare_stack_trace_callback() { } } +#[cfg(not(feature = "no_icu"))] #[test] fn icu_date() { let _setup_guard = setup::parallel_test(); @@ -9805,6 +9807,7 @@ fn icu_date() { } } +#[cfg(not(feature = "no_icu"))] #[test] fn icu_set_common_data_fail() { assert!( @@ -9812,6 +9815,7 @@ fn icu_set_common_data_fail() { ); } +#[cfg(not(feature = "no_icu"))] #[test] fn icu_format() { let _setup_guard = setup::parallel_test(); @@ -9833,6 +9837,7 @@ fn icu_format() { } } +#[cfg(not(feature = "no_icu"))] #[test] fn icu_collator() { let _setup_guard = setup::parallel_test(); @@ -10633,6 +10638,7 @@ fn instance_of() { assert!(array.instance_of(&scope, array_constructor).unwrap()); } +#[cfg(not(feature = "no_icu"))] #[test] fn get_default_locale() { v8::icu::set_default_locale("nb_NO"); diff --git a/tests/test_cppgc.rs b/tests/test_cppgc.rs index 2dfc8b4e05..d02e793a42 100644 --- a/tests/test_cppgc.rs +++ b/tests/test_cppgc.rs @@ -28,6 +28,7 @@ mod setup { fn initialize_once() { static START: Once = Once::new(); START.call_once(|| { + #[cfg(not(feature = "no_icu"))] assert!(v8::icu::set_common_data_77(align_data::include_aligned!( align_data::Align16, "../third_party/icu/common/icudtl.dat" diff --git a/tools/__pycache__/v8_deps.cpython-311.pyc b/tools/__pycache__/v8_deps.cpython-311.pyc new file mode 100644 index 0000000000..1246f0490f Binary files /dev/null and b/tools/__pycache__/v8_deps.cpython-311.pyc differ