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

609 commits

Author SHA1 Message Date
Divy Srivastava
3a05ab4cd6
Add WasmMemoryObject::buffer method (#1128) 2022-11-23 21:44:37 +05:30
Bartek Iwańczuk
dd5fa705d4
Add v8::V8Inspector::context_destroyed API (#1125) 2022-11-22 23:50:49 +01:00
Andreu Botella
d992c5056b
Update ArrayBuffer::was_detached to not use OpenHandle (#1126)
In #1103, the `ArrayBuffer::was_detached` method was added to rusty_v8
to fill a gap in the C++ API, and it was implemented using the
internal `v8::Utils::OpenHandle`. Since then, a `WasDetached` method
was added to `ArrayBuffer` in V8 10.9. This PR updates the
implementation to use that.
2022-11-21 12:47:12 +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
Bartek Iwańczuk
b8d7925774
docs: add note how to create a v8::Local out of v8::Global (#1113) 2022-11-02 22:09:07 +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
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
Nugine
8f8636b4f7
feat: add String::write_utf8_uninit (#1019) 2022-10-06 19:26:38 +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
9f78b0abe7
Inline API functions (#1078) 2022-09-21 08:15:33 +05:30
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
Ryan Dahl
0d1ada4387
chore: small clean ups (#1073) 2022-09-19 09:33:58 +02:00
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
Will Glozer
fa01b39f32
Fix compilation for 32-bit targets (#1050) 2022-08-21 10:16:43 +05:30
Bartek Iwańczuk
4b3b081c03
Add support for Fast calls with Uint8Array (#1047) 2022-08-13 19:56:29 +02:00
Bartek Iwańczuk
33e426bfe4
Export WasmAsyncSuccess enum, change signature of WasmAsyncResolvePro… (#1046)
Export WasmAsyncSuccess enum, change signature of WasmAsyncResolvePromiseCallback
2022-08-13 17:55:56 +02:00
Divy Srivastava
606fee5ec7
support V8 FastApiCallbackOptions (#1044) 2022-08-03 16:07:18 +05:30
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
Bartek Iwańczuk
2193d827b9
feat: WasmAsyncResolvePromiseCallback (#1029) 2022-07-13 07:51:10 +02:00
Aapo Alasuutari
d8480fc7ef
Add Uint32 / Int32 Value method bindings (#1030) 2022-07-13 09:33:55 +05:30
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
Divy Srivastava
f5d275f622
Add type specialized setters for v8::ReturnValue (#1015) 2022-06-27 08:12:06 +05:30
denobot
c53d85114e
Rolling to V8 10.4.132.5 (#1002)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2022-06-15 00:26:50 +02:00
Andreu Botella
d43535c48b
ShadowRealm integration callback (#959) 2022-05-24 16:26:12 +02:00
Chengzhong Wu
5f90045ad0
feat: add Context::get_extras_binding_object (#975) 2022-05-24 15:57:35 +02:00
Colin Ihrig
0605e9bc34
feat: add ObjectTemplate::set_immutable_proto() (#977)
This commit exposes SetImmutableProto().
2022-05-19 18:15:32 -04:00
Andreu Botella
15ac9f4533
feat: Context slots (#937) 2022-05-19 23:24:58 +02:00
Bert Belder
2f189e1668
Upgrade V8 to 10.3.174.3 (#969) 2022-05-18 10:53:34 +02:00
Timo
242e4cf97f
Fix misuse of MaybeUninit and avoid refs to uninit memory (#954) 2022-05-11 02:22:10 +02:00
Spencer
0cd8ae6f16
feat: add FunctionTemplate::instance_template binding (#952) 2022-05-09 19:43:33 +02:00
Andreu Botella
1ed35fd22e
feat: Weak handles and finalizers (#895)
This change adds support for weak handles that don't prevent GC of the
referenced objects, through the `v8::Weak<T>` API. A weak handle can
be empty (if it was created empty or its object was GC'd) or
non-empty, and if non-empty it allows getting its object as a global
or local.

When creating a `v8::Weak` you can also set a finalizer that will be
called at some point after the object is GC'd, as long as the weak
handle is still alive at that point. This finalization corresponds to
the second-pass callback in `kParameter` mode in the C++ API, so it
will only be called after the object is GC'd. The finalizer function
is a `FnOnce` that may close over data, and which takes a
`&mut Isolate` as an argument.

The C++ finalization API doesn't guarantee _when_ or even _if_ the
finalizer will ever be called, but in order to prevent memory leaks,
the rusty_v8 wrapper ensures that it will be called at some point,
even if it's just before the isolate gets dropped.

`v8::Weak<T>` implements `Clone`, but a finalizer is tied to a single
weak handle, so its clones won't be able to keep the finalizer alive.
And in fact, cloning will create a new weak handle that isn't tied to
a finalizer at all. `v8::Weak::clone_with_finalizer` can be used to
make a clone of a weak handle which has a finalizer tied to it.

Note that `v8::Weak<T>` doesn't implement `Hash`, because the hash
would have to change once the handle's object is GC'd, which is a big
gotcha and would break some of the algorithms that rely on hashes,
such as the Rust std's `HashMap`.
2022-05-09 12:20:55 +02:00
Luca Casonato
2dcced58d1
feat: add WasmModuleObject::compile bindings (#960)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-05-07 18:02:39 +02:00
legendecas
196145abf1
feat: add binding for Context::SetPromiseHooks (#938) 2022-05-05 18:31:29 +02:00
Aaron O'Mullan
7772779210
feat: v8::ArrayBuffer::new_backing_store_from_vec (#946)
So we can avoid `.into_boxed_slice()` calls which may require a (costly) memmove when instantiating from a Vec
2022-04-20 19:36:10 +02:00
DjDeveloper
aa9f78e09c
feat: ArrayBuffer::new_backing_store_from_ptr (#926) 2022-04-05 15:55:25 +02:00
Bert Belder
48cc6cb791
Sync V8 heap object type hierarchy with C++ (#929) 2022-03-25 03:15:30 +01:00
Bert Belder
25dd770570
perf: avoid double boxing of Arc/Box/Rc in Isolate slot (#925) 2022-03-21 11:50:45 +01:00
Aaron O'Mullan
aaacaa292f
feat: raw APIs to build v8::Functions from ptrs (#917)
Unblocks https://github.com/denoland/deno/pull/13861

The MapFnTo trait is quite contrived and can't be turned into a trait object thus blocking declarative ops
2022-03-10 23:04:48 +01:00
Ryan Dahl
184467a9cc
Upgrade to ICU 70 (#919) 2022-03-10 09:27:22 -08:00
github-actions[bot]
b91d363d2f
Rolling to V8 10.0.139.6 (#915)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-03-09 14:41:46 +01:00
Divy Srivastava
6b0dcdb440
chore: upgrade Rust to 1.59.0 (#909) 2022-03-02 17:30:58 +05:30
Divy Srivastava
90f2f79c42
Add ObjectTemplate::set_accessor_property (#908) 2022-03-02 15:40:54 +05:30
Bert Belder
0ce68a675f
fix: Global::from_raw() should not create a new Global (#906) 2022-02-24 18:15:54 -08:00
Romain Marcadier
2404d208f5
feat: add bindings for String::kMaxLength and TypedArray::kMaxLength (#904) 2022-02-22 21:23:28 -08:00
Divy Srivastava
fe447c88df
feat: support adding raw pointers to ExternalReferences (#901) 2022-02-18 16:08:54 -08:00
Bartek Iwańczuk
da7ef32ead
feat: v8::Global::from_raw, v8::Global::into_raw (#902)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2022-02-18 01:26:00 +01:00
Divy Srivastava
41003d097d
Add v8::FunctionCallbackInfo::NewTarget bindings (#898) 2022-02-11 20:51:13 +05:30
Divy Srivastava
378631e793
Add v8::Object::HasOwnProperty bindings (#897) 2022-02-11 10:04:14 +05:30
Divy Srivastava
0f34359fb4
Add v8::Value::InstanceOf bindings (#879) 2022-02-11 08:27:56 +05:30
Romain Marcadier
db7229ef14
Add bindings for v8::ScriptCompiler::CreateCodeCacheForFunction (#888) 2022-02-04 06:29:53 -08:00
github-actions[bot]
b12987ac81
Rolling to V8 9.9.115.5 (#887)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-02-02 00:51:14 +01:00
Romain Marcadier
a09d392711
Make v8::script_compiler::Source.get_cached_data return Option (#885)
The `cached_data` property of `Source` is optional, so reading the value
should return `Option<&CachedData>`.
2022-02-01 01:15:49 +01:00
Romain Marcadier
729c5b323f
Add support for v8::Object.set_integrity_level (#874)
This allows making objects frozen or sealed from rust code. This is
useful to control mutations that are allowed to happen in JS on the
given object.
2022-01-24 11:09:05 +01:00
Divy Srivastava
4b5514711a
Add v8::Isolate:AdjustAmountOfExternalAllocatedMemory bindings (#880) 2022-01-23 22:49:29 +05:30
Romain Marcadier
2180716923
Add v8::Map bindings (#872)
Support v8::Map operations (`new`, `clear`, `get`, `set`, `has`,
and `delete`).
2022-01-19 19:01:55 +01:00
Divy Srivastava
a29740df6b
Add aarch64-linux-android support (#860) 2022-01-04 21:32:48 +01:00
Aaron O'Mullan
b3e09e69a0
feat: v8::StackTrace::CurrentStackTrace() bindings (#800) 2021-12-28 16:52:12 +01:00
Bert Belder
65e78fd960
chore: upgrade Rust to 1.57.0 (#856) 2021-12-14 21:25:10 -08:00
Andreu Botella
06648dd1bd
fix: segfault when dropping BackingStore constructed from empty slice (#851)
This fixes in a segmentation fault when dropping a `BackingStore`
constructed through `ArrayBuffer::new_backing_store_from_boxed_slice()`
from an empty slice, since zero length boxed slices are invalid
(dangling) pointers, while Rust expects a `Box<c_void>` to always be a
valid pointer.

Fixes: #849
2021-12-13 15:37:59 -08:00
Bert Belder
251f1e9ac9
fix: url param to v8::WasmStreaming::SetUrl() must be null terminated (#854) 2021-12-12 21:25:11 -08:00
Sujay Jayakar
62d33c4d7e
Add Function::GetScript{Line,Column}Number bindings (#843) 2021-11-30 21:55:41 +01:00
Andreu Botella
aac37a6d4f
refactor: Have BackingStore::data return Option<NonNull<c_void>> (#817)
The pointer returned by `BackingStore::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 is a breaking API change.
2021-11-17 12:14:03 +01:00
Rafael Ávila de Espíndola
a043407ae8
Make lifetime in FunctionCallback signature more restrictive (#822)
This makes the callbacks themselves less restrictive. A test is added
the would fail to compile before.
2021-11-08 12:51:53 -08:00
github-actions[bot]
7cc28c5e47
Rolling to V8 9.7.106.2 (#827)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-11-08 01:24:05 +01:00
Ryan Dahl
8297216a1c
Narrow dead_code allowance (#818) 2021-10-28 16:29:04 -04:00
Luca Casonato
5ee0a375f2
chore: rename rusty_v8 to v8 (#803) 2021-10-27 14:32:12 +02:00
Andreu Botella
2a21f5abf9
fix: Make derefing a zero-size BackingStore no longer UB (#809)
For zero-size `BackingStore`s, it seems like `BackingStore::data` always
returns a null pointer. The `Deref` impl for `BackingStore` called
`std::slice::from_raw_parts` on that pointer, even though it is UB to
call that function on a null pointer even for empty slices. This change
fixes that by obtaining a valid pointer from `NonNull::dangling()` if
the original is null.

Reported in
https://github.com/denoland/rusty_v8/issues/711#issuecomment-950637136.
2021-10-25 22:40:14 +02:00
Bert Belder
d478c450dd
Rename Handle::get() to Handle::open() instead (#806)
This also adds a deprecated `Global::get()` method to avoid unnecessarily
breaking a lot of users code.

Ref: #799
2021-10-13 21:45:10 +02:00
Rafael Ávila de Espíndola
8285b3da34
Rename Handle::get() to Handle::inner() (#799) 2021-10-13 16:47:34 +02:00
Aaron O'Mullan
6ccf15c69d
feat: Function::get/set_name() (#792)
Add bindings for v8::Function::GetName() and v8::Function::SetName()
2021-10-01 22:38:05 +02:00
Andreu Botella
b32d0b0540
feat: WasmStreaming::set_url, CompiledWasmModule::source_url (#786)
Needed for denoland/deno#12151
2021-09-22 14:34:39 -04:00
Ben Noordhuis
09347d32c8
Throw DataCloneError if SAB cannot be cloned (#781)
Best case, it produces serialized output that cannot be deserialized.

Worst case, it hits this assert in V8:

    # Fatal error in v8::FromJust
    # Maybe value is Nothing.
2021-09-18 15:21:04 +02:00
Andreu Botella
babe41a990
feat: Add v8::CompiledWasmModule (#776)
`v8::CompiledWasmModule` is a representation of a compiled WebAssembly
module, which can be shared by multiple `v8::WasmModuleObject`s.

Closes #759.
2021-09-17 12:02:40 -04:00
Aaron O'Mullan
8094d5d971
fix(json): relax lifetime for json_object (#778)
Amongst other things this will enable serde_v8 to print JSON object dumps
2021-09-13 23:34:17 +02:00
Rami Sabbagh
16708359bc
feat: Implement Isolate::remove_slot (#769) 2021-09-09 00:41:50 +02:00
Ben Noordhuis
cb07d4f914
feat: implement counter_lookup_callback (#756) 2021-08-19 14:05:48 +02:00
Ben Noordhuis
5a27cb7655
Upgrade V8 to 9.4.146.2 (#753) 2021-08-15 15:13:08 +02:00
PerfectLaugh
580a89cf10
Fix x86 build 2021-08-12 06:00:20 +02:00
Bartek Iwańczuk
c525555e42
feat: add V8InspectorSession::can_dispatch_method (#746) 2021-08-09 15:53:30 +02:00
Bartek Iwańczuk
45006fb7e7
Add Isolate::has_pending_background_tasks (#724) 2021-07-02 20:17:48 +02:00
Bert Belder
0bc6ea49f9
chore: clang-format (#719) 2021-07-01 19:03:21 +02:00
Tim Ramlot
14bcf04bef
Add support for Platform::pump_message_loop and Platform::run_idle_tasks (#706)
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2021-07-01 16:05:07 +02:00
Jomer
89c8ae8af3
feat: add various FunctionTemplate methods (#718)
This commit adds the following methods:
* `FunctionTemplate::inherit()`
* `FunctionTemplate::prototype_template()`
* `FunctionTemplate::read_only_prototype()`
* `FunctionTemplate::remove_prototype()`
2021-06-30 16:55:14 +02:00
Luca Casonato
cfa5d7060f
fix: pass serializer helpers as mut refs (#712)
They are only useful in read_host_object and write_host_object if
the helpers are available as a mut ref.
2021-06-24 15:59:03 +02:00
Andreu Botella
dfd5842913
Add missing methods for one- and two-byte strings (#704)
Fixes #703.
2021-06-22 14:11:38 +02:00
Yusuke Tanaka
f85508868e
chore: upgrade Rust to 1.53.0 (#705) 2021-06-18 11:35:53 -04:00
Ryan Dahl
fca78fb0c1
Rename set_common_data to set_common_data_69 (#702) 2021-06-18 06:55:38 -04:00
Ryan Dahl
3c22821499
CreateParams cleanup (#701) 2021-06-15 12:05:53 -04:00
Ryan Dahl
fe298359d9
Upgrade V8 to 9.2.230.10 (#700)
* We are floating a revert of v8/v8@7f9d7f0 because of the issue described in #694.
* Upgrade ICU 68 -> 69
* Upgrade //build and //buildtools
* set v8_enable_shared_ro_heap = false to fix tests
2021-06-15 11:12:23 -04:00
Matthew McAllister
6d25d19b4c
Add ObjectTemplate::set_accessor{_with_setter} (#687) 2021-05-11 16:40:53 +02:00
Nicholas Sielicki
4b7f57081a
Avoid warnings by adding explicit dyns in a few spots (#677) 2021-04-29 22:12:54 +02:00
Ben Noordhuis
92ea90bdbf
Add ScriptCompiler::compile_function_in_context() (#670) 2021-04-27 20:32:40 +02:00
Ben Noordhuis
efa6c71b10
Add Signature::new() (#666)
Refs #478.
2021-04-20 12:48:20 +02:00
Ben Noordhuis
84f1241b68
Fix bad assumption in static_assert (#668)
v8::Location is the size of two ints, not the size of one size_t.

`2 * sizeof(int) == sizeof(size_t)` on 64 bits architectures but not on
32 bits architectures.

Fixes #667.
2021-04-19 16:43:58 +02:00
Ben Noordhuis
03e74c6f1b
Add new_single_threaded_default_platform() (#659)
This is a v8::Platform implementation that doesn't spawn additional
threads. Useful in combination with the --single_threaded flag.
2021-04-12 21:40:52 +02:00
Bert Belder
de9a7e2698
String::new_external_onebyte_static() should take &[u8] instead of &str (#658) 2021-04-09 19:49:55 +02:00
Ryan Dahl
d520fe85bd
Add String::new_from_one_byte (#654) 2021-04-02 16:23:05 -04:00
Ben Noordhuis
3a5ce45245
Remove dead platform code (#653)
The Task struct and Platform::pump_message_loop() method were
non-functional, remove them.
2021-03-30 14:33:39 +02:00
Yusuke Tanaka
3c7ff01ad4
Upgrade Rust to 1.51.0 (#652) 2021-03-27 20:16:35 +01:00
Ben Noordhuis
7d514ae4cb
Add ArrayBuffer::detach() and is_detachable() (#648)
Fixes #646.
2021-03-16 23:35:27 +01:00
Aaron O'Mullan
f2766ed1af
Support for external v8 strings (#641) 2021-03-07 10:21:59 -05:00
Heyang Zhou
a6d36d1193
Add more ScriptCompiler APIs (#638) 2021-03-07 08:05:50 -05:00
Heyang Zhou
be89cfc131
Add code cache API (#635) 2021-03-05 05:26:37 -05:00
Ryan Dahl
83052c4535 Enter isolate on construction, exit on drop
Fixes #626
2021-02-20 09:41:26 -05:00
Bartek Iwańczuk
8551c62511
Add Module::source_offset_to_location, deprecate old APIs (#624) 2021-02-15 12:08:39 +01:00
Bartek Iwańczuk
ec54f28bfd
feat: Add ModuleRequest (#623) 2021-02-14 19:49:37 +01:00
Ryan Dahl
50a15085f7
update copyrights to 2021 (#620) 2021-02-13 07:31:18 -05:00
Ben Noordhuis
5dc6117dd7
Fix ValueDeserializer::read_value() lifetime (#609)
The return value should have the lifetime of the context, not the
deserializer.

Fixes #607.
2021-02-10 07:27:27 +01:00
Ben Noordhuis
9a8f6443fe
Fix doc comment in src/icu.rs (#608)
Rustdoc interprets code snippets as Rust unless told otherwise.
Tell it otherwise because this particular snippet is C++.
2021-02-09 23:12:42 +01:00
Bartek Iwańczuk
4ef7ab3fd6
docs: add info about settings --harmony-import-assertions flag (#606) 2021-02-09 23:03:25 +01:00
Ryan Dahl
d60489c395
Support ICU (#603)
Co-authored-by: Kunihiro Ishiguro <kunihiro@zebra.dev>
2021-02-09 09:17:02 -05:00
Ben Noordhuis
64aa11e34d
Add Isolate::set_prepare_stack_trace_callback() (#594)
Refs: https://github.com/denoland/deno/issues/7644
2021-02-08 13:11:48 +01:00
Ben Noordhuis
8809068f01
build: upgrade Rust to 1.49.0 (#601) 2021-02-07 23:49:07 +01:00
Bartek Iwańczuk
d6be279a06
Add support for import assertions (#598)
This commit adds support for import assertions.

Major changes include:
- removal of "ResolveCallback" (deprecated in V8) 
in favor of "ModuleResolveCallback"
- removal of "HostImportModuleDynamicallyCallback" (deprecated in V8)
in favor of "HostImportModuleDynamicallyWithImportAssertionsCallback"
2021-02-05 00:22:26 +01:00
Ben Noordhuis
30ad399f9b
Add V8InspectorClientImpl::generate_unique_id() (#590) 2021-01-21 10:06:34 +01:00
Ben Noordhuis
0d093a02f6
Upgrade V8 to 8.9.255.3 (#567)
This floats https://chromium-review.googlesource.com/c/v8/v8/+/2608209
because it just missed the merge window for 8.9.
2021-01-18 21:46:44 +01:00
Heyang Zhou
bcbe7e9348
Support setting OOM callback on Isolate (#585) 2021-01-16 10:30:38 +01:00
Heyang Zhou
3fd7cae994
Expose ArrayBuffer::Allocator interface (#578) 2021-01-14 23:29:06 +01:00
Ben Noordhuis
5cb14847aa
Expose v8::WriteOptions (#583)
Without it, v8::String::write_utf8() is pretty much unusable.
2021-01-13 00:49:59 +01:00
Heyang Zhou
584a037800
Add Script::get_unbound_script() and UnboundScript::bind_to_current_context() (#572) 2021-01-11 19:39:51 -08:00
Bert Belder
7a480fd563
Run clang-format (#582) 2021-01-11 19:38:20 -08:00
Daniel Bevenius
54a72d7628
Remove set_flags_from_command_line_with_usage test (#570)
This commit removes the set_flags_from_command_line_with_usage and puts
it in an example code section instead.

The motivation for doing this is that the test output currently contains
the usage string and all the V8 options which creates a lot of output
when the tests is run regardless if --nocapture is used or not.
2021-01-07 22:42:30 +01:00
Ben Noordhuis
ea412d0554
Add Isolate::set_wasm_streaming_callback() (#560)
Add the hook necessary to implement `WebAssembly.compileStreaming()`.

Fixes #556
2020-12-31 16:06:29 +01:00
Bartek Iwańczuk
41f29a19c4
Isolate::thread_safe_handle() no longer requires mutable reference (#562) 2020-12-30 23:30:30 -08:00
Bartek Iwańczuk
cf7bb2d001
Add methods for termination to Isolate (#561)
This commit adds following methods to Isolate:
- terminate_execution
- cancel_terminate_execution
- is_execution_terminating
2020-12-25 22:45:57 +01:00
Daniel Bevenius
756388c140
typo (#554) 2020-12-10 06:47:32 -05:00
Ben Noordhuis
f37601cab2
Add FunctionBuilder (#512)
v8::Function and v8::FunctionTemplate have a lot of options that can be
configured. The builder() associated functions on those types help with
that.
2020-12-07 17:03:46 -05:00
Ben Noordhuis
530c876aff
Make Private work with context-less HandleScope (#549)
v8::Private is like v8::String and other primitives, it doesn't need an
active v8::Context.
2020-12-07 16:48:51 -05:00
Daniel Bevenius
4e8eaf94c3
Add set_flags_from_command_line_with_usage (#536)
The motivation for this is to enable embedders of rusty_v8 to
pass their own usage string and have their usage printed before V8's
options.
2020-12-07 16:46:38 -05:00
Daniel Bevenius
98bb4506d9
typo (#540) 2020-12-07 16:42:37 -05:00
Ben Noordhuis
343d7f2800
Make Symbol work with context-less HandleScope (#550)
v8::Symbol is like v8::String and other primitives, it doesn't need an
active v8::Context.
2020-12-04 13:56:55 +01:00
Ben Noordhuis
c1509cac08
Make PromiseHookType Clone, Copy and PartialEq (#548) 2020-12-04 13:56:27 +01:00
Bert Belder
73d4bfebc5
Improve consistency of some c++ function signatures (#541) 2020-11-20 23:34:13 +01:00
Daniel Bevenius
eb0222ce08
docs: Fix typo in scope module comment (#538) 2020-11-19 19:20:31 +01:00
Ben Noordhuis
64faf683d2
Add Value::to_rust_string_lossy() (#530)
If it's convenient to have on String objects, then it's convenient to
have on all Value instances.
2020-11-19 11:58:23 +01:00
Moritz Gunz
efe0e76a75
#[derive(Debug)] all the things (#468)
This commit implements Debug trait for most public structs.
2020-11-18 15:17:25 +01:00
Ben Noordhuis
0915d14efd
Revert "Fix rustdoc warnings (#526)" (#528)
This reverts commit 58ca728c5f.

The commit passed CI but it's causing `cargo test` to fail locally for
me. This is with rustc 1.47.0.
2020-11-17 00:23:32 +01:00
Daniel Bevenius
58ca728c5f
Fix rustdoc warnings (#526)
This commit attempts to fix the reported warnings that are generated by
rustdoc.
2020-11-15 17:57:06 +01:00
Ben Noordhuis
3fa9fb36ed
Fix runtime assert when hashing module object (#522)
The blanket `std:#️⃣:Hash` impl for instances of `v8::Data` invokes
`v8::internal::Object::GetHash()` but that crashes for `v8::Module`
objects. Use a custom impl that calls `v8::Module::get_identity_hash()`.

Fixes the following runtime assertion:

    # Fatal error in ../../../v8/src/objects/objects-inl.h, line 1043
    # Debug check failed: object.IsJSReceiver().

Refs: https://github.com/denoland/deno/pull/8354#discussion_r522157813
2020-11-15 00:07:52 +01:00
Daniel Bevenius
0e54213cc8
Remove mut from Example in lib.rs (#523)
This commit removes mut from the script variable to avoid the following
warning if used:

25 |   let mut script = v8::Script::compile(scope, code, None).unwrap();
   |       ----^^^^^^
   |       |
   |       help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 1 warning emitted
2020-11-13 21:55:52 +01:00
Daniel Bevenius
0f772d7a31
Fix typo in ReturnValue struct comment (#521) 2020-11-13 14:41:15 +01:00
Ben Noordhuis
315e9a83e0
Simplify Function::new_with_data() (#510)
It's not necessary to have a separate C++ glue function, it can be
shared with Function::new().
2020-10-27 15:15:00 +01:00
l3ops
fb049cb934
Add Function::new_instance (#508) 2020-10-26 08:57:14 +01:00
Ben Noordhuis
b8a2e06dc8
Add Isolate::clear_kept_objects() (#507)
Refs: https://github.com/denoland/deno/issues/7674
2020-10-21 08:00:44 +02:00
Ben Noordhuis
1988c98f3c
Add Isolate::set_allow_atomics_wait() (#500) 2020-10-15 22:12:44 +02:00
Ben Noordhuis
1c38b66093
Add Object::get_private() and friends (#498) 2020-10-15 14:37:29 +02:00
Ben Noordhuis
836557e84f
Add Module::script_id() (#497) 2020-10-15 11:05:38 +02:00
Ben Noordhuis
57390ec4ee
Add Isolate::set_promise_hook() (#496) 2020-10-12 22:33:46 +02:00
Ben Noordhuis
ea0c7c9383
Fix PromiseRejectMessage::get_value() (#493)
Change its return type to `Option<Local<Value>>`. The C++ API
returns `Local<Value>` but that can be an empty handle.

Fixes #491
2020-10-09 12:58:57 +02:00
devsnek
4f924a686a
add all TypedArray constructors (#482) 2020-10-06 14:16:22 -04:00
Inteon
dbc0509f2a
add basic serializer bindings (#442) 2020-10-06 18:39:38 +02:00
devsnek
e5f56e218c
add Symbol, Private, BigInt (#466) 2020-09-29 20:20:07 -04:00
Ben Noordhuis
6b90cbe499
add Object + ObjectTemplate internal field support (#477)
The rusty_v8 API deviates slightly from the V8 C++ API because the
latter is definitely unsound when you pass in out-of-range indexes.
2020-09-29 19:04:59 -04:00
devsnek
405a5a5158
Add APIs to store/retrieve embedder data in a Context or Isolate snapshot (#449)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-09-10 02:39:49 +02:00
Bert Belder
b3f9cb1f01
Work around a bug in the V8 headers (#463) 2020-09-09 12:07:11 +02:00
Gus Caplan
3b27748a17
Implement TryFrom<Data> for subclasses of Data (#453) 2020-09-09 02:21:58 +02:00
Ben Noordhuis
d60e367a9b
Add V8::set_entropy_source() (#460) 2020-09-08 03:01:36 +02:00
Bert Belder
b31dbc89dc
Simplify 'Isolate::get/set_slot()' and use optimized hasher (#461) 2020-09-07 19:50:36 +02:00
Moritz Gunz
8513c8fa69
Add bindings to 'v8::Isolate::LowMemoryNotification()' (#459) 2020-09-07 13:00:35 +02:00
Ben Noordhuis
de58267948
Add V8::set_flags_from_string() (#457) 2020-09-06 15:40:07 -04:00
Bert Belder
21f6ecf483
Fix flaky tests caused by relaxed load in C++ 'shared_ptr::use_count()' (#450)
Fixes: #284
2020-09-02 17:38:39 +02:00
Bert Belder
d91970dcf6
Fix minor SharedPtr/SharedRef issues, and add unit tests (#450)
* The `Default` trait did not actually get derived for `SharedPtr<T>`.
  This is solved by implementing `Default` manually.
* Trait function `Shared::get()` used to return a mutable raw pointer
  (`*mut Self`), but it would be inconceivable to ever mutate the
  referenced value. It was changed to return a const pointer instead.
* Added some basic unit tests for types `SharedPtr` and `SharedRef`.
2020-09-02 17:25:21 +02:00
Ben Noordhuis
b88f9f5bbc
Add Date::new() and Date::value_of() (#452) 2020-09-01 22:28:08 -04:00
Bert Belder
d90742277d
Format source code and fix clippy warning (#443) 2020-08-27 20:46:25 +02:00
devsnek
6d5686cd7c
Add synthetic module support (#441) 2020-08-25 17:39:18 -04:00
Ben Noordhuis
6b2c7a56a7
Add Isolate::[gs]et_microtasks_policy() (#439)
Isolate::run_microtasks() already exists but the microtasks queue
is also flushed on script entry and exit. Some embedders want strict
control over when microtasks run, which is set by the policy.

And deprecate Isolate::run_microtasks(). The corresponding V8 API is
tagged with V8_DEPRECATE_SOON.
2020-08-23 10:25:16 -04:00
Ben Noordhuis
fd5458c959
Add Isolate::get_heap_statistics() (#440) 2020-08-23 10:16:45 -04:00
Bert Belder
d84be8ca2a
SnapshotCreator::GetIsolate() should have been a const method (#432) 2020-08-07 18:35:51 +02:00
Marcus Weiner
b0dc42f900
Add support for setting V8 heap limits and using a near-heap-limit callback (#427) 2020-07-30 18:40:18 +02:00
Bert Belder
da0c5f76e4
Add 'CallbackScope<()>' that doesn't assume an entered Context (#425)
Certain callbacks (e.g. `WasmLoadSourceMapCallback`) expect the
embedder to return a local handle (a `Local<String>` in this case), but
do not provide a `Local<Context>` as an argument, nor does it provide
any other argument that we might obtain a context from. This is not
unexpected - WASM execution as such is not tied to a context, and a
`Local<String>` can be created without a context too because it's a
primitive value that has no JavaScript prototype.
2020-07-19 11:02:23 +02:00
Ben Sheffield
e74b6bcd0d
Add 'Object::set_accessor_with_setter' (#422) 2020-07-17 11:17:29 -04:00
Bert Belder
9684640b48
Implement the 'Hash' trait for local and global handles (#415) 2020-07-08 10:27:34 +02:00
Bert Belder
2b11a57d47
Refactor 'v8__internal__GetIsolateFromHeapObject' (#415)
It turns out that using `v8::internal::MaybeObject` was, although
harmless, not appropriate here, because this function does not deal
deal with (potentially) weak handles.
2020-07-08 09:41:37 +02:00
Bert Belder
82d0287028
'External' handles can be created without entering a Context (#416) 2020-07-05 01:36:51 +02:00
Bert Belder
91c8c7d1c7
Implement 'Eq' for all subtypes of 'Value' and its handles (#414) 2020-07-04 07:11:56 +02:00
Bert Belder
d3f6e4d36c
Add 'Value::same_value_zero()' (#414) 2020-07-04 07:11:04 +02:00
Skyler Lipthay
1b84bc74f6
Add 'Value::boolean_value()' and 'Value::to_boolean()' (#412) 2020-07-03 14:42:19 +02:00
Skyler Lipthay
8ebfb027c0
Add 'Object::has(_index)' and 'Object::delete(_index)' (#412) 2020-07-03 14:41:40 +02:00
Bert Belder
b981aaceee
Add 'External::new()' and 'External::value()' (#413) 2020-07-03 14:01:42 +02:00
Bert Belder
acf6bfe0e4
Add the 'HandleScope::with_context()' scope constructor (#410) 2020-07-01 10:44:23 +02:00
Bert Belder
c13625148f
Refactor handle types 'Local' and 'Global' (#410)
* Merged all handle type implementations into one file ('handle.h').
* Made it so that `Global` handles cannot be empty.
* Renamed the `AsHandle` trait to `Handle`, and made it more generally
  useful.
* Simplified how `PartialEq` is implemented for V8 heap objects and/or
  the `Local`/`Global` handles that reference them.
2020-07-01 10:44:23 +02:00