Sign In

v8

Package Overview
Dependencies
Maintainers
0
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8 - cargo Package Compare versions

Comparing version
152.1.0
to
152.2.0
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "8149304f6924411df09a1917cd6de0fc90fa7fec",
"sha1": "2768994f664e8a6e3aba27503606c58339136e2a",
"dirty": true

@@ -5,0 +5,0 @@ },

@@ -776,3 +776,3 @@ # This file is automatically @generated by Cargo.

name = "v8"
version = "152.1.0"
version = "152.2.0"
dependencies = [

@@ -779,0 +779,0 @@ "align-data",

@@ -15,3 +15,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "v8"
version = "152.1.0"
version = "152.2.0"
authors = ["the Deno authors"]

@@ -18,0 +18,0 @@ build = "build.rs"

+120
-4

@@ -5,3 +5,3 @@ # Rusty V8 Binding

[![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/rusty_v8/actions)
[![ci](https://github.com/denoland/rusty_v8/actions/workflows/ci.yml/badge.svg)](https://github.com/denoland/rusty_v8/actions)
[![crates](https://img.shields.io/crates/v/v8.svg)](https://crates.io/crates/v8)

@@ -73,2 +73,39 @@ [![docs](https://docs.rs/v8/badge.svg)](https://docs.rs/v8)

For every artifact (the static lib and the generated `src_binding` file), the
build script tries an ordered list of locations and uses the first one that
works:
1. `RUSTY_V8_ARCHIVE` (static lib) or `RUSTY_V8_SRC_BINDING_URL` (binding
file), if set; either short-circuits everything else for its artifact.
2. The mirror, if `RUSTY_V8_MIRROR` is set. A plain base is expanded to
`<base>/<tag>/<file>`; a value containing `{` placeholders is treated as a
full URL template (see below).
3. For plain filesystem mirrors only: the flat layout `<base>/<file>`, so a
directory of downloaded artifacts works without tag subdirectories.
4. The upstream GitHub release,
`https://github.com/denoland/rusty_v8/releases/download/<tag>/<file>`.
With a mirror configured this is only tried when
`RUSTY_V8_MIRROR_FALLBACK=1` is set: a mirror fails closed by default and
never silently reaches the network.
If every candidate fails, the build script panics with the full list of URLs
it tried.
`<tag>` defaults to `v<version>` (the crate version). Set
`RUSTY_V8_MIRROR_TAG` to override it; the value is used verbatim (no `v` is
prepended), so `RUSTY_V8_MIRROR_TAG=v152.0.0 cargo build` fetches the
artifacts of the last published release when building a checkout whose
`Cargo.toml` version is unpublished.
If the `RUSTY_V8_MIRROR` value contains a `{` placeholder, the whole value is
used as a URL template instead of a base. Supported placeholders: `{tag}`,
`{version}` (no `v` prefix), `{target}`, `{profile}` (`release`/`debug`),
`{features}` (e.g. `_ptrcomp`), and `{file}` (the full artifact filename).
For example:
export RUSTY_V8_MIRROR=https://example.com/rusty_v8/{version}/{file}
Set `RUSTY_V8_MIRROR_FALLBACK=1` to fall back to the upstream GitHub release
when the mirror is missing an artifact, e.g. for partially populated caches.
File-based mirrors are good for using cached downloads. First, point the

@@ -87,7 +124,7 @@ environment variable to a suitable location:

for REL in v0.13.0 v0.12.0; do
for REL in v152.1.0 v152.0.0; do
mkdir -p $RUSTY_V8_MIRROR/$REL
for FILE in \
librusty_v8_debug_x86_64-unknown-linux-gnu.a \
librusty_v8_release_x86_64-unknown-linux-gnu.a \
librusty_v8_release_x86_64-unknown-linux-gnu.a.gz \
src_binding_release_x86_64-unknown-linux-gnu.rs \
; do

@@ -102,2 +139,18 @@ if [ ! -f $RUSTY_V8_MIRROR/$REL/$FILE ]; then

## The `~/.cargo/.rusty_v8` download cache
Before downloading an artifact, the build script looks for a copy in the
`.rusty_v8` directory inside your Cargo home (usually `~/.cargo/.rusty_v8`).
Entries are keyed on the release tag plus the artifact filename, with every
non-alphanumeric character replaced by `_` — for example
`v152.1.0/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz` becomes
`v152_1_0_librusty_v8_release_x86_64_unknown_linux_gnu_a_gz`. The escaped
full source URL, the key used by older versions of the build script, is
still checked as a fallback, so existing caches keep working.
Because the key does not include the source, a cache entry populated for one
mirror also satisfies a build configured for a different mirror (or for the
upstream release) under the same tag. If you need the archive bytes
themselves verified, pin them with `RUSTY_V8_ARCHIVE_SHA256` (below).
## The `RUSTY_V8_ARCHIVE` environment variable

@@ -113,2 +166,49 @@

The value may also name a directory, in which case the expected artifact
filename (e.g. `librusty_v8_release_x86_64-unknown-linux-gnu.a.gz`, gzipped
or plain) is looked up inside it. A directory is also the authoritative
source for the generated `src_binding` file: it is never fetched from the
mirror or the upstream release, so an offline setup that configured only the
directory never reaches the network. If the directory lacks the binding, a
usable binding left on disk by a previous build is reused with a warning;
otherwise the build fails:
```bash
export RUSTY_V8_ARCHIVE=/path/to/downloaded/artifacts
cargo build
```
Set `RUSTY_V8_ARCHIVE_SHA256` to the SHA-256 of the archive to pin its
content. A cached or previously downloaded archive that does not match is
re-fetched, and the build fails if the fresh download does not match either.
The pin covers the archive bytes as fetched, i.e. what `sha256sum` reports
on the `.gz` release asset (or on the plain file when the archive is not
gzipped). Independently of the pin, the build script records the SHA-256 of
every downloaded artifact and re-fetches it if the file on disk no longer
matches.
## The `RUSTY_V8_SRC_BINDING_PATH` and `RUSTY_V8_SRC_BINDING_URL` environment variables
The build also needs a generated `src_binding_..._<target>.rs` file, published
alongside the static library. `RUSTY_V8_SRC_BINDING_PATH` points the build at
a local binding file that is used directly, with no download at all.
`RUSTY_V8_SRC_BINDING_URL` instead gives a URL or path to fetch the binding
from, mirroring what `RUSTY_V8_ARCHIVE` does for the static library. If both
are set, `RUSTY_V8_SRC_BINDING_PATH` wins.
## The `RUSTY_V8_SKIP_DOWNLOAD` environment variable
Set `RUSTY_V8_SKIP_DOWNLOAD=1` to skip downloading the prebuilt static
library. The small generated binding file is still fetched, so `cargo check`
and rust-analyzer work without the (large) prebuilt artifact. Producing a
binary still requires the static library: `cargo build` fails at link time
until the crate is built again with the variable unset.
This variable takes precedence over `RUSTY_V8_ARCHIVE` and `RUSTY_V8_MIRROR`
(the static library is not fetched from anywhere, not even from a local
archive), and it has no effect on `V8_FROM_SOURCE=1` builds. If the binding
file cannot be fetched (for example, the configured mirror does not carry it)
but a previously downloaded binding exists on disk, that file is reused with
a warning instead of failing the build.
## Build V8 from Source

@@ -136,2 +236,18 @@

Linux cross-builds normally discover Clang's builtin headers and the target
libc headers from the host toolchain. For hermetic toolchains where those files
are not installed in host search paths, set the explicit bindgen inputs:
```bash
export LIBCLANG_PATH=/path/to/libclang/lib
export RUSTY_V8_BINDGEN_RESOURCE_DIR=/path/to/lib/clang/21
export RUSTY_V8_GLIBC_PREFIX=/path/to/aarch64-linux-gnu
V8_FROM_SOURCE=1 cargo build -vv --target aarch64-unknown-linux-gnu
```
`RUSTY_V8_BINDGEN_RESOURCE_DIR` takes the directory printed by
`clang -print-resource-dir`. `RUSTY_V8_GLIBC_PREFIX` takes a GNU target prefix
whose `include` child contains the target libc headers. Musl cross-builds use
`RUSTY_V8_MUSL_SYSROOT` instead; it is passed to Clang with `--sysroot`.
For Windows builds: the 64-bit toolchain needs to be used. 32-bit targets are

@@ -138,0 +254,0 @@ not supported. The default source build downloads Chromium's pinned libclang

@@ -238,6 +238,3 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.

fn test_default_allocator() {
crate::V8::initialize_platform(
crate::new_default_platform(0, false).make_shared(),
);
crate::V8::initialize();
crate::initialize_v8();
new_default_allocator();

@@ -244,0 +241,0 @@ }

@@ -18,2 +18,3 @@ use crate::isolate::RealIsolate;

use std::ffi::c_void;
use std::ptr::NonNull;
use std::ptr::{null, null_mut};

@@ -146,9 +147,27 @@ use std::rc::Rc;

/// Returns the microtask queue associated with this context.
///
/// Returns `None` if the context has no microtask queue, which is the case
/// after its global object has been detached — detaching clears the native
/// context's microtask queue pointer.
#[inline(always)]
pub fn get_microtask_queue(&self) -> &MicrotaskQueue {
unsafe { &*v8__Context__GetMicrotaskQueue(self) }
pub fn get_microtask_queue(&self) -> Option<&MicrotaskQueue> {
let queue = unsafe { v8__Context__GetMicrotaskQueue(self) };
NonNull::new(queue.cast_mut()).map(|queue| unsafe { &*queue.as_ptr() })
}
/// Associates this context with the given microtask queue.
///
/// # Panics
///
/// Panics if this context has no microtask queue, i.e. if its global object
/// has been detached. V8 unconditionally dereferences the existing queue
/// when setting a new one, so a detached context cannot be re-associated
/// with a microtask queue.
#[inline(always)]
pub fn set_microtask_queue(&self, microtask_queue: &MicrotaskQueue) {
assert!(
self.get_microtask_queue().is_some(),
"cannot set a microtask queue on a context whose global object has been detached"
);
unsafe {

@@ -155,0 +174,0 @@ v8__Context__SetMicrotaskQueue(self, microtask_queue);

@@ -8,2 +8,4 @@ use crate::support::char;

fn icu_set_default_locale(locale: *const char);
fn icu_get_default_time_zone(output: *mut char, output_len: usize) -> usize;
fn icu_set_default_time_zone(time_zone_id: *const char) -> bool;
fn udata_setCommonData_78(this: *const u8, error_code: *mut i32);

@@ -73,1 +75,42 @@ }

}
/// Returns the id of ICU's current default time zone, usually an IANA id such
/// as `"America/New_York"`. It can also be a custom offset id like
/// `"GMT+05:00"`, either because one was installed with
/// [`set_default_time_zone`] or because the host reported its zone that way,
/// so don't assume the result resolves against the tz database.
///
/// If the host time zone could not be determined, ICU reports the special
/// id `"Etc/Unknown"`, which behaves as GMT.
pub fn get_default_time_zone() -> String {
let mut output = [0u8; 1024];
let len = unsafe {
icu_get_default_time_zone(output.as_mut_ptr() as *mut char, output.len())
};
std::str::from_utf8(&output[..len]).unwrap().to_owned()
}
/// Sets ICU's default time zone from a time zone id (e.g. `"UTC"`,
/// `"Asia/Manila"`). This makes `Date` resolve the given zone on every
/// platform, including Windows, where ICU otherwise reads the host time
/// zone from the OS and ignores the `TZ` environment variable.
///
/// Returns `false` — leaving the current default untouched — if `time_zone_id`
/// is not a time zone id ICU recognizes. Note that ICU's own "unknown zone"
/// id, `"Etc/Unknown"`, is rejected as well. Besides IANA ids, ICU accepts
/// custom offset ids such as `"GMT+05:00"`.
///
/// This mutates process wide state and is not synchronized with isolates
/// running on other threads, so it should be called before those isolates
/// evaluate any code observing the time zone. Afterwards, notify each isolate
/// via [`crate::Isolate::date_time_configuration_change_notification`] with
/// [`crate::TimeZoneDetection::Skip`] so cached values are refreshed without
/// re-detecting (and overwriting) the zone just set here.
#[must_use]
pub fn set_default_time_zone(time_zone_id: &str) -> bool {
let Ok(c_str) = CString::new(time_zone_id) else {
// An interior nul byte can't be a valid time zone id.
return false;
};
unsafe { icu_set_default_time_zone(c_str.as_ptr()) }
}

@@ -98,2 +98,10 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.

) -> *mut RawRemoteObject;
fn v8_inspector__V8InspectorSession__unwrapObject(
session: *mut RawV8InspectorSession,
error: *mut *mut StringBuffer,
object_id: StringView,
value: *mut *const Value,
context: *mut *const Context,
object_group: *mut *mut StringBuffer,
) -> bool;
fn v8_inspector__RemoteObject__DELETE(this: *mut RawRemoteObject);

@@ -852,2 +860,51 @@ fn v8_inspector__RemoteObject__toBytes(

/// Resolves an Inspector-generated object ID to its V8 value and context.
///
/// On success, the returned object group contains the group name supplied
/// when the object was wrapped. An empty group name is returned as a
/// non-null buffer containing an empty string. On failure, the error buffer
/// is non-null and contains the Inspector's error message. This includes an
/// invalid ID or an ID made stale by releasing its object group.
///
/// `_scope` is intentionally unused by Rust; borrowing it keeps the caller's
/// V8 `HandleScope` alive and ties the returned local handles to that scope.
#[allow(clippy::type_complexity)]
pub fn unwrap_object<'s>(
&self,
_scope: &mut PinScope<'s, '_>,
object_id: StringView,
) -> Result<
(
Local<'s, Value>,
Local<'s, Context>,
UniquePtr<StringBuffer>,
),
UniquePtr<StringBuffer>,
> {
let mut error = std::ptr::null_mut();
let mut value = std::ptr::null();
let mut context = std::ptr::null();
let mut object_group = std::ptr::null_mut();
let success = unsafe {
v8_inspector__V8InspectorSession__unwrapObject(
self.raw.as_ptr(),
&mut error,
object_id,
&mut value,
&mut context,
&mut object_group,
)
};
if !success {
return Err(unsafe { UniquePtr::from_raw(error) });
}
Ok((
unsafe { Local::from_raw(value).unwrap() },
unsafe { Local::from_raw(context).unwrap() },
unsafe { UniquePtr::from_raw(object_group) },
))
}
pub fn schedule_pause_on_next_statement(

@@ -854,0 +911,0 @@ &self,

@@ -127,2 +127,4 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.

pub use isolate::MicrotasksPolicy;
pub use isolate::ModifyCodeGenerationFromStringsCallback;
pub use isolate::ModifyCodeGenerationFromStringsResult;
pub use isolate::ModuleImportPhase;

@@ -129,0 +131,0 @@ pub use isolate::NearHeapLimitCallback;

@@ -107,2 +107,17 @@ // Copyright 2019-2026 the Deno authors. All rights reserved. MIT license.

/// fewer workers, it is worth doing.
///
/// # Initialize V8 before creating the threads that will lock
///
/// Every thread that calls [`SharedIsolate::lock`] must have been created
/// *after* [`V8::initialize`](crate::V8::initialize). On hardware with
/// memory protection keys, V8 guards its pointer tables with a key whose
/// access lives in the per-thread `PKRU` register, and a thread inherits
/// that access only at creation time. A worker created before V8 was
/// initialized will lock successfully and then take `SIGSEGV` with
/// `si_code == SEGV_PKUERR` the first time it runs JavaScript.
///
/// The failure is easy to misread: it presents as a fault on a mapped,
/// readable page, and no debug build, heap verifier or handle check
/// reports anything, because nothing is corrupt. See
/// [`V8::initialize`](crate::V8::initialize) for the full description.
#[derive(Debug)]

@@ -109,0 +124,0 @@ pub struct SharedIsolate {

@@ -244,2 +244,3 @@ use std::mem::MaybeUninit;

fn v8__Module__IsGraphAsync(this: *const Module) -> bool;
fn v8__Module__HasTopLevelAwait(this: *const Module) -> bool;
fn v8__Module__IsSourceTextModule(this: *const Module) -> bool;

@@ -498,2 +499,14 @@ fn v8__Module__IsSyntheticModule(this: *const Module) -> bool;

/// Returns whether this module is individually asynchronous (for example,
/// if it's a Source Text Module Record containing a top-level await).
/// See [[HasTLA]] in <https://tc39.es/ecma262/#sec-cyclic-module-records>
///
/// Unlike [`Self::is_graph_async`], this says nothing about the module's
/// dependencies and imposes no requirement on the module's status, so it can
/// be called on a module that has only been compiled.
#[inline(always)]
pub fn has_top_level_await(&self) -> bool {
unsafe { v8__Module__HasTopLevelAwait(self) }
}
/// Returns whether the module is a SourceTextModule.

@@ -500,0 +513,0 @@ #[inline(always)]

@@ -31,2 +31,3 @@ use std::mem::MaybeUninit;

) -> *const UnboundScript;
fn v8__Script__ScriptId(script: *const Script) -> i32;
fn v8__Script__Run(

@@ -91,2 +92,8 @@ script: *const Script,

/// Returns the ID assigned to the underlying script by V8.
#[inline(always)]
pub fn script_id(&self) -> i32 {
unsafe { v8__Script__ScriptId(self) }
}
/// Runs the script returning the resulting value. It will be run in the

@@ -93,0 +100,0 @@ /// context in which it was created (ScriptCompiler::CompileBound or

@@ -13,2 +13,3 @@ use crate::CachedData;

) -> *const Script;
fn v8__UnboundScript__ScriptId(script: *const UnboundScript) -> i32;
fn v8__UnboundScript__CreateCodeCache(

@@ -40,2 +41,8 @@ script: *const UnboundScript,

/// Returns the ID assigned to this context-unbound script by V8.
#[inline(always)]
pub fn script_id(&self) -> i32 {
unsafe { v8__UnboundScript__ScriptId(self) }
}
/// Creates and returns code cache for the specified unbound_script.

@@ -42,0 +49,0 @@ /// This will return nullptr if the script cannot be serialized. The

@@ -204,2 +204,35 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.

/// is created. It always returns true.
///
/// # Call this before creating threads that will enter an isolate
///
/// On platforms with memory protection keys (x86-64 with `pku`/`ospke`,
/// which covers most current server hardware), V8 allocates a protection
/// key here and uses it to guard its internal pointer tables. Access to a
/// protection key is governed by the `PKRU` register, which is **per
/// thread** and is **inherited from the creating thread at thread creation
/// time**.
///
/// A thread created *before* this call therefore never gains access to that
/// key. Such a thread runs correctly until it enters an isolate, at which
/// point its first read of a pointer table traps with `SIGSEGV` and
/// `si_code == SEGV_PKUERR`. The faulting address lies in a mapping that
/// `/proc/<pid>/maps` reports as present and readable, because protection
/// keys are enforced by the MMU and appear in no mapping flag.
///
/// This matters most for embedders that build a thread pool up front and
/// then enter a [`SharedIsolate`](crate::SharedIsolate) from its workers:
///
/// ```no_run
/// // Correct: the pool inherits access to the key.
/// v8::V8::initialize_platform(
/// v8::new_default_platform(0, false).make_shared(),
/// );
/// v8::V8::initialize();
/// let pool = std::thread::spawn(|| { /* may enter an isolate */ });
/// # let _ = pool;
/// ```
///
/// Creating the pool first compiles and runs, and fails only once a worker
/// first executes JavaScript. V8 states the same requirement internally, in
/// the name of `SandboxHardwareSupport::TryActivateBeforeThreadCreation`.
pub fn initialize() {

@@ -206,0 +239,0 @@ let mut global_state_guard = GLOBAL_STATE.lock().unwrap();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display