summaryrefslogtreecommitdiff
path: root/core/runtime.rs
AgeCommit message (Collapse)Author
2022-08-10feat(core): Add support for async ops in realms (#14734)Andreu Botella
Pull request #14019 enabled initial support for realms, but it did not include support for async ops anywhere other than the main realm. The main issue was that the `js_recv_cb` callback, which resolves promises corresponding to async ops, was only set for the main realm, so async ops in other realms would never resolve. Furthermore, promise ID's are specific to each realm, which meant that async ops from other realms would result in a wrong promise from the main realm being resolved. This change creates a `ContextState` struct, similar to `JsRuntimeState` but stored in a slot of each `v8::Context`, which contains a `js_recv_cb` callback for each realm. Combined with a new list of known realms, which stores them as `v8::Weak<v8::Context>`, and a change in the `#[op]` macro to pass the current context to `queue_async_op`, this makes it possible to send the results of promises for different realms to their realm, and prevent the ID's from getting mixed up. Additionally, since promise ID's are no longer unique to the isolate, having a single set of unrefed ops doesn't work. This change therefore also moves `unrefed_ops` from `JsRuntimeState` to `ContextState`, and adds the lengths of the unrefed op sets for all known realms to get the total number of unrefed ops to compare in the event loop. Co-authored-by: Luis Malheiro <luismalheiro@gmail.com>
2022-07-25refactor(core): remove unneeded ops for uncaughtException (#15296)Bartek Iwańczuk
2022-07-23fix: unhandledrejection handling for sync throw in top level (#15279)Bartek Iwańczuk
Fixes an edge in "unhandledrejection" event that prevent synchronous errors being surfaced when throw from a top-level scope.
2022-07-22Revert "feat(ops): V8 Fast Calls (#15122)" (#15276)Divy Srivastava
This reverts commit 03dc3b8972f460e40d0b75fc3207cae9fe4f60da.
2022-07-22feat(ops): V8 Fast Calls (#15122)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-07-18reland: "fix(core): unhandled rejection in top-level scope" (#15236)Bartek Iwańczuk
Reland #15204
2022-07-18Revert "fix(core): unhandled rejection in top-level scope (#15204)" (#15226)Bartek Iwańczuk
This reverts commit 48a7312f3871e3b76c51eb0143ca1c48da43b20c.
2022-07-14fix(core): unhandled rejection in top-level scope (#15204)Bartek Iwańczuk
Update "deno_core" to not forward rejection of top level module if it was already handled by appropriate handlers. Co-authored-by: Colin Ihrig cjihrig@gmail.com
2022-07-11chore(core): Deduplicate code related to `op_event_loop_has_more_work` (#15147)Andreu Botella
The `op_event_loop_has_more_work` op, introduced in #14830, duplicates code from `JsRuntime::poll_event_loop`. That PR also added the unused method `JsRuntime::event_loop_has_work`, which is another duplication of that same code, and which isn't used anywhere. This change deduplicates this by renaming `JsRuntime::event_loop_has_work` to `event_loop_pending_state`, and making it the single place to determine what in the event loop is pending. This result is then returned in a struct which is used both in the event loop and in the `op_event_loop_has_more_work` op.
2022-07-09fix(ext/ffi): Avoid keeping JsRuntimeState RefCell borrowed for event loop ↵Aapo Alasuutari
middleware calls (#15116)
2022-07-08perf(ext/ffi): leverage V8 Fast Calls (#15125)Divy Srivastava
2022-07-07fix(core): deflake WASM termination test (#15103)Bartek Iwańczuk
2022-07-06refactor(core): Use `&mut Isolate` as an argument in `JsRealm` methods (#15093)Andreu Botella
Currently almost every `JsRealm` method has a `&mut JsRuntime` argument. This argument, however, is only used to get the runtime's corresponding isolate. Given that a mutable reference to the corresponding `v8::Isolate` can be reached from many more places than a mutable reference to the `JsRuntime` (for example, by derefing a V8 scope), changing that will make `JsRealm` usable from many more places than it currently is.
2022-07-01chore: use Rust 1.62.0 (#15028)Bartek Iwańczuk
2022-07-01fix(core): handle exception from Wasm termination (#15014)João Avelino Bellomo Filho
Co-authored-by: Augusto Lenz <augustollenz@gmail.com>
2022-06-28feat(web): add beforeunload event (#14830)Colin Ihrig
This commit adds the 'beforeunload' event. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-06-28feat(ext/ffi): Thread safe callbacks (#14942)Aapo Alasuutari
2022-06-26build: require safety comments on unsafe code (#13870)Luca Casonato
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2022-06-25fix(modules): Immediately resolve follow-up dyn imports to a dyn imported ↵Andreu Botella
module (#14958) When a dynamically imported module gets resolved, any code that comes after an await import() to that module will continue running. However, if that is the last code in the evaluation of another dynamically imported module, that second module will not resolve until the next iteration of the event loop, even though it does not depend on the event loop at all. When the event loop is being blocked by a long-running operation, such as a long-running timer, or by an async op that might never end, such as with workers or BroadcastChannels, that will result in the second dynamically imported module not being resolved for a while, or ever. This change fixes this by running the dynamic module loading steps in a loop until no more dynamic modules can be resolved.
2022-06-20perf(core): Cache source lookups (#14816)Nayeem Rahman
Keep a cache for source maps and source lines. We sort of already had a cache argument for source map lookup functions but we just passed an empty map instead of storing it. Extended it to cache source line lookups as well and plugged it into runtime state.
2022-06-20docs: Improve `mod_evaluate` documentation (#14827)Christian Dürr
2022-06-07refactor(core): Move Deno.core bindings to ops (#14793)Nayeem Rahman
2022-06-06fix: Format non-error exceptions (#14604)Nayeem Rahman
This commit adds "Deno.core.setFormatExceptionCallback" which can be used to provide custom formatting for errors. It is useful in cases when user throws something that is non-Error (eg. a string, plain object, etc).
2022-05-30test(core): Test that sync ops return/throw objects in the right realm (#14750)Andreu Botella
This behavior was introduced in #14019 but wasn't properly tested in that PR.
2022-05-26chore: upgrade rusty_v8 to 0.43.1 (#14713)Bartek Iwańczuk
2022-05-17feat(core): deterministic snapshots (#14037)Divy Srivastava
2022-05-15Revert "core: don't include_str extension js code (#10786)" (#14614)Aaron O'Mullan
This reverts commit 10e50a120744de71d6915af4ae93f8231607573d Alternative to #13217, IMO the tradeoffs made by #10786 aren't worth it. It breaks abstractions (crates being self-contained, deno_core without snapshotting etc...) and causes pain points / gotchas for both embedders & devs for a relatively minimal gain in incremental build time ... Closes #11030
2022-05-05refactor(core): use Box<u8> for ModuleSource.code instead of a String (#14487)Bartek Iwańczuk
2022-04-27refactor: Remove PrettyJsError and js_error_create_fn (#14378)Nayeem Rahman
This commit: - removes "fmt_errors::PrettyJsError" in favor of "format_js_error" fn - removes "deno_core::JsError::create" and "deno_core::RuntimeOptions::js_error_create_fn" - adds new option to "deno_runtime::ops::worker_host::init"
2022-04-26refactor(core): Remove ErrWithV8Handle (#14394)Nayeem Rahman
2022-04-17feat(core): Add initial support for realms (#14019)Andreu Botella
This commit adds tentative support for multiple realms in "deno_core". It adds the "JsRealm" API that adds methods like "JsRuntime"'s "handle_scope", "global_object" and "execute_script" specific to the realm.
2022-04-15refactor: Move source map lookups to core (#14274)Nayeem Rahman
The following transformations gradually faced by "JsError" have all been moved up front to "JsError::from_v8_exception()": - finding the first non-"deno:" source line; - moving "JsError::script_resource_name" etc. into the first error stack in case of syntax errors; - source mapping "JsError::script_resource_name" etc. when wrapping the error even though the frame locations are source mapped earlier; - removing "JsError::{script_resource_name,line_number,start_column,end_column}" entirely in favour of "js_error.frames.get(0)". We also no longer pass a js-side callback to "core/02_error.js" from cli. I avoided doing this on previous occasions because the source map lookups were in an awkward place.
2022-04-13refactor(core/error): Clarify JsError message fields (#14269)Nayeem Rahman
2022-04-13feat(ext/web): Add error events for event listener and timer errors (#14159)Nayeem Rahman
- feat: Add handleable error event for even listener errors - feat: Add handleable error event for setTimeout()/setInterval() errors - feat: Add Deno.core.destructureError() - feat: Add Deno.core.terminate() - fix: Don't throw listener errors from dispatchEvent() - fix: Use biased mode when selecting between mod_evaluate() and run_event_loop() results
2022-04-08refactor(core): OpCtx (#14228)Aaron O'Mullan
2022-04-02feat(serde_v8): DetachedBuffer (#14102)Aaron O'Mullan
2022-04-02feat(ops): #[op(unstable)] (#14124)Aaron O'Mullan
2022-03-22chore(core): Remove a note that is no longer relevant. (#14069)Andreu Botella
This note about how `v8::SnapshotCreator::create_blob` must not be called from a `HandleScope` stopped being relevant in #6801, and was now attached to code that had nothing to do with `HandleScope`s.
2022-03-22feat(core): disableable extensions & ops (#14063)Aaron O'Mullan
Streamlines a common middleware pattern and provides foundations for avoiding variably sized v8::ExternalReferences & enabling fully monomorphic op callpaths
2022-03-22feat(core): Add JsRuntime::get_module_namespace to access the namespace ↵Filip Kieres
object of a module (#14026)
2022-03-21fix(core): variadic opSync/opAsync (#14062)Aaron O'Mullan
2022-03-19fix(ops): throw TypeError on op return failure (#14033)Aaron O'Mullan
Fixes #14028
2022-03-16cleanup(core): recursive get & ensure helpers (#13972)Aaron O'Mullan
2022-03-16feat(ops): optional OpState (#13954)Aaron O'Mullan
2022-03-15cleanup(core): OpPair => OpDecl (#13952)Aaron O'Mullan
2022-03-15fix(core): nuke Deno.core.ops pre-snapshot (#13970)Aaron O'Mullan
To avoid OOB & other ExternalReference snapshot serialization issues Co-authored-by: Bert Belder <bertbelder@gmail.com>
2022-03-14feat(ops): custom arity (#13949)Aaron O'Mullan
Also cleanup & drop ignored wildcard op-args
2022-03-14feat(core): codegen ops (#13861)Divy Srivastava
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-03-11chore: update rusty_v8 to 0.41.0 (#13909)Divy Srivastava
2022-03-08feat(core): Event loop middlewares for Extensions (#13816)Divy Srivastava