This commit is contained in:
Divy Srivastava 2024-03-09 09:34:39 +05:30
commit 3393d48f5f
10 changed files with 84 additions and 15 deletions

12
.gn
View File

@ -75,6 +75,18 @@ default_args = {
v8_enable_builtins_optimization = true
# V8 12.3 added google/fuzztest as a third party dependency.
# https://chromium.googlesource.com/v8/v8.git/+/d5acece0c9b89b18716c177d1fcc8f734191e1e2%5E%21/#F4
#
# This flag disables it.
v8_enable_fuzztest = false
# Disable v8::HandleScope LIFO checks.
# https://chromium-review.googlesource.com/c/v8/v8/+/5110566
#
# rusty_v8 scopes are not on the stack.
v8_enable_v8_checks = false
# Enable Deno-specific extra bindings
deno_enable_extras = true
}

2
Cargo.lock generated
View File

@ -1303,7 +1303,7 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "v8"
version = "0.84.0"
version = "0.85.0"
dependencies = [
"align-data",
"bitflags 2.4.1",

View File

@ -1,6 +1,6 @@
[package]
name = "v8"
version = "0.84.0"
version = "0.85.0"
description = "Rust bindings to V8"
readme = "README.md"
authors = ["the Deno authors"]

View File

@ -1,6 +1,6 @@
# Rusty V8 Binding
V8 Version: 12.1.285.27
V8 Version: 12.3.219.9
[![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)

View File

@ -3073,9 +3073,9 @@ int v8__ModuleRequest__GetSourceOffset(const v8::ModuleRequest& self) {
return self.GetSourceOffset();
}
const v8::FixedArray* v8__ModuleRequest__GetImportAssertions(
const v8::FixedArray* v8__ModuleRequest__GetImportAttributes(
const v8::ModuleRequest& self) {
return local_to_ptr(self.GetImportAssertions());
return local_to_ptr(self.GetImportAttributes());
}
struct WasmStreamingSharedPtr {

View File

@ -548,7 +548,7 @@ impl Isolate {
// Byte offset inside `Isolate` where the isolate data slots are stored. This
// should be the same as the value of `kIsolateEmbedderDataOffset` which is
// defined in `v8-internal.h`.
const EMBEDDER_DATA_OFFSET: usize = size_of::<[*const (); 65]>();
const EMBEDDER_DATA_OFFSET: usize = size_of::<[*const (); 67]>();
// Isolate data slots used internally by rusty_v8.
const ANNEX_SLOT: u32 = 0;

View File

@ -193,7 +193,7 @@ extern "C" {
this: *const ModuleRequest,
) -> *const String;
fn v8__ModuleRequest__GetSourceOffset(this: *const ModuleRequest) -> int;
fn v8__ModuleRequest__GetImportAssertions(
fn v8__ModuleRequest__GetImportAttributes(
this: *const ModuleRequest,
) -> *const FixedArray;
fn v8__Module__GetStalledTopLevelAwaitMessage(
@ -480,7 +480,7 @@ impl ModuleRequest {
unsafe { v8__ModuleRequest__GetSourceOffset(self) }
}
/// Contains the import assertions for this request in the form:
/// Contains the import attributes for this request in the form:
/// [key1, value1, source_offset1, key2, value2, source_offset2, ...].
/// The keys and values are of type v8::String, and the source offsets are of
/// type Int32. Use Module::source_offset_to_location to convert the source
@ -493,8 +493,14 @@ impl ModuleRequest {
/// opposed to, for example, triggering an error if an unsupported assertion is
/// present).
#[inline(always)]
pub fn get_import_assertions(&self) -> Local<FixedArray> {
unsafe { Local::from_raw(v8__ModuleRequest__GetImportAssertions(self)) }
pub fn get_import_attributes(&self) -> Local<FixedArray> {
unsafe { Local::from_raw(v8__ModuleRequest__GetImportAttributes(self)) }
.unwrap()
}
#[inline(always)]
#[deprecated(note = "Use get_import_attributes instead")]
pub fn get_import_assertions(&self) -> Local<FixedArray> {
self.get_import_attributes()
}
}

View File

@ -4,7 +4,7 @@ use std::any::type_name;
use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::convert::{Into, TryFrom, TryInto};
use std::ffi::c_void;
use std::ffi::CStr;
@ -4528,6 +4528,57 @@ fn security_token() {
}
}
#[test]
fn context_with_object_template() {
let _setup_guard = setup::parallel_test();
let isolate = &mut v8::Isolate::new(Default::default());
static mut CALLS: Vec<String> = Vec::new();
fn definer<'s>(
_scope: &mut v8::HandleScope<'s>,
_key: v8::Local<'s, v8::Name>,
_descriptor: &v8::PropertyDescriptor,
_args: v8::PropertyCallbackArguments<'s>,
_rv: v8::ReturnValue,
) {
unsafe {
CALLS.push("definer".to_string());
}
}
pub fn setter<'s>(
_scope: &mut v8::HandleScope<'s>,
_key: v8::Local<'s, v8::Name>,
_value: v8::Local<'s, v8::Value>,
_args: v8::PropertyCallbackArguments<'s>,
_rv: v8::ReturnValue,
) {
unsafe {
CALLS.push("setter".to_string());
}
}
{
let scope = &mut v8::HandleScope::new(isolate);
let object_template = v8::ObjectTemplate::new(scope);
let mut config = v8::NamedPropertyHandlerConfiguration::new().flags(
v8::PropertyHandlerFlags::NON_MASKING
| v8::PropertyHandlerFlags::HAS_NO_SIDE_EFFECT,
);
config = config.definer_raw(definer.map_fn_to());
config = config.setter_raw(setter.map_fn_to());
object_template.set_named_property_handler(config);
let context = v8::Context::new_from_template(scope, object_template);
let scope = &mut v8::ContextScope::new(scope, context);
eval(scope, r#"Object.defineProperty(globalThis, 'key', { value: 9, enumerable: true, configurable: true, writable: true })"#).unwrap();
let calls_set =
unsafe { CALLS.clone().into_iter().collect::<HashSet<String>>() };
assert!(calls_set.contains("setter"));
assert!(calls_set.contains("definer"));
}
}
#[test]
fn allow_code_generation_from_strings() {
let _setup_guard = setup::parallel_test();
@ -4693,7 +4744,7 @@ fn module_instantiation_failures1() {
let loc = module.source_offset_to_location(mr1.get_source_offset());
assert_eq!(0, loc.get_line_number());
assert_eq!(7, loc.get_column_number());
assert_eq!(0, mr1.get_import_assertions().length());
assert_eq!(0, mr1.get_import_attributes().length());
let mr2 = v8::Local::<v8::ModuleRequest>::try_from(
module_requests.get(scope, 1).unwrap(),
@ -4703,7 +4754,7 @@ fn module_instantiation_failures1() {
let loc = module.source_offset_to_location(mr2.get_source_offset());
assert_eq!(1, loc.get_line_number());
assert_eq!(15, loc.get_column_number());
assert_eq!(0, mr2.get_import_assertions().length());
assert_eq!(0, mr2.get_import_attributes().length());
// Instantiation should fail.
{

View File

@ -1,4 +1,4 @@
const V8_TRACKING_BRANCH = "12.2-lkgr-denoland";
const V8_TRACKING_BRANCH = "12.3-lkgr-denoland";
const AUTOROLL_BRANCH = "autoroll";
function extractVersion() {

2
v8

@ -1 +1 @@
Subproject commit ef1375169ab459a6e0219f849769bd949d10fe42
Subproject commit db2b8439ec4d3ae972330cc2e9830ccd517d7235