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

166 commits

Author SHA1 Message Date
Aaron O'Mullan
895e474295
cleanup(core): recursive get & ensure helpers (#13972) 2022-03-16 09:04:38 +01:00
Aaron O'Mullan
bb53135ed8
cleanup(core): OpPair => OpDecl (#13952) 2022-03-15 23:43:17 +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
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
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
Divy Srivastava
6de53b631f
refactor: use once_cell instead of lazy_static (#13135) 2021-12-18 16:14:42 -05: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
34f05f673e
fix(core): improve error on invalid op id (#13056) 2021-12-12 17:11:41 +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
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
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
Yoshiya Hinosawa
8e010b6844
feat(compat): add .code to dyn import error (#12633) 2021-11-08 16:02:40 +09: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
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
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
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
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
Aaron O'Mullan
ea7a63cd5a
refactor(core): split opcall into sync/async (#12312) 2021-10-04 12:34:53 +02:00
Aaron O'Mullan
26de516558
feat(core): implement Deno.core.isProxy() (#12288) 2021-10-01 20:25:33 +02:00
Andreu Botella
cdb252af0a
feat: support serializing WebAssembly.Module objects (#12140) 2021-09-29 10:47:24 +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
Luca Casonato
5d814a4c24
feat: ArrayBuffer in structured clone transfer (#11840) 2021-08-25 13:48:53 +02: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
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
Yusuke Tanaka
8f00b5542c
chore: upgrade Rust to 1.54.0 (#11554) 2021-07-30 15:03:41 +02:00
Aaron O'Mullan
01cf8aab9f
perf(core): avoid extra alloc in Deno.core.encode() (#11323) 2021-07-08 17:57:57 +02: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
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
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
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
Luca Casonato
22e7b0f585
fix: MessagePort in message for postMessage transfers (#11103) 2021-06-26 11:17:05 +02:00
Yusuke Tanaka
8031644e65
chore: upgrade Rust to 1.53.0 (#11021) 2021-06-17 15:56:30 -04: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
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
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
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
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
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
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
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
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
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
19d0e6b671
perf(serde_v8): introduce Serializable boxable object (#9983) 2021-04-04 01:17:02 +02:00
Aaron O'Mullan
fec1b2a5a4
refactor: new optimized op-layer using serde_v8 (#9843)
- Improves op performance.
- Handle op-metadata (errors, promise IDs) explicitly in the op-layer vs
  per op-encoding (aka: out-of-payload).
- Remove shared queue & custom "asyncHandlers", all async values are
  returned in batches via js_recv_cb.
- The op-layer should be thought of as simple function calls with little
  indirection or translation besides the conceptually straightforward
  serde_v8 bijections.
- Preserve concepts of json/bin/min as semantic groups of their
  inputs/outputs instead of their op-encoding strategy, preserving these
  groups will also facilitate partial transitions over to v8 Fast API for the
  "min" and "bin" groups
2021-03-31 10:37:38 -04:00
Ryan Dahl
f46e39c5c5
remove macro_use (#9884) 2021-03-26 12:34:25 -04:00
Aaron O'Mullan
505db5da2c
refactor(core): simplify heapStats() by using serde_v8 (#9901) 2021-03-26 09:09:22 -04:00
Aaron O'Mullan
3d2e05dc7b
Introduce serde_v8 (#9722) 2021-03-25 22:36:46 -04:00
Aaron O'Mullan
876f075dde
feat(core): Deno.core.heapStats() (#9659)
This commit implements "Deno.core.heapStats()" function 
that allows to programatically measure isolate heap-usage.
2021-03-23 15:33:06 +01:00
Andrew Mitchell
c00872c0c0
fix(core): don't panic on invalid arguments for Deno.core.print (#9834) 2021-03-21 08:52:28 -04:00
Bartek Iwańczuk
dc3683c7a4
refactor(core): cleanup module implementation (#9580)
* remove "ModuleNameMap", instead define that map inline inside "Modules" struct
* remove "dyn_import_id" argument from "mod_instantiate"
* rename "Modules" struct to "ModuleMap"
* rename "JsRuntime::modules" to "JsRuntime::module_map"
2021-02-23 15:22:55 +01:00
Inteon
dccf5e0c5c
refactor(core): Allow multiple overflown responses in single poll (#9433)
This commit rewrites "JsRuntime::poll" function to fix a corner case that
might caused "overflown_response" to be overwritten by other overflown response.

The logic has been changed to allow returning multiple overflown response
alongside responses from shared queue.
2021-02-23 13:08:50 +01:00
Nayeem Rahman
14ec22e880
fix(core/bindings): Add stacks for dynamic import resolution errors (#9562) 2021-02-21 16:22:06 +01:00
Ryan Dahl
c7dabc99ee
Make ModuleSpecifier a type alias, not wrapper struct (#9531) 2021-02-17 13:47:18 -05:00
Inteon
e2a91190c3
feat: add structured cloning to Deno.core (#9458)
This commit adds two new "Deno.core" APIs:
- "Deno.core.serialize"
- "Deno.core.deserialize"

These APIs are used to provide structured cloning of values
and will be used for further web worker implementation.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-02-16 14:20:21 +01:00
Aaron O'Mullan
1afe6b48e0
refactor(core): Reduce verbosity of binding core functions (#9497) 2021-02-15 12:53:33 +01:00
Bartek Iwańczuk
a6723fafc5
upgrade: rusty_v8 0.17.0, v8 9.0.123 (#9413) 2021-02-05 22:25:02 +01:00
Ryan Dahl
9312d48e69
upgrade: rusty_v8 0.16.0, v8 8.9.255.3 (#9180) 2021-01-19 18:40:30 -08:00
Ryan Dahl
2b75a11559
update copyright to 2021 (#9081) 2021-01-10 21:59:07 -05:00
Luca Casonato
0d41e21b0e
fix: align encoding APIs to spec using WPT (#9004) 2021-01-05 19:50:40 +01:00
Kitson Kelly
e2858d0bbb
chore: clippy future cleanups (#8514) 2020-11-28 06:47:35 +11:00
Bartek Iwańczuk
ec7f1e399e
refactor(core): don't depend on get_identity_hash for modules (#8354)
This commit refactors "deno_core::Modules" structure to not depend on
"get_identity_hash" function to identify modules, but instead use default
hash implementation.
2020-11-21 16:23:35 +01:00
Bartek Iwańczuk
d4c8fa263d
refactor(core): don't depend on get_identity_hash for promises (#8352)
This commit changes how pending promise exceptions are stored
in JsRuntime by using global handle to promise instead of its
identity hash.
2020-11-11 23:11:40 +01:00
Yoshiya Hinosawa
e736d0f60f
fix(prompt): fix display of non-ASCII characters on Windows (#8199) 2020-11-03 01:15:29 +01:00
Bartek Iwańczuk
8d95bd15e1
refactor(core): remove Deno.core.formatError() (#8091)
With recent improvements to REPL implementation,
Deno.core.formatError() API is no longer needed.
2020-10-23 22:16:12 +02:00
Ryan Dahl
59888ff0b2
upgrade rusty_v8 (#8017) 2020-10-18 13:07:11 -04:00
Ryan Dahl
055dfe2ff4
Make JsRuntimeState private (#7484) 2020-09-14 23:49:12 -04:00
Bert Belder
f5b40c918c
refactor: use the 'anyhow' crate instead of 'ErrBox' (#7476) 2020-09-15 01:50:52 +02:00
Ryan Dahl
7c2e7c6608
Use gotham-like state for ops (#7385)
Provides a concrete state type that can be dynamically added. This is necessary for op crates.
* renames BasicState to OpState
* async ops take `Rc<RefCell<OpState>>`
* sync ops take `&mut OpState`
* removes `OpRegistry`, `OpRouter` traits
* `get_error_class_fn` moved to OpState
* ResourceTable moved to OpState
2020-09-10 09:57:45 -04:00
Bartek Iwańczuk
25053f92ff
fix(core): panic on big string allocation (#7395)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-09-09 20:52:11 +02:00
uki00a
ac455050ee
feat(console): print proxy details (#7139) 2020-09-08 16:06:26 +02:00
Bartek Iwańczuk
f57a2c1e85
refactor(core): rename CoreIsolate to JsRuntime (#7373)
deno_core/
- rename core_isolate.rs to runtime.rs
- rename CoreIsolate to JsRuntime
- rename JSError to JsError
- rename JSStackFrame to JsStackFrame

cli/
- update references from deno_core::CoreIsolate to deno_core::JsRuntime
- rename deno_core::JSError to deno_core::JsError
- rename fmt_errors::JSError to fmt_errors::JsError
2020-09-06 21:44:29 +02:00
Bartek Iwańczuk
803bdd37c7
refactor(core): merge CoreIsolate and EsIsolate (#7370) 2020-09-06 16:50:49 +02:00
Bert Belder
c821e8f2f1
Move JSON ops to deno_core (#7336) 2020-09-06 02:34:02 +02:00
Bert Belder
fd83df7cdb
Convert the remaining http_bench ops to json ops (#7143) 2020-08-21 13:11:04 +02:00
Bert Belder
faa64edaf4
Upgrade to rusty_v8 0.7.0 (#6801) 2020-07-19 01:47:45 +02:00
Valentin Anger
be7e0f2d49
BREAKING(core): Remove control slice from ops (#6048) 2020-07-08 11:23:50 -04:00
Bert Belder
e10d74a3d3
Upgrade to rusty_v8 0.4.2 / V8 8.5.216 (#6503) 2020-06-26 20:17:15 +02:00
Ryan Dahl
aa39dfc62f
upgrade: rusty_v8 0.5.0 (#6070) 2020-06-03 12:19:21 -04:00
Ryan Dahl
23dc9c13db
Fix REPL BorrowMutError panic (#6055) 2020-06-02 16:37:52 -04:00
Valentin Anger
becbb56b19
feat(core): Ops can take several zero copy buffers (#4788) 2020-06-01 14:20:47 -04:00
Ryan Dahl
d4b05dd89e
refactor: Split isolate and state using safe get_slot() (#5929) 2020-05-29 17:41:39 -04:00
Ryan Dahl
2610ceac20
tidy up deno_core modules (#5923) 2020-05-28 13:36:43 -04:00
Bartek Iwańczuk
d062ffc1ba
fix: source maps in inspector (#5223)
This commit fixes problems with source maps in Chrome Devtools
by substituting source map URL generated by TS compiler with
actual file URL pointing to DENO_DIR.

Dummy value of "source_map_url" has been removed from
"ScriptOrigin".

Also fixes lock file which used compiled source code to generate
lock hash; it now uses source code of the file that is
being compiled.
2020-05-11 23:48:36 +02:00
Bartek Iwańczuk
f7d1f82796
core: add id field to RecursiveModuleLoad (#4905)
This commit unifies handling of ids for main module/dynamic 
import loads in EsIsolate.
2020-04-26 19:00:10 +02:00
Ryan Dahl
d8711155ca
Rename deno_core::Isolate to deno_core::CoreIsolate (#4851) 2020-04-23 11:51:07 +02:00
Bert Belder
10a174834e
Upgrade to rusty_v8 v0.4.0 (#4856) 2020-04-23 03:35:52 +02:00
Michał Sabiniarz
30fdf6dc83
console: print promise details (#4524) 2020-03-30 19:01:19 -04:00
Bartek Iwańczuk
87d2ba42bf
perf: Optimize TextEncoder and TextDecoder (#4430)
* add tests for "Deno.core.encode" and "Deno.core.decode" for empty inputs
* use "Deno.core.encode" in "TextEncoder"
* use "Deno.core.decode" in "TextDecoder"
* remove "core_decode" and "core_encode" benchmarks
2020-03-19 21:31:56 +01:00
Kevin (Kun) "Kassimo" Qian
2f3de4b425
Simplify timer with macrotask callback (#4385) 2020-03-19 10:45:28 -04:00
Nikolai Vavilov
8c1c929034
fix: stack traces for modules imported via std/node's require (#4035) 2020-03-19 10:42:07 -04:00
Bartek Iwańczuk
dc6e0c3591
feat: Deno.core.{encode,decode}; standalone UTF-8 encoding/decoding (#4349)
This commits add two new methods to "Deno.core" namespace: "encode" and "decode".

Those methods are bound in Rust to provide a) fast b) generally available of encoding and decoding UTF-8 strings. 

Both methods are now used in "cli/js/dispatch_json.ts".
2020-03-15 15:31:55 +01:00