Skip to content

Commit 678a450

Browse files
committed
update to v8 v14.5
1 parent 4d9f927 commit 678a450

File tree

17 files changed

+104
-104
lines changed

17 files changed

+104
-104
lines changed

build

Submodule build updated 105 files

buildtools

Submodule buildtools updated from 1267724 to 4dc32b3

src/binding.cc

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ static_assert(
6868
sizeof(v8::ScriptCompiler::CompilationDetails)),
6969
"Source size mismatch");
7070

71-
static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
72-
"FunctionCallbackInfo size mismatch");
73-
7471
static_assert(sizeof(v8::ReturnValue<v8::Value>) == sizeof(size_t) * 1,
7572
"ReturnValue size mismatch");
7673

@@ -2358,15 +2355,47 @@ const v8::ObjectTemplate* v8__FunctionTemplate__InstanceTemplate(
23582355
return local_to_ptr(ptr_to_local(&self)->InstanceTemplate());
23592356
}
23602357

2361-
const extern int v8__FunctionCallbackInfo__kArgsLength = 6;
2362-
// NOTE(bartlomieju): V8 made this field private in 11.4
2363-
// v8::FunctionCallbackInfo<v8::Value>::kArgsLength;
2358+
v8::Isolate* v8__FunctionCallbackInfo__GetIsolate(
2359+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2360+
return self.GetIsolate();
2361+
}
23642362

23652363
const v8::Value* v8__FunctionCallbackInfo__Data(
23662364
const v8::FunctionCallbackInfo<v8::Value>& self) {
23672365
return local_to_ptr(self.Data());
23682366
}
23692367

2368+
const v8::Value* v8__FunctionCallbackInfo__NewTarget(
2369+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2370+
return local_to_ptr(self.NewTarget());
2371+
}
2372+
2373+
const v8::Object* v8__FunctionCallbackInfo__This(
2374+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2375+
return local_to_ptr(self.This());
2376+
}
2377+
2378+
const v8::Value* v8__FunctionCallbackInfo__Get(
2379+
const v8::FunctionCallbackInfo<v8::Value>& self, int index) {
2380+
return local_to_ptr(self[index]);
2381+
}
2382+
2383+
int v8__FunctionCallbackInfo__Length(
2384+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2385+
return self.Length();
2386+
}
2387+
2388+
bool v8__FunctionCallbackInfo__IsConstructCall(
2389+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2390+
return self.IsConstructCall();
2391+
}
2392+
2393+
uintptr_t* v8__FunctionCallbackInfo__GetReturnValue(
2394+
const v8::FunctionCallbackInfo<v8::Value>& self) {
2395+
v8::ReturnValue<v8::Value> rv = self.GetReturnValue();
2396+
return *reinterpret_cast<uintptr_t**>(&rv);
2397+
}
2398+
23702399
v8::Isolate* v8__PropertyCallbackInfo__GetIsolate(
23712400
const v8::PropertyCallbackInfo<v8::Value>& self) {
23722401
return self.GetIsolate();

src/function.rs

Lines changed: 46 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::Local;
1414
use crate::Name;
1515
use crate::Object;
1616
use crate::PropertyDescriptor;
17+
use crate::ScriptOrigin;
1718
use crate::SealedLocal;
1819
use crate::Signature;
1920
use crate::String;
@@ -29,7 +30,6 @@ use crate::support::ToCFn;
2930
use crate::support::UnitType;
3031
use crate::support::{Opaque, int};
3132
use crate::template::Intercepted;
32-
use crate::{ScriptOrigin, undefined};
3333

3434
unsafe extern "C" {
3535
fn v8__Function__New(
@@ -66,11 +66,30 @@ unsafe extern "C" {
6666
script: *const Function,
6767
) -> *mut CachedData<'static>;
6868

69-
static v8__FunctionCallbackInfo__kArgsLength: int;
70-
69+
fn v8__FunctionCallbackInfo__GetIsolate(
70+
this: *const FunctionCallbackInfo,
71+
) -> *mut RealIsolate;
7172
fn v8__FunctionCallbackInfo__Data(
7273
this: *const FunctionCallbackInfo,
7374
) -> *const Value;
75+
fn v8__FunctionCallbackInfo__This(
76+
this: *const FunctionCallbackInfo,
77+
) -> *const Object;
78+
fn v8__FunctionCallbackInfo__NewTarget(
79+
this: *const FunctionCallbackInfo,
80+
) -> *const Value;
81+
fn v8__FunctionCallbackInfo__IsConstructCall(
82+
this: *const FunctionCallbackInfo,
83+
) -> bool;
84+
fn v8__FunctionCallbackInfo__Get(
85+
this: *const FunctionCallbackInfo,
86+
index: int,
87+
) -> *const Value;
88+
fn v8__FunctionCallbackInfo__Length(this: *const FunctionCallbackInfo)
89+
-> int;
90+
fn v8__FunctionCallbackInfo__GetReturnValue(
91+
this: *const FunctionCallbackInfo,
92+
) -> usize;
7493

7594
fn v8__PropertyCallbackInfo__GetIsolate(
7695
this: *const RawPropertyCallbackInfo,
@@ -160,8 +179,10 @@ impl<'cb, T> ReturnValue<'cb, T> {
160179
impl<'cb> ReturnValue<'cb, Value> {
161180
#[inline(always)]
162181
pub fn from_function_callback_info(info: &'cb FunctionCallbackInfo) -> Self {
163-
let nn = info.get_return_value_non_null();
164-
Self(RawReturnValue(nn.as_ptr() as _), PhantomData)
182+
Self(
183+
unsafe { RawReturnValue(v8__FunctionCallbackInfo__GetReturnValue(info)) },
184+
PhantomData,
185+
)
165186
}
166187
}
167188

@@ -232,54 +253,35 @@ where
232253
/// the holder of the function.
233254
#[repr(C)]
234255
#[derive(Debug)]
235-
pub struct FunctionCallbackInfo {
236-
// The layout of this struct must match that of `class FunctionCallbackInfo`
237-
// as defined in v8.h.
238-
implicit_args: *mut *const Opaque,
239-
values: *mut *const Opaque,
240-
length: int,
241-
}
242-
243-
// These constants must match those defined on `class FunctionCallbackInfo` in
244-
// v8-function-callback.h.
245-
#[allow(dead_code, non_upper_case_globals)]
246-
impl FunctionCallbackInfo {
247-
const kHolderIndex: i32 = 0;
248-
const kIsolateIndex: i32 = 1;
249-
const kContextIndex: i32 = 2;
250-
const kReturnValueIndex: i32 = 3;
251-
const kTargetIndex: i32 = 4;
252-
const kNewTargetIndex: i32 = 5;
253-
const kArgsLength: i32 = 6;
254-
}
256+
pub struct FunctionCallbackInfo(*mut Opaque);
255257

256258
impl FunctionCallbackInfo {
257259
#[inline(always)]
258260
pub(crate) fn get_isolate_ptr(&self) -> *mut RealIsolate {
259-
let arg_nn =
260-
self.get_implicit_arg_non_null::<*mut RealIsolate>(Self::kIsolateIndex);
261-
*unsafe { arg_nn.as_ref() }
262-
}
263-
264-
#[inline(always)]
265-
pub(crate) fn get_return_value_non_null(&self) -> NonNull<Value> {
266-
self.get_implicit_arg_non_null::<Value>(Self::kReturnValueIndex)
261+
unsafe { v8__FunctionCallbackInfo__GetIsolate(self) }
267262
}
268263

269264
#[inline(always)]
270265
pub(crate) fn new_target(&self) -> Local<'_, Value> {
271-
unsafe { self.get_implicit_arg_local(Self::kNewTargetIndex) }
266+
unsafe {
267+
let ptr = v8__FunctionCallbackInfo__NewTarget(self);
268+
let nn = NonNull::new_unchecked(ptr as *mut _);
269+
Local::from_non_null(nn)
270+
}
272271
}
273272

274273
#[inline(always)]
275274
pub(crate) fn this(&self) -> Local<'_, Object> {
276-
unsafe { self.get_arg_local(-1) }
275+
unsafe {
276+
let ptr = v8__FunctionCallbackInfo__This(self);
277+
let nn = NonNull::new_unchecked(ptr as *mut _);
278+
Local::from_non_null(nn)
279+
}
277280
}
278281

279282
#[inline]
280283
pub fn is_construct_call(&self) -> bool {
281-
// The "new.target" value is only set for construct calls.
282-
!self.new_target().is_undefined()
284+
unsafe { v8__FunctionCallbackInfo__IsConstructCall(self) }
283285
}
284286

285287
#[inline(always)]
@@ -292,62 +294,23 @@ impl FunctionCallbackInfo {
292294
}
293295

294296
#[inline(always)]
295-
pub(crate) fn length(&self) -> i32 {
296-
self.length
297+
pub(crate) fn length(&self) -> int {
298+
unsafe { v8__FunctionCallbackInfo__Length(self) }
297299
}
298300

299301
#[inline(always)]
300302
pub(crate) fn get(&self, index: int) -> Local<'_, Value> {
301-
if index >= 0 && index < self.length {
302-
unsafe { self.get_arg_local(index) }
303-
} else {
304-
let isolate = unsafe {
305-
crate::isolate::Isolate::from_raw_ptr(self.get_isolate_ptr())
306-
};
307-
undefined(&isolate).into()
303+
unsafe {
304+
let ptr = v8__FunctionCallbackInfo__Get(self, index);
305+
let nn = NonNull::new_unchecked(ptr as *mut Value);
306+
Local::from_non_null(nn)
308307
}
309308
}
310-
311-
#[inline(always)]
312-
fn get_implicit_arg_non_null<T>(&self, index: i32) -> NonNull<T> {
313-
// In debug builds, check that `FunctionCallbackInfo::kArgsLength` matches
314-
// the C++ definition. Unfortunately we can't check the other constants
315-
// because they are declared protected in the C++ header.
316-
debug_assert_eq!(
317-
unsafe { v8__FunctionCallbackInfo__kArgsLength },
318-
Self::kArgsLength
319-
);
320-
// Assert that `index` is in bounds.
321-
assert!(index >= 0);
322-
assert!(index < Self::kArgsLength);
323-
// Compute the address of the implicit argument and cast to `NonNull<T>`.
324-
let ptr = unsafe { self.implicit_args.offset(index as isize) as *mut T };
325-
debug_assert!(!ptr.is_null());
326-
unsafe { NonNull::new_unchecked(ptr) }
327-
}
328-
329-
// SAFETY: caller must guarantee that the implicit argument at `index`
330-
// contains a valid V8 handle.
331-
#[inline(always)]
332-
unsafe fn get_implicit_arg_local<T>(&self, index: i32) -> Local<'_, T> {
333-
let nn = self.get_implicit_arg_non_null::<T>(index);
334-
unsafe { Local::from_non_null(nn) }
335-
}
336-
337-
// SAFETY: caller must guarantee that the `index` value lies between -1 and
338-
// self.length.
339-
#[inline(always)]
340-
unsafe fn get_arg_local<T>(&self, index: i32) -> Local<'_, T> {
341-
let ptr = unsafe { self.values.offset(index as _) } as *mut T;
342-
debug_assert!(!ptr.is_null());
343-
let nn = unsafe { NonNull::new_unchecked(ptr) };
344-
unsafe { Local::from_non_null(nn) }
345-
}
346309
}
347310

348311
#[repr(C)]
349312
#[derive(Debug)]
350-
struct RawPropertyCallbackInfo(Opaque);
313+
struct RawPropertyCallbackInfo(*mut Opaque);
351314

352315
/// The information passed to a property callback about the context
353316
/// of the property access.

src/support.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ static_assert(sizeof(bool) == sizeof(uint8_t), "");
1818
static_assert(sizeof(std::unique_ptr<void>) == sizeof(void*), "");
1919

2020
namespace support {
21+
22+
template <std::size_t Len, std::size_t Align>
23+
struct aligned_storage {
24+
struct type {
25+
alignas(Align) unsigned char data[Len];
26+
};
27+
};
28+
2129
template <class T>
22-
using uninit_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
30+
using uninit_t = typename aligned_storage<sizeof(T), alignof(T)>::type;
2331

2432
template <class T, class... Args>
2533
class construct_in_place_helper {

third_party/abseil-cpp

Submodule abseil-cpp updated from dcfa08f to 1597226

third_party/libc++/src

Submodule src updated from 99d9ab2 to 7ab6565

third_party/libc++abi/src

Submodule src updated from de02e5d to 8f11bb1

third_party/libunwind/src

Submodule src updated from 7ff36f1 to a726f53

0 commit comments

Comments
 (0)