summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2023-02-22perf(core, runtime): Further improve startup time (#17860)Bartek Iwańczuk
This commit further improves startup time by: - no relying on "JsRuntime::execute_script" for runtime bootstrapping, this is instead done using V8 APIs directly - registering error classes during the snapshot time, instead of on startup Further improvements can be made, mainly around removing "core.initializeAsyncOps()" which takes around 2ms. This commit should result in ~1ms startup time improvement.
2023-02-21refactor(core): More efficient serde for ES modules in snapshot (#17856)Bartek Iwańczuk
Instead of relying on "serde_v8" which is very inefficient in serializing enums, I'm hand rolling serde for "ModuleMap" data that is stored in the V8 snapshot to make ES modules snapshottable. ``` // this branch Benchmark #2: ./target/release/deno run empty.js Time (mean ± σ): 21.4 ms ± 0.9 ms [User: 15.6 ms, System: 6.4 ms] Range (min … max): 20.2 ms … 24.4 ms // main branch Benchmark #2: ./target/release/deno run empty.js Time (mean ± σ): 23.1 ms ± 1.2 ms [User: 17.0 ms, System: 6.2 ms] Range (min … max): 21.0 ms … 26.0 ms ```
2023-02-20build: add "include_js_files_for_snapshotting" Cargo feature (#17826)Bartek Iwańczuk
This allows to not include source code into the binary (because it will already be included in the V8 snapshot). Nothing changes for the embedders - everything should still build the same. This commit brings the binary size from 87Mb to 82Mb on M1. Alternative to https://github.com/denoland/deno/pull/17820 and https://github.com/denoland/deno/pull/17653 --------- Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2023-02-20refactor(core): definition of "ExtensionFileSource" (#17823)Bartek Iwańczuk
This commit changes definition of "ExtensionFileSource", by changing "code" field to being "ExtensionFileSourceCode" enum. Currently the enum has only a single variant "IncludedInBinary". It is done in preparation to allow embedders to decide if they want to include the source code in the binary when snapshotting (in most cases they shouldn't do that). In the follow up commit we'll add more variants to "ExtensionFileSourceCode". "include_js_files_dir!" macro was removed in favor "include_js_files!" macro which can now accept "dir" option.
2023-02-16test: add unit tests from std/node (#17794)Bartek Iwańczuk
Adds two test files: "cli/tests/unit_node/process_test.ts" and "cli/tests/unit_node/child_process_test.ts" --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-02-15feat: wire up ext/node to the Node compatibility layer (#17785)Bartek Iwańczuk
This PR changes Node.js/npm compatibility layer to use polyfills for built-in Node.js embedded in the snapshot (that are coming from "ext/node" extension). As a result loading `std/node`, either from "https://deno.land/std@<latest>/" or from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is imported via "npm:" specifiers now uses code embedded in the snapshot. Several fixes were applied to various modules in "ext/node" to make tests pass. --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-02-14chore(build): don't compress TSC snapshot in debug build (#17772)Bartek Iwańczuk
Compressing the TSC snapshot in debug build took ~45s on M1 MacBook Pro; without compression it took ~1s. Thus we're not not using compressed snapshot, trading off a lot of build time for some startup time in debug build.
2023-02-14feat(core): allow to specify entry point for snapshotted ES modules (#17771)Bartek Iwańczuk
This commit adds "ExtensionBuilder::esm_entry_point()" function that allows to specify which of the extension files should be treated as an entry point. If the entry point is not provided all modules are loaded and evaluated, but if it is provided then only the entry point is explicitly loaded and evaluated. Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
2023-02-12fix: add WouldBlock error (#17339)Leo Kettmeir
2023-02-11docs: fix minor typo in AsyncRefCell comment (#17732)Mike Mulchrone
2023-02-10chore: upgrade rusty_v8 to 0.63.0 (#17705)Bartek Iwańczuk
2023-02-10perf(core): speed up promise hook dispatch (#17616)Bert Belder
2023-02-08refactor: internal runtime code TS support (#17672)Leo Kettmeir
This is a proof of concept for being able to snapshot TypeScript files. Currently only a single runtime file is authored in TypeScript - "runtime/js/01_version.ts". Not needed infrastructure was removed from "core/snapshot_util.rs". --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-08fix(core): don't allow to import internal code is snapshot is loaded (#17694)Bartek Iwańczuk
Addressing Luca concerns from https://github.com/denoland/deno/pull/17648#discussion_r1099352286
2023-02-08refactor(core): change SourcePair to ExtensionFileSource (#17686)Bartek Iwańczuk
2023-02-07 refactor: remove prefix from include_js_files & use extension name (#17683)Leo Kettmeir
2023-02-07refactor: Use ES modules for internal runtime code (#17648)Leo Kettmeir
This PR refactors all internal js files (except core) to be written as ES modules. `__bootstrap`has been mostly replaced with static imports in form in `internal:[path to file from repo root]`. To specify if files are ESM, an `esm` method has been added to `Extension`, similar to the `js` method. A new ModuleLoader called `InternalModuleLoader` has been added to enable the loading of internal specifiers, which is used in all situations except when a snapshot is only loaded, and not a new one is created from it. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-07chore: upgrade rusty_v8 to 0.62.2 (#17604)Bartek Iwańczuk
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2023-02-07chore: forward v1.30.3 release commit to main (#17677)denobot
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-06refactor: create JsRuntime outside of run_in_task (#17667)Leo Kettmeir
2023-02-05 refactor: rename `deno` specifiers to `internal` (#17655)Leo Kettmeir
2023-02-05chore(core): improve error message in module loader example (#17654)Waldir Pimenta
Just a small tweak to the error message to avoid confusion.
2023-02-03chore: forward v1.30.2 release commit to main (#17641)denobot
This is the release commit being forwarded back to main for 1.30.2 Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-02-03Revert "chore(core): remove have_unpolled_ops on rt state (#17601)" (#17631)Bartek Iwańczuk
This reverts commit e85ca8be0dafdab28e6283aed64c8ee0eb3a338d. This commit caused a huge spike in various benchmarks we track at https://deno.land/benchmarks
2023-02-02chore: forward v1.30.1 release commit to main (#17623)denobot
This is the release commit being forwarded back to main for 1.30.1
2023-01-31chore(core): remove have_unpolled_ops on rt state (#17601)Luca Casonato
It's not needed - `!state.have_unpolled_ops.is_empty()` does the same thing. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-29fix(ext): internal `structuredClone` for `ArrayBuffer` and `TypedArray` ↵Kenta Moriuchi
subclasses (#17431)
2023-01-29refactor(core): derive equality traits for `ResolutionKind` enum (#17578)Satya Rohith
The commit derives Eq, PartialEq, and Debug traits for the `ResolutionKind` enum to make it possible for external implementors to assert ResolutionKind.
2023-01-27chore: upgrade to Rust 1.67 (#17548)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-26fix(core): Add lint check for core (#17223)Kenta Moriuchi
The prefer-primordials lint was skipped for `core/*.js`.
2023-01-26chore(core): fix typo in runtime.rs (#17537)Ikko Eltociear Ashimine
determinstic -> deterministic
2023-01-261.30.0 (#17532)denobot
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-25Revert "chore: upgrade rusty_v8 to 0.62.0 (#17200)" (#17523)Bartek Iwańczuk
This reverts commit e2d75491d5fc6fbac67da89c7350c4c9ca99d8e9.
2023-01-25chore: upgrade rusty_v8 to 0.62.0 (#17200)Bartek Iwańczuk
2023-01-19refactor(core): Overwrite `ArrayPrototypeToString` in primordials (#17470)Kenta Moriuchi
2023-01-19refactor: cleanup ModuleMap (#17469)Leo Kettmeir
- changes module id to be usize & 0 based instead of 1 based - merges `ids_by_handle` & `handles_by_id` to be a single `handles` vector - removes `next_module_id`, as vector is used - turns `info` into a vector
2023-01-19feat: ES module snapshotting (#17460)Leo Kettmeir
This commit adds support for snapshotting ES modules. This is done by adding an ability to serialize and deserialize a "ModuleMap" and attach it to the snapshot, using "add_context_data" API. This has been tested with 400 modules and seems to not have a limit on the number of modules that might be snapshotted. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-18Optimize http_bench_json_ops example (#16505)Divy Srivastava
2023-01-17chore: forward v1.29.4 release commit to main (#17453)denobot
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-16refactor(core): Move `pending_promise_rejections` to `ContextState` (#17447)Andreu Botella
This is a requirement before supporting modules in realms.
2023-01-16refactor(core): rename pending_promise_exception to ↵Bartek Iwańczuk
pending_promise_rejection (#17441) These are technically rejections - a rejection can then raise an exception.
2023-01-15fix(core): Add `Generator` and `AsyncGenerator` to promordials (#17241)Kenta Moriuchi
2023-01-14chore: use rustfmt imports_granularity option (#17421)Divy Srivastava
Closes https://github.com/denoland/deno/issues/2699 Closes https://github.com/denoland/deno/issues/2347 Uses unstable rustfmt features. Since dprint invokes `rustfmt` we do not need to switch the cargo toolchain to nightly. Do we care about formatting stability of our codebase across Rust versions? (I don't)
2023-01-15refactor: clean up `unwrap` and `clone` (#17282)Yiyu Lin
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-01-15refactor(core): Move optional callbacks from `JsRuntimeState` to ↵Andreu Botella
`ContextState` (#17422) 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. This is a reland of #15599. Towards #13239.
2023-01-14feat(core): Reland support for async ops in realms (#17204)Andreu Botella
Currently realms are supported on `deno_core`, but there was no support for async ops anywhere other than the main realm. The main issue is 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 takes the `ContextState` struct added in #17050, and adds to it a `js_recv_cb` callback for each realm. Combined with the fact that that same PR also added a list of known realms to `JsRuntimeState`, and that #17174 made `OpCtx` instances realm-specific and had them include an index into that list of known realms, this makes it possible to know the current realm in the `queue_async_op` and `queue_fast_async_op` methods, and therefore to send the results of promises for each realm to that 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. This PR is a reland of #14734 after it was reverted in #16366, except that `ContextState` and `JsRuntimeState::known_realms` were previously relanded in #17050. Another significant difference with the original PR is passing around an index into `JsRuntimeState::known_realms` instead of a `v8::Global<v8::Context>` to identify the realm, because async op queuing in fast calls cannot call into V8, and therefore cannot have access to V8 globals. This also simplified the implementation of `resolve_async_ops`. Co-authored-by: Luis Malheiro <luismalheiro@gmail.com>
2023-01-13chore: forward 1.29.3 release back to main (#17401)David Sherret
2023-01-13chore: add `copyright_checker` tool and add the missing copyright (#17285)Yiyu Lin
2023-01-10fix(npm): allow to read package.json if permissions are granted (#17209)Bartek Iwańczuk
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass an enum indicating whether or not we're resolving a specifier for dynamic import. Additionally "CliModuleLoader" was changes to store both "parent permissions" (or "root permissions") as well as "dynamic permissions" that allow to check for permissions in top-level module load an dynamic imports. Then all code paths that have anything to do with Node/npm compat are now checking for permissions which are passed from module loader instance associated with given worker.
2023-01-08feat(core): allow specifying name and dependencies of an Extension (#17301)Leo Kettmeir