0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00
Commit graph

407 commits

Author SHA1 Message Date
Divy Srivastava
3de68239a5
Upgrade to V8 12.1.285.6 (#1374)
1. [[exceptions] Unify pending and scheduled exceptions](https://chromium-review.googlesource.com/c/v8/v8/+/5050065)

Reset no longer clears exception if it was rethrown. The test had to be adjusted for the same.

2. [[api] Allow passing CppHeap on Isolate creation](https://chromium-review.googlesource.com/c/v8/v8/+/4989254)

`AttachCppHeap` was deprecated but the alternative of passing `CppHeap` via Isolate CreateParams hard crashes (SIGSEGV). There are no tests for this in V8 and it seems the [Chromium CL](https://chromium-review.googlesource.com/c/chromium/src/+/4992764) is also crashing. For now I've just suppressed the deprecation warning until the crash is fixed in V8.

3. v8::Serializer impl must not throw more than one exception. 

I changed `get_shared_buffer_id()` to not throw and return `None`. V8 internally calls data clone error when it's the SAB is not clonable.

Other changes:

- `v8::ScriptCompiler` size increased by 3 words with `v8::ScriptCompiler::CompilationDetails`.
- `v8::ObjectTemplate::SetAccessor` & `v8::ObjectTemplate::SetAccessorProperty` signature changed and also deprecated.
- `v8::Context::SetContinuationPreservedEmbedderData` deprecated. Use `v8::Isolate::GetContinuationPreservedEmbedderData` instead.
- `GetStalledTopLevelAwaitMessage` deprecated. Use `GetStalledTopLevelAwaitMessages` instead.
- `v8::Isolate::AttachCppHeap` deprecated. Set the heap on Isolate creation using CreateParams instead. 
- `v8::ScriptOrigin` deprecated. Use constructor without the isolate.
- `v8::SnapshotCreator` is deprecated. Use the version that passes CreateParams instead.
- `v8::Isolate` assertion failures.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-05 18:50:42 +05:30
Guillaume Bort
60e0859514
Explicit panic instead of silent memory corruption (#1377)
Due to the automatic entry and exit behavior of Isolate upon creation and drop, it is crucial to ensure that v8::OwnedIsolate instances are dropped in the reverse order of their creation. Dropping them in the incorrect order can result in the corruption of the thread-local stack managed by v8, leading to memory corruption and potential segfaults. This introduces a check to verify the `this == Isolate::GetCurrent()` requirement before invoking the exit function. If the requirement is not met, a clean panic is triggered to provide explicit error handling instead of allowing silent memory corruption.
2023-12-12 07:32:40 -07:00
Laurence Rowe
ec2c901895
feat: Support custom host objects in ValueSerializer (#1322)
Add v8::ValueSerializerImpl::{has_custom_host_object,is_host_object} 
equivalents for v8::ValueSerializer::Delegate::{HasCustomHostObject,IsCustomHostObject}.

This enables serializing custom host objects without embedder fields.
2023-11-21 00:24:59 +01:00
denobot
92f7d41a4c
Rolling to V8 12.0.267.1 (#1361)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-01 01:26:06 +01:00
Divy Srivastava
7072da4199
Add cppgc bindings (#1336)
https://v8.dev/blog/high-performance-cpp-gc

Oilpan in Deno design doc: https://www.notion.so/denolandinc/Oilpan-cppgc-in-Deno-e194f4268e9f4135ba97610ff7d3a949?pvs=4

Oilpan can be used to implement GC'able resources in Deno

Closes https://github.com/denoland/rusty_v8/issues/933
2023-10-30 20:40:15 +05:30
Matt Mastracci
01d82405e1
feat: add call_with_context to v8::Function (#1350) 2023-10-26 12:28:14 -06:00
Bartek Iwańczuk
be0e017cd5
chore: update V8 to latest floated patch (#1354)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-10-26 16:39:22 +00:00
Divy Srivastava
cdfb89e8a7
Add test for --expose-deno-builtins (#1344) 2023-10-07 16:04:11 +00:00
Matt Mastracci
da5ca4f2d1
feat: add get_backing_store to ArrayBufferView (#1342) 2023-10-03 15:23:59 +00:00
Matt Mastracci
efca1408f6
fix: arraybuffer init from vec was broken if vec reallocated to box (#1341) 2023-10-03 09:17:18 -06:00
Matt Mastracci
bf277f4f8e
feat: new_backing_store_from_bytes and empty for ArrayBuffer and SharedArrayBuffer (#1334) 2023-10-02 12:08:51 -06:00
Matt Mastracci
12dca0cf03
feat: add scope-less data() access on ArrayBufferView (#1338) 2023-09-29 18:20:29 -06:00
Matt Mastracci
bb5dadb418
fix: better fix for empty Uint8Array (#1329) 2023-09-22 17:34:30 +00:00
Laurence Rowe
b2a7cfe0c2
fix(Symbol): deprecate for_global in favour of for_key and for_api (#1324)
`for_global` was documented as `for_key` but implemented as `for_api`.

Closes #1323
2023-09-18 17:48:13 -06:00
Bert Belder
53e048ffc7
fix: crash on x86_64 systems that support memory protection keys (#1318)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-09-12 23:26:42 +00:00
denobot
4573256203
Rolling to V8 11.7.439.1 (#1296)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-08 23:29:54 +00:00
Andreu Botella
f360663e67
feat: Add {Dis,}allowJavascriptExecutionScope (#862)
This commit adds two new types of scopes:
- DisallowJavascriptExecutionScope
- AllowJavascriptExecutionScope

The first one can be used to prevent execution of JavaScript 
(with customizable behavior on an attempt of executing JS, eg.
crashing the process); while the second one can be constructed
from the first to temporarily enable executing JS.

These are useful for "value serializers" to prevent user defined objects
from causing unintended behavior.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-07-19 14:52:58 +02:00
Aapo Alasuutari
308a113445
feat: Implement Rust-side const ExternalOneByteStringResource subclass (#1275)
MSVC and Itanium C++ ABIs agree that for simple inheritance the basic structure of a vtable contains metadata fields at a "negative offset" from the vtable pointer, and at zero or positive offsets come the virtual function pointers in the order of declaration. The only difference between the two is that MSVC only places the virtual deleting destructor in the vtable while Itanium ABI places both the deleting and the complete object destructors in it, leading to a vtable that is one pointer larger in Itanium / on Linux. Also MSVC only has a single metadata field instead of two for Itanium. Itanium inlines the base offset into the vtable while MSVC keeps it in what is essentially the entry point into the type info data.

Since the two are so similar, creating a custom vtable on Rust-side is pretty easy and can be done entirely at compile-time, meaning that instances of the class can also be created entirely at compile time. This leads to fully const external strings being possible.
2023-07-12 07:22:12 -06:00
Bartek Iwańczuk
4dd8b60bf0
chore: update to Rust 1.70.0 (#1277) 2023-07-11 12:50:03 -06:00
Matt Mastracci
4110d1bf4e
chore: Add Debug for ExternalReference (#1272) 2023-07-11 10:09:29 -06:00
Leo Kettmeir
c6fe9e70d0
feat: v8::Object::PreviewEntries (#1276) 2023-07-10 19:30:11 +02:00
Bartek Iwańczuk
73dcb46674
Add v8::NamedPropertyHandlerConfiguration::*_raw methods (#1273) 2023-07-09 22:40:15 +02:00
Matt Mastracci
d706291c5d
fix: Ensure that one-byte strings that are not ASCII go through write_utf8_uninit (#1261) 2023-06-30 09:46:29 -06:00
Matt Mastracci
ad0a65d0a5
feat: Use MaybeUninit for to_rust_string_lossy and add to_rust_cow_lossy (#1256)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-06-28 07:46:50 -06:00
Rakeeb Hossain
7419b38aac
Add Function::{ScriptId, GetScriptOrigin}, ScriptOrigin::Get{ScriptId, ResourceName, SourceMapUrl} bindings (#1250) 2023-06-28 08:09:07 +02:00
Matt Mastracci
672254e113
feat: Fix is_onebyte and add an uninit write for onebyte (#1255)
Some fixes around one-byte strings:

 - `is_onebyte` was calling the wrong v8 API.
 - We didn't have a way to write one-byte strings with uninitialized buffers
 - (bonus) The test_string method was quite slow making testing a bit of a pain
2023-06-26 09:30:16 -06:00
Aapo Alasuutari
6cc61a26b2
feat(fastcall): Int64Representation (#1238)
* feat(fastcall): Int64Representation

* Add tests, new_with_bigint API

* Fix build, actually
2023-06-02 11:28:14 -06:00
Luca Casonato
e7f96ac708
Improved ObjectTemplate::set_*_handlers (#1237)
Prior to this commit, `v8::NamedPropertyHandlerConfiguration`
and `v8::IndexedPropertyHandlerConfiguration` did not expose the
`definer` hook, or `flags`.

This commit adds these options. In the process of doing this a couple of
other changes were made:

- Bitflag enum consts are now member consts of the related struct.
  This is done because PropertyHandlerFlags has conflicts with
  PropertyAttribute.
- PropertyDescriptor gets all C++ introspection methods exposed to Rust.
- NamedPropertyHandlerConfiguration callback types get rustdoc comments.
- IndexedPropertyHandlerConfiguration callback types get rustdoc
  comments.
- GenericNamedPropertySetterCallback gets a ReturnValue parameter, to
  signal trap passthrough.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-26 13:14:18 +02:00
Luca Casonato
43b798a39d
Add more Object methods (#1240)
Specifically Object::get_own_property_descriptor
and Object::get_property_attributes
2023-05-25 13:04:50 +00:00
Bartek Iwańczuk
367be04178
feat: Add v8::CreateParams::has_set_array_buffer_allocator (#1232) 2023-05-22 12:33:17 +00:00
denobot
c68038bc7d
Rolling to V8 11.4.183.11 (#1228)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-20 03:04:12 +02:00
Bartek Iwańczuk
dec3aa2d0b
Fix exception not caught in debug build for v8::Function::call (#1229) 2023-05-12 18:47:05 +02:00
Bartek Iwańczuk
6ac0fabb56
test: Add tests showing incorrect exception behavior in debug build (#1227)
Reproduces #1226 and denoland/deno#19021

```
// Fails
$ V8_FROM_SOURCE=1 cargo test exception
// Passes
$ V8_FROM_SOURCE=1 cargo test --release exception
```

We bisected this and this problem first appeared with V8 v11.2 upgrade. After further
bisects we established that v8/v8@1f349da#diff-de75fc3e7b84373d94e18b4531827e8b749f9bbe05b59707e894e4e0ce2a1535
is the first V8 commit that causes this failure. However after more investigation we can't
find any reason why that particular commit might cause this problem.

It is only reproducible in debug build, but not release build. Current working theory
is that it is a Rust compiler bug as changing the optimization level for this code
makes the bug go away. This commit should be considered a band-aid that works
around the problem, but doesn't fix it completely. We are gonna go with it as it
unblocks un on day-to-day work, but ultimately we should track it down (or wait
for another Rust upgrade which might fix it?).

---------

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2023-05-12 02:46:42 +02:00
Giovanny Gutiérrez
5417e2af7f
feat: Add the option to disable generation from strings (#1222) 2023-04-30 12:29:40 +02:00
Giovanny Gutiérrez
e0c8cb50e8
feat: Expose set_accessor_with_configuration to include data and property attribute (#1220) 2023-04-28 00:39:09 +02:00
Giovanny Gutiérrez
fb20194130
feat: Add bindings for "v8::Set" (#1221) 2023-04-28 00:38:16 +02:00
Bartek Iwańczuk
f049ad0229
feat: Add v8::Object::get_constructor_name (#1212) 2023-04-21 23:53:51 +02:00
Bartek Iwańczuk
48c2ac89db
feat: Add v8::StackTrace::current_script_name_or_source_url (#1211) 2023-04-21 19:09:56 +02:00
Bartek Iwańczuk
9394983d15
refactor: migrate from lazy_static to once_cell (#1210) 2023-04-21 15:01:27 +05:30
Divy Srivastava
fe7610aa4a
FastApiOneByteString is not always utf-8 (#1206) 2023-03-31 12:02:47 +02:00
Levente Kurusa
cb8bcb4f1b
ArrayBuffer: add binding for IsResizableByUserJavaScript (#1205) 2023-03-27 19:33:58 +02:00
Divy Srivastava
49c77327a6
New const evaluated FastFunction API (#1201) 2023-03-22 20:37:48 +05:30
Aapo Alasuutari
57c5d93d29
Add tests for invalid UTF-8 sequences in v8::String::new_from_utf8 (#1190) 2023-03-16 09:25:52 -04:00
Bartek Iwańczuk
b1884eb1f5
Change signature of FunctionTemplate::build_fast (#1197)
Changes signature of "FunctionTemplate::build_fast" to allow
to pass "CFunctionInfo" explicitly. If it's not passed explicitly,
it's still autogenerated.
2023-03-16 08:23:04 +01:00
Giovanny Gutiérrez
c58f4c08d9
feat: Expose the security token API from V8 (#1192) 2023-03-10 08:31:13 -05:00
Bartek Iwańczuk
831f6e9bf1
test: fix flaky cached_data_version_tag test (#1194) 2023-03-07 07:44:16 +01:00
Divy Srivastava
ffb875d5ae
Add PropertyDescriptor::new_from_value_writable and new_from_value (#1187) 2023-02-11 22:51:51 +05:30
Bartek Iwańczuk
36cf16b594
refactor: Move set_promise_hooks API to HandleScope (#1186) 2023-02-09 20:38:25 +01:00
Bartek Iwańczuk
3b6d79c0e6
feat: Add bindings for continuation embedder data (#1184)
Adds bindings for:

- v8::Context::GetContinuationPreservedEmbedderData
- v8::Context::SetContinuationPreservedEmbedderData

These APIs are available on the "HandleScope".
---------

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2023-02-09 13:34:28 +01:00
Bartek Iwańczuk
83b54692c1
refactor: v8::Context::set_promise_hooks requires scope (#1185) 2023-02-05 20:14:57 +01:00