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

305 commits

Author SHA1 Message Date
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
8b36e84060
test: make the 'heap_limits' test run a lot faster (#972) 2022-05-18 12:06:12 +02:00
Bert Belder
2f189e1668
Upgrade V8 to 10.3.174.3 (#969) 2022-05-18 10:53:34 +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
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
Ben Noordhuis
8e9fd60e79
Fix unused import warning (#875) 2022-01-22 04:10:38 +01:00
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
b6a16916ce
test: don't use --harmony-top-level-await flag (#854)
Top level await is now enabled by default and the flag no longer exists.
2021-12-12 21:25:01 -08:00
Sujay Jayakar
62d33c4d7e
Add Function::GetScript{Line,Column}Number bindings (#843) 2021-11-30 21:55:41 +01:00
Bert Belder
c4c48f30b1
v8: fix segfault during concurrent isolate creation/disposal on Windows (#829)
This patch includes a test for this issue.

The V8 patch is intentionally left simple to avoid merge conflicts in
the future. To be landed upstream, the `unwindinfo_use_count_` would
probably have to be made non-atomic and we'd have to add a cctest.

Upstream bug: https://bugs.chromium.org/p/v8/issues/detail?id=12393

Fixes: #714
2021-11-17 09:52:27 -08: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
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