0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-23 15:17:01 -05:00

Upgrade V8 to 8.9.255.3 (#567)

This floats https://chromium-review.googlesource.com/c/v8/v8/+/2608209
because it just missed the merge window for 8.9.
This commit is contained in:
Ben Noordhuis 2021-01-18 21:46:44 +01:00 committed by GitHub
parent bcbe7e9348
commit 0d093a02f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 68 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,7 @@
[submodule "v8"]
path = v8
url = https://chromium.googlesource.com/v8/v8
#url = https://chromium.googlesource.com/v8/v8
url = https://github.com/bnoordhuis/v8
[submodule "build"]
path = build
url = https://github.com/denoland/chromium_build.git

View file

@ -1,6 +1,6 @@
# Rusty V8 Binding
V8 Version: 8.8.278.2
V8 Version: 8.9.255.3
[![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=master)](https://github.com/denoland/rusty_v8/actions)
[![crates](https://img.shields.io/crates/v/rusty_v8.svg)](https://crates.io/crates/rusty_v8)

View file

@ -108,17 +108,20 @@ fn execute_string(
) {
let mut scope = v8::TryCatch::new(scope);
let filename = v8::String::new(&mut scope, filename).unwrap();
let undefined = v8::undefined(&mut scope);
let script = v8::String::new(&mut scope, script).unwrap();
let origin = v8::ScriptOrigin::new(
v8::String::new(&mut scope, filename).unwrap().into(),
v8::Integer::new(&mut scope, 0),
v8::Integer::new(&mut scope, 0),
v8::Boolean::new(&mut scope, false),
v8::Integer::new(&mut scope, 0),
v8::undefined(&mut scope).into(),
v8::Boolean::new(&mut scope, false),
v8::Boolean::new(&mut scope, false),
v8::Boolean::new(&mut scope, false),
&mut scope,
filename.into(),
0,
0,
false,
0,
undefined.into(),
false,
false,
false,
);
let script = if let Some(script) =

View file

@ -22,7 +22,7 @@ static_assert(sizeof(two_pointers_t) ==
sizeof(std::shared_ptr<v8::BackingStore>),
"std::shared_ptr<v8::BackingStore> size mismatch");
static_assert(sizeof(v8::ScriptOrigin) == sizeof(size_t) * 7,
static_assert(sizeof(v8::ScriptOrigin) <= sizeof(size_t) * 8,
"ScriptOrigin size mismatch");
static_assert(sizeof(v8::HandleScope) == sizeof(size_t) * 3,
@ -36,7 +36,7 @@ static_assert(sizeof(v8::PromiseRejectMessage) == sizeof(size_t) * 3,
static_assert(sizeof(v8::Locker) == sizeof(size_t) * 2, "Locker size mismatch");
static_assert(sizeof(v8::ScriptCompiler::Source) == sizeof(size_t) * 8,
static_assert(sizeof(v8::ScriptCompiler::Source) <= sizeof(size_t) * 8,
"Source size mismatch");
static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
@ -1560,19 +1560,18 @@ const v8::Value* v8__Script__Run(const v8::Script& script,
}
void v8__ScriptOrigin__CONSTRUCT(
v8::Isolate* isolate,
uninit_t<v8::ScriptOrigin>* buf, const v8::Value& resource_name,
const v8::Integer& resource_line_offset,
const v8::Integer& resource_column_offset,
const v8::Boolean& resource_is_shared_cross_origin,
const v8::Integer& script_id, const v8::Value& source_map_url,
const v8::Boolean& resource_is_opaque, const v8::Boolean& is_wasm,
const v8::Boolean& is_module) {
int resource_line_offset, int resource_column_offset,
bool resource_is_shared_cross_origin, int script_id,
const v8::Value& source_map_url,
bool resource_is_opaque, bool is_wasm, bool is_module) {
construct_in_place<v8::ScriptOrigin>(
buf, ptr_to_local(&resource_name), ptr_to_local(&resource_line_offset),
ptr_to_local(&resource_column_offset),
ptr_to_local(&resource_is_shared_cross_origin), ptr_to_local(&script_id),
ptr_to_local(&source_map_url), ptr_to_local(&resource_is_opaque),
ptr_to_local(&is_wasm), ptr_to_local(&is_module));
buf, isolate, ptr_to_local(&resource_name),
resource_line_offset, resource_column_offset,
resource_is_shared_cross_origin, script_id,
ptr_to_local(&source_map_url),
resource_is_opaque, is_wasm, is_module);
}
const v8::Value* v8__ScriptOrModule__GetResourceName(

View file

@ -170,6 +170,10 @@ struct CreateParamAllocations {
pub(crate) mod raw {
use super::*;
use crate::support::long;
use crate::support::Shared;
use crate::support::SharedPtrBase;
use crate::support::UniquePtr;
#[repr(C)]
#[derive(Debug)]
@ -187,6 +191,10 @@ pub(crate) mod raw {
pub only_terminate_in_safe_scope: bool,
pub embedder_wrapper_type_index: int,
pub embedder_wrapper_object_index: int,
pub cpp_heap_params: SharedPtr<CppHeapCreateParams>,
// This is an std::vector<std::string>. It's usually no bigger
// than three or four words but let's take a generous upper bound.
pub supported_import_assertions: [usize; 8],
}
extern "C" {
@ -199,7 +207,7 @@ pub(crate) mod raw {
impl Default for CreateParams {
fn default() -> Self {
let size = unsafe { v8__Isolate__CreateParams__SIZEOF() };
assert_eq!(size_of::<Self>(), size);
assert!(size <= size_of::<Self>());
let mut buf = MaybeUninit::<Self>::uninit();
unsafe { v8__Isolate__CreateParams__CONSTRUCT(&mut buf) };
unsafe { buf.assume_init() }
@ -228,7 +236,6 @@ pub(crate) mod raw {
code_range_size_: usize,
max_old_generation_size_: usize,
max_young_generation_size_: usize,
max_zone_pool_size_: usize,
initial_old_generation_size_: usize,
initial_young_generation_size_: usize,
stack_limit_: *mut u32,
@ -257,4 +264,28 @@ pub(crate) mod raw {
};
}
}
#[repr(C)]
#[derive(Debug)]
pub(crate) struct CppHeapCreateParams(Opaque);
impl Shared for CppHeapCreateParams {
fn clone(_: &SharedPtrBase<Self>) -> SharedPtrBase<Self> {
todo!()
}
fn from_unique_ptr(_: UniquePtr<Self>) -> SharedPtrBase<Self> {
todo!()
}
fn get(_: &SharedPtrBase<Self>) -> *const Self {
todo!()
}
fn reset(_: &mut SharedPtrBase<Self>) {}
fn use_count(_: &SharedPtrBase<Self>) -> long {
0
}
}
}

View file

@ -2,10 +2,9 @@ use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::ptr::null;
use crate::Boolean;
use crate::Context;
use crate::HandleScope;
use crate::Integer;
use crate::Isolate;
use crate::Local;
use crate::Script;
use crate::String;
@ -15,7 +14,7 @@ use crate::Value;
/// The origin, within a file, of a script.
#[repr(C)]
#[derive(Debug)]
pub struct ScriptOrigin<'s>([usize; 7], PhantomData<&'s ()>);
pub struct ScriptOrigin<'s>([usize; 8], PhantomData<&'s ()>);
extern "C" {
fn v8__Script__Compile(
@ -32,16 +31,17 @@ extern "C" {
) -> *const Value;
fn v8__ScriptOrigin__CONSTRUCT(
isolate: *mut Isolate,
buf: *mut MaybeUninit<ScriptOrigin>,
resource_name: *const Value,
resource_line_offset: *const Integer,
resource_column_offset: *const Integer,
resource_is_shared_cross_origin: *const Boolean,
script_id: *const Integer,
resource_line_offset: i32,
resource_column_offset: i32,
resource_is_shared_cross_origin: bool,
script_id: i32,
source_map_url: *const Value,
resource_is_opaque: *const Boolean,
is_wasm: *const Boolean,
is_module: *const Boolean,
resource_is_opaque: bool,
is_wasm: bool,
is_module: bool,
);
}
@ -92,29 +92,31 @@ impl Script {
impl<'s> ScriptOrigin<'s> {
#[allow(clippy::too_many_arguments)]
pub fn new(
scope: &mut HandleScope<'s, ()>,
resource_name: Local<'s, Value>,
resource_line_offset: Local<'s, Integer>,
resource_column_offset: Local<'s, Integer>,
resource_is_shared_cross_origin: Local<'s, Boolean>,
script_id: Local<'s, Integer>,
resource_line_offset: i32,
resource_column_offset: i32,
resource_is_shared_cross_origin: bool,
script_id: i32,
source_map_url: Local<'s, Value>,
resource_is_opaque: Local<'s, Boolean>,
is_wasm: Local<'s, Boolean>,
is_module: Local<'s, Boolean>,
resource_is_opaque: bool,
is_wasm: bool,
is_module: bool,
) -> Self {
unsafe {
let mut buf = std::mem::MaybeUninit::<ScriptOrigin>::uninit();
v8__ScriptOrigin__CONSTRUCT(
scope.get_isolate_ptr(),
&mut buf,
&*resource_name,
&*resource_line_offset,
&*resource_column_offset,
&*resource_is_shared_cross_origin,
&*script_id,
resource_line_offset,
resource_column_offset,
resource_is_shared_cross_origin,
script_id,
&*source_map_url,
&*resource_is_opaque,
&*is_wasm,
&*is_module,
resource_is_opaque,
is_wasm,
is_module,
);
buf.assume_init()
}

View file

@ -744,9 +744,24 @@ fn throw_exception() {
fn isolate_termination_methods() {
let _setup_guard = setup();
let isolate = v8::Isolate::new(Default::default());
assert_eq!(false, isolate.is_execution_terminating());
assert_eq!(true, isolate.terminate_execution());
assert_eq!(true, isolate.cancel_terminate_execution());
let handle = isolate.thread_safe_handle();
drop(isolate);
assert_eq!(false, handle.terminate_execution());
assert_eq!(false, handle.cancel_terminate_execution());
assert_eq!(false, handle.is_execution_terminating());
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
extern "C" fn callback(
_isolate: &mut v8::Isolate,
data: *mut std::ffi::c_void,
) {
assert_eq!(data, std::ptr::null_mut());
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
}
assert_eq!(
false,
handle.request_interrupt(callback, std::ptr::null_mut())
);
assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 0);
}
#[test]
@ -971,16 +986,17 @@ fn script_origin() {
let scope = &mut v8::ContextScope::new(scope, context);
let resource_name = v8::String::new(scope, "foo.js").unwrap();
let resource_line_offset = v8::Integer::new(scope, 4);
let resource_column_offset = v8::Integer::new(scope, 5);
let resource_is_shared_cross_origin = v8::Boolean::new(scope, true);
let script_id = v8::Integer::new(scope, 123);
let resource_line_offset = 4;
let resource_column_offset = 5;
let resource_is_shared_cross_origin = true;
let script_id = 123;
let source_map_url = v8::String::new(scope, "source_map_url").unwrap();
let resource_is_opaque = v8::Boolean::new(scope, true);
let is_wasm = v8::Boolean::new(scope, false);
let is_module = v8::Boolean::new(scope, false);
let resource_is_opaque = true;
let is_wasm = false;
let is_module = false;
let script_origin = v8::ScriptOrigin::new(
scope,
resource_name.into(),
resource_line_offset,
resource_column_offset,
@ -1865,15 +1881,16 @@ fn mock_script_origin<'s>(
resource_name_: &str,
) -> v8::ScriptOrigin<'s> {
let resource_name = v8::String::new(scope, resource_name_).unwrap();
let resource_line_offset = v8::Integer::new(scope, 0);
let resource_column_offset = v8::Integer::new(scope, 0);
let resource_is_shared_cross_origin = v8::Boolean::new(scope, true);
let script_id = v8::Integer::new(scope, 123);
let resource_line_offset = 0;
let resource_column_offset = 0;
let resource_is_shared_cross_origin = true;
let script_id = 123;
let source_map_url = v8::String::new(scope, "source_map_url").unwrap();
let resource_is_opaque = v8::Boolean::new(scope, true);
let is_wasm = v8::Boolean::new(scope, false);
let is_module = v8::Boolean::new(scope, true);
let resource_is_opaque = true;
let is_wasm = false;
let is_module = true;
v8::ScriptOrigin::new(
scope,
resource_name.into(),
resource_line_offset,
resource_column_offset,

2
v8

@ -1 +1 @@
Subproject commit ecf7c5b959f91043241bb2442932ca4da7fe7d00
Subproject commit 12b4fabf964b4646d607cb147ac5292d60ffc3b3