summaryrefslogtreecommitdiff
path: root/core/runtime.rs
AgeCommit message (Collapse)Author
2022-12-20fix(core): Have custom errors be created in the right realm (#17050)Andreu Botella
Although PR #16366 did not fully revert `deno_core`'s support for realms, since `JsRealm` still existed after that, it did remove the `ContextState` struct, originally introduced in #14734. This change made `js_build_custom_error_cb`, among other properties, a per-runtime callback, rather than per-realm, which cause a bug where errors thrown from an op would always be constructed in the main realm, rather than in the current one. This change adds back `ContextState` to fix this bug, adds back the `known_realms` field of `JsRuntimeState` (needed to be able to drop the callback when snapshotting), and also relands #14750, which adds the `js_realm_sync_ops` test for this bug that was removed in #16366.
2022-12-19fix(runtime): expose `extensions_with_js` from WorkerOptions (#17109)Leo Kettmeir
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-12-17chore: update to Rust 1.66.0 (#17078)linbingquan
2022-12-17chore(core): Small realm-related fixes (#17044)Andreu Botella
- `JsRuntime::built_from_snapshot` was removed because it was redundant with `JsRuntime::snapshot_options`. - Updates to stale documentation of `JsRuntime::create_realm`. - `JsRuntime::create_realm` now calls `JsRuntime::init_extension_js` unconditionally, since if the runtime was built from a snapshot, `init_extension_js` will be a no-op. - Typo fix in the documentation for `JsRealm`.
2022-12-13chore(core): Deduplicate `event_loop_pending_state` (#17039)Andreu Botella
2022-11-30chore: remove unnecessary lifetimes (#16878)David Sherret
It seems we don't really need to allow these clippy rules.
2022-11-28feat(core): show unresolved promise origin (#16650)Bartek Iwańczuk
This commit updates unhelpful messages that are raised when event loop stalls on unresolved top-level promises. Instead of "Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promises." and "Dynamically imported module evaluation is still pending but there are no pending ops. This situation is often caused by unresolved promises." we are now printing a message like: error: Top-level await promise never resolved [SOURCE LINE] ^ at [FUNCTION NAME] ([FILENAME]) eg: error: Top-level await promise never resolved await new Promise((_resolve, _reject) => {}); ^ at <anonymous> (file:///Users/ib/dev/deno/cli/tests/testdata/test/unresolved_promise.ts:1:1) Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2022-11-27feat(core): support initializing extensions with and without JS (#16789)Bartek Iwańczuk
This commit allows to execute more JS code from extensions when creating a snapshot from an existing snapshot. "deno_core::RuntimeOptions::extensions_with_js" field was added that is used to pass a list of extensions whose both "ops" and associated JS source should be executed upon start. Co-authored-by: crowlkats <crowlkats@toaxl.com>
2022-11-27feat(core): send "executionContextDestroyed" notification on program end ↵Bartek Iwańczuk
(#16831) This commit changes "JsRuntime" to send "executionContextDestroyed" notification when the program finishes and shows a prompt informing that runtime is waiting for inspector to disconnect.
2022-11-26fix(inspector): send "isDefault" in aux data (#16836)Bartek Iwańczuk
With trial and error I found that most debuggers expect "isDefault" to be sent in "auxData" field of "executionContextCreated" notification. This stems from the fact that Node.js sends this data and eg. VSCode requires it to close connection to the debugger when the program finishes execution.
2022-11-18chore: use Rust 1.65.0 (#16688)Aaron O'Mullan
2022-11-12chore: upgrade rusty_v8 to 0.55.0 (#16604)Bartek Iwańczuk
<!-- Before submitting a PR, please read http://deno.land/manual/contributing 1. Give the PR a descriptive title. Examples of good title: - fix(std/http): Fix race condition in server - docs(console): Update docstrings - feat(doc): Handle nested reexports Examples of bad title: - fix #7123 - update docs - fix bugs 2. Ensure there is a related issue and it is referenced in the PR text. 3. Ensure there are tests that cover the changes. 4. Ensure `cargo test` passes. 5. Ensure `./tools/format.js` passes without changing files. 6. Ensure `./tools/lint.js` passes. -->
2022-11-11feat(ops): implement fast lazy async ops (#16579)Divy Srivastava
Implements fast scheduling of deferred op futures. ```rs #[op(fast)] async fn op_read( state: Rc<RefCell<OpState>>, rid: ResourceId, buf: &mut [u8], ) -> Result<u32, Error> { // ... } ``` The future is scheduled via a fast API call and polled by the event loop after being woken up by its waker.
2022-11-10perf(core): minimize trivial heap allocations in `resolve_async_ops` (#16584)Divy Srivastava
* Use stack allocated array for 16 promises and spill rest to heap. the exact number can change, maybe 128? (tokio's coop budget limit) * Avoid v8::Global::clone for global context. * Do not open global opresolve when its not needed.
2022-11-08refactor: simplify deno_core's grab_global and ensure_objs (#16564)Ryan Dahl
- refactor: remove JsRuntime::ensure_objs - refactor: Replace JsRuntime::grab_global with JsRuntime::eval
2022-10-28feat(core): support creating snapshots from existing snapshots (#14744)Bartek Iwańczuk
2022-10-28Reland "perf(core): generate inlined wrappers for async ops" (#16455)Divy Srivastava
Reland https://github.com/denoland/deno/pull/16428
2022-10-27Revert "perf(core): generate inlined wrappers for async ops (#16428)" (#16443)Divy Srivastava
2022-10-27perf(core): generate inlined wrappers for async ops (#16428)Divy Srivastava
V8's JIT can do a better job knowing the argument count and also enable fast call path (in future). This also lets us call async ops without `opAsync`: ```js const { ops } = Deno.core; await ops.op_void_async(); ``` this patch: 4405286 ops/sec main: 3508771 ops/sec
2022-10-26fix(core) Include causes when converting anyhow errors to JS exceptions (#16397)Jan Špaček
When an op returns an `anyhow` error with a cause (usually added using the `.context()` method), the `Error` thrown into JavaScript contains only the message of the outernmost error in the chain. This PR simply changes the formatting of `anyhow::Error` from `"{}"` to `"{:#}"`: This significantly improves errors for code that embeds Deno and defines custom ops. For example, in [chiselstrike/chiselstrike](https://github.com/chiselstrike/chiselstrike), this PR improves an error message like ``` Error: could not plan migration ``` to ``` Error: could not plan migration: could not migrate table for entity "E": could not add column for field "title": the field does not have a default value ```
2022-10-26core: enable --harmony-change-array-by-copy V8 flag (#16429)Bartek Iwańczuk
Enables [Change Array by copy proposal](https://github.com/tc39/proposal-change-array-by-copy) via a V8 flag.
2022-10-26perf(core): do not drive JsInspector by default (#16410)Divy Srivastava
Part of https://github.com/denoland/deno/pull/16377
2022-10-25perf(core): avoid isolate slots for ModuleMap (#16409)Divy Srivastava
2022-10-21perf(core): don't access isolate slots for JsRuntimeState (#16376)Divy Srivastava
example writeFile benchmark: ``` # before time 188 ms rate 53191 time 168 ms rate 59523 time 167 ms rate 59880 time 166 ms rate 60240 time 168 ms rate 59523 time 173 ms rate 57803 time 183 ms rate 54644 # after time 157 ms rate 63694 time 152 ms rate 65789 time 151 ms rate 66225 time 151 ms rate 66225 time 152 ms rate 65789 ```
2022-10-21Revert realms from deno_core (#16366)Divy Srivastava
This revert has been discussed at length out-of-band (including with @andreubotella). The realms work in impeding ongoing event loop and performance work. We very much want to land realms but it needs to wait until these lower-level refactors are complete. We hope to bring realms back in a couple weeks.
2022-10-15fix(docs): Documentation improvements related to `JsRealm`. (#16247)Andreu Botella
2022-10-15refactor(core): use isolate get_data/set_data instead of slots (#16286)Bartek Iwańczuk
2022-10-15chore: upgrade rusty_v8 to 0.53.0 (#16272)Bartek Iwańczuk
2022-10-07feat(core): Reorder extension initialization (#16136)Jakub Łabor
2022-10-05feat(npm): implement Node API (#13633)Divy Srivastava
This PR implements the NAPI for loading native modules into Deno. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: DjDeveloper <43033058+DjDeveloperr@users.noreply.github.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2022-10-02fix(serde_v8): serialize objects with numeric keys correctly (#15946)Darshan Sen
Signed-off-by: Darshan Sen <raisinten@gmail.com>
2022-09-17chore: upgrade rusty_v8 to v0.50.0 (#15762)Darshan Sen
Signed-off-by: Darshan Sen <raisinten@gmail.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-06perf(runtime): short-circuit `queue_async_op` for Poll::Ready (#15773)Divy Srivastava
2022-09-06fix(core): Register external references for imports to the SnapshotCreator ↵Giovanny Gutiérrez
(#15621) Several functions used for handling of dynamic imports and "import.meta" object were not registered as external references and caused V8 to crash during snapshotting. These functions are now registered as external refs and aborts are no longer happening.
2022-09-06fix(watch): ignore unload errors on drop (#15782)Nayeem Rahman
2022-09-02refactor(test): grab runTests() and runBenchmarks() from __bootstrap (#15420)Nayeem Rahman
2022-09-02fix(repl): don't terminate on unhandled error events (#15548)Nayeem Rahman
2022-09-01refactor(core): Move optional callbacks from `JsRuntimeState` to ↵Andreu Botella
`ContextState` (#15599) The `JsRuntimeState` struct stores a number of JS callbacks that are used either in the event loop or when interacting with V8. Some of these callback fields are vectors of callbacks, and therefore could plausibly store at least one callback per realm. However, some of those fields are `Option<v8::Global<v8::Function>>`, which would make the callbacks set by a realm override the one that might have been set by a different realm. As it turns out, all of the current such optional callbacks (`js_promise_reject_cb`, `js_format_exception_cb` and `js_wasm_streaming_cb`) are only used from inside a realm, and therefore this change makes it so such callbacks can only be set from inside a realm, and will only affect that realm.
2022-09-01fix(serde_v8): no panic on reading large text file (#15494)Geert-Jan Zwiers
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2022-09-01chore(serde_v8): take mutable reference in `ToV8::to_v8` (#15707)Divy Srivastava
2022-08-30perf: use fast api for `core.isProxy` (#15682)Divy Srivastava
2022-08-23chore: upgrade rusty_v8 to v0.49.0 (#15547)Bartek Iwańczuk
2022-08-23refactor(core/runtime): clean up extra type cast (#15539)Geert-Jan Zwiers
2022-08-21fix: Free up JsRuntime state global handles before snapshot (#15491)Giovanny Gutiérrez
2022-08-21feat(ops): V8 Fast Calls (#15291)Divy Srivastava
2022-08-21fix(core/runtime): always cancel termination in exception handling (#15514)Nayeem Rahman
2022-08-18feat(ext/flash): An optimized http/1.1 server (#15405)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl> Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2022-08-15chore: upgrade rusty_v8 to 0.48.1 (#15310)Bartek Iwańczuk
2022-08-11perf(ops): Monomorphic sync op calls (#15337)Aapo Alasuutari
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params). Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple: ``` opSync("op_foo", param1, param2); // -> turns to ops.op_foo(param1, param2); ``` This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path. Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
2022-08-11refactor(core): unwrap sync ops in rust (#15449)Nayeem Rahman