From 043fee48fd72fbce2357e93431753db5b086cffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 7 Feb 2024 02:16:08 +0100 Subject: [PATCH] chore: upgrade deno_core to 0.259.0 (#22311) This update brings number of ops available to user code down to 45. --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- cli/js/40_test.js | 4 ++-- cli/tests/unit/ops_test.ts | 2 +- cli/tests/unit/text_encoding_test.ts | 28 ++-------------------------- cli/tools/test/mod.rs | 2 +- ext/fs/30_fs.js | 8 ++++---- ext/net/01_net.js | 4 ++-- ext/web/lib.rs | 16 ---------------- runtime/js/99_main.js | 6 ------ 10 files changed, 19 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebf28430e9..345323b583 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1196,9 +1196,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.258.0" +version = "0.259.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f200cdc161745281e4ec56e3b0e563058d2cc50a824ac901823ed0720b481619" +checksum = "f62dc88f7f56fa48906e37fbea089128da7405e09b0f99bcd488f4f13f20c491" dependencies = [ "anyhow", "bit-set", @@ -1646,9 +1646,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.134.0" +version = "0.135.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe122714b90abf065a746f452f69beae37324436a1541118ca4078b9b9d2b260" +checksum = "5f53a36c6138b760bda9c032ab9251a8f83286da4ef7724de313d1621931263e" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -5408,9 +5408,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.167.0" +version = "0.168.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b38f6831f968e3813a480ca5a236c9a0972d9dcf0bb241f193ba524e4cf4e" +checksum = "a64d740e74bee1f5bc3f4fe49aab63b08ee6dcc606e9321dec71628ba80e4293" dependencies = [ "bytes", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 1771ec18bd..e081f8c670 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "0.32.0", features = ["transpiling"] } -deno_core = { version = "0.258.0" } +deno_core = { version = "0.259.0" } deno_bench_util = { version = "0.130.0", path = "./bench_util" } deno_lockfile = "0.18.0" diff --git a/cli/js/40_test.js b/cli/js/40_test.js index f18cccd988..b9735fc01b 100644 --- a/cli/js/40_test.js +++ b/cli/js/40_test.js @@ -172,7 +172,7 @@ function assertOps(fn) { opIdHostRecvCtrl, ); } - const preTraces = new Map(core.opCallTraces); + const preTraces = core.getAllOpCallTraces(); let postTraces; let report = null; @@ -195,7 +195,7 @@ function assertOps(fn) { opIdHostRecvCtrl, ); } - postTraces = new Map(core.opCallTraces); + postTraces = core.getAllOpCallTraces(); if (res === 3) { report = op_test_op_sanitizer_report(desc.id); } diff --git a/cli/tests/unit/ops_test.ts b/cli/tests/unit/ops_test.ts index 1b7377dc5a..ae225c78da 100644 --- a/cli/tests/unit/ops_test.ts +++ b/cli/tests/unit/ops_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -const EXPECTED_OP_COUNT = 49; +const EXPECTED_OP_COUNT = 45; Deno.test(function checkExposedOps() { // @ts-ignore TS doesn't allow to index with symbol diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 24dd35aa37..719e5907e4 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -270,7 +270,7 @@ Deno.test(function textEncoderShouldCoerceToString() { Deno.test(function binaryEncode() { // @ts-ignore: Deno[Deno.internal].core allowed - const ops = Deno[Deno.internal].core.ops; + const core = Deno[Deno.internal].core; function asBinaryString(bytes: Uint8Array): string { return Array.from(bytes).map( (v: number) => String.fromCodePoint(v), @@ -281,30 +281,6 @@ Deno.test(function binaryEncode() { const chars: string[] = Array.from(binaryString); return chars.map((v: string): number | undefined => v.codePointAt(0)); } - - // invalid utf-8 code points - const invalid = new Uint8Array([0xC0]); - assertEquals( - ops.op_encode_binary_string(invalid), - asBinaryString(invalid), - ); - - const invalid2 = new Uint8Array([0xC1]); - assertEquals( - ops.op_encode_binary_string(invalid2), - asBinaryString(invalid2), - ); - - for (let i = 0, j = 255; i <= 255; i++, j--) { - const bytes = new Uint8Array([i, j]); - const binaryString = ops.op_encode_binary_string(bytes); - assertEquals( - binaryString, - asBinaryString(bytes), - ); - assertEquals(Array.from(bytes), decodeBinary(binaryString)); - } - const inputs = [ "σ😀", "Кириллица is Cyrillic", @@ -315,7 +291,7 @@ Deno.test(function binaryEncode() { ]; for (const input of inputs) { const bytes = new TextEncoder().encode(input); - const binaryString = ops.op_encode_binary_string(bytes); + const binaryString = core.encodeBinaryString(bytes); assertEquals( binaryString, asBinaryString(bytes), diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 3095e727d8..332bfa8c81 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -496,7 +496,7 @@ async fn test_specifier_inner( if options.trace_ops { worker.execute_script_static( located_script_name!(), - "Deno[Deno.internal].core.enableOpCallTracing();", + "Deno[Deno.internal].core.setOpCallTracingEnabled(true);", )?; } diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index aa7f345e50..46358c42ae 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -4,9 +4,9 @@ import { core, internals, primordials } from "ext:core/mod.js"; const { isDate, internalRidSymbol, + createCancelHandle, } = core; import { - op_cancel_handle, op_fs_chdir, op_fs_chmod_async, op_fs_chmod_sync, @@ -823,7 +823,7 @@ async function readFile(path, options) { let abortHandler; if (options?.signal) { options.signal.throwIfAborted(); - cancelRid = op_cancel_handle(); + cancelRid = createCancelHandle(); abortHandler = () => core.tryClose(cancelRid); options.signal[abortSignal.add](abortHandler); } @@ -853,7 +853,7 @@ async function readTextFile(path, options) { let abortHandler; if (options?.signal) { options.signal.throwIfAborted(); - cancelRid = op_cancel_handle(); + cancelRid = createCancelHandle(); abortHandler = () => core.tryClose(cancelRid); options.signal[abortSignal.add](abortHandler); } @@ -899,7 +899,7 @@ async function writeFile( let abortHandler; if (options.signal) { options.signal.throwIfAborted(); - cancelRid = op_cancel_handle(); + cancelRid = createCancelHandle(); abortHandler = () => core.tryClose(cancelRid); options.signal[abortSignal.add](abortHandler); } diff --git a/ext/net/01_net.js b/ext/net/01_net.js index 1523f5aa5f..50f4971f5e 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -5,9 +5,9 @@ const { BadResourcePrototype, InterruptedPrototype, internalRidSymbol, + createCancelHandle, } = core; import { - op_cancel_handle, op_dns_resolve, op_net_accept_tcp, op_net_accept_unix, @@ -67,7 +67,7 @@ async function resolveDns(query, recordType, options) { let abortHandler; if (options?.signal) { options.signal.throwIfAborted(); - cancelRid = op_cancel_handle(); + cancelRid = createCancelHandle(); abortHandler = () => core.tryClose(cancelRid); options.signal[abortSignal.add](abortHandler); } diff --git a/ext/web/lib.rs b/ext/web/lib.rs index acac78f562..3defbd74e4 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -14,7 +14,6 @@ use deno_core::op2; use deno_core::url::Url; use deno_core::v8; use deno_core::ByteString; -use deno_core::CancelHandle; use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; @@ -71,7 +70,6 @@ deno_core::extension!(deno_web, op_encoding_new_decoder, op_encoding_decode, op_encoding_encode_into, - op_encode_binary_string, op_blob_create_part, op_blob_slice_part, op_blob_read_part, @@ -87,7 +85,6 @@ deno_core::extension!(deno_web, compression::op_compression_finish, op_now

, op_timer_handle, - op_cancel_handle, op_sleep, op_transfer_arraybuffer, stream_resource::op_readable_stream_resource_allocate, @@ -439,19 +436,6 @@ fn op_transfer_arraybuffer<'a>( Ok(v8::ArrayBuffer::with_backing_store(scope, &bs)) } -#[op2] -#[serde] -fn op_encode_binary_string(#[buffer] s: &[u8]) -> ByteString { - ByteString::from(s) -} - -/// Creates a [`CancelHandle`] resource that can be used to cancel invocations of certain ops. -#[op2(fast)] -#[smi] -pub fn op_cancel_handle(state: &mut OpState) -> u32 { - state.resource_table.add(CancelHandle::new()) -} - pub fn get_declaration() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts") } diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index f956db67ca..191d123b98 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -622,12 +622,6 @@ const NOT_IMPORTED_OPS = [ // TODO(bartlomieju): used in a regression test, but probably not needed // anymore if ops are not user accessible. "op_spawn_child", - - // TODO(bartlomieju): can be removed after the `deno_core` upgrade. - "op_encode_binary_string", - "op_format_file_name", - "op_apply_source_map", - "op_apply_source_map_filename", ]; function removeImportedOps() {