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

455 commits

Author SHA1 Message Date
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
Bartek Iwańczuk
d3fff51d2d
Don't run GC on isolate disposal (#1181)
Removing this garbage collection trigger removes the guarantee that
"regular" FinalizerCallbacks will be called before the isolate goes away.
It is fine as both spec and V8 do not provide this guarantee and we were
overly strict in this case.
2023-02-02 11:59:14 +01:00
Bartek Iwańczuk
623c6cd81d
feat: v8::Context::set_promise_hooks accepts None (#1178)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2023-02-01 17:42:47 +01:00
Divy Srivastava
55e8a2d60d
feat: Add v8::Object::DefineProperty (#1172) 2023-01-24 21:03:00 +05:30
Mike Mulchrone
7c1b08e6a8
Avoid referencing uninitalized in Inspector API (#1164) 2023-01-15 20:00:38 +05:30
Bartek Iwańczuk
961a4940b5
feat: Add v8::TypedArray::length (#1166) 2023-01-08 15:11:19 +01:00
Aapo Alasuutari
8d9864c8fc
feat: Add tests for void pointer support in Fast API calls (#1162) 2022-12-27 22:05:50 +01:00
Bert Belder
9b76cf8fb1 fix: use default value (true) for 'v8_enable_shared_ro_heap' config flag (#1160)
V8 11.0.226.2 can't make snapshots succesfully when
'v8_enable_shared_ro_heap' is set to false.
2022-12-18 22:55:12 +01:00
Bert Belder
8548b39833 deps: upgrade ICU to 72-1 (#1160)
ICU was upgraded to the version specified in V8's `DEPS` file as of V8
11.0.226.2.
2022-12-18 22:55:12 +01:00
Bartek Iwańczuk
9fc29f439e
feat: v8::Inspector::exception_thrown, v8::Inspector::create_stack_trace (#1149)
Adds APIs required to notify inspector about exceptions raised
by the runtime.
2022-12-07 14:43:55 +01:00
Bartek Iwańczuk
3e8a572ceb
feat: Add v8::Isolate::request_garbage_collection_for_testing (#1148) 2022-12-02 21:10:37 +01:00
Bartek Iwańczuk
caa2ef4510
feat: v8::Isolate::{add,remove}_gc_prologue_callback (#1142) 2022-11-30 19:10:42 +01:00
Ryan Dahl
3783a5c725
feat: Isolate::memory_pressure_notification() (#1139)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-11-30 17:25:10 +01:00
Divy Srivastava
e57c3ec90f
Optional key in v8::ArrayBuffer:detach (#1141) 2022-11-30 15:33:28 +01:00
Divy Srivastava
f5c9e90c6d
Add SeqOneByteString to fast API calls (#1129) 2022-11-29 22:06:55 +01:00
Mike Mulchrone
3c6d259507
Exposing Value::TypeOf (#1133) 2022-11-27 03:02:08 +01:00
Bartek Iwańczuk
06f385afb6
Add 'aux_data' to v8::Inspector::contextCreated() (#1134) 2022-11-26 16:11:35 +01:00
Bartek Iwańczuk
65ff64e5cd
chore: update Rust to 1.65.0 (#1116) 2022-11-25 14:32:52 +01:00
Andreu Botella
d718370a07
refactor: Have ArrayBuffer::data return Option<NonNull<c_void>> (#1131)
The pointer returned by `ArrayBuffer::data` might be null if the
backing store has zero length, but the return type `*mut c_void` does
not force the user to consider this case. This change makes the return
type `Option<NonNull<c_void>>`, which is semantically equivalent, but
which forces users of the API to handle the `None` case.

This PR is the `ArrayBuffer` counterpart to #817.

This is a breaking API change.
2022-11-24 15:31:11 +01:00
Bartek Iwańczuk
dd5fa705d4
Add v8::V8Inspector::context_destroyed API (#1125) 2022-11-22 23:50:49 +01:00
Andreu Botella
acba887fa4
Add ArrayBuffer::set_detach_key (#1127)
This method, introduced in V8 10.9, makes it so an `ArrayBuffer`
object is impossible to detach unless a specific detach key is passed
to the `detach` method. Such `ArrayBuffer`s still count as detachable
as per the `ArrayBuffer::is_detachable` method, but otherwise behave
much like WebAssembly memories.
2022-11-21 12:46:57 +01:00
Bartek Iwańczuk
3d30e7cc82
feat: v8::Module::get_stalled_top_level_await_message (#1123)
This commit adds "v8::Module::get_stalled_top_level_await_message" API
that allows to retrieve a vector of tuples with handles to v8::Module and v8::Message.
This information can be used to display a nice error when event loop runs out
of work to do but there are still unresolved promises.
2022-11-17 19:35:15 +01:00
Bartek Iwańczuk
9d15050214
fix: Rework deprecated v8::ArrayBuffer:detach API (#1121) 2022-11-12 01:51:21 +01:00
Bert Belder
d85f78527f
perf: optimize FunctionCallbackInfo and PropertyCallbackInfo methods (#1104) 2022-10-19 21:41:22 +02:00
Divy Srivastava
8a3a049d9f
Access to raw v8::Context slots (#1092)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-18 14:01:54 +02:00
Marcos Casagrande
c06986c12e
feat: add ArrayBuffer::was_detached() (#1103) 2022-10-16 22:03:48 +02:00
Leo Kettmeir
885e0163a1
feat: add v8::Isolate::snapshot_creator_from_existing_snapshot API (#973)
This commit adds "v8::Isolate::snapshot_creator_from_existing_snapshot" API,
that allows to create a new snapshot from already existing snapshot.

Following APIs were added as well:

"v8::Context::from_snapshot"
"v8::Isolate::add_context"

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2022-10-14 12:33:09 +02:00
Bartek Iwańczuk
4b704ed8a9
refactor: v8::Isolate::snapshot_creator instead of v8::SnapshotCreator (#1098)
This commit removes "v8::SnapshotCreator" in favor of
"v8::Isolate::snapshot_creator" API. All methods from
"v8::SnapshotCreator" are now available on the "v8::Isolate".
If a method is called and isolate was not set up as a snapshot
creator then it will panic.

This commit gets rid of long standing unsoundness in typing
that allowed to easily induce a panic or segfault if a user didn't
use snapshot creator API properly.
2022-10-14 10:46:54 +02:00
Ben Noordhuis
213305b3de
Strengthen fast call API test (#1093)
Check that it actually performs the expected operation (adding two
numbers) because it didn't - the callback's function prototype was
wrong. V8 always passes the receiver object as the first parameter.
2022-10-09 15:26:06 +02:00
Bert Belder
b2a09e2f14
perf: optimize scope construction and Isolate::get_slot/set_slot() (#1090) 2022-10-08 18:08:37 +05:30
Bert Belder
fc26f634e4
Don't use embedder slot in HostImportModuleDynamicallyCallback ABI adapter (#1089) 2022-10-08 00:30:01 +00:00
PerfectLaugh
403d6c525d
Enable running on 32 bits and several minor fixes (#976) 2022-10-07 15:02:51 +02:00
Divy Srivastava
5dd41e9dba
use Isolate for creating primitives (#1082) 2022-10-06 20:44:16 +02:00
Aaron O'Mullan
de7a1acbde
feat(isolate): expose get/set_data (#911)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-06 19:19:38 +02:00
Andreu Botella
cfdb8b0ccd
feat: Guaranteed finalizers (#1076)
Currently, when a finalizer callback is registered, it is not
guaranteed to be called if there is a global reference to the
corresponding object that survives the isolate. This is because the
finalizer callback takes a `&mut Isolate`, and so it must be called
before the isolate is fully destroyed, but all existing globals
(including possibly the one being currently finalized) are still
usable while there still exists a mutable reference to the isolate.

However, there are still use cases for having finalizers that are
guaranteed to run regardless of any remaining globals, but that don't
require any interaction with the isolate. This change adds them.

This change also changes the context annex to use a guaranteed
finalizer, fixing a bug with context slots not being freed if there
were any globals to the context at the time the isolate is dropped.
2022-10-06 17:25:45 +02:00
Giovanny Gutiérrez
cd51ea1bf2
feat: Add ObjectTemplate NamedProperty and IndexedProperty handlers (#1064) 2022-10-06 00:23:01 +02:00
Luca Matei Pintilie
760c48a089
feat: Add v8::icu::get_language_tag() (#953)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2022-10-05 23:19:42 +02:00
Divy Srivastava
c549b19df3
fastcall: Fix get_storage_if_aligned for non-uint8arrays (#1077) 2022-09-20 17:55:15 +05:30
Aapo Alasuutari
2ba52ed276
fix(fastcall): Fix options.data representation (#1074) 2022-09-20 09:57:23 +05:30
Divy Srivastava
31291f64a6
Add v8::ArrayBuffer::Data (#1068) 2022-09-16 11:30:05 +02:00
Darshan Sen
780eb7946b
fix: property_attribute operator (#1067)
property_attribute previously had an addition operator overload which
doesn't make much sense in comparison to the corresponding V8
enumeration. This changes that to a bitor overload.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
2022-09-13 08:48:53 -04:00
Darshan Sen
dbf19c8545
Improve Object::get_property_names() and Object::get_own_property_names() (#1049)
This change allows the customization of the behavior of
v8::Object::GetOwnPropertyNames() and v8::Object::GetPropertyNames() by
accepting all the options that the raw V8 API supports.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
2022-09-03 18:11:40 +02:00
Bartek Iwańczuk
4b3b081c03
Add support for Fast calls with Uint8Array (#1047) 2022-08-13 19:56:29 +02:00
Divy Srivastava
606fee5ec7
support V8 FastApiCallbackOptions (#1044) 2022-08-03 16:07:18 +05:30
denobot
21a8d4a580
Rolling to V8 10.5.218.1 (#1036)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-07-25 19:22:32 +02:00
Divy Srivastava
3be46ecc52
Support Fast API Overloads (#1031) 2022-07-16 19:57:58 +05:30
Divy Srivastava
08e1a1c361
Add v8::Object [Get/Set]AlignedPointer[From/In]InternalField (#1026) 2022-07-13 12:35:31 +05:30
Aapo Alasuutari
d8480fc7ef
Add Uint32 / Int32 Value method bindings (#1030) 2022-07-13 09:33:55 +05:30
denobot
d2db387448
Rolling to V8 10.4.132.16 (#1012) 2022-07-12 22:27:57 +00:00
Divy Srivastava
47a7bece35
V8 Fast API Sequence (#1022)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-07-08 08:54:24 +05:30
Divy Srivastava
1d0a4c1792
V8 Fast API Calls (#1021)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-07-07 16:30:35 +05:30
Divy Srivastava
e6b443a6e8
Add ReturnValue::set_bool (#1020) 2022-07-04 07:02:13 +05:30
Divy Srivastava
95f2ba399c
Expose from_function_callback_info (#1016) 2022-06-28 16:49:37 +05:30