Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions changelog.d/8671-async-hooks-parity.md

This file was deleted.

2 changes: 0 additions & 2 deletions crates/perry-api-manifest/src/entries/part_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ pub(crate) const API_MANIFEST_PART_4: &[ApiEntry] = &[
method("http", "ref", true, Some("HttpServer")),
method("http", "unref", true, Some("HttpServer")),
method("http", "on", true, Some("IncomingMessage")),
method("http", "once", true, Some("IncomingMessage")),
method("http", "addListener", true, Some("IncomingMessage")),
method("http", "pause", true, Some("IncomingMessage")),
method("http", "resume", true, Some("IncomingMessage")),
Expand All @@ -857,7 +856,6 @@ pub(crate) const API_MANIFEST_PART_4: &[ApiEntry] = &[
// method, so the manifest-consistency drift guard requires a row
// here even though the test collapses class_filter variants.
method("http", "setTimeout", true, Some("ClientRequest")),
method("http", "once", true, Some("ClientRequest")),
method("http", "listenerCount", true, Some("ClientRequest")),
method("http", "setHeader", true, Some("ClientRequest")),
method("http", "getHeader", true, Some("ClientRequest")),
Expand Down
11 changes: 3 additions & 8 deletions crates/perry-codegen/src/expr/calls/crypto_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,13 @@ pub(crate) fn arm_crypto_prime(
unreachable!()
};
let first_box = lower_expr(ctx, &args[0])?;
let is_async = matches!(property, "generatePrime" | "checkPrime");
// The callback forms are `(value, callback)` or
// `(value, options, callback)`. Treating the second argument as options
// unconditionally accidentally routed the common two-argument form to
// the synchronous implementation and returned the generated value.
let options_box = if args.len() >= 2 && (!is_async || args.len() >= 3) {
let options_box = if args.len() >= 2 {
lower_expr(ctx, &args[1])?
} else {
double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED))
};
let callback_box = if is_async && args.len() >= 2 {
Some(lower_expr(ctx, &args[args.len().min(3) - 1])?)
let callback_box = if matches!(property, "generatePrime" | "checkPrime") && args.len() >= 3 {
Some(lower_expr(ctx, &args[2])?)
} else {
None
};
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-codegen/src/expr/env_clones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
let blk = ctx.block();
let raw = blk.call(
I64,
"js_ext_net_create_server",
"js_net_create_server",
&[(I64, &options_i64), (I64, &listener_i64)],
);
Ok(nanbox_pointer_inline(blk, &raw))
Expand Down
2 changes: 0 additions & 2 deletions crates/perry-codegen/src/expr/instance_misc1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
// Promise values are raw promise allocations, not ObjectHeader
// instances with a class_id field.
"Promise" => 0xFFFF0027u32,
"AsyncLocalStorage" => 0xFFFF0078u32,
"AsyncResource" => 0xFFFF0079u32,
// WHATWG fetch types. Like Blob/streams these are pointer-tagged
// small-int handles; the runtime resolves them via the stdlib
// fetch kind-probe (`res instanceof Response`, etc.).
Expand Down
3 changes: 1 addition & 2 deletions crates/perry-codegen/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ pub(crate) use write_barrier::{
emit_root_heap_word_store_on_block, emit_root_nanbox_store_on_block, emit_write_barrier,
emit_write_barrier_slot_generation_tested, emit_write_barrier_slot_on_block,
emit_write_barrier_slot_value_and_generation_tested, lower_array_super_init,
lower_event_emitter_async_resource_subclass_init, lower_event_emitter_subclass_init,
lower_node_stream_super_init, lower_stream_super_init,
lower_event_emitter_subclass_init, lower_node_stream_super_init, lower_stream_super_init,
};

// Issue #1098 phase 3: the `FnCtx` definition stays in this trunk, but its
Expand Down
9 changes: 0 additions & 9 deletions crates/perry-codegen/src/expr/property_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,15 +1376,6 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
if receiver_class_is_proven && is_net_native_method_value(&class_name, property) {
return lower_class_method_bind(ctx, object, property);
}
if receiver_class_is_proven
&& class_name == "AsyncResource"
&& matches!(
property.as_str(),
"asyncId" | "triggerAsyncId" | "emitDestroy" | "runInAsyncScope" | "bind"
)
{
return lower_runtime_property_get_by_name(ctx, object, property);
}
if class_has_computed_runtime_members(ctx, &class_name) {
return lower_runtime_property_get_by_name(ctx, object, property);
}
Expand Down
82 changes: 2 additions & 80 deletions crates/perry-codegen/src/expr/this_super_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use crate::nanbox::{double_literal, POINTER_MASK_I64};
use crate::types::{DOUBLE, I1, I32, I64, PTR};

use super::{
lower_array_super_init, lower_event_emitter_async_resource_subclass_init,
lower_event_emitter_subclass_init, lower_expr, lower_node_stream_super_init,
lower_stream_super_init, nanbox_pointer_inline, FnCtx,
lower_array_super_init, lower_event_emitter_subclass_init, lower_expr,
lower_node_stream_super_init, lower_stream_super_init, nanbox_pointer_inline, FnCtx,
};

/// Enter one derived constructor's `super()` binding scope.
Expand Down Expand Up @@ -827,83 +826,6 @@ pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
)?;
return Ok(double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)));
}
if parent_name.as_str() == "EventEmitterAsyncResource" {
let mut lowered = Vec::with_capacity(super_args.len());
for arg in super_args {
lowered.push(lower_expr(ctx, arg)?);
}
let options = lowered.first().cloned().unwrap_or_else(|| {
double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED))
});
let this_box = match ctx.this_stack.last().cloned() {
Some(slot) => ctx.block().load(DOUBLE, &slot),
None => double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)),
};
lower_event_emitter_async_resource_subclass_init(ctx, &this_box, &options);
bind_derived_this_after_super(ctx);
let current_class_name =
ctx.class_stack.last().cloned().unwrap_or_default();
crate::lower_call::apply_field_initializers_recursive(
ctx,
&current_class_name,
crate::lower_call::FieldInitMode::SelfOnly,
)?;
return Ok(double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)));
}
if parent_name.as_str() == "AsyncLocalStorage" {
for arg in super_args {
let _ = lower_expr(ctx, arg)?;
}
let this_box = match ctx.this_stack.last().cloned() {
Some(slot) => ctx.block().load(DOUBLE, &slot),
None => double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)),
};
ctx.block().call(
DOUBLE,
"js_async_local_storage_subclass_init",
&[(DOUBLE, &this_box)],
);
bind_derived_this_after_super(ctx);
let current_class_name =
ctx.class_stack.last().cloned().unwrap_or_default();
crate::lower_call::apply_field_initializers_recursive(
ctx,
&current_class_name,
crate::lower_call::FieldInitMode::SelfOnly,
)?;
return Ok(double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)));
}
if parent_name.as_str() == "AsyncResource" {
let undef = double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED));
let mut lowered = Vec::with_capacity(super_args.len());
for arg in super_args {
lowered.push(lower_expr(ctx, arg)?);
}
let type_value = lowered.first().cloned().unwrap_or_else(|| undef.clone());
let options = lowered.get(1).cloned().unwrap_or_else(|| undef.clone());
let this_box = match ctx.this_stack.last().cloned() {
Some(slot) => ctx.block().load(DOUBLE, &slot),
None => undef,
};
ctx.block().call(
DOUBLE,
"js_async_resource_subclass_init",
&[
(DOUBLE, &this_box),
(DOUBLE, &type_value),
(DOUBLE, &options),
],
);
bind_derived_this_after_super(ctx);
let current_class_name =
ctx.class_stack.last().cloned().unwrap_or_default();
crate::lower_call::apply_field_initializers_recursive(
ctx,
&current_class_name,
crate::lower_call::FieldInitMode::SelfOnly,
)?;
return Ok(double_literal(f64::from_bits(crate::nanbox::TAG_UNDEFINED)));
}
// `class X extends Request` / `extends Response`:
// `super(input, init)` allocates the underlying native
// Web-Fetch handle and stashes its id on `this` under
Expand Down
12 changes: 0 additions & 12 deletions crates/perry-codegen/src/expr/write_barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,15 +1081,3 @@ pub(crate) fn lower_event_emitter_subclass_init(ctx: &mut FnCtx<'_>, this_box: &
&[(DOUBLE, this_box)],
);
}

pub(crate) fn lower_event_emitter_async_resource_subclass_init(
ctx: &mut FnCtx<'_>,
this_box: &str,
options_box: &str,
) {
ctx.block().call(
DOUBLE,
"js_event_emitter_async_resource_subclass_init",
&[(DOUBLE, this_box), (DOUBLE, options_box)],
);
}
17 changes: 3 additions & 14 deletions crates/perry-codegen/src/ext_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ const FFI_REGISTRY: &[(&str, OwnerKind)] = &[
// import flip might not fire. Tagging here so the linker pulls
// libperry_ext_net.a in regardless.
("js_net_create_server", OwnerKind::WellKnown("net")),
("js_ext_net_create_server", OwnerKind::WellKnown("net")),
("js_ext_net_socket_connect", OwnerKind::WellKnown("net")),
("js_net_server_listen", OwnerKind::WellKnown("net")),
("js_net_server_close", OwnerKind::WellKnown("net")),
("js_net_server_address", OwnerKind::WellKnown("net")),
Expand Down Expand Up @@ -441,9 +439,6 @@ const FFI_REGISTRY: &[(&str, OwnerKind)] = &[
// program that doesn't otherwise import socket-side surface.
("js_net_socket_address", OwnerKind::WellKnown("net")),
("js_net_socket_once", OwnerKind::WellKnown("net")),
("js_ext_net_socket_once", OwnerKind::WellKnown("net")),
("js_ext_net_socket_on", OwnerKind::WellKnown("net")),
("js_ext_tls_connect", OwnerKind::WellKnown("net")),
("js_net_socket_remove_listener", OwnerKind::WellKnown("net")),
("js_net_socket_remove_all_listeners", OwnerKind::WellKnown("net")),
("js_net_socket_listener_count", OwnerKind::WellKnown("net")),
Expand Down Expand Up @@ -544,15 +539,11 @@ const FFI_REGISTRY: &[(&str, OwnerKind)] = &[
// `external-events-construct` feature (see optimized_libs.rs), which the
// default-import dynamic-`new` path relies on (#4995).
//
// EventEmitterAsyncResource lives alongside the external EventEmitter so
// optimized node:events builds retain one coherent handle registry.
// Only the core surface defined by perry-ext-events is listed; the
// `js_event_emitter_async_resource_*` helpers live in perry-stdlib and
// are out of scope here (`EventEmitterAsyncResource` is node:events-only).
("js_event_emitter_new", OwnerKind::WellKnown("events")),
("js_event_emitter_new_with_options", OwnerKind::WellKnown("events")),
("js_event_emitter_async_resource_new", OwnerKind::WellKnown("events")),
("js_event_emitter_async_resource_async_id", OwnerKind::WellKnown("events")),
("js_event_emitter_async_resource_trigger_async_id", OwnerKind::WellKnown("events")),
("js_event_emitter_async_resource_async_resource", OwnerKind::WellKnown("events")),
("js_event_emitter_async_resource_emit_destroy", OwnerKind::WellKnown("events")),
("js_event_emitter_on", OwnerKind::WellKnown("events")),
("js_event_emitter_once", OwnerKind::WellKnown("events")),
("js_event_emitter_prepend_listener", OwnerKind::WellKnown("events")),
Expand All @@ -568,8 +559,6 @@ const FFI_REGISTRY: &[(&str, OwnerKind)] = &[
("js_event_emitter_set_max_listeners", OwnerKind::WellKnown("events")),
("js_event_emitter_get_max_listeners", OwnerKind::WellKnown("events")),
("js_event_emitter_domain_value", OwnerKind::WellKnown("events")),
("js_ext_net_socket_write3", OwnerKind::WellKnown("net")),
("js_ext_net_socket_end3", OwnerKind::WellKnown("net")),

// ── mysql2 (perry-ext-mysql2) ────────────────────────────────────
// Normally `import "mysql2"` flips the `[bindings.mysql2]` well-known
Expand Down
26 changes: 0 additions & 26 deletions crates/perry-codegen/src/lower_call/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,32 +133,6 @@ pub(super) fn lower_builtin_new<'a>(
}
}
match class_name {
"Resolver"
if import_src.is_some_and(|source| {
matches!(
source.strip_prefix("node:").unwrap_or(source),
"dns" | "dns/promises"
)
}) =>
{
// `new Resolver()` is a constructor expression, so it bypasses
// the native-module call table used by `dns.Resolver()`. Route it
// to the same runtime constructor and preserve evaluation of any
// superfluous arguments.
for arg in args {
let _ = lower_expr(ctx, arg)?;
}
let runtime = if import_src.is_some_and(|source| {
source.strip_prefix("node:").unwrap_or(source) == "dns/promises"
}) {
"js_dns_promises_resolver_new"
} else {
"js_dns_resolver_new"
};
ctx.pending_declares
.push((runtime.to_string(), DOUBLE, vec![I64]));
Ok(Some(ctx.block().call(DOUBLE, runtime, &[(I64, "0")])))
}
"Utf8Stream"
if import_src
.map(|source| source.strip_prefix("node:").unwrap_or(source) == "fs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ pub(super) const HTTP_CLIENT_ROWS: &[NativeModSig] = &[
args: &[NA_STR, NA_PTR],
ret: NR_PTR,
},
NativeModSig {
module: "http",
has_receiver: true,
method: "once",
class_filter: Some("ClientRequest"),
runtime: "js_http_on",
args: &[NA_STR, NA_PTR],
ret: NR_PTR,
},
NativeModSig {
module: "http",
has_receiver: true,
Expand Down
13 changes: 0 additions & 13 deletions crates/perry-codegen/src/lower_call/native_table/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,6 @@ pub(super) const HTTP_SERVER_ROWS: &[NativeModSig] = &[
args: &[NA_STR, NA_PTR],
ret: NR_F64,
},
// IncomingMessage events in the async-hooks provider probes are terminal
// (`end`/`error`), so the shared registration path also provides the
// observable one-shot behaviour while ensuring client responses are
// cross-routed into perry-ext-http's listener registry.
NativeModSig {
module: "http",
has_receiver: true,
method: "once",
class_filter: Some("IncomingMessage"),
runtime: "js_node_http_im_on",
args: &[NA_STR, NA_PTR],
ret: NR_F64,
},
NativeModSig {
module: "http",
has_receiver: true,
Expand Down
Loading
Loading