1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

1122 commits

Author SHA1 Message Date
Aaron O'Mullan
8744ee883e
perf(core): optimize encode on large strings (#14619)
Follow up to serde_v8's #14450
2022-05-15 17:52:32 +02:00
Aaron O'Mullan
f5c31b56e3
Revert "core: don't include_str extension js code (#10786)" (#14614)
This reverts commit 10e50a1207

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-15 13:27:56 +02:00
Divy Srivastava
20ee3110d8
chore: upgrade rusty_v8 to 0.42.1 (#14597) 2022-05-14 15:26:31 +05:30
Andreu Botella
3e7afb8918
chore(runtime): Make some ops in ext and runtime infallible. (#14589)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-05-13 10:36:31 +02:00
Aaron O'Mullan
c6063e390a
feat(ops): infallible / result-free ops (#14585) 2022-05-12 19:13:25 +02:00
Aaron O'Mullan
5e6d3d42c7
feat(ops): #[op(v8)] (#14582) 2022-05-12 19:06:42 +02:00
Bert Belder
89b428234c
1.21.3 (#14584) 2022-05-12 18:43:00 +02:00
Aaron O'Mullan
d0f5cd6a06
fix(core): avoid panic on non-string Error.name (#14529)
Fixes #14518
2022-05-08 23:03:00 +02:00
Bartek Iwańczuk
bcd875030a
refactor(core): add AssertedModuleType enum (#14501)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-05-07 18:46:35 +02:00
Colin Ihrig
23c77df664
1.21.2 (#14508)
1.21.2
2022-05-05 19:37:27 -04:00
Bartek Iwańczuk
45a4d75296
refactor(core): use Box<u8> for ModuleSource.code instead of a String (#14487) 2022-05-05 13:16:25 +02:00
Luca Casonato
242273e69b
chore: update deps (#14416) 2022-05-05 12:41:59 +02:00
Bartek Iwańczuk
3f08a40412
refactor: add core.formatLocationFilename, remove op_format_filename (#14474)
This commit moves "op_format_location" to "core/ops_builtin.rs"
and removes "Deno.core.createPrepareStackTrace" in favor of
"Deno.core.prepareStackTrace".

Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-05-03 19:45:57 +02:00
Leo Kettmeir
de2004dec5
Forward 1.21.1 (#14428) 2022-04-28 23:32:42 +02:00
Nayeem Rahman
9853c96cc4
refactor: Remove PrettyJsError and js_error_create_fn (#14378)
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-27 01:06:10 +02:00
Nayeem Rahman
74175c039a
refactor(core): Remove ErrWithV8Handle (#14394) 2022-04-26 15:28:42 +02:00
Aaron O'Mullan
12f7581ed9
cleanup(serde_v8): disambiguate ZeroCopyBuf (#14380) 2022-04-25 16:56:47 +02:00
Luca Casonato
1ad8c11bc9
chore: bump crates (#14365) 2022-04-22 16:54:42 +02:00
Divy Srivastava
57f7e07c13
Reland "perf(http): optimize ReadableStreams backed by a resource" (#14346) 2022-04-22 16:19:08 +05:30
denobot
29c8cd8aae
1.21.0 (#14336)
Co-authored-by: ry <ry@users.noreply.github.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-04-20 21:50:16 -04:00
Bartek Iwańczuk
03019e7781
Revert various PRs related to "ext/http" (#14339)
* Revert "feat(ext/http): stream auto resp body compression (#14325)"
* Revert "core: introduce `resource.read_return` (#14331)"
* Revert "perf(http): optimize `ReadableStream`s backed by a resource (#14284)"
2022-04-21 02:22:55 +02:00
Ryan Dahl
78c9cd9789
upgrade: rusty_v8 0.42.0 (#14334) 2022-04-20 19:13:31 -04:00
Divy Srivastava
2612b6f20f
core: introduce resource.read_return (#14331) 2022-04-20 18:39:13 +02:00
David Sherret
a64e63c361
perf: move Deno.writeTextFile and like functions to Rust (#14221)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-04-18 18:00:14 -04:00
Andreu Botella
19bb82aa40
feat(core): Add initial support for realms (#14019)
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-17 13:53:08 +02:00
Bartek Iwańczuk
a87be28a46
feat: Better formatting for AggregateError (#14285)
This commit adds "aggregated" field to "deno_core::JsError" that stores
instances of "JsError" recursively to properly handle "AggregateError"
formatting. Appropriate logics was added to "PrettyJsError" and
"console" API to format AggregateErrors.

Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2022-04-16 16:12:26 +02:00
Nayeem Rahman
8b31fc23cd
refactor: Move source map lookups to core (#14274)
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-15 16:08:09 +02:00
Bartek Iwańczuk
244926e83c
feat(test): format user code output (#14271)
This commit changes "deno test" to better denote user output coming
from test cases.

This is done by printing "---- output ----" and "---- output end ----"
markers if an output is produced. The output from "console" and
"Deno.core.print" is captured, as well as direct writes to "Deno.stdout"
and "Deno.stderr".

To achieve that new APIs were added to "deno_core" crate, that allow
to replace an existing resource with a different one (while keeping resource
ids intact). Resources for stdout and stderr are replaced by pipes.

Co-authored-by: David Sherret <dsherret@gmail.com>
2022-04-15 14:24:41 +02:00
David Sherret
0e4574b2e3
chore: forward v1.20.6 release commit to main (#14288) 2022-04-14 15:50:48 -04:00
Nayeem Rahman
7d50a5fd43
refactor(core/error): Clarify JsError message fields (#14269) 2022-04-13 16:41:39 +02:00
Nayeem Rahman
4d18f558e4
feat(ext/web): Add error events for event listener and timer errors (#14159)
- 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-13 11:50:57 +02:00
David Sherret
a4c1e1bdcf
fix: upgrade to swc_ecmascript 0.143 (#14238) 2022-04-08 12:31:47 -04:00
Aaron O'Mullan
f5f7b56aca
refactor(core): OpCtx (#14228) 2022-04-08 10:32:48 +02:00
David Sherret
b2aaf708ab
chore: forward v1.20.5 release commit to main (#14232) 2022-04-07 14:40:20 -04:00
Bartek Iwańczuk
6c25b5135d
chore: update tokio, tokio-util and libc dependencies (#14174) 2022-04-02 19:54:40 +02:00
Aaron O'Mullan
13b9fc9304
feat(serde_v8): DetachedBuffer (#14102) 2022-04-02 13:35:57 +02:00
Aaron O'Mullan
25b6b2ed66
feat(ops): #[op(unstable)] (#14124) 2022-04-02 00:09:21 +02:00
David Sherret
7fec7c834c
1.20.4 (#14168) 2022-03-31 15:48:35 -04:00
Divy Srivastava
b18216a0d4
perf: micro-optimize core.encode (#14120) 2022-03-27 13:10:54 +05:30
Luca Casonato
37b0ec454c
chore: forward v1.20.3 release commit to main (#14121) 2022-03-25 18:53:55 +01:00
Kitson Kelly
cff1e92ecf 1.20.2 2022-03-24 14:47:06 +11:00
Andreu Botella
49be140d2b
chore(core): Remove a note that is no longer relevant. (#14069)
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-22 22:57:15 +01:00
Aaron O'Mullan
f81334d5bd
feat(core): disableable extensions & ops (#14063)
Streamlines a common middleware pattern and provides foundations for avoiding variably sized v8::ExternalReferences & enabling fully monomorphic op callpaths
2022-03-22 16:39:58 +01:00
Filip Kieres
d2b7192c1b
feat(core): Add JsRuntime::get_module_namespace to access the namespace object of a module (#14026) 2022-03-22 14:32:32 +01:00
David Sherret
49012cbc33
feat: upgrade to swc_ecmascript 0.137.0 (#14067) 2022-03-22 09:19:53 -04:00
Andreu Botella
12d28dffc6
fix(fetch): Fix uncaught rejection panic with WebAssembly.instantiateStreaming (#13925)
When an exception is thrown during the processing of streaming WebAssembly,
`op_wasm_streaming_abort` is called. This op calls into V8, which synchronously
rejects the promise and calls into the promise rejection handler, if applicable.
But calling an op borrows the isolate's `JsRuntimeState` for the duration of the
op, which means it is borrowed when V8 calls into `promise_reject_callback`,
which tries to borrow it again, panicking.

This change changes `op_wasm_streaming_abort` from an op to a binding
(`Deno.core.abortWasmStreaming`). Although that binding must borrow the
`JsRuntimeState` in order to access the `WasmStreamingResource` stored in the
`OpTable`, it also takes ownership of that `WasmStreamingResource` instance,
which means it can drop any borrows of the `JsRuntimeState` before calling into
V8.
2022-03-22 11:33:29 +01:00
Aaron O'Mullan
c5792d6d1d
fix(core): variadic opSync/opAsync (#14062) 2022-03-21 18:04:57 +01:00
Aaron O'Mullan
d0a7305676
cleanup(core): drop op_void_async's state arg (#14045) 2022-03-20 14:54:38 +01:00
Divy Srivastava
5e82bcf0e4
chore(core): update deno_core README (#14042)
Co-authored-by: Andreu Botella <andreu@andreubotella.com>
2022-03-20 16:08:35 +05:30
Aaron O'Mullan
52459faf0b
fix(ops): throw TypeError on op return failure (#14033)
Fixes #14028
2022-03-19 15:59:44 +01:00
Aapo Alasuutari
ad8e238348
chore(core,ext): minor JS optimisations (#13950) 2022-03-19 18:26:54 +09:00
Ryan Dahl
fce60f2cc2
v1.20.1 2022-03-16 21:40:31 -04:00
Ryan Dahl
418c1eb4b3
v1.20.0 2022-03-16 16:07:35 -04:00
Aaron O'Mullan
895e474295
cleanup(core): recursive get & ensure helpers (#13972) 2022-03-16 09:04:38 +01:00
Aaron O'Mullan
bd481bf095
feat(ops): optional OpState (#13954) 2022-03-16 00:33:46 +01:00
Andreu Botella
672f66dde1
perf(web): Optimize TextDecoder by adding a new U16String type (#13923) 2022-03-16 00:22:00 +01:00
Aaron O'Mullan
bb53135ed8
cleanup(core): OpPair => OpDecl (#13952) 2022-03-15 23:43:17 +01:00
Aaron O'Mullan
60466de5d5
cleanup(core): remove void_op_a?sync (#13953)
In favour of `op_void_sync` & `op_void_async`
2022-03-15 22:58:03 +01:00
Aaron O'Mullan
07d8431f10
fix(core): nuke Deno.core.ops pre-snapshot (#13970)
To avoid OOB & other ExternalReference snapshot serialization issues

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2022-03-15 22:50:17 +01:00
Aaron O'Mullan
88d0f01948
feat(ops): custom arity (#13949)
Also cleanup & drop ignored wildcard op-args
2022-03-14 23:38:53 +01:00
Andreu Botella
c6bf07ec6d
fix(core): Don't override structured clone error messages from V8 (#13942)
In the implementation of structured serialization in
`Deno.core.serialize`, whenever there is a serialization error, an
exception will be thrown with the message "Failed to serialize
response", even though V8 provides a message to use in such cases.
This change instead throws an exception with the V8-provided message,
if there is one.
2022-03-14 19:35:15 +01:00
Divy Srivastava
b4e42953e1
feat(core): codegen ops (#13861)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-03-14 18:44:15 +01:00
Yoshiya Hinosawa
b198bfd795
refactor(core): validate promise id in refOp (#13905) 2022-03-12 01:18:49 +09:00
Divy Srivastava
189e2f617e
chore: update rusty_v8 to 0.41.0 (#13909) 2022-03-11 19:59:01 +05:30
Yoshiya Hinosawa
3c11768aab
v1.19.3 2022-03-10 23:29:14 +09:00
Divy Srivastava
e166d7eed0
feat(core): Event loop middlewares for Extensions (#13816) 2022-03-08 20:10:34 +05:30
Aaron O'Mullan
303d691a16
perf(core): micro-optimize OpsTracker (#13868) 2022-03-08 09:28:20 +01:00
Satya Rohith
70690f54af
chore: update deps (#13821) 2022-03-05 03:38:04 +05:30
Satya Rohith
95459e60f6 chore: bump crate version for 1.19.2 (#13824) 2022-03-03 15:05:18 -05:00
Bartek Iwańczuk
d332bf1132
feat: deno test --trace-ops (#13770)
This commit adds "--trace-ops" flag to "deno test" subcommand.

This flag enables saving of stack traces for async ops, that before were always
saved. While the feature proved to be very useful it comes with a significant performance
hit, it's caused by excessive source mapping of stack frames.
2022-02-25 16:14:46 +01:00
David Sherret
3b12afd072
chore: upgrade to Rust 1.59 (#13767) 2022-02-24 20:03:12 -05:00
David Sherret
4deefafdd1 chore: bump crate versions for 1.19.1 (#13760) 2022-02-24 17:45:39 -05:00
David Sherret
49b6fc34b4
chore: upgrade swc_ecmascript to 0.114 (#13758) 2022-02-24 10:43:46 -05:00
Bartek Iwańczuk
e17ab6322e
chore: release crates for v1.19.0 (#13698) 2022-02-17 00:57:40 +01:00
Luca Casonato
53088e16de
feat(test): improved op sanitizer errors + traces (#13676)
This commit improves the error messages for the `deno test` async op
sanitizer. It does this in two ways:
- it uses handwritten error messages for each op that could be leaking
- it includes traces showing where each op was started

This "async op tracing" functionality is a new feature in deno_core.
It likely has a significant performance impact, which is why it is only
enabled in tests.
2022-02-16 19:53:17 +01:00
Luca Casonato
be61a85886
chore: update v8 (#13680) 2022-02-16 13:14:34 +01:00
Leo Kettmeir
4799aaac15
refactor: factor out CDP message types (#13551) 2022-02-07 17:05:49 +01:00
Bartek Iwańczuk
82284d8052
chore: forward v1.18.2 to main (#13595) 2022-02-04 21:44:38 +01:00
Bartek Iwańczuk
975e55d524
chore: upgrade crates (#13560) 2022-02-02 19:24:24 +01:00
Luca Casonato
dbf23725f7
chore: update rusty_v8 (#13575) 2022-02-02 18:51:37 +01:00
Bartek Iwańczuk
8176a4d166
refactor: primordials for instanceof (#13527) 2022-02-01 18:06:11 +01:00
Bartek Iwańczuk
b7b6b9c9e5
Revert "refactor: factor out CDP message types (#13501)" (#13540)
This reverts commit 382a978859.
2022-01-31 14:00:18 +01:00
Andreu Botella
56ea75817e
example(core): Add example for TypeScript transpiling via deno_ast (#13545) 2022-01-31 13:43:32 +01:00
Bartek Iwańczuk
5cf23176dc
chore: forward v1.18.1 to main (#13514) 2022-01-27 18:52:34 +01:00
Bartek Iwańczuk
f248e6f177
Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511)
This reverts commit 884143218f.
2022-01-27 16:27:22 +01:00
Leo Kettmeir
382a978859
refactor: factor out CDP message types (#13501) 2022-01-27 15:09:47 +01:00
Bartek Iwańczuk
884143218f
refactor: update runtime code for primordial checks for "instanceof" (#13497) 2022-01-27 13:36:36 +01:00
Rafael Ávila de Espíndola
ae0414fa35
refactor(core): Extract JsRuntime::poll_value out of JsRuntime::resolve_value (#13461) 2022-01-24 17:59:41 +01:00
Divy Srivastava
16776c9ade
chore: bump crate version for 0.18.0 (#13441) 2022-01-20 20:50:39 +05:30
Yoshiya Hinosawa
4c1053ad33
chore: update copyright year (#13434) 2022-01-20 16:10:16 +09:00
Luca Casonato
1259a3f48c
chore: update v8 to 0.38.1 (#13415) 2022-01-19 13:17:23 +01:00
David Sherret
ad224f53c7
chore: upgrade to rust 1.58 (#13377) 2022-01-15 07:10:12 +01:00
Bartek Iwańczuk
9975ede773
chore: forward v1.17.3 to main (#13364) 2022-01-13 20:47:42 +01:00
Ryan Dahl
1fb5858009
chore: update copyright to 2022 (#13306)
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Bartek Iwańczuk
46f2ff1205
chore: forward 1.17.2 to main (#13295) 2022-01-06 13:20:42 +01:00
Rafael Ávila de Espíndola
2d978a73eb
fix: Get lib.deno_core.d.ts to parse correctly (#13238) 2022-01-06 10:58:44 +01:00
Bartek Iwańczuk
9872fbf189
refactor(core): InspectorSession implements Stream (#13270)
This commit rewrites "InspectorSession" to no longer implement "Future"
trait but instead implement "Stream" trait. "Stream" trait is implemented
by yielding a raw pointer to the "v8::inspector::V8InspectorSession" and
received message. In effect received messages are no longer dispatched
from within the future, but are explicitly dispatched by the caller.

This change should allow us to dispatch a message to the session when
another message is being dispatched, ie.
"V8InspectorSesssion::dispatch_protocol_message" is already on the
call stack.
2022-01-04 18:26:00 +01:00
Ben Noordhuis
7746cc7a04
chore: upgrade v8 from 9.7 to 9.8 (#13269) 2022-01-04 11:49:34 +01:00
Bartek Iwańczuk
1adf8ee545
fix(core): inspector works if no "Runtime.runIfWaitingForDebugger" message is sent (#13191)
This commit changes flow in inspector code to no longer require 
"Runtime.runIfWaitingForDebugger" message to complete a handshake.

Even though clients like Chrome DevTools always send this message on startup,
it is against the protocol to require this message to start an inspector
session.

Instead "Runtime.runIfWaitingForDebugger" is required only when running with
"--inspect-brk" flag, which matches behavior of Node.js.
2021-12-30 16:47:58 +01:00
Bartek Iwańczuk
de9778949b
chore(core): remove stale TODOs (#13232) 2021-12-30 03:24:02 +01:00
Andreu Botella
0ead12d673
fix(doc): Make private types which show up in the rustdocs public (#13230)
`CrossIsolateStore`, `ExtensionBuilder` and `InMemoryChannelResource`
are private types which are referred to by other public APIs, and so
don't show up as links in the rustdoc. This is especially confusing for
`ExtensionBuilder`, since there is nothing in the docs that explains how
to build an extension.

Exposing these three types doesn't add any new capabilities:
`ExtensionBuilder` can be created from `Extension::builder()`,
`SharedArrayBufferStore` and `CompiledWasmModuleStore` already enable
doing anything that `CrossIsolateStore` can do by itself, and
`InMemoryChannelResource` isn't constructable.
2021-12-30 02:05:26 +01:00
Leo Kettmeir
167982be9e
feat: output cause on JS runtime errors (#13209) 2021-12-29 19:34:13 +01:00
Aaron O'Mullan
92e8a29269
cleanup(core): use Extensions to register ops (#13224)
In examples and tests
2021-12-29 15:21:42 +01:00
Bartek Iwańczuk
ee7ab81768
refactor(core): cleanup Inspector implementation (#12962) 2021-12-28 17:40:42 +01:00
Bartek Iwańczuk
9391ba1098
chore: merge v1.17.1 into main (#13184) 2021-12-22 22:20:17 +01:00
Bartek Iwańczuk
aca41a472a
refactor: Cleanup core/modules.rs (#13149) 2021-12-21 15:53:46 +01:00
Divy Srivastava
6de53b631f
refactor: use once_cell instead of lazy_static (#13135) 2021-12-18 16:14:42 -05:00
Bartek Iwańczuk
e0cba6b19b
chore: release crates for v1.17.0 (#13112) 2021-12-16 18:51:23 +01:00
Bartek Iwańczuk
a1f0796fcc
feat: Add support for import assertions and JSON modules (#12866)
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-15 19:22:36 +01:00
Bartek Iwańczuk
cd03de3c7b
example(core): add example for FS module loading (#13064) 2021-12-13 13:14:04 +01:00
Bartek Iwańczuk
34f05f673e
fix(core): improve error on invalid op id (#13056) 2021-12-12 17:11:41 +01:00
David Sherret
1507b8c984
fix: upgrade swc fixing many bundling and --no-check bugs (#13025) 2021-12-08 19:12:14 -05:00
Bartek Iwańczuk
c59f90d01f
chore: upgrade to Rust 1.57.0 (#12968) 2021-12-04 14:19:06 +01:00
Luca Casonato
72e9720e91
chore: merge v1.16.4 into main (#12984) 2021-12-04 01:26:54 +01:00
Luca Casonato
27ef275d27
chore: update to rusty v8 0.36.0 (#12979) 2021-12-03 15:56:04 +01:00
Aaron O'Mullan
f6d4a63c7f
fix(core): throw on invalid callConsole args (#12973)
Instead of panicking via asserts, since JS-callable code (even Deno.core ...) should not cause process crashes/panics
2021-12-03 11:55:14 +01:00
KnorpelSenf
4c36fa1fdf
chore: Fix typo in no-pending-ops error message (#12948) 2021-12-01 15:22:11 +01:00
Andreu Botella
48c57001c8
fix(core): Wake up the runtime if there are ticks scheduled (#12933) 2021-11-30 00:31:12 +01:00
Ben Noordhuis
2d830c263b
feat(core): intercept unhandled promise rejections (#12910)
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-28 00:46:12 +01:00
Bartek Iwańczuk
f3c0f0565b
feat(core): Add ability to "ref" and "unref" pending ops (#12889)
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-25 19:49:09 +01:00
Bert Belder
c6f3493f18
chore: merge v1.16.3 into main (#12892) 2021-11-24 15:56:18 -08:00
Giacomo Rizzi
86e5238384
core(examples): Deserialize the result of execute_script (#12806)
Example of transforming execute_script response to a serde_json::Value

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-11-22 14:47:29 +01:00
Bartek Iwańczuk
f6d04bfe70
fix(core): don't panic when evaluating module after termination (#12833) 2021-11-22 13:51:20 +01:00
Ben Noordhuis
22dcf82230
fix(core): keep event loop alive if there are ticks scheduled (#12814)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-11-19 14:01:30 +01:00
Bert Belder
c4c8543d5c
upgrade: v8 crate 0.35.0 (V8 9.7.106.5) (#12797)
Fixes: #11406
2021-11-17 14:09:13 -08:00
David Sherret
cd61cedd19
chore: bump crates for 1.16.2 (#12792) 2021-11-17 10:14:23 -05:00
Bartek Iwańczuk
fd78953e1c
feat(core): Deno.core.setNextTickCallback (#12771)
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-16 20:23:12 +01:00
Ryan Dahl
b2036a4db7
refactor: re-export anyhow from deno_core (#12777) 2021-11-16 09:02:28 -05:00
Luca Casonato
3250ffe020
chore: bump crate versions for 1.16.1 (#12729) 2021-11-11 11:16:05 +01:00
Aaron O'Mullan
375ce63c63
feat(core): streams (#12596)
This allows resources to be "streams" by implementing read/write/shutdown. These streams are implicit since their nature (read/write/duplex) isn't known until called, but we could easily add another method to explicitly tag resources as streams.

`op_read/op_write/op_shutdown` are now builtin ops provided by `deno_core`

Note: this current implementation is simple & straightforward but it results in an additional alloc per read/write call

Closes #12556
2021-11-09 19:26:17 +01:00
Luca Casonato
4f64acd4e4
chore: bump crate versions for 1.16.0 (#12706) 2021-11-09 13:03:17 +01:00
Bert Belder
4c468628d4
perf(core): optimize waker capture in AsyncRefCell (#12332) 2021-11-08 12:49:10 -08:00
Luca Casonato
80d3a5f8be
feat: update to V8 9.7 (#12685)
This commit updates the rusty_v8 to 0.34.0. This commit also adds
the required typings for the new Array#findLast and Array#findIndexLast
methods.
2021-11-08 14:24:54 +01:00
Yoshiya Hinosawa
8e010b6844
feat(compat): add .code to dyn import error (#12633) 2021-11-08 16:02:40 +09:00
Aaron O'Mullan
44511e4f33
feat(runtime): give OS errors .code attributes (#12591)
This adds `.code` attributes to errors returned by the op-layer, facilitating classifying OS errors and helping node-compat.

Similar to Node, these `.code` attributes are stringified names of unix ERRNOs, the mapping tables are generated by [tools/codegen_error_codes.js](https://gist.github.com/AaronO/dfa1106cc6c7e2a6ebe4dba9d5248858) and derived from libuv and rust's std internals
2021-11-04 16:44:34 +01:00
Ryan Dahl
7c2abb9d57
fix: Deno.emit crashes with BorrowMutError (#12627)
Warn on await_holding_refcell_ref clippy rule to avoid this in the future.

Fixes #12453
2021-11-03 09:27:36 -04:00
Bartek Iwańczuk
8e31bbbe55
chore: update to Rust edition 2021 (#12578) 2021-11-02 10:03:37 -04:00
Luca Casonato
be68b82eb4
chore: update to rusty_v8 0.33.0 (#12564) 2021-10-27 23:26:15 +02:00
Yoshiya Hinosawa
c7dcf1cbdd
chore: bump crate version for 1.15.3 (#12531) 2021-10-25 15:48:01 +09:00
Aaron O'Mullan
53d38ad1e5
cleanup(core): AsyncOpIterator (#11860) 2021-10-24 21:41:57 +02:00
Aaron O'Mullan
439a2914db
fix(core): avoid op_state.borrow_mut() for OpsTracker (#12525)
By allowing interior mutability in OpsTracker (owning a RefCell<Vec> instead of just a Vec)

Fixes #12453
2021-10-24 19:30:55 +02:00
Aaron O'Mullan
f250faaf05
feat(serde_v8): allow all values to deserialize to unit type (#12504) 2021-10-20 23:17:12 +02:00
Aaron O'Mullan
783b4da48a
feat(serde_v8): StringOrBuffer (#12503) 2021-10-20 15:40:20 +02:00
Nayeem Rahman
e8ee5da459
fix(core/bindings): use is_instance_of_error() instead of is_native_error() (#12479) 2021-10-19 18:26:45 +02:00
Bartek Iwańczuk
1cd9272a91
chore: release crates for v1.15.2 (#12478) 2021-10-18 20:30:00 +02:00
Bert Belder
ff932b411d
fix(core): poll async ops eagerly (#12385)
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-17 19:50:42 +02:00
Bert Belder
ff95fc167d
fix(core): avoid polling future after cancellation (#12385) 2021-10-17 15:16:10 +02:00
Satya Rohith
fb094ae026
chore: bump crate version for 1.15.0 (#12406) 2021-10-12 22:16:15 +05:30
Luca Casonato
fef8b08614
feat: update to V8 9.5 (#12399) 2021-10-12 13:30:39 +02:00
Aaron O'Mullan
5a8a989b78
refactor(metrics): move to core (#12386)
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
2021-10-10 17:20:30 +02:00
Aaron O'Mullan
f2ac7ff23a
bench(deno_common): track void ops (#12389)
To track overhead through the entire CLI opcall stack (metrics included, etc...)
2021-10-10 16:36:55 +02:00
Andreu Botella
5edd277161
feat: Show the URL of streaming WASM modules in stack traces (#12268)
WebAssembly modules compiled through `WebAssembly.compile()` and similar
non-streaming APIs don't have a URL associated to them, because they
have been compiled from a buffer source. In stack traces, V8 will use
a URL such as `wasm://wasm/d1c677ea`, with a hash of the module.

However, wasm modules compiled through streaming APIs, like
`WebAssembly.compileStreaming()`, do have a known URL, which can be
obtained from the `Response` object passed into the streaming APIs. And
as per the developer-facing display conventions in the WebAssembly
Web API spec, this URL should be used in stack traces. This change
implements that.
2021-10-10 16:03:23 +02:00
Aaron O'Mullan
370c27e09a
feat(core): cleaner opcall stack traces (#12358) 2021-10-07 18:39:27 +02:00
Aaron O'Mullan
22328f8758
feat(core): native binding names (#12290)
Makes native builtin functions easier to recognize when debugging/profiling, they would otherwise appear as "(anonymous)" functions
2021-10-05 22:55:51 +02:00
Leo K
77a00ce1fb
chore: various op cleanup (#12329) 2021-10-05 22:38:27 +02:00
Bartek Iwańczuk
d67e858506
chore: merge v1.14.3 into main (#12327) 2021-10-05 21:40:39 +02:00
Aaron O'Mullan
ea7a63cd5a
refactor(core): split opcall into sync/async (#12312) 2021-10-04 12:34:53 +02:00
Aaron O'Mullan
4a1300edde
fix(core/runtime): sync_ops_cache if nuked Deno ns (#12302)
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-04 11:45:41 +02:00
Aaron O'Mullan
11acdf1ea8
perf(core): use opcall() directly (#12310)
Instead of the wrapper dispatch() func, also now forbids passing opIds to opSync()/opAsync() callers must always pass names
2021-10-03 21:02:50 +02:00
Aaron O'Mullan
26de516558
feat(core): implement Deno.core.isProxy() (#12288) 2021-10-01 20:25:33 +02:00
Andreu Botella
a2632c86b1
fix: Don't panic when a worker is closed in the reactions to a wasm operation. (#12270) 2021-09-30 19:52:58 +02:00
Andreu Botella
cdb252af0a
feat: support serializing WebAssembly.Module objects (#12140) 2021-09-29 10:47:24 +02:00
Aaron O'Mullan
e8901281da
chore: bump crate versions for 1.14.2 (#12253) 2021-09-28 12:19:03 +02:00
Ryan Dahl
683a38e47c
refactor: Remove unused code (#12210) 2021-09-25 00:35:35 +02:00
Ryan Dahl
9705efd419
refactor: Remove op_state parameter (#12202) 2021-09-24 11:11:16 -04:00
Ryan Dahl
958b374f09
upgrade serde_v8 and rusty_v8 (#12175)
* upgrade serde_v8 and rusty_v8

* rusty_v8 0.30.0

* cycle keys
2021-09-22 18:51:11 +02:00
Kitson Kelly
2a56cd545c
chore: bump crate versions for 1.14.1 (#12172) 2021-09-22 06:53:47 +10:00
Nayeem Rahman
75ca013f07
fix(cli/fmt_errors): Abbreviate long data URLs in stack traces (#12127)
Co-authored-by: Mike White <mike.white@auctane.com>
2021-09-18 15:40:04 +02:00
Bartek Iwańczuk
f840906943
fix(core): prevent multiple main module loading (#12128)
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-18 03:44:53 +02:00
Squirrel
4b79e5a459
chore: Remove unused deps from Cargo.toml files (#12106) 2021-09-17 14:39:32 +02:00
Satya Rohith
3c97dbf06b
chore: update tagline (#12095) 2021-09-16 11:55:06 +05:30
David Sherret
16c27fce1f
chore: bump crate versions for 0.14 (#12072) 2021-09-14 15:38:35 -04:00
Luca Casonato
3b30ba8031
chore: update rusty_v8 (#12026) 2021-09-13 15:33:20 +02:00
Andreu Botella
4d6f412b0b
refactor(core): Turn the wasm_streaming_feed binding into ops (#11985)
Async WebAssembly compilation was implemented by adding two
bindings: `set_wasm_streaming_callback`, which registered a callback to
be called whenever a streaming wasm compilation was started, and
`wasm_streaming_feed`, which let the JS callback modify the state of the
v8 wasm compiler.

`set_wasm_streaming_callback` cannot currently be implemented as
anything other than a binding, but `wasm_streaming_feed` does not really
need to use anything specific to bindings, and could indeed be
implemented as one or more ops. This PR does that, resulting in a
simplification of the relevant code.

There are three operations on the state of the v8 wasm compiler that
`wasm_streaming_feed` allowed: feeding new bytes into the compiler,
letting it know that there are no more bytes coming from the network,
and aborting the compilation. This PR provides `op_wasm_streaming_feed`
to feed new bytes into the compiler, and `op_wasm_streaming_abort` to
abort the compilation. It doesn't provide an op to let v8 know that the
response is finished, but closing the resource with `Deno.core.close()`
will achieve that.
2021-09-13 14:27:54 +02:00
Bartek Iwańczuk
ba8bbe6f1c
refactor: use Deno.core.tryClose (#11980) 2021-09-11 02:54:37 +02:00
Bert Belder
fa963909e5
perf(ext/http): optimize auto cleanup of request resource (#11978)
Fixes #11963.
2021-09-10 15:47:09 -07:00
Nayeem Rahman
d331c4b283
fix(ext/web): Format terminal DOMExceptions properly (#11834) 2021-09-06 22:59:20 +02:00
Feng Yu
bb99d5da4c
fix(doc): fix rustdoc bare_urls warning (#11921) 2021-09-05 16:22:45 +02:00
Casper Beyer
f9d29115a0
feat(cli): close test worker once all tests complete (#11727) 2021-09-04 20:19:26 +02:00
David Sherret
987716798f
feat(fmt): add basic JS doc formatting (#11902) 2021-09-02 18:28:12 -04:00
Luca Casonato
1bf7b90ca8
chore: update dependencies (#11856)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-09-02 23:38:44 +02:00
Aaron O'Mullan
b518f5e1ba
feat(core): facilitate op-disabling middleware (#11858)
* feat(core): facilitate op-disabling middleware

By providing `void_op_sync()` and `void_op_async() as well as `core/examples/disable_ops.rs`
2021-08-31 13:08:16 +02:00
Luca Casonato
0aa6b1e79f
chore: update to rusty_v8 0.27.0 (#11877)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-08-30 18:40:00 +02:00
Luca Casonato
5d814a4c24
feat: ArrayBuffer in structured clone transfer (#11840) 2021-08-25 13:48:53 +02:00
Bartek Iwańczuk
f84cd9403d
refactor: cleanup Inspector and InspectorServer implementations (#11837) 2021-08-25 13:39:23 +02:00
David Sherret
6db8cbb650
chore: release crates for 1.13.2 (#11820) 2021-08-23 15:48:08 -04:00
Luca Casonato
df084b9f14
fix(ext/ffi): don't panic on invalid enum values (#11815)
Co-authored-by: Feng Yu <f3n67u@gmail.com>
2021-08-23 18:31:19 +02:00
Aaron O'Mullan
bfc197f33e
cleanup(core): rename handleAsyncMsgFromRust() to opresolve() (#11774)
No user impact, but is simpler and aligns with `opcall()`
2021-08-19 17:19:00 +02:00
Antoine du Hamel
7e5698fb2e
chore: add FinalizationRegistry and WeakRef to primordials (#11735)
Because it was possible to disable those with a runtime flag, they were
not available through primordials. The flag has since been removed
upstream.

Refs: d59db06bf5
2021-08-17 12:04:09 +02:00
David Sherret
a66a7bebbe
chore: release crates for 1.13.1 (#11729) 2021-08-16 16:49:14 -04:00
Aaron O'Mullan
2ca454b402
refactor(ops): return BadResource errors in ResourceTable calls (#11710)
* refactor(ops): return BadResource errors in ResourceTable calls

Instead of relying on callers to map Options to Results via `.ok_or_else(bad_resource_id)` at over 176 different call sites ...
2021-08-15 13:29:19 +02:00
Bartek Iwańczuk
548e466112
chore: release crates (#11628) 2021-08-10 14:19:42 +02:00
Bartek Iwańczuk
162ec192b7
upgrade: rusty_v8 0.26.0 (#11625) 2021-08-10 09:13:02 +02:00
Leo K
16ae4a0d57
feat(extensions/web): add structuredClone function (#11572)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-08-09 10:39:00 +02:00
David Sherret
d7d452efc1
chore: format toml files internally (#11563) 2021-08-02 10:19:27 -04:00
Yusuke Tanaka
8f00b5542c
chore: upgrade Rust to 1.54.0 (#11554) 2021-07-30 15:03:41 +02:00
Ben Noordhuis
c909faf9e6
chore(core): use oneshot channel in mod_evaluate() (#11556)
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-30 13:36:43 +02:00
Bartek Iwańczuk
f9bb7949b8
chore: release crates (#11519) 2021-07-26 15:45:40 +02:00
Yusuke Tanaka
865d9ddd51
refactor: use primordials in runtime, extensions and core (#11500) 2021-07-26 13:52:59 +02:00
Bartek Iwańczuk
cd445a2a0d
chore: release crates (#11454) 2021-07-19 20:20:42 +02:00
Bartek Iwańczuk
642dd3d3c4
chore: release crates (#11378) 2021-07-13 02:16:49 +02:00
Bartek Iwańczuk
6d4e9bad98
chore: upgrade rusty_v8 (#11372) 2021-07-12 21:03:10 +02:00
Luca Casonato
ab079a8d63
chore: update crates (#11332) 2021-07-09 17:15:50 +02:00
Bartek Iwańczuk
27e1b4cb5a
feat(core): return v8::Value from JsRuntime::execute_script (#11129)
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-08 18:56:53 +02:00
Aaron O'Mullan
01cf8aab9f
perf(core): avoid extra alloc in Deno.core.encode() (#11323) 2021-07-08 17:57:57 +02:00
David Sherret
7fc0e8ec8c
chore: use parking_lot for synchronization primitives to align with tokio (#11289)
parking_lot is already transitively used in tokio via the "full" cargo feature
2021-07-06 23:48:01 -04:00
Luca Casonato
bdfad23dd0
feat: support SharedArrayBuffer sharing between workers (#11040)
This commit adds support for sharing SABs between workers.
2021-07-06 19:42:52 +02:00
Bartek Iwańczuk
1aac47720b
refactor: use primordials in extensions/web (#11273)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2021-07-06 14:38:12 +02:00
Nayeem Rahman
060dd3ae82
fix(core): Delay deadlock detection for dynamic imports (#11282) 2021-07-05 18:59:49 +02:00
Yusuke Tanaka
0a33cc1951
chore: upgrade Tokio to 1.8.0 (#11281) 2021-07-05 15:50:56 +02:00
Luca Casonato
3ee0c36453
refactor: introduce primordials for web/streams (#11251) 2021-07-05 12:18:41 +02:00
Andreu Botella
ffa75be480
feat: enable WebAssembly.instantiateStreaming and wasm async compilation (#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-03 23:33:36 +02:00
Luca Casonato
caf87694d0
chore: add TypedArray to primordials typings (#11236) 2021-07-03 00:49:47 +02:00
Bartek Iwańczuk
da654fddff
chore: upgrade rusty_v8 and serde_v8 (#11233) 2021-07-02 22:59:33 +02:00
Luca Casonato
4ae50f5c06
refactor: use primordials for extensions/webidl (#11227) 2021-07-02 16:37:41 +02:00
Luca Casonato
c9204c4aee
refactor: introduce primordials (#10939)
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-02 12:18:30 +02:00
Bartek Iwańczuk
513f921219
feat(core): pump V8 message loop on event loop tick (#11221)
This commit adds support for Atomics and FinalizationRegistry by integrating
V8's message loop into "JsRuntime::poll_event_loop".
2021-07-02 10:46:37 +02:00
Bartek Iwańczuk
bce662d5bb
chore: upgrade rusty_v8 and serde_v8 (#11216) 2021-07-02 09:32:48 +02:00
Nayeem Rahman
c577c273a4
fix(core/modules): Fix concurrent loading of dynamic imports (#11089)
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-29 03:03:02 +02:00
Bartek Iwańczuk
38a7128cdd
feat: Add "deno_net" extension (#11150)
This commits moves implementation of net related APIs available on "Deno"
namespace to "deno_net" extension.

Following APIs were moved:
- Deno.listen()
- Deno.connect()
- Deno.listenTls()
- Deno.serveHttp()
- Deno.shutdown()
- Deno.resolveDns()
- Deno.listenDatagram()
- Deno.startTls()
- Deno.Conn
- Deno.Listener
- Deno.DatagramConn
2021-06-29 01:43:03 +02:00
Bartek Iwańczuk
30cba24848
chore: release deno_core (#11164) 2021-06-28 20:59:23 +02:00
Bartek Iwańczuk
7b9737b9f4
feat(inspector): pipe console messages between terminal and inspector (#11134)
This commit adds support for piping console messages to inspector.

This is done by "wrapping" Deno's console implementation with default
console provided by V8 by the means of "Deno.core.callConsole" binding.

Effectively each call to "console.*" methods calls a method on Deno's
console and V8's console.
2021-06-27 02:27:50 +02:00
Andreu Botella
015f252066
fix(fetch): encode and decode headers as byte strings (#11070) 2021-06-26 17:34:24 +02:00
Luca Casonato
22e7b0f585
fix: MessagePort in message for postMessage transfers (#11103) 2021-06-26 11:17:05 +02:00
Nick Randall
2f1ac46091
feat(core): Re-export serde_v8 (#11125) 2021-06-26 03:09:25 +02:00
Bartek Iwańczuk
e86c1710f4
chore: upgrade serde_v8 (#11120) 2021-06-25 18:58:18 +02:00
Ryan Dahl
48f9df9aa2
upgrade: rusty_v8 0.23.0 (V8 9.2.230.12) (#11113) 2021-06-25 12:54:53 +02:00
Yoshiya Hinosawa
606611708c
fix(runtime/signal): use op_async_unref for op_signal_poll (#11097) 2021-06-25 13:15:35 +09:00
Maxime Guerreiro
abd7a8a9cd
docs(core): Use op name in example (#11094)
The first argument to opSync/opAsync is the op name. In the examples,
the name is 'hello', and so it should be the first argument.
2021-06-23 21:11:00 +02:00
Maxime Guerreiro
02f7a52235
cleanup(core): top-level-await is now always enabled (#11082)
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-22 17:47:09 +02:00
Charlie Moog
580c9f9ef0
fix(core): don't panic on stdout/stderr write failures in Deno.core.print (#11039) 2021-06-22 04:39:59 +02:00
Bartek Iwańczuk
9105892ec8
refactor: unify JavaScript script execution method (#11043)
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-22 01:45:41 +02:00
Bartek Iwańczuk
a2f939b99c
refactor(core): always attach inspector to isolate (#11042)
This commit changes "deno_core::JsRuntime" to always create
"deno_core::JsRuntimeInspector" instance.
2021-06-21 19:37:51 +02:00
Bartek Iwańczuk
90e3abe8f9
chore: release crates (#11068) 2021-06-21 16:37:34 +02:00
Max
bbc2745350
docs(core): replaces dispatch references with op (#11054) 2021-06-20 17:12:55 +02:00
Nayeem Rahman
2ea41d3ac1
fix(core/modules): Prepare modules only once per runtime (#11015)
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-06-19 16:14:43 +02:00
Yusuke Tanaka
b0c04a7941
chore: upgrade Tokio to 1.7.1 (#11045) 2021-06-19 15:37:07 +02:00
Yusuke Tanaka
8031644e65
chore: upgrade Rust to 1.53.0 (#11021) 2021-06-17 15:56:30 -04:00
Yusuke Tanaka
a8007059b7
chore: upgrade Tokio to 1.7.0 (#11008) 2021-06-16 16:39:51 +02:00
Bartek Iwańczuk
ba91a727a6
chore: release crates (#10976) 2021-06-15 22:14:58 +02:00
Bartek Iwańczuk
e75ffab0c8
chore: move serde_v8 to separate repo (#10909)
Now available at https://github.com/denoland/serde_v8
2021-06-09 20:37:43 +02:00
Bartek Iwańczuk
3a96fe55a0
chore: release crates (#10896) 2021-06-08 20:34:18 +02:00
Bartek Iwańczuk
d679ebbb37
upgrade: rusty_v8 0.22.3 (#10892) 2021-06-08 18:25:53 +02:00
Luca Casonato
a66f327250
tests: run wpt scripts with Deno.core.evalContext (#10852)
This means wpts are now run in script context, and there are better
stack traces.
2021-06-06 18:32:06 +02:00
Luca Casonato
c73ef5fa14
refactor(web): use encoding_rs for text encoding (#10844)
This commit removes all JS based text encoding / text decoding. Instead
encoding now happens in Rust via encoding_rs (already in tree). This
implementation retains stream support, but adds the last missing
encodings. We are incredibly close to 100% WPT on text encoding now.

This should reduce our baseline heap by quite a bit.
2021-06-05 23:10:07 +02:00
Bert Belder
f891368057 v1.10.3 / 2021.05.31
- feat(lsp): diagnostics for deno types and triple-slash refs (#10699)
 - feat(lsp): provide X-Deno-Warning as a diagnostic (#10680)
 - feat(lsp): show hints from `deno_lint` in addition to messages
   (#10739)
 - feat(lsp): support formatting json and markdown files (#10180)
 - fix(cli): always allow documentation modules to be checked (#10581)
 - fix(cli): canonicalize coverage dir (#10364)
 - fix(cli): don't statically error on dynamic unmapped bare specifiers
   (#10618)
 - fix(cli): empty tsconfig.json file does not cause error (#10734)
 - fix(cli): support source maps with Deno.emit() and bundle (#10510)
 - fix(cli/dts): fix missing error class (NotSupported) in types (#10713)
 - fix(cli/install): support `file:` scheme URLs (#10562)
 - fix(cli/test): don't use reserved symbol `:` in specifier (#10751)
 - fix(cli/test): ensure coverage dir exists (#10717)
 - fix(cli/upgrade): modify download size paddings (#10639)
 - fix(runtime/http): expose nextRequest() errors in respondWith()
   (#10384)
 - fix(runtime/http): fix empty blob response (#10689)
 - fix(serde_v8): remove intentional deserialization error on non-utf8
   strings (#10156)
 - fix(ext/fetch): fix error message of Request constructor (#10772)
 - fix(ext/fetch): make prototype properties writable (#10769)
 - fix(ext/fetch): remove unimplemented Request attributes (#10784)
 - fix(ext/file): update File constructor following the spec (#10760)
 - fix(ext/webstorage): use opstate for sqlite connection (#10692)
 - fix(lsp): deps diagnostics include data property (#10696)
 - fix(lsp): ignore type definition not found diagnostic (#10610)
 - fix(lsp): local module import added by code action now includes the
   file extension (#10778)
 - fix(lsp): make failed to load config error descriptive (#10685)
 - fix(lsp): memoize script versions per tsc request (#10601)
 - fix(lsp): re-enable the per resource configuration without a deadlock
   (#10625)
 - docs(cli): update getting started for clarity (#10694)
 - docs(cli/dts) replace `read()` with `readSync()` (#10732)
 - docs(cli/dts): fix plugin example (#10647)
 - docs(cli/dts): fix typo in `TestDefinition.only` description (#10697)
 - docs(cli/dts): fix unix socket examples (#10705)
 - docs(cli/dts): make worker example pass (#10703)
 - docs(cli/dts): tag test permission example as typescript (#10753)
 - docs(permissions): fix grammatical error in permissions docs (#10755)
 - docs(runtime): fix fetch API usage of HTTP server (#10777)
 - docs(testing): fix misspelling (#10683)
 - docs(typescript): fix typo in faqs (#10682)
 -----BEGIN PGP SIGNATURE-----
 
 iQFJBAABCgAzFiEERCcr7u+ib5W/fkyWeneIey4u1GEFAmC1RbwVHGJlcnRiZWxk
 ZXJAZ21haWwuY29tAAoJEHp3iHsuLtRhXJsH/RETkMkLj1rZSdQWaOdVnRmP02pb
 QmbmtfPVtM0Xvh+zL23Jk2fU2cJPRsf71U260QMyzxE8LVDZ58k9KFID24MdB3b/
 J6Y5zLxyhkzc1EutN+D09y2nwrvJv3UKOls2ZLXtZ/HEmqQVOmqlGIaPIGxiQOPO
 yAWXKXid/hZ41xDygJpL6FEmemnVlOzPHX/AeccKcyQos7CUUqcNocReUklZcje6
 1IEEe6NcAi7x7hRB6lfjtXIZRcEjMD21ZmLsyKEH6YOJfoPzlR0uKYJR0i0ZO5Hr
 H4erWA9R3OJDwvx5DhCGxyqW6IuD4A3HGChHtcANdH+RWTyHquqgDSzpeHA=
 =Hhjk
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQFJBAABCgAzFiEERCcr7u+ib5W/fkyWeneIey4u1GEFAmC1TdsVHGJlcnRiZWxk
 ZXJAZ21haWwuY29tAAoJEHp3iHsuLtRhYVEH/iHbk8AXA5xF8kV+q2R0IhRrtZjV
 8VjDiC1nTGfIJcjXxoUVa1VaYQlfxNxcKPc/PSoW/oUwSoS0I9QvAxPY81dPYNUe
 TtiJjf7fNWssu04TK/5rillRuag3e+AGrR605uK2A1b0Y/qlOumtaGN48TXcbyFt
 p/p4zXT9TSC+/cOxZFNjnh+UVwpqOJxWxXBBtzrsDcsBfdvOCy/fo7qwjmqbe/q4
 BDXNAG4AYHtg5X94b8bEgPDutUjk5HY08KA0EvVffGD0c3czvaF3lO7p8FHt95/3
 rG+hS02OxUWRe8rltZk6s1mItypig4EyWWoiUJMaPt8zTz1t9rdy+M0oEpY=
 =bAil
 -----END PGP SIGNATURE-----

Merge v1.10.3 into main (#10801)
2021-05-31 20:58:03 +00:00
Bert Belder
1567c1013c
v1.10.3 2021-05-31 20:20:42 +00:00
Nayeem Rahman
8a7e1c616d
fix(cli): Don't statically error on dynamic unmapped bare specifiers (#10618)
Fixes #10168
Fixes #10615
Fixes #10616
2021-05-31 16:37:36 +02:00
Yusuke Tanaka
475bc35646
chore: upgrade Tokio to 1.6.1 (#10782) 2021-05-31 16:37:35 +02:00
Nayeem Rahman
3a33510bd4
fix(cli): Don't statically error on dynamic unmapped bare specifiers (#10618)
Fixes #10168
Fixes #10615
Fixes #10616
2021-05-31 10:20:34 +10:00
Luca Casonato
10e50a1207
core: don't include_str extension js code (#10786)
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-29 16:20:52 +02:00
Yusuke Tanaka
5f92f35bee
chore: upgrade Tokio to 1.6.1 (#10782) 2021-05-29 13:18:24 +02:00
Bartek Iwańczuk
e5beb800c9
refactor: move JsRuntimeInspector to deno_core (#10763)
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.
2021-05-26 21:07:12 +02:00
Bartek Iwańczuk
0768f8d369
refactor(core): move ModuleMap to separate RefCell (#10656)
This commit moves bulk of the logic related to module loading
from "JsRuntime" to "ModuleMap".

Next steps are to rewrite the actual loading logic (represented by
"RecursiveModuleLoad") to be a part of "ModuleMap" as well --
that way we will be able to track multiple module loads from within
the map which should help me solve the problem of concurrent
loads (since all info about currently loading/loaded modules will
be contained in the ModuleMap, so we'll be able to know if actually
all required modules have been loaded).
2021-05-19 20:53:43 +02:00
Aaron O'Mullan
24da0aa37d
tooling: re-enable bench_util (#10674) 2021-05-19 19:41:23 +02:00
Aaron O'Mullan
21d62b9b9e
cleanup(core.js): make op wrapper arg names generic (#10675)
These bits were missed in #10448.
2021-05-18 13:43:21 +02:00
Luca Casonato
5887dd3c95
chore: release crates (#10661)
For the Deno 1.10.2 release.
2021-05-17 17:34:35 +02:00
Luca Casonato
94eabfeeba
chore: update dependencies (#10660) 2021-05-17 14:44:40 +02:00
Aaron O'Mullan
9f9a50a3e8
cleanup(core/example/hello_world): use Deno.core.print instead of new op (#10645) 2021-05-15 15:24:01 +02:00
Aaron O'Mullan
d059f9b06e
cleanup(core): flatten print's op args (#10643) 2021-05-15 15:22:57 +02:00
Yusuke Tanaka
be2347ddc2
chore: upgrade Tokio to 1.6.0 (#10637) 2021-05-15 15:13:10 +02:00
Bartek Iwańczuk
de706961dc
chore: release crates (#10596) 2021-05-11 23:14:24 +02:00
Tim Ramlot
635253bd3a
feat(runtime/worker): Structured cloning worker message passing (#9323)
This commit upgrade "Worker.postMessage()" implementation to use 
structured clone algorithm instead of non-spec compliant JSON serialization.
2021-05-11 21:09:09 +02:00
Bartek Iwańczuk
7fc211e627
upgrade: rusty_v8 0.22.2 (#10551) 2021-05-10 14:46:50 +02:00
heddi.nabbisen
beba52c17c
docs: fix a tiny typo (#10535) 2021-05-09 11:39:44 +10:00
Aaron O'Mullan
d5f39fd121
cleanup(ops): remove unused ZeroCopyBuf arg-types (#10530) 2021-05-08 14:37:42 +02:00
Elias Sjögreen
4ed1428c34
fix: align plugin api with Extension (#10427) 2021-05-07 09:45:07 -04:00
Aaron O'Mullan
1e8e44f4c3
refactor(ops): replace ZeroCopyBuf arg by 2nd generic deserializable arg (#10448) 2021-05-06 19:32:03 +02:00
Aaron O'Mullan
d21380728f
fix(core): error registration could pollute constructors (#10422)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
2021-05-03 17:30:41 +02:00
Aaron O'Mullan
3a37444cb5
fix(core/print): flush stderr (#10480) 2021-05-03 14:51:32 +02:00
Aaron O'Mullan
ea917384fe
refactor(core): convert core.print() to a builtin op (#10436) 2021-05-02 19:30:03 -04:00
Aditya Pandit
012da3ae1e
fix(core): fix typo in error message of print function (#10456) 2021-05-01 23:20:20 +09:00
Aaron O'Mullan
c5be20aa67
cleanup(core): use ZeroCopyBuf for serialize & encode bindings (#10435) 2021-04-30 21:09:58 -04:00
Aaron O'Mullan
578f2ba45e
refactor(core): provide builtins as an Extension (#10449) 2021-04-30 21:08:29 -04:00
Andy Hayden
684c357136
Rename crate_ops to extensions (#10431) 2021-04-30 15:51:48 -04:00
Aaron O'Mullan
fc9c7de94b
cleanup(core): replace OpResponse with OpResult (#10434)
Drop the Value/Buffer enum since #10432 allows buffers to be serialized rust => v8
2021-04-30 10:51:54 -04:00
Aaron O'Mullan
5ec478b5fa
refactor(core): initialize extensions in runtime constructor (#10421)
This ensures that provided extensions are all correctly setup and ready to use once the JsRuntime constructor returns

Note: this will also initialize ops for to-be-snapshotted runtimes
2021-04-30 10:38:35 -04:00
Aaron O'Mullan
4e6790a5fa
feat(serde_v8): ZeroCopyBuf (#10432)
Bidirectional zero-copy serialization of buffers between v8 & rust
that can be nested in structs/tuples/etc.
2021-04-30 08:42:09 -04:00
Aaron O'Mullan
8922639c1d
refactor(core.js): provide window.__bootstrap (#10423) 2021-04-30 08:13:23 -04:00
Aaron O'Mullan
e89295b176
refactor(extensions): reintroduce builder (#10412) 2021-04-28 18:16:45 -04:00
Ryan Dahl
e63c533154
enable error-on-warning (#10410)
Only on linux and osx. Fixes one warning.
2021-04-28 15:10:44 -04:00
Aaron O'Mullan
0260b488fb
core: introduce extensions (#9800)
Extensions allow declarative extensions to "JsRuntime" (ops, state, JS or middleware).

This allows for:
- `op_crates` to be plug-and-play & self-contained, reducing complexity leaked to consumers
- op middleware (like metrics_op) to be opt-in and for new middleware (unstable, tracing,...)
- `MainWorker` and `WebWorker` to be composable, allowing users to extend workers with their ops whilst benefiting from the other infrastructure (inspector, etc...)

In short extensions improve deno's modularity, reducing complexity and leaky abstractions for embedders and the internal codebase.
2021-04-28 18:41:50 +02:00
Bartek Iwańczuk
b28f9445aa
refactor(core): simplify module loading code (#10385)
General cleanup of module loading code, tried to reduce indentation in various methods
on "JsRuntime" to improve readability.

Added "JsRuntime::handle_scope" helper function, which returns a "v8::HandleScope".
This was done to reduce a code pattern that happens all over the "deno_core".

Additionally if event loop hangs during loading of dynamic modules a list of
currently pending dynamic imports is printed.
2021-04-28 18:28:46 +02:00
Satya Rohith
2bd087ab1b
chore: upgrade dprint plugins (#10397) 2021-04-28 10:08:51 -04:00
Bert Belder
299518d935 fix(tls): throw meaningful error when hostname is invalid (#10387)
`InvalidDNSNameError` is thrown when a string is not a valid hostname,
e.g. it contains invalid characters, or starts with a numeric digit. It
does not involve a (failed) DNS lookup.
2021-04-26 23:40:45 +02:00
Casper Beyer
e4e7d957e8
feat(core): enable wasm threading support (#10116) 2021-04-26 17:54:07 +02:00
Ryan Dahl
9c3da280e0
remove #![deny(warnings)] (#10376)
Prefer RUSTFLAGS="-D warnings" to prevent warnings, but cannot 
enable yet due to #10378.
2021-04-26 10:10:57 -04:00
Aaron O'Mullan
83bece56b0
refactor(core): move op cache sync responsibility to rust space (#10340)
Even if bootstrapping the JS runtime is low level, it's an abstraction leak of 
core to require users to call `Deno.core.ops()` in JS space.

So instead we're introducing a `JsRuntime::sync_ops_cache()` method, 
once we have runtime extensions a new runtime will ensure the ops 
cache is setup (for the provided extensions) and then loading/unloading 
plugins should be the only operations that require op cache syncs
2021-04-25 22:00:05 +02:00
Aaron O'Mullan
1c7164257d
refactor(core): move builtin ops to their own file (#10336) 2021-04-25 19:23:22 +02:00
Aaron O'Mullan
c130cbb7b7
feat(core): allow async opcalls in snapshots (#10308) 2021-04-25 18:57:48 +02:00
Anssi Eteläniemi
c14bd77086
docs: updated link (#10345) 2021-04-24 09:45:40 -04:00
Aaron O'Mullan
dd156e886b
refactor(core): rename send() to opcall() (#10307)
I think it's a better fit since recv() was killed and opcall <> syscall (send/recv 
was too reminiscent of request/response and custom payloads)
2021-04-23 11:50:45 -04:00
Luca Casonato
52d316f143
chore: release crates (#10327)
Release crates for the cli 1.9.2 release.
2021-04-23 15:05:12 +02:00
Ryan Dahl
1f821dd5e5
chore: remove dead code (#10321) 2021-04-23 10:39:02 +10:00
Aaron O'Mullan
ff9ff4a377
refactor(core): simplify error handling (#10297)
- register builtin v8 errors in core.js so consumers don't have to
- remove complexity of error args handling (consumers must provide a 
  constructor with custom args, core simply provides msg arg)
2021-04-21 20:50:50 -04:00
Aaron O'Mullan
89bb774010
refactor(core): kill recv() and init() (#10299)
`init()` was previously needed to init the shared queue, but now that it's
gone `init()` only registers the async msg handler which is snapshot 
safe and constant since the op layer refactor.
2021-04-21 20:48:17 -04:00
Bartek Iwańczuk
3432833574
chore: release crates (#10269)
* Revert "tooling(bench_util): benching and profiling utilities (#10223)"

This reverts commit 733a000305.

* Upgrade notify
2021-04-21 00:15:39 +02:00
Yoshiya Hinosawa
8424647d22
chore: update copyright headers (#10243) 2021-04-20 14:27:36 +09:00
Aaron O'Mullan
167f017ca0
refactor(core): move SerializablePkg to serde_v8 (#10231) 2021-04-19 15:19:49 +02:00
Aaron O'Mullan
5b31d0f846
cleanup(core): simplify op_async(), drop need for try_dispatch_op() (#10240) 2021-04-18 15:29:06 +02:00