summaryrefslogtreecommitdiff
path: root/core/examples
AgeCommit message (Collapse)Author
2021-11-22core(examples): Deserialize the result of execute_script (#12806)Giacomo Rizzi
Example of transforming execute_script response to a serde_json::Value Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-11-16refactor: re-export anyhow from deno_core (#12777)Ryan Dahl
2021-11-09feat(core): streams (#12596)Aaron O'Mullan
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-02chore: update to Rust edition 2021 (#12578)Bartek Iwańczuk
2021-10-05chore: various op cleanup (#12329)Leo K
2021-08-31feat(core): facilitate op-disabling middleware (#11858)Aaron O'Mullan
* 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-15refactor(ops): return BadResource errors in ResourceTable calls (#11710)Aaron O'Mullan
* 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-06-22refactor: unify JavaScript script execution method (#11043)Bartek Iwańczuk
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-05-26refactor: move JsRuntimeInspector to deno_core (#10763)Bartek Iwańczuk
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-15cleanup(core/example/hello_world): use Deno.core.print instead of new op ↵Aaron O'Mullan
(#10645)
2021-05-08cleanup(ops): remove unused ZeroCopyBuf arg-types (#10530)Aaron O'Mullan
2021-05-06refactor(ops): replace `ZeroCopyBuf` arg by 2nd generic deserializable arg ↵Aaron O'Mullan
(#10448)
2021-04-25refactor(core): move op cache sync responsibility to rust space (#10340)Aaron O'Mullan
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-23refactor(core): rename send() to opcall() (#10307)Aaron O'Mullan
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-21refactor(core): simplify error handling (#10297)Aaron O'Mullan
- 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-12refactor(deno): remove concept of bin & json ops (#10145)Aaron O'Mullan
2021-04-08fix(core): error handling in examples (#9867)Inteon
2021-04-02refactor(ops): remove variadic buffers (#9944)Aaron O'Mullan
2021-03-31refactor: new optimized op-layer using serde_v8 (#9843)Aaron O'Mullan
- 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-26remove macro_use (#9884)Ryan Dahl
2021-03-20refactor: Move bin ops to deno_core and unify logic with json ops (#9457)Inteon
This commit moves implementation of bin ops to "deno_core" crates as well as unifying logic between bin ops and json ops to reuse as much code as possible (both in Rust and JavaScript).
2021-03-19chores: enforce type ResourceId across codebase (#9837)Divy Srivastava
2021-02-13refactor(core): Strongly typed deserialization of JSON ops (#9423)Jared Beller
This PR makes json_op_sync/async generic to all Deserialize/Serialize types instead of the loosely-typed serde_json::Value. Since serde_json::Value implements Deserialize/Serialize, very little existing code needs to be updated, however as json_op_sync/async are now generic, type inference is broken in some cases (see cli/build.rs:146). I've found this reduces a good bit of boilerplate, as seen in the updated deno_core examples. This change may also reduce serialization and deserialization overhead as serde has a better idea of what types it is working with. I am currently working on benchmarks to confirm this and I will update this PR with my findings.
2021-01-10update copyright to 2021 (#9081)Ryan Dahl
2020-12-22core: fix http_bench_json_ops, register Error (#8860)Ben Noordhuis
Fixes the following runtime error for me when benchmarking: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error: Unregistered error class: "Error" Connection reset by peer (os error 104) Classes of errors returned from ops should be registered via Deno.core.registerErrorClass(). at processResponse (deno:core/core.js:219:13) at Object.jsonOpAsync (deno:core/core.js:240:12) at async read (http_bench_json_ops.js:29:21) at async serve (http_bench_json_ops.js:45:19)', core/examples/http_bench_json_ops.rs:260:28
2020-12-16refactor: rewrite ops to use ResourceTable2 (#8512)Bartek Iwańczuk
This commit migrates all ops to use new resource table and "AsyncRefCell". Old implementation of resource table was completely removed and all code referencing it was updated to use new system.
2020-12-09core: add plumbing for canceling ops when closing a resource (#8661)Bert Belder
2020-11-25core: implement 'AsyncRefCell' and 'ResourceTable2' (#8273)Bert Belder
2020-10-11reland JsRuntime/Worker is not a Future (#7924)Bartek Iwańczuk
2020-10-10Fix 100% CPU idling problem by reverting #7672 (#7911)Ryan Dahl
* Revert "refactor: Worker is not a Future (#7895)" This reverts commit f4357f0ff9d39411f22504fcc20db6bd5dec6ddb. * Revert "refactor(core): JsRuntime is not a Future (#7855)" This reverts commit d8879feb8c832dbb38649551b1cb0730874f7be6. * Revert "fix(core): module execution with top level await (#7672)" This reverts commit c7c767782538243ded64742dca9b34d6af74d62d.
2020-10-07refactor(core): JsRuntime is not a Future (#7855)Bartek Iwańczuk
This commit rewrites deno_core::JsRuntime to not implement Future trait. Instead there are two separate methods: - JsRuntime::poll_event_loop() - does single tick of event loop - JsRuntime::run_event_loop() - runs event loop to completion
2020-10-07refactor: rename isolate to js_runtime (#7858)Bartek Iwańczuk
This commit renames occurrences of "isolate" variable name to "js_runtime". This was outstanding debt after renaming deno_core::CoreIsolate to JsRuntime.
2020-09-23Add example for deno_core (#7611)Valentin Anger
2020-09-22refactor(core): support error stack, remove js_check (#7629)Bartek Iwańczuk
This commit adds support for stack traces in "deno_core". Implementation of "Display" trait for "JsError" has been updated and in consequence "deno_core::js_check" became obsolete and removed.
2020-09-21chore: add copyright (#7593)tokiedokie
2020-09-15refactor: use the 'anyhow' crate instead of 'ErrBox' (#7476)Bert Belder
2020-09-11refactor(core): JsRuntime initialization (#7415)Bartek Iwańczuk
Removes: - "deno_core::StartupData" - "deno_core::Script" - "deno_core::OwnedScript" Changes to "JsRuntime": - remove "new_with_loader()" - remove "with_heap_limits()" - rename "IsolateOptions" to "RuntimeOptions" and make public - "JsRuntime::new()" takes "RuntimeOptions" as a single param
2020-09-10Use gotham-like state for ops (#7385)Ryan Dahl
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-06refactor(core): rename CoreIsolate to JsRuntime (#7373)Bartek Iwańczuk
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-06Move JSON ops to deno_core (#7336)Bert Belder
2020-08-21Split core http benchmark into 'bin_ops' and 'json_ops' variants (#7147)Bert Belder
2020-08-21Convert the remaining http_bench ops to json ops (#7143)Bert Belder
2020-08-20First pass at json ops in core (#7033)Ryan Dahl
Adds Deno.core.jsonOpSync and Deno.core.jsonOpAsync
2020-08-17Simplify deno_core_http_bench op state (#7038)Ryan Dahl
Removes unnecessary wrappers around ResourceTable and CoreIsolate. Importantly: now uses the resource table inside CoreIsolateState rather than a different one. Removes derive_deref dependency
2020-07-14Use dprint for internal formatting (#6682)David Sherret
2020-07-08BREAKING(core): Remove control slice from ops (#6048)Valentin Anger
2020-06-01feat(core): Ops can take several zero copy buffers (#4788)Valentin Anger
2020-05-29refactor: Split isolate and state using safe get_slot() (#5929)Ryan Dahl
2020-04-23Rename deno_core::Isolate to deno_core::CoreIsolate (#4851)Ryan Dahl
2020-04-19Modify op dispatcher to include &mut Isolate argument (#4821)Ryan Dahl
- Removes unnecessary RwLock and Rc around the op registry table - Preparation to move resource_table to deno_core::Isolate. - Towards #3453, #4222