diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/bench/http.rs | 16 | ||||
-rw-r--r-- | cli/build.rs | 6 | ||||
-rw-r--r-- | cli/lsp/tsc.rs | 4 | ||||
-rw-r--r-- | cli/ops/errors.rs | 4 | ||||
-rw-r--r-- | cli/ops/mod.rs | 12 | ||||
-rw-r--r-- | cli/ops/runtime_compiler.rs | 2 | ||||
-rw-r--r-- | cli/tests/unit/dispatch_test.ts (renamed from cli/tests/unit/dispatch_bin_test.ts) | 10 | ||||
-rw-r--r-- | cli/tests/unit/unit_tests.ts | 2 | ||||
-rw-r--r-- | cli/tsc.rs | 4 | ||||
-rw-r--r-- | cli/tsc/99_main_compiler.js | 30 | ||||
-rw-r--r-- | cli/tsc/compiler.d.ts | 2 |
11 files changed, 40 insertions, 52 deletions
diff --git a/cli/bench/http.rs b/cli/bench/http.rs index 690e26cf4..7fdab9844 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -21,9 +21,6 @@ pub(crate) fn benchmark( let hyper_hello_exe = target_path.join("test_server"); let hyper_hello_exe = hyper_hello_exe.to_str().unwrap(); - let core_http_bin_ops_exe = target_path.join("examples/http_bench_bin_ops"); - let core_http_bin_ops_exe = core_http_bin_ops_exe.to_str().unwrap(); - let core_http_json_ops_exe = target_path.join("examples/http_bench_json_ops"); let core_http_json_ops_exe = core_http_json_ops_exe.to_str().unwrap(); @@ -40,12 +37,8 @@ pub(crate) fn benchmark( "deno_proxy_tcp".to_string(), deno_tcp_proxy(deno_exe, hyper_hello_exe)?, ); - // "core_http_bin_ops" was once called "deno_core_single" - // "core_http_bin_ops" was once called "deno_core_http_bench" - res.insert( - "core_http_bin_ops".to_string(), - core_http_bin_ops(core_http_bin_ops_exe)?, - ); + // "core_http_json_ops" previously had a "bin op" counterpart called "core_http_bin_ops", + // which was previously also called "deno_core_http_bench", "deno_core_single" res.insert( "core_http_json_ops".to_string(), core_http_json_ops(core_http_json_ops_exe)?, @@ -246,11 +239,6 @@ fn deno_http_proxy( ) } -fn core_http_bin_ops(exe: &str) -> Result<HttpBenchmarkResult> { - println!("http_benchmark testing CORE http_bench_bin_ops"); - run(&[exe], 4544, None, None) -} - fn core_http_json_ops(exe: &str) -> Result<HttpBenchmarkResult> { println!("http_benchmark testing CORE http_bench_json_ops"); run(&[exe], 4544, None, None) diff --git a/cli/build.rs b/cli/build.rs index 1b1e913d2..930ba376f 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -1,7 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use deno_core::error::custom_error; -use deno_core::json_op_sync; +use deno_core::op_sync; use deno_core::serde::Deserialize; use deno_core::serde_json; use deno_core::serde_json::json; @@ -156,7 +156,7 @@ fn create_compiler_snapshot( }); js_runtime.register_op( "op_build_info", - json_op_sync(move |_state, _args: Value, _bufs| { + op_sync(move |_state, _args: Value, _bufs| { Ok(json!({ "buildSpecifier": build_specifier, "libs": build_libs, @@ -167,7 +167,7 @@ fn create_compiler_snapshot( // files, but a slightly different implementation at build time. js_runtime.register_op( "op_load", - json_op_sync(move |_state, args, _bufs| { + op_sync(move |_state, args, _bufs| { let v: LoadArgs = serde_json::from_value(args)?; // we need a basic file to send to tsc to warm it up. if v.specifier == build_specifier { diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 38b736349..aaea82421 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -18,7 +18,7 @@ use crate::tsc_config::TsConfig; use deno_core::error::anyhow; use deno_core::error::custom_error; use deno_core::error::AnyError; -use deno_core::json_op_sync; +use deno_core::op_sync; use deno_core::resolve_url; use deno_core::serde::de; use deno_core::serde::Deserialize; @@ -1480,7 +1480,7 @@ where V: de::DeserializeOwned, R: Serialize + 'static, { - json_op_sync(move |s, args, _bufs| { + op_sync(move |s, args, _bufs| { let state = s.borrow_mut::<State>(); op_fn(state, args) }) diff --git a/cli/ops/errors.rs b/cli/ops/errors.rs index 5dc4026f7..b3591b6f9 100644 --- a/cli/ops/errors.rs +++ b/cli/ops/errors.rs @@ -15,8 +15,8 @@ use std::collections::HashMap; use std::sync::Arc; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_apply_source_map", op_apply_source_map); - super::reg_json_sync(rt, "op_format_diagnostic", op_format_diagnostic); + super::reg_sync(rt, "op_apply_source_map", op_apply_source_map); + super::reg_sync(rt, "op_format_diagnostic", op_format_diagnostic); } #[derive(Deserialize)] diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs index 782b0a201..8caede260 100644 --- a/cli/ops/mod.rs +++ b/cli/ops/mod.rs @@ -4,8 +4,8 @@ pub mod errors; pub mod runtime_compiler; use deno_core::error::AnyError; -use deno_core::json_op_async; -use deno_core::json_op_sync; +use deno_core::op_async; +use deno_core::op_sync; use deno_core::serde_json::Value; use deno_core::JsRuntime; use deno_core::OpState; @@ -15,18 +15,18 @@ use std::cell::RefCell; use std::future::Future; use std::rc::Rc; -pub fn reg_json_async<F, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F) +pub fn reg_async<F, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F) where F: Fn(Rc<RefCell<OpState>>, Value, Option<ZeroCopyBuf>) -> R + 'static, R: Future<Output = Result<Value, AnyError>> + 'static, { - rt.register_op(name, metrics_op(name, json_op_async(op_fn))); + rt.register_op(name, metrics_op(name, op_async(op_fn))); } -pub fn reg_json_sync<F>(rt: &mut JsRuntime, name: &'static str, op_fn: F) +pub fn reg_sync<F>(rt: &mut JsRuntime, name: &'static str, op_fn: F) where F: Fn(&mut OpState, Value, Option<ZeroCopyBuf>) -> Result<Value, AnyError> + 'static, { - rt.register_op(name, metrics_op(name, json_op_sync(op_fn))); + rt.register_op(name, metrics_op(name, op_sync(op_fn))); } diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs index acd307f2f..dc9cd2163 100644 --- a/cli/ops/runtime_compiler.rs +++ b/cli/ops/runtime_compiler.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use std::sync::Mutex; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_async(rt, "op_emit", op_emit); + super::reg_async(rt, "op_emit", op_emit); } #[derive(Debug, Deserialize)] diff --git a/cli/tests/unit/dispatch_bin_test.ts b/cli/tests/unit/dispatch_test.ts index 01f29d0bc..6805d1af7 100644 --- a/cli/tests/unit/dispatch_bin_test.ts +++ b/cli/tests/unit/dispatch_test.ts @@ -9,7 +9,7 @@ unitTest(async function sendAsyncStackTrace() { } catch (error) { const s = error.stack.toString(); console.log(s); - assertStringIncludes(s, "dispatch_bin_test.ts"); + assertStringIncludes(s, "dispatch_test.ts"); assertStringIncludes(s, "read"); } }); @@ -21,10 +21,10 @@ declare global { } } -unitTest(async function binOpsAsyncBadResource(): Promise<void> { +unitTest(async function opsAsyncBadResource(): Promise<void> { try { const nonExistingRid = 9999; - await Deno.core.binOpAsync( + await Deno.core.opAsync( "op_read_async", nonExistingRid, new Uint8Array(0), @@ -36,10 +36,10 @@ unitTest(async function binOpsAsyncBadResource(): Promise<void> { } }); -unitTest(function binOpsSyncBadResource(): void { +unitTest(function opsSyncBadResource(): void { try { const nonExistingRid = 9999; - Deno.core.binOpSync("op_read_sync", nonExistingRid, new Uint8Array(0)); + Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0)); } catch (e) { if (!(e instanceof Deno.errors.BadResource)) { throw e; diff --git a/cli/tests/unit/unit_tests.ts b/cli/tests/unit/unit_tests.ts index 0dcbfe80b..ebf87651d 100644 --- a/cli/tests/unit/unit_tests.ts +++ b/cli/tests/unit/unit_tests.ts @@ -15,7 +15,7 @@ import "./console_test.ts"; import "./copy_file_test.ts"; import "./custom_event_test.ts"; import "./dir_test.ts"; -import "./dispatch_bin_test.ts"; +import "./dispatch_test.ts"; import "./error_stack_test.ts"; import "./event_test.ts"; import "./event_target_test.ts"; diff --git a/cli/tsc.rs b/cli/tsc.rs index 834b0cc58..0fac29ce3 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -10,7 +10,7 @@ use deno_core::error::anyhow; use deno_core::error::bail; use deno_core::error::AnyError; use deno_core::error::Context; -use deno_core::json_op_sync; +use deno_core::op_sync; use deno_core::resolve_url_or_path; use deno_core::serde::Deserialize; use deno_core::serde_json; @@ -227,7 +227,7 @@ fn op<F>(op_fn: F) -> Box<OpFn> where F: Fn(&mut State, Value) -> Result<Value, AnyError> + 'static, { - json_op_sync(move |s, args, _bufs| { + op_sync(move |s, args, _bufs| { let state = s.borrow_mut::<State>(); op_fn(state, args) }) diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 9396ba4ad..dc2b59533 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -200,7 +200,7 @@ delete Object.prototype.__proto__; debug( `snapshot.getText(${start}, ${end}) specifier: ${specifier} version: ${version}`, ); - return core.jsonOpSync("op_get_text", { specifier, version, start, end }); + return core.opSync("op_get_text", { specifier, version, start, end }); } /** * @returns {number} @@ -208,7 +208,7 @@ delete Object.prototype.__proto__; getLength() { const { specifier, version } = this; debug(`snapshot.getLength() specifier: ${specifier} version: ${version}`); - return core.jsonOpSync("op_get_length", { specifier, version }); + return core.opSync("op_get_length", { specifier, version }); } /** * @param {ScriptSnapshot} oldSnapshot @@ -221,7 +221,7 @@ delete Object.prototype.__proto__; debug( `snapshot.getLength() specifier: ${specifier} oldVersion: ${oldVersion} version: ${version}`, ); - return core.jsonOpSync( + return core.opSync( "op_get_change_range", { specifier, oldLength, oldVersion, version }, ); @@ -229,7 +229,7 @@ delete Object.prototype.__proto__; dispose() { const { specifier, version } = this; debug(`snapshot.dispose() specifier: ${specifier} version: ${version}`); - core.jsonOpSync("op_dispose", { specifier, version }); + core.opSync("op_dispose", { specifier, version }); } } @@ -250,7 +250,7 @@ delete Object.prototype.__proto__; }, readFile(specifier) { debug(`host.readFile("${specifier}")`); - return core.jsonOpSync("op_load", { specifier }).data; + return core.opSync("op_load", { specifier }).data; }, getSourceFile( specifier, @@ -272,7 +272,7 @@ delete Object.prototype.__proto__; specifier = normalizedToOriginalMap.get(specifier) ?? specifier; /** @type {{ data: string; hash?: string; scriptKind: ts.ScriptKind }} */ - const { data, hash, scriptKind } = core.jsonOpSync( + const { data, hash, scriptKind } = core.opSync( "op_load", { specifier }, ); @@ -304,7 +304,7 @@ delete Object.prototype.__proto__; if (sourceFiles) { maybeSpecifiers = sourceFiles.map((sf) => sf.moduleName); } - return core.jsonOpSync( + return core.opSync( "op_emit", { maybeSpecifiers, fileName, data }, ); @@ -326,7 +326,7 @@ delete Object.prototype.__proto__; debug(` base: ${base}`); debug(` specifiers: ${specifiers.join(", ")}`); /** @type {Array<[string, ts.Extension] | undefined>} */ - const resolved = core.jsonOpSync("op_resolve", { + const resolved = core.opSync("op_resolve", { specifiers, base, }); @@ -349,7 +349,7 @@ delete Object.prototype.__proto__; } }, createHash(data) { - return core.jsonOpSync("op_create_hash", { data }).hash; + return core.opSync("op_create_hash", { data }).hash; }, // LanguageServiceHost @@ -359,7 +359,7 @@ delete Object.prototype.__proto__; }, getScriptFileNames() { debug("host.getScriptFileNames()"); - return core.jsonOpSync("op_script_names", undefined); + return core.opSync("op_script_names", undefined); }, getScriptVersion(specifier) { debug(`host.getScriptVersion("${specifier}")`); @@ -367,7 +367,7 @@ delete Object.prototype.__proto__; if (sourceFile) { return sourceFile.version ?? "1"; } - return core.jsonOpSync("op_script_version", { specifier }); + return core.opSync("op_script_version", { specifier }); }, getScriptSnapshot(specifier) { debug(`host.getScriptSnapshot("${specifier}")`); @@ -386,7 +386,7 @@ delete Object.prototype.__proto__; }; } /** @type {string | undefined} */ - const version = core.jsonOpSync("op_script_version", { specifier }); + const version = core.opSync("op_script_version", { specifier }); if (version != null) { return new ScriptSnapshot(specifier, version); } @@ -505,7 +505,7 @@ delete Object.prototype.__proto__; ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code)); performanceProgram({ program }); - core.jsonOpSync("op_respond", { + core.opSync("op_respond", { diagnostics: fromTypeScriptDiagnostic(diagnostics), stats: performanceEnd(), }); @@ -517,7 +517,7 @@ delete Object.prototype.__proto__; * @param {any} data */ function respond(id, data = null) { - core.jsonOpSync("op_respond", { id, data }); + core.opSync("op_respond", { id, data }); } /** @@ -767,7 +767,7 @@ delete Object.prototype.__proto__; // A build time only op that provides some setup information that is used to // ensure the snapshot is setup properly. /** @type {{ buildSpecifier: string; libs: string[] }} */ - const { buildSpecifier, libs } = core.jsonOpSync("op_build_info", {}); + const { buildSpecifier, libs } = core.opSync("op_build_info", {}); for (const lib of libs) { const specifier = `lib.${lib}.d.ts`; // we are using internal APIs here to "inject" our custom libraries into diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts index ec82af1e2..0b1f5e4de 100644 --- a/cli/tsc/compiler.d.ts +++ b/cli/tsc/compiler.d.ts @@ -34,7 +34,7 @@ declare global { interface DenoCore { // deno-lint-ignore no-explicit-any - jsonOpSync<T>(name: string, params: T): any; + opSync<T>(name: string, params: T): any; ops(): void; print(msg: string, code?: number): void; registerErrorClass( |