Skip to content

Commit

Permalink
Rolling to V8 11.7.439.1 (denoland#1296)
Browse files Browse the repository at this point in the history
Co-authored-by: Bartek Iwańczuk <[email protected]>
  • Loading branch information
denobot and bartlomieju committed Aug 8, 2023
1 parent 8c8f88a commit 4573256
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "third_party/icu"]
path = third_party/icu
url = https://github.com/denoland/icu.git
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git
6 changes: 0 additions & 6 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ default_args = {
# compiler" snapshots, and sometimes uses them both at the same time.
v8_enable_shared_ro_heap = false

# V8 introduced a bug in 11.1 that causes the External Pointer Table to never
# be cleaned which causes resource exhaustion. Disabling pointer compression
# makes sure that the EPT is not used.
# https://bugs.chromium.org/p/v8/issues/detail?id=13640&q=garbage%20collection&can=2
v8_enable_pointer_compression = false

# V8 11.6 hardcoded an assumption in `mksnapshot` that shared RO heap
# is enabled. In our case it's disabled so without this flag we can't
# compile.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rusty V8 Binding

V8 Version: 11.6.189.16
V8 Version: 11.7.439.1

[![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)
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,6 @@ edge [fontsize=10]
fn test_static_lib_size() {
let static_lib_size = std::fs::metadata(static_lib_path()).unwrap().len();
eprintln!("static lib size {}", static_lib_size);
assert!(static_lib_size <= 230u64 << 20); // No more than 230 MiB.
assert!(static_lib_size <= 270u64 << 20); // No more than 270 MiB.
}
}
38 changes: 23 additions & 15 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,17 +484,17 @@ bool v8__Data__EQ(const v8::Data& self, const v8::Data& other) {
}

bool v8__Data__IsBigInt(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsBigInt();
return IsBigInt(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsBoolean(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsBoolean();
return IsBoolean(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsContext(const v8::Data& self) { return self.IsContext(); }

bool v8__Data__IsFixedArray(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsFixedArray();
return IsFixedArray(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsFunctionTemplate(const v8::Data& self) {
Expand All @@ -504,33 +504,33 @@ bool v8__Data__IsFunctionTemplate(const v8::Data& self) {
bool v8__Data__IsModule(const v8::Data& self) { return self.IsModule(); }

bool v8__Data__IsModuleRequest(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsModuleRequest();
return IsModuleRequest(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsName(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsName();
return IsName(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsNumber(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsNumber();
return IsNumber(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsObjectTemplate(const v8::Data& self) {
return self.IsObjectTemplate();
}

bool v8__Data__IsPrimitive(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsPrimitive() && !self.IsPrivate();
return IsPrimitive(*v8::Utils::OpenHandle(&self)) && !self.IsPrivate();
}

bool v8__Data__IsPrivate(const v8::Data& self) { return self.IsPrivate(); }

bool v8__Data__IsString(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsString();
return IsString(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsSymbol(const v8::Data& self) {
return v8::Utils::OpenHandle(&self)->IsPublicSymbol();
return IsPublicSymbol(*v8::Utils::OpenHandle(&self));
}

bool v8__Data__IsValue(const v8::Data& self) { return self.IsValue(); }
Expand Down Expand Up @@ -3060,11 +3060,19 @@ void v8__HeapProfiler__TakeHeapSnapshot(v8::Isolate* isolate,
const_cast<v8::HeapSnapshot*>(snapshot)->Delete();
}

// This is necessary for v8__internal__GetIsolateFromHeapObject() to be
// reliable enough for our purposes.
#if UINTPTR_MAX == 0xffffffffffffffff && \
!(defined V8_SHARED_RO_HEAP or defined V8_COMPRESS_POINTERS)
#error V8 must be built with either the 'v8_enable_pointer_compression' or \
'v8_enable_shared_ro_heap' feature enabled.
#endif

v8::Isolate* v8__internal__GetIsolateFromHeapObject(const v8::Data& data) {
namespace i = v8::internal;
i::Object object(reinterpret_cast<const i::Address&>(data));
i::Isolate* isolate;
return object.IsHeapObject() &&
return IsHeapObject(object) &&
i::GetIsolateFromHeapObject(object.GetHeapObject(), &isolate)
? reinterpret_cast<v8::Isolate*>(isolate)
: nullptr;
Expand All @@ -3074,10 +3082,10 @@ int v8__Value__GetHash(const v8::Value& data) {
namespace i = v8::internal;
i::Object object(reinterpret_cast<const i::Address&>(data));
i::Isolate* isolate;
int hash = object.IsHeapObject() && i::GetIsolateFromHeapObject(
int hash = IsHeapObject(object) && i::GetIsolateFromHeapObject(
object.GetHeapObject(), &isolate)
? object.GetOrCreateHash(isolate).value()
: i::Smi::ToInt(object.GetHash());
? i::Object::GetOrCreateHash(object, isolate).value()
: i::Smi::ToInt(i::Object::GetHash(object));
assert(hash != 0);
return hash;
}
Expand Down Expand Up @@ -3401,8 +3409,8 @@ void v8__CompiledWasmModule__DELETE(v8::CompiledWasmModule* self) {
extern "C" {

size_t icu_get_default_locale(char* output, size_t output_len) {
const icu_72::Locale& default_locale = icu::Locale::getDefault();
icu_72::CheckedArrayByteSink sink(output, static_cast<uint32_t>(output_len));
const icu_73::Locale& default_locale = icu::Locale::getDefault();
icu_73::CheckedArrayByteSink sink(output, static_cast<uint32_t>(output_len));
UErrorCode status = U_ZERO_ERROR;
default_locale.toLanguageTag(sink, status);
assert(status == U_ZERO_ERROR);
Expand Down
6 changes: 3 additions & 3 deletions src/icu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::ffi::CString;
extern "C" {
fn icu_get_default_locale(output: *mut char, output_len: usize) -> usize;
fn icu_set_default_locale(locale: *const char);
fn udata_setCommonData_72(this: *const u8, error_code: *mut i32);
fn udata_setCommonData_73(this: *const u8, error_code: *mut i32);
}

/// This function bypasses the normal ICU data loading process and allows you to force ICU's system
Expand Down Expand Up @@ -42,10 +42,10 @@ extern "C" {
/// functionality for application data.
// TODO(ry) Map error code to something useful.
#[inline(always)]
pub fn set_common_data_72(data: &'static [u8]) -> Result<(), i32> {
pub fn set_common_data_73(data: &'static [u8]) -> Result<(), i32> {
let mut error_code = 0i32;
unsafe {
udata_setCommonData_72(data.as_ptr(), &mut error_code);
udata_setCommonData_73(data.as_ptr(), &mut error_code);
}
if error_code == 0 {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,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 (); 62]>();
const EMBEDDER_DATA_OFFSET: usize = size_of::<[*const (); 67]>();

// Isolate data slots used internally by rusty_v8.
const ANNEX_SLOT: u32 = 0;
Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod setup {
fn initialize_once() {
static START: Once = Once::new();
START.call_once(|| {
assert!(v8::icu::set_common_data_72(align_data::include_aligned!(
assert!(v8::icu::set_common_data_73(align_data::include_aligned!(
align_data::Align16,
"../third_party/icu/common/icudtl.dat"
))
Expand Down Expand Up @@ -8193,7 +8193,7 @@ fn icu_date() {

#[test]
fn icu_set_common_data_fail() {
assert!(v8::icu::set_common_data_72(&[1, 2, 3]).is_err());
assert!(v8::icu::set_common_data_73(&[1, 2, 3]).is_err());
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp
Submodule abseil-cpp added at 583dc6
2 changes: 1 addition & 1 deletion third_party/icu
Submodule icu updated 1796 files
2 changes: 1 addition & 1 deletion v8
Submodule v8 updated 1906 files

0 comments on commit 4573256

Please sign in to comment.