summaryrefslogtreecommitdiff
path: root/core/01_core.js
AgeCommit message (Collapse)Author
2023-07-02refactor(core): Extract deno_core (#19658)Matt Mastracci
`deno_core` is moving out! You'll find it at https://github.com/denoland/deno_core/ once this PR lands.
2023-06-26chore: fix typos (#19572)Martin Fischer
2023-06-26Revert "Reland "refactor(core): cleanup feature flags for js source i… ↵Bartek Iwańczuk
(#19611) …nclusion" (#19519)" This reverts commit 28a4f3d0f5383695b1d49ccdc8b0f799a715b2c2. This change causes failures when used outside Deno repo: ``` ============================================================ Deno has panicked. This is a bug in Deno. Please report this at https://github.com/denoland/deno/issues/new. If you can reliably reproduce this panic, include the reproduction steps and re-run with the RUST_BACKTRACE=1 env var set and include the backtrace in your report. Platform: linux x86_64 Version: 1.34.3+b37b286 Args: ["/opt/hostedtoolcache/deno/0.0.0-b37b286f7fa68d5656f7c180f6127bdc38cf2cf5/x64/deno", "test", "--doc", "--unstable", "--allow-all", "--coverage=./cov"] thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to read "/home/runner/work/deno/deno/core/00_primordials.js" Caused by: No such file or directory (os error 2)', core/runtime/jsruntime.rs:699:8 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ```
2023-06-25Reland "refactor(core): cleanup feature flags for js source inclusion" (#19519)Nayeem Rahman
Relands #19463. This time the `ExtensionFileSourceCode` enum is preserved, so this effectively just splits feature `include_js_for_snapshotting` into `exclude_js_sources` and `runtime_js_sources`, adds a `force_include_js_sources` option on `extension!()`, and unifies `ext::Init_ops_and_esm()` and `ext::init_ops()` into `ext::init()`.
2023-06-14perf: don't run microtask checkpoint if macrotask callback did no work (#19492)Bartek Iwańczuk
Most of the time there's no firing timers, nor pending promise rejections, so it's wasteful to run microtask checkpoint additionally twice on each tick of the event loop. Closes https://github.com/denoland/deno/issues/18871 Ref https://github.com/denoland/deno/issues/19451
2023-06-13Revert "refactor(core): cleanup feature flags for js source inclusion… ↵Bartek Iwańczuk
(#19490) … (#19463)" This reverts commit ceb03cfb037cf7024a5048b17b508ddda59cfa05. This is being reverted because it causes 3.5Mb increase in the binary size, due to runtime JS code being included in the binary, even though it's already snapshotted. CC @nayeemrmn
2023-06-13refactor(core): cleanup feature flags for js source inclusion (#19463)Nayeem Rahman
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature `include_js_for_snapshotting` since they leak paths that are only applicable in this repo to embedders. Replace with feature `exclude_js_sources`. Additionally the feature `force_include_js_sources` allows negating it, if both features are set. We need both of these because features are additive and there must be a way of force including sources for snapshot creation while still having the `exclude_js_sources` feature. `force_include_js_sources` is only set for build deps, so sources are still excluded from the final binary. You can also specify `force_include_js_sources` on any extension to override the above features for that extension. Towards #19398. But there was still the snapshot-from-snapshot situation where code could be executed twice, I addressed that by making `mod_evaluate()` and scripts like `core/01_core.js` behave idempotently. This allowed unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into `ext::init()`.
2023-06-06refactor(core): ensureFastOps is an op-generating proxy (#19377)Matt Mastracci
Startup benchmark shows no changes (within 1ms, identical system/user times).
2023-05-21refactor(core): set function names for ops in JavaScript (#19208)Bartek Iwańczuk
This commit ensures that JavaScript functions generated for registered ops have proper names set up - the function name matches the name of the op. A test was added in `core/runtime.rs` that verifies this. Closes https://github.com/denoland/deno/issues/19206
2023-05-01refactor: migrate async ops to generated wrappers (#18937)Bartek Iwańczuk
Migrates some of existing async ops to generated wrappers introduced in https://github.com/denoland/deno/pull/18887. As a result "core.opAsync2" was removed. I will follow up with more PRs that migrate all the async ops to generated wrappers.
2023-05-01fix(core): Use primordials for methods (#18839)Kenta Moriuchi
I would like to get this change into Deno before merging https://github.com/denoland/deno_lint/pull/1152
2023-04-30perf(core): async op pseudo-codegen and performance work (#18887)Matt Mastracci
Performance: ``` async_ops.js: 760k -> 1030k (!) async_ops_deferred.js: 730k -> 770k Deno.serve bench: 118k -> 124k WS test w/ third_party/prebuilt/mac/load_test 100 localhost 8000 0 0: unchanged Startup time: approx 0.5ms slower (13.7 -> 14.2ms) ```
2023-04-28Revert "refactor: don't expose Deno[Deno.internal].core namespace" (#18881)Bartek Iwańczuk
Also conditionally disabled one test if there's not enough space on device.
2023-04-26refactor: don't expose Deno[Deno.internal].core namespace (#18816)Bartek Iwańczuk
2023-04-19refactor(core): return better error for non-existent async ops (#18772)Bartek Iwańczuk
2023-04-14fix(core): Use safe primordials wrappers (#18687)Kenta Moriuchi
2023-04-14refactor(core): limit number of boundary crossings between Rust and V8 (#18652)Bartek Iwańczuk
This commit refactors "deno_core" to do fewer boundary crossings from Rust to V8. In other words we are now calling V8 from Rust fewer times. This is done by merging 3 distinct callbacks into a single one. Instead of having "op resolve" callback, "next tick" callback and "macrotask queue" callback, we now have only "Deno.core.eventLoopTick" callback, which is responsible for doing the same actions previous 3 callbacks. On each of the event loop we were doing at least 2 boundary crosses (timers macrotask queue callback and unhandled promise rejection callback) and up to 4 crosses if there were op response and next tick callbacks coming from Node.js compatibility layer. Now this is all done in a single callback. Closes https://github.com/denoland/deno/issues/18620
2023-04-13perf(ops): directly respond for eager ops (#18683)Bartek Iwańczuk
This commit changes "eager ops" to directly return a response value instead of calling "opresponse" callback in JavaScript. This saves one boundary crossing and has a fantastic impact on the "async_ops.js" benchmark: ``` v1.32.4 $ deno run cli/bench/async_ops.js time 329 ms rate 3039513 time 322 ms rate 3105590 time 307 ms rate 3257328 time 301 ms rate 3322259 time 303 ms rate 3300330 time 306 ms rate 3267973 time 300 ms rate 3333333 time 301 ms rate 3322259 time 301 ms rate 3322259 time 301 ms rate 3322259 time 302 ms rate 3311258 time 301 ms rate 3322259 time 302 ms rate 3311258 time 302 ms rate 3311258 time 303 ms rate 3300330 ``` ``` this branch $ ./target/release/deno run -A cli/bench/async_ops.js time 257 ms rate 3891050 time 248 ms rate 4032258 time 251 ms rate 3984063 time 246 ms rate 4065040 time 238 ms rate 4201680 time 227 ms rate 4405286 time 228 ms rate 4385964 time 229 ms rate 4366812 time 228 ms rate 4385964 time 226 ms rate 4424778 time 226 ms rate 4424778 time 227 ms rate 4405286 time 228 ms rate 4385964 time 227 ms rate 4405286 time 228 ms rate 4385964 time 227 ms rate 4405286 time 229 ms rate 4366812 time 228 ms rate 4385964 ``` Prerequisite for https://github.com/denoland/deno/pull/18652
2023-04-06feat(core): sync io ops in core (#18603)Luca Casonato
This commit adds op_read_sync and op_write_sync to core. These ops are similar to op_read and op_write, but they are synchronous. Just like the async ops, they operate on generic `deno_core::Resource` objects. These now have new `read_byob_sync` and `write_sync` methods, with default implementations throwing "NotSupported" errors, just like the async counterparts. There are no `write_all` or `read` equivalents, because the optimizations they unlock are not useful in synchronous contexts.
2023-03-31perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525)Divy Srivastava
This commit adds a new core API `opAsync2` to call an async op with atmost 2 arguments. Spread argument iterators has a pretty big perf hit when calling ops. | name | avg msg/sec/core | | --- | --- | | 1.32.1 | `127820.750000` | | #18506 | `140079.000000` | | #18506 + #18509 | `150104.250000` | | #18506 + #18509 + this | `157340.000000` |
2023-03-13fix(core): `SafePromiseAll` to be unaffected by `Array#@@iterator` (#17542)Kenta Moriuchi
2023-03-05refactor: move definition of Deno.build from "runtime" to "core" (#18036)Bartek Iwańczuk
We use information about build in several extension crates like "ext/node" or "runtime/". In an effort to move "fs" APIs to a separate crate it is a prerequisite to have this information available outside of the "runtime/" crate. This commit moves definition of "build" object to "Deno.core" that is later forwarded to "Deno.build".
2023-02-23fix(core): remove async op inlining optimization (#17899)Divy Srivastava
Runtime generation of async op wrappers contributed to increased startup time and core became unusable with `--disallow-code-generation-from-strings` flag. The optimization only affects very small microbenchmarks so this revert will not cause any regressions.
2023-02-10perf(core): speed up promise hook dispatch (#17616)Bert Belder
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-01-26fix(core): Add lint check for core (#17223)Kenta Moriuchi
The prefer-primordials lint was skipped for `core/*.js`.
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-13refactor(core): add more information when unable to build error (#17027)Bartek Iwańczuk
This should help debug problem in https://github.com/denoland/deno/issues/16963
2022-12-06fix(test): handle scenario where --trace-ops would cause an unhandled ↵David Sherret
promise rejection (#16970) Closes #16969
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-24perf(ext/streams): fast path when consuming body of tee'd stream (#16329)Marcos Casagrande
Add a fast path for consuming the body of cloned `Request`/`Response`, which is very common specially when using `cache` API.
2022-10-21chore(core): remove `core.opSync` (#16379)Divy Srivastava
This patch removes the last uses of `core.opSync` from Deno. The new and JIT-friendly way to call sync ops is `core.ops.op_name()`.
2022-10-10feat(core): add Deno.core.writeAll(rid, chunk) (#16228)Luca Casonato
This commit adds a new op_write_all to core that allows writing an entire chunk in a single async op call. Internally this calls `Resource::write_all`. The `writableStreamForRid` has been moved to `06_streams.js` now, and uses this new op. Various other code paths now also use this new op. Closes #16227
2022-09-28feat(core): add Deno.core.setPromiseHooks (#15475)Guilherme Bernal
2022-09-22feat(ops): Automatic fast ops creation (#15527)Aapo Alasuutari
2022-09-07fix(ext/flash): use utf8 length as Content-Length (#15793)Divy Srivastava
2022-09-07fix(core): opAsync leaks a promise on type error (#15795)Aapo Alasuutari
2022-09-06perf(runtime): short-circuit `queue_async_op` for Poll::Ready (#15773)Divy Srivastava
2022-09-02fix(repl): don't terminate on unhandled error events (#15548)Nayeem Rahman
2022-08-30perf: use fast api for `core.isProxy` (#15682)Divy Srivastava
2022-08-21feat: `queueMicrotask()` error handling (#15522)Nayeem Rahman
Adds error event dispatching for queueMicrotask(). Consequently unhandled errors are now reported with Deno.core.terminate(), which is immune to the existing quirk with plainly thrown errors (#14158).
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
2022-08-01refactor(core/error): use evaluated call sites for formatting (#15369)Nayeem Rahman
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-20Reland "feat: add "unhandledrejection" event support" (#15211)Bartek Iwańczuk
2022-07-15Revert "feat: add "unhandledrejection" event support (#12994) (#15080)" (#15210)Bartek Iwańczuk
This reverts commit 1a7259b04b7229f6350a7a7c21b50497b5c80c17.