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

906 commits

Author SHA1 Message Date
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
Aaron O'Mullan
733a000305
tooling(bench_util): benching and profiling utilities (#10223) 2021-04-18 14:51:48 +02:00
Aaron O'Mullan
8fb1af1412
refactor(core): remove ZeroCopyBuf's dep on the bindings mod (#10232)
Also cleanup `bindings::deserialize()/decode()` so they 
use the `ZeroCopyBuf` abstraction rather than reimplementing it.

This cleanup will facilitate moving `ZeroCopyBuf` to `serde_v8` 
since it's now self contained and there are no other 
`get_backing_store_slice()` callers.
2021-04-18 14:39:26 +02:00
Ben Noordhuis
ad7f6d4510
fix(core): better "missing type" GothamState error (#10189)
Include the type name in the error message so you know what to look for.
2021-04-14 23:11:39 +02:00
Bartek Iwańczuk
1be65bbe4f
chore: release crates (#10164) 2021-04-13 18:22:48 +02:00
Casper Beyer
ec1fce58d9
fix(core): remove wasm-test-streaming flag (#10158) 2021-04-13 06:20:05 -04:00
Bert Belder
36f147364a
upgrade: rusty_v8 0.22.1 (V8 9.1.269.5) (#10159) 2021-04-13 08:47:24 +00:00
Bert Belder
b9f758d3ad upgrade: rusty_v8 0.22.0 (V8 9.1.269.2) (#10152) 2021-04-13 02:54:36 +02:00
Aaron O'Mullan
2eafbf2b98
perf(core/ops): avoid allocs when returning primitives (#10149) 2021-04-12 17:38:26 -04:00
Ben Noordhuis
73b7bd92e5 core: remove some unnecessary heap allocations 2021-04-12 22:03:32 +02:00
Ben Noordhuis
986513c080 core: let embedders plug in their own V8 platform
Fixes #9912.
2021-04-12 22:03:32 +02:00
Aaron O'Mullan
46b1c653c0
refactor(deno): remove concept of bin & json ops (#10145) 2021-04-12 15:55:05 -04:00
Aaron O'Mullan
bf99039ea9
feat: Add Deno.memoryUsage() (#9986) 2021-04-12 10:47:44 +02:00
Aaron O'Mullan
29eca72fea
core: avoid async op future reboxing to bundle PromiseId (#10123) 2021-04-11 07:05:43 +02:00
Aaron O'Mullan
0fd1fb9329
perf: use BTreeMap for ResourceTable (#10074) 2021-04-09 14:07:24 -04:00
Aaron O'Mullan
0b4cb29386
perf(core): use BTreeMap for GothamState (#10073)
This commit replaces GothamState's internal HashMap 
with a BTreeMap to improve performance.

OpState/GothamState keys by TypeId which is essentially 
an opaque u64. For small sets of integer keys BTreeMap 
outperforms HashMap mainly since it removes the hashing 
overhead and Eq/Comp on integer-like types is very cheap, 
it should also have a smaller memory footprint.

We only use ~30 unique types and thus ~30 unique keys to 
access OpState, so the keyset is small and immutable 
throughout the life of a JsRuntime, there's no meaningful 
churn in keys added/removed.
2021-04-09 19:49:11 +02:00
Nayeem Rahman
c86ee742a2
fix: async op error stacktraces (#10080)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2021-04-09 11:55:33 -04:00