From 678a450ff5ef226b5873f32ce2b978c94f825ddb Mon Sep 17 00:00:00 2001 From: snek Date: Tue, 13 Jan 2026 12:36:05 +0100 Subject: [PATCH] update to v8 v14.5 --- build | 2 +- buildtools | 2 +- src/binding.cc | 41 ++++++++++-- src/function.rs | 129 +++++++++++++----------------------- src/support.h | 10 ++- third_party/abseil-cpp | 2 +- third_party/dragonbox/src | 2 +- third_party/libc++/src | 2 +- third_party/libc++abi/src | 2 +- third_party/libunwind/src | 2 +- third_party/llvm-libc/src | 2 +- third_party/partition_alloc | 2 +- third_party/rust | 2 +- third_party/simdutf | 2 +- tools/auto_update_v8.ts | 2 +- tools/clang | 2 +- v8 | 2 +- 17 files changed, 104 insertions(+), 104 deletions(-) diff --git a/build b/build index 750480888e..097f22a7ef 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 750480888eb8f1f16f4d52d51582feaef6a651e8 +Subproject commit 097f22a7ef0935635c46de65d141f45f93f75dfb diff --git a/buildtools b/buildtools index 1267724b67..4dc32b3f51 160000 --- a/buildtools +++ b/buildtools @@ -1 +1 @@ -Subproject commit 1267724b67c1e44a778f610ae9dac191f06e2ff4 +Subproject commit 4dc32b3f510b330137385e2b3a631ca8e13a8e22 diff --git a/src/binding.cc b/src/binding.cc index a98ffd1f19..a3efebaf5f 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -68,9 +68,6 @@ static_assert( sizeof(v8::ScriptCompiler::CompilationDetails)), "Source size mismatch"); -static_assert(sizeof(v8::FunctionCallbackInfo) == sizeof(size_t) * 3, - "FunctionCallbackInfo size mismatch"); - static_assert(sizeof(v8::ReturnValue) == sizeof(size_t) * 1, "ReturnValue size mismatch"); @@ -2358,15 +2355,47 @@ const v8::ObjectTemplate* v8__FunctionTemplate__InstanceTemplate( return local_to_ptr(ptr_to_local(&self)->InstanceTemplate()); } -const extern int v8__FunctionCallbackInfo__kArgsLength = 6; -// NOTE(bartlomieju): V8 made this field private in 11.4 -// v8::FunctionCallbackInfo::kArgsLength; +v8::Isolate* v8__FunctionCallbackInfo__GetIsolate( + const v8::FunctionCallbackInfo& self) { + return self.GetIsolate(); +} const v8::Value* v8__FunctionCallbackInfo__Data( const v8::FunctionCallbackInfo& self) { return local_to_ptr(self.Data()); } +const v8::Value* v8__FunctionCallbackInfo__NewTarget( + const v8::FunctionCallbackInfo& self) { + return local_to_ptr(self.NewTarget()); +} + +const v8::Object* v8__FunctionCallbackInfo__This( + const v8::FunctionCallbackInfo& self) { + return local_to_ptr(self.This()); +} + +const v8::Value* v8__FunctionCallbackInfo__Get( + const v8::FunctionCallbackInfo& self, int index) { + return local_to_ptr(self[index]); +} + +int v8__FunctionCallbackInfo__Length( + const v8::FunctionCallbackInfo& self) { + return self.Length(); +} + +bool v8__FunctionCallbackInfo__IsConstructCall( + const v8::FunctionCallbackInfo& self) { + return self.IsConstructCall(); +} + +uintptr_t* v8__FunctionCallbackInfo__GetReturnValue( + const v8::FunctionCallbackInfo& self) { + v8::ReturnValue rv = self.GetReturnValue(); + return *reinterpret_cast(&rv); +} + v8::Isolate* v8__PropertyCallbackInfo__GetIsolate( const v8::PropertyCallbackInfo& self) { return self.GetIsolate(); diff --git a/src/function.rs b/src/function.rs index 910caf4221..9d823a3c2e 100644 --- a/src/function.rs +++ b/src/function.rs @@ -14,6 +14,7 @@ use crate::Local; use crate::Name; use crate::Object; use crate::PropertyDescriptor; +use crate::ScriptOrigin; use crate::SealedLocal; use crate::Signature; use crate::String; @@ -29,7 +30,6 @@ use crate::support::ToCFn; use crate::support::UnitType; use crate::support::{Opaque, int}; use crate::template::Intercepted; -use crate::{ScriptOrigin, undefined}; unsafe extern "C" { fn v8__Function__New( @@ -66,11 +66,30 @@ unsafe extern "C" { script: *const Function, ) -> *mut CachedData<'static>; - static v8__FunctionCallbackInfo__kArgsLength: int; - + fn v8__FunctionCallbackInfo__GetIsolate( + this: *const FunctionCallbackInfo, + ) -> *mut RealIsolate; fn v8__FunctionCallbackInfo__Data( this: *const FunctionCallbackInfo, ) -> *const Value; + fn v8__FunctionCallbackInfo__This( + this: *const FunctionCallbackInfo, + ) -> *const Object; + fn v8__FunctionCallbackInfo__NewTarget( + this: *const FunctionCallbackInfo, + ) -> *const Value; + fn v8__FunctionCallbackInfo__IsConstructCall( + this: *const FunctionCallbackInfo, + ) -> bool; + fn v8__FunctionCallbackInfo__Get( + this: *const FunctionCallbackInfo, + index: int, + ) -> *const Value; + fn v8__FunctionCallbackInfo__Length(this: *const FunctionCallbackInfo) + -> int; + fn v8__FunctionCallbackInfo__GetReturnValue( + this: *const FunctionCallbackInfo, + ) -> usize; fn v8__PropertyCallbackInfo__GetIsolate( this: *const RawPropertyCallbackInfo, @@ -160,8 +179,10 @@ impl<'cb, T> ReturnValue<'cb, T> { impl<'cb> ReturnValue<'cb, Value> { #[inline(always)] pub fn from_function_callback_info(info: &'cb FunctionCallbackInfo) -> Self { - let nn = info.get_return_value_non_null(); - Self(RawReturnValue(nn.as_ptr() as _), PhantomData) + Self( + unsafe { RawReturnValue(v8__FunctionCallbackInfo__GetReturnValue(info)) }, + PhantomData, + ) } } @@ -232,54 +253,35 @@ where /// the holder of the function. #[repr(C)] #[derive(Debug)] -pub struct FunctionCallbackInfo { - // The layout of this struct must match that of `class FunctionCallbackInfo` - // as defined in v8.h. - implicit_args: *mut *const Opaque, - values: *mut *const Opaque, - length: int, -} - -// These constants must match those defined on `class FunctionCallbackInfo` in -// v8-function-callback.h. -#[allow(dead_code, non_upper_case_globals)] -impl FunctionCallbackInfo { - const kHolderIndex: i32 = 0; - const kIsolateIndex: i32 = 1; - const kContextIndex: i32 = 2; - const kReturnValueIndex: i32 = 3; - const kTargetIndex: i32 = 4; - const kNewTargetIndex: i32 = 5; - const kArgsLength: i32 = 6; -} +pub struct FunctionCallbackInfo(*mut Opaque); impl FunctionCallbackInfo { #[inline(always)] pub(crate) fn get_isolate_ptr(&self) -> *mut RealIsolate { - let arg_nn = - self.get_implicit_arg_non_null::<*mut RealIsolate>(Self::kIsolateIndex); - *unsafe { arg_nn.as_ref() } - } - - #[inline(always)] - pub(crate) fn get_return_value_non_null(&self) -> NonNull { - self.get_implicit_arg_non_null::(Self::kReturnValueIndex) + unsafe { v8__FunctionCallbackInfo__GetIsolate(self) } } #[inline(always)] pub(crate) fn new_target(&self) -> Local<'_, Value> { - unsafe { self.get_implicit_arg_local(Self::kNewTargetIndex) } + unsafe { + let ptr = v8__FunctionCallbackInfo__NewTarget(self); + let nn = NonNull::new_unchecked(ptr as *mut _); + Local::from_non_null(nn) + } } #[inline(always)] pub(crate) fn this(&self) -> Local<'_, Object> { - unsafe { self.get_arg_local(-1) } + unsafe { + let ptr = v8__FunctionCallbackInfo__This(self); + let nn = NonNull::new_unchecked(ptr as *mut _); + Local::from_non_null(nn) + } } #[inline] pub fn is_construct_call(&self) -> bool { - // The "new.target" value is only set for construct calls. - !self.new_target().is_undefined() + unsafe { v8__FunctionCallbackInfo__IsConstructCall(self) } } #[inline(always)] @@ -292,62 +294,23 @@ impl FunctionCallbackInfo { } #[inline(always)] - pub(crate) fn length(&self) -> i32 { - self.length + pub(crate) fn length(&self) -> int { + unsafe { v8__FunctionCallbackInfo__Length(self) } } #[inline(always)] pub(crate) fn get(&self, index: int) -> Local<'_, Value> { - if index >= 0 && index < self.length { - unsafe { self.get_arg_local(index) } - } else { - let isolate = unsafe { - crate::isolate::Isolate::from_raw_ptr(self.get_isolate_ptr()) - }; - undefined(&isolate).into() + unsafe { + let ptr = v8__FunctionCallbackInfo__Get(self, index); + let nn = NonNull::new_unchecked(ptr as *mut Value); + Local::from_non_null(nn) } } - - #[inline(always)] - fn get_implicit_arg_non_null(&self, index: i32) -> NonNull { - // In debug builds, check that `FunctionCallbackInfo::kArgsLength` matches - // the C++ definition. Unfortunately we can't check the other constants - // because they are declared protected in the C++ header. - debug_assert_eq!( - unsafe { v8__FunctionCallbackInfo__kArgsLength }, - Self::kArgsLength - ); - // Assert that `index` is in bounds. - assert!(index >= 0); - assert!(index < Self::kArgsLength); - // Compute the address of the implicit argument and cast to `NonNull`. - let ptr = unsafe { self.implicit_args.offset(index as isize) as *mut T }; - debug_assert!(!ptr.is_null()); - unsafe { NonNull::new_unchecked(ptr) } - } - - // SAFETY: caller must guarantee that the implicit argument at `index` - // contains a valid V8 handle. - #[inline(always)] - unsafe fn get_implicit_arg_local(&self, index: i32) -> Local<'_, T> { - let nn = self.get_implicit_arg_non_null::(index); - unsafe { Local::from_non_null(nn) } - } - - // SAFETY: caller must guarantee that the `index` value lies between -1 and - // self.length. - #[inline(always)] - unsafe fn get_arg_local(&self, index: i32) -> Local<'_, T> { - let ptr = unsafe { self.values.offset(index as _) } as *mut T; - debug_assert!(!ptr.is_null()); - let nn = unsafe { NonNull::new_unchecked(ptr) }; - unsafe { Local::from_non_null(nn) } - } } #[repr(C)] #[derive(Debug)] -struct RawPropertyCallbackInfo(Opaque); +struct RawPropertyCallbackInfo(*mut Opaque); /// The information passed to a property callback about the context /// of the property access. diff --git a/src/support.h b/src/support.h index 3b2666c5b6..99c513d32d 100644 --- a/src/support.h +++ b/src/support.h @@ -18,8 +18,16 @@ static_assert(sizeof(bool) == sizeof(uint8_t), ""); static_assert(sizeof(std::unique_ptr) == sizeof(void*), ""); namespace support { + +template +struct aligned_storage { + struct type { + alignas(Align) unsigned char data[Len]; + }; +}; + template -using uninit_t = typename std::aligned_storage::type; +using uninit_t = typename aligned_storage::type; template class construct_in_place_helper { diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index dcfa08fa08..1597226b82 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp @@ -1 +1 @@ -Subproject commit dcfa08fa08bb8ee1f28a2e94d80e0ac1a7015013 +Subproject commit 1597226b825a16493de66c1732171efe89b271d9 diff --git a/third_party/dragonbox/src b/third_party/dragonbox/src index 6c7c925b57..beeeef91cf 160000 --- a/third_party/dragonbox/src +++ b/third_party/dragonbox/src @@ -1 +1 @@ -Subproject commit 6c7c925b571d54486b9ffae8d9d18a822801cbda +Subproject commit beeeef91cf6fef89a4d4ba5e95d47ca64ccb3a44 diff --git a/third_party/libc++/src b/third_party/libc++/src index 99d9ab2603..7ab65651ae 160000 --- a/third_party/libc++/src +++ b/third_party/libc++/src @@ -1 +1 @@ -Subproject commit 99d9ab2603b02b6fb974cf19be99777f5cd99e7a +Subproject commit 7ab65651aed6802d2599dcb7a73b1f82d5179d05 diff --git a/third_party/libc++abi/src b/third_party/libc++abi/src index de02e5d570..8f11bb1d44 160000 --- a/third_party/libc++abi/src +++ b/third_party/libc++abi/src @@ -1 +1 @@ -Subproject commit de02e5d57052b3b6d5fcd76dccde9380bca39360 +Subproject commit 8f11bb1d4438d0239d0dfc1bd9456a9f31629dda diff --git a/third_party/libunwind/src b/third_party/libunwind/src index 7ff36f1e35..a726f5347e 160000 --- a/third_party/libunwind/src +++ b/third_party/libunwind/src @@ -1 +1 @@ -Subproject commit 7ff36f1e358ffb63e25f27a1b5e8e0c52e15c49c +Subproject commit a726f5347e1e423d59f5c2d434b6a29265c43051 diff --git a/third_party/llvm-libc/src b/third_party/llvm-libc/src index b2be5ea77d..259b6a7101 160000 --- a/third_party/llvm-libc/src +++ b/third_party/llvm-libc/src @@ -1 +1 @@ -Subproject commit b2be5ea77d1978b763e282d5572be69fcbca96d1 +Subproject commit 259b6a7101beea301d6dfb96445f03f7d2e13754 diff --git a/third_party/partition_alloc b/third_party/partition_alloc index c0a91c9963..b2155fca49 160000 --- a/third_party/partition_alloc +++ b/third_party/partition_alloc @@ -1 +1 @@ -Subproject commit c0a91c99639bc5e15f420ae8a6c764f3bcd0bccf +Subproject commit b2155fca494c5b6266d42f9129ae3a7b85482c95 diff --git a/third_party/rust b/third_party/rust index e6ee35e1c9..c39a70c914 160000 --- a/third_party/rust +++ b/third_party/rust @@ -1 +1 @@ -Subproject commit e6ee35e1c94c62365c41db142d17bb96210b6dad +Subproject commit c39a70c914bbac46c52bddb7ee136e04fdf1e687 diff --git a/third_party/simdutf b/third_party/simdutf index 880a4923a9..75bea7342f 160000 --- a/third_party/simdutf +++ b/third_party/simdutf @@ -1 +1 @@ -Subproject commit 880a4923a95e0b525f7bf72da82661cfffe46fb3 +Subproject commit 75bea7342fdac6b57f7e3099ddf4dc84d77384f6 diff --git a/tools/auto_update_v8.ts b/tools/auto_update_v8.ts index d907656f62..b88f65a444 100644 --- a/tools/auto_update_v8.ts +++ b/tools/auto_update_v8.ts @@ -1,4 +1,4 @@ -const V8_TRACKING_BRANCH = "14.4-lkgr-denoland"; +const V8_TRACKING_BRANCH = "14.5-lkgr-denoland"; const AUTOROLL_BRANCH = "autoroll"; function extractVersion() { diff --git a/tools/clang b/tools/clang index 768d15952d..3240f2283a 160000 --- a/tools/clang +++ b/tools/clang @@ -1 +1 @@ -Subproject commit 768d15952d4ac4789455b947375c2ebd7e78d143 +Subproject commit 3240f2283a294839cf928f7329fe1a89230fa74e diff --git a/v8 b/v8 index 1d454ac875..8defb67673 160000 --- a/v8 +++ b/v8 @@ -1 +1 @@ -Subproject commit 1d454ac875e0ef0685db402a81fdb2ceae087da1 +Subproject commit 8defb67673c5483ae56258a2de01b07e947dc921