summaryrefslogtreecommitdiff
path: root/core/runtime.rs
AgeCommit message (Collapse)Author
2022-01-24refactor(core): Extract JsRuntime::poll_value out of ↵Rafael Ávila de Espíndola
JsRuntime::resolve_value (#13461)
2022-01-07chore: update copyright to 2022 (#13306)Ryan Dahl
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2021-12-30chore(core): remove stale TODOs (#13232)Bartek Iwańczuk
2021-12-29cleanup(core): use Extensions to register ops (#13224)Aaron O'Mullan
In examples and tests
2021-12-15feat: Add support for import assertions and JSON modules (#12866)Bartek Iwańczuk
This commit adds proper support for import assertions and JSON modules. Implementation of "core/modules.rs" was changed to account for multiple possible module types, instead of always assuming that the code is an "ES module". In effect "ModuleMap" now has knowledge about each modules' type (stored via "ModuleType" enum). Module loading pipeline now stores information about expected module type for each request and validates that expected type matches discovered module type based on file's "MediaType". Relevant tests were added to "core/modules.rs" and integration tests, additionally multiple WPT tests were enabled. There are still some rough edges in the implementation and not all WPT were enabled, due to: a) unclear BOM handling in source code by "FileFetcher" b) design limitation of Deno's "FileFetcher" that doesn't download the same module multiple times in a single run Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2021-12-04chore: upgrade to Rust 1.57.0 (#12968)Bartek Iwańczuk
2021-12-01chore: Fix typo in no-pending-ops error message (#12948)KnorpelSenf
2021-11-30fix(core): Wake up the runtime if there are ticks scheduled (#12933)Andreu Botella
2021-11-28feat(core): intercept unhandled promise rejections (#12910)Ben Noordhuis
Provide a programmatic means of intercepting rejected promises without a .catch() handler. Needed for Node compat mode. Also do a first pass at uncaughtException support because they're closely intertwined in Node. It's like that Frank Sinatra song: you can't have one without the other. Stepping stone for #7013.
2021-11-25feat(core): Add ability to "ref" and "unref" pending ops (#12889)Bartek Iwańczuk
This commit adds an ability to "ref" or "unref" pending ops. Up to this point Deno had a notion of "async ops" and "unref async ops"; the former keep event loop alive, while the latter do not block event loop from finishing. It was not possible to change between op types after dispatching, one had to decide which type to use before dispatch. Instead of storing ops in two separate "FuturesUnordered" collections, now ops are stored in a single collection, with supplemental "HashSet" storing ids of promises that were "unrefed". Two APIs were added to "Deno.core": "Deno.core.refOp(promiseId)" which allows to mark promise id to be "refed" and keep event loop alive (the default behavior) "Deno.core.unrefOp(promiseId)" which allows to mark promise id as "unrefed" which won't block event loop from exiting
2021-11-22fix(core): don't panic when evaluating module after termination (#12833)Bartek Iwańczuk
2021-11-19fix(core): keep event loop alive if there are ticks scheduled (#12814)Ben Noordhuis
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-11-16feat(core): Deno.core.setNextTickCallback (#12771)Bartek Iwańczuk
This commit adds several new "Deno.core" bindings: * "setNextTickCallback" * "hasScheduledTick" * "setHasScheduledTick" * "runMicrotasks" Additionally it changes "Deno.core.setMacrotaskCallback" to allow registering multiple callbacks. All these changes were necessary to polyfill "process.nextTick" in Node compat layer. Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
2021-11-16refactor: re-export anyhow from deno_core (#12777)Ryan Dahl
2021-11-03fix: Deno.emit crashes with BorrowMutError (#12627)Ryan Dahl
Warn on await_holding_refcell_ref clippy rule to avoid this in the future. Fixes #12453
2021-11-02chore: update to Rust edition 2021 (#12578)Bartek Iwańczuk
2021-10-27chore: update to rusty_v8 0.33.0 (#12564)Luca Casonato
2021-10-24cleanup(core): AsyncOpIterator (#11860)Aaron O'Mullan
2021-10-24fix(core): avoid op_state.borrow_mut() for OpsTracker (#12525)Aaron O'Mullan
By allowing interior mutability in OpsTracker (owning a RefCell<Vec> instead of just a Vec) Fixes #12453
2021-10-17fix(core): poll async ops eagerly (#12385)Bert Belder
Currently all async ops are polled lazily, which means that op initialization code is postponed until control is yielded to the event loop. This has some weird consequences, e.g. ```js let listener = Deno.listen(...); let conn_promise = listener.accept(); listener.close(); // `BadResource` is thrown. A reasonable error would be `Interrupted`. let conn = await conn_promise; ``` JavaScript promises are expected to be eagerly evaluated. This patch makes ops actually do that.
2021-10-10refactor(metrics): move to core (#12386)Aaron O'Mullan
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
2021-10-05feat(core): native binding names (#12290)Aaron O'Mullan
Makes native builtin functions easier to recognize when debugging/profiling, they would otherwise appear as "(anonymous)" functions
2021-10-05chore: various op cleanup (#12329)Leo K
2021-10-04refactor(core): split opcall into sync/async (#12312)Aaron O'Mullan
2021-10-04fix(core/runtime): sync_ops_cache if nuked Deno ns (#12302)Aaron O'Mullan
Decouple JsRuntime::sync_ops_cache() from the availability of the Deno.* namespace in the global scope This avoids crashes when calling sync_ops_cache() on a bootstrapped WebWorker who has dropped its Deno.* namespace It's also just cleaner and more robust ...
2021-10-03perf(core): use opcall() directly (#12310)Aaron O'Mullan
Instead of the wrapper dispatch() func, also now forbids passing opIds to opSync()/opAsync() callers must always pass names
2021-10-01feat(core): implement Deno.core.isProxy() (#12288)Aaron O'Mullan
2021-09-30fix: Don't panic when a worker is closed in the reactions to a wasm ↵Andreu Botella
operation. (#12270)
2021-09-29feat: support serializing `WebAssembly.Module` objects (#12140)Andreu Botella
2021-09-25refactor: Remove unused code (#12210)Ryan Dahl
2021-09-24refactor: Remove op_state parameter (#12202)Ryan Dahl
2021-09-18fix(core): prevent multiple main module loading (#12128)Bartek Iwańczuk
This commit fixes a problem where loading and executing multiple modules leads to all of the having "import.meta.main" set to true. Following Rust APIs were deprecated: - deno_core::JsRuntime::load_module - deno_runtime::Worker::execute_module - deno_runtime::WebWorker::execute_module Following Rust APIs were added: - deno_core::JsRuntime::load_main_module - deno_core::JsRuntime::load_side_module - deno_runtime::Worker::execute_main_module - deno_runtime::Worker::execute_side_module - deno_runtime::WebWorker::execute_main_module Trying to load multiple "main" modules into the runtime now results in an error. If user needs to load additional "non-main" modules they should use APIs for "side" module.
2021-09-04feat(cli): close test worker once all tests complete (#11727)Casper Beyer
2021-08-19cleanup(core): rename handleAsyncMsgFromRust() to opresolve() (#11774)Aaron O'Mullan
No user impact, but is simpler and aligns with `opcall()`
2021-07-30chore(core): use oneshot channel in mod_evaluate() (#11556)Ben Noordhuis
Oneshot is more appropriate because mod_evaluate() only sends a single value. It also makes it easier to use it correctly. As an embedder, I wasn't sure if I'm expected to drain the channel or not.
2021-07-08feat(core): return v8::Value from JsRuntime::execute_script (#11129)Bartek Iwańczuk
This commit changes return type of JsRuntime::execute_script to include v8::Value returned from evaluation. When embedding deno_core it is sometimes useful to be able to inspect script evaluation value without the hoops of adding ops to store the value on the OpState. v8::Global<v8::Value> is used so consumers don't have to pass scope themselves.
2021-07-06feat: support SharedArrayBuffer sharing between workers (#11040)Luca Casonato
This commit adds support for sharing SABs between workers.
2021-07-05fix(core): Delay deadlock detection for dynamic imports (#11282)Nayeem Rahman
2021-07-03feat: enable WebAssembly.instantiateStreaming and wasm async compilation ↵Andreu Botella
(#11200) The WebAssembly streaming APIs used to be enabled, but used to take buffer sources as their first argument (see #6154 and #7259). This change re-enables them, requiring a Promise<Response> instead, as well as enabling asynchronous compilation of WebAssembly modules.
2021-07-02refactor: introduce primordials (#10939)Luca Casonato
This commit introduces primordials to deno_core. Primordials are a frozen set of all intrinsic objects in the runtime. They are not vulnerable to prototype pollution.
2021-07-02feat(core): pump V8 message loop on event loop tick (#11221)Bartek Iwańczuk
This commit adds support for Atomics and FinalizationRegistry by integrating V8's message loop into "JsRuntime::poll_event_loop".
2021-07-02chore: upgrade rusty_v8 and serde_v8 (#11216)Bartek Iwańczuk
2021-06-29fix(core/modules): Fix concurrent loading of dynamic imports (#11089)Nayeem Rahman
This commit changes implementation of module loading in "deno_core" to track all currently fetched modules across all existing module loads. In effect a bug that caused concurrent dynamic imports referencing the same module to fail is fixed.
2021-06-25upgrade: rusty_v8 0.23.0 (V8 9.2.230.12) (#11113)Ryan Dahl
2021-06-22cleanup(core): top-level-await is now always enabled (#11082)Maxime Guerreiro
Starting with V8 9.1, top-level-await is always enabled by default. See https://v8.dev/blog/v8-release-91 for the release notes. - Remove the now redundant v8 flag. - Clarify doc comment and add link to the feature explainer.
2021-06-22refactor: unify JavaScript script execution method (#11043)Bartek Iwańczuk
This commit renames "JsRuntime::execute" to "JsRuntime::execute_script". Additionally same renames were applied to methods on "deno_runtime::Worker" and "deno_runtime::WebWorker". A new macro was added to "deno_core" called "located_script_name" which returns the name of Rust file alongside line no and col no of that call site. This macro is useful in combination with "JsRuntime::execute_script" and allows to provide accurate place where "one-off" JavaScript scripts are executed for internal runtime functions. Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2021-06-21refactor(core): always attach inspector to isolate (#11042)Bartek Iwańczuk
This commit changes "deno_core::JsRuntime" to always create "deno_core::JsRuntimeInspector" instance.
2021-06-19fix(core/modules): Prepare modules only once per runtime (#11015)Nayeem Rahman
This commit changes module loading implementation in "deno_core" to call "ModuleLoader::prepare" hook only once per entry point. This is done to avoid multiple type checking of the same code in case of duplicated dynamic imports. Relevant code in "cli/module_graph.rs" was updated as well.
2021-05-29core: don't include_str extension js code (#10786)Luca Casonato
This speeds up incremental rebuild when only touching JS files by 13-15% Rebuild time after `touch 01_broadcast_channel.js`: main: run 1 49.18s, run 2 50.34s this: run 1 43.12s, run 2 43.19s
2021-05-26refactor: move JsRuntimeInspector to deno_core (#10763)Bartek Iwańczuk
This commit moves implementation of "JsRuntimeInspector" to "deno_core" crate. To achieve that following changes were made: * "Worker" and "WebWorker" no longer own instance of "JsRuntimeInspector", instead it is now owned by "deno_core::JsRuntime". * Consequently polling of inspector is no longer done in "Worker"/"WebWorker", instead it's done in "deno_core::JsRuntime::poll_event_loop". * "deno_core::JsRuntime::poll_event_loop" and "deno_core::JsRuntime::run_event_loop", now accept "wait_for_inspector" boolean that tells if event loop should still be "pending" if there are active inspector sessions - this change fixes the problem that inspector disconnects from the frontend and process exits once the code has stopped executing.