Skip to content

33 codegen↔runtime call-signature mismatches on native targets (found by runtime_abi_check.py) #11408

Closed

Description

@proggeramlug

scripts/runtime_abi_check.py (#11398) compares every runtime declaration, call site, pending declare and NativeModSig row in perry-codegen against the runtime's real #[no_mangle] extern "C" signature. Besides the wasm32 worklist, it reports 33 mismatches that are wrong on native targets today:

  • class (float vs int/pointer): the value travels in the wrong register class (xmm vs gpr), so the callee reads garbage.
  • width: upper bits are undefined.
  • arity: the callee reads unset argument registers.

Hand-verified examples:

  • js_typed_feedback_array_set_index_or_string (perry-codegen/src/expr/index_set.rs:912) passes 4 args; the runtime reads a 5th, strict: i32.
  • js_is_truthy is declared returning i64 at lower_call/native/native_ui_appshell_branch.rs:159, but it returns i32.
  • The js_lodash_pad*/trim*/random declarations are one parameter short.
  • js_json_get_bool / js_http_request_has_header / js_cheerio_selection_is are declared double over a bool return.

Caveat for native_table arity rows: the dispatcher pads to the table's arity and appends extra JS arguments, so such a row is a live bug only for calls that omit the runtime's extra parameters.

class

  • js_cheerio_selection_has_class (native_table): return: codegen f64, runtime bool — perry-codegen/src/lower_call/native_table/media.rs:333 vs perry-stdlib/src/cheerio.rs:318
  • js_cheerio_selection_is (declare): return: codegen f64, runtime bool — perry-codegen/src/runtime_decls/stdlib_ffi/third_party.rs:296 vs perry-stdlib/src/cheerio.rs:346
  • js_http_agent_free_sockets (native_table): return: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/http_client.rs:597 vs perry-ext-http/src/agent.rs:1444
  • js_http_agent_requests (native_table): return: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/http_client.rs:615 vs perry-ext-http/src/agent.rs:1452
  • js_http_agent_sockets (native_table): return: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/http_client.rs:579 vs perry-ext-http/src/agent.rs:1436
  • js_http_request_has_header (declare): return: codegen f64, runtime bool — perry-codegen/src/runtime_decls/stdlib_ffi/net_http.rs:120 vs perry-stdlib/src/framework/request.rs:102
  • js_http_request_is_method (declare): return: codegen f64, runtime bool — perry-codegen/src/runtime_decls/stdlib_ffi/net_http.rs:124 vs perry-stdlib/src/framework/request.rs:130
  • js_json_get_bool (declare): return: codegen f64, runtime bool — perry-codegen/src/runtime_decls/stdlib_ffi/language_core.rs:82 vs perry-runtime/src/json/stringify_api.rs:481
  • js_json_stringify_bool (declare): param 0: codegen f64, runtime bool — perry-codegen/src/runtime_decls/stdlib_ffi/language_core.rs:86 vs perry-runtime/src/json/stringify_api.rs:397
  • js_lodash_size (declare): param 0: codegen i64, runtime f64 — perry-codegen/src/runtime_decls/stdlib_ffi/utilities.rs:63 vs perry-stdlib/src/lodash.rs:862
  • js_net_server_address (native_table): param 0: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/net_events.rs:783 vs perry-runtime/src/net.rs:121
  • js_nodemailer_create_transport (native_table): param 0: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/utils_crypto.rs:5 vs perry-stdlib/src/nodemailer.rs:129
  • js_process_initgroups (native_table): param 0: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/node_core_process.rs:576 vs perry-runtime/src/process/credentials.rs:243
  • js_process_setgroups (native_table): param 0: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/node_core_process.rs:566 vs perry-runtime/src/process/credentials.rs:204
  • js_sqlite_stmt_get (declare): return: codegen i64, runtime f64 — perry-codegen/src/runtime_decls/stdlib_ffi/data_stores.rs:16 vs perry-stdlib/src/sqlite/better.rs:249
  • js_tls_socket_set_key_cert (native_table): param 1: codegen i64, runtime f64 — perry-codegen/src/lower_call/native_table/tls_events.rs:290 vs perry-stdlib/src/tls/socket_api.rs:280
  • js_ws_server_emit (native_table): return: codegen f64, runtime i32 — perry-codegen/src/lower_call/native_table/ws_events.rs:136 vs perry-ext-ws/src/server.rs:355

width

  • js_color_parse_channel (pending_declare): param 1: codegen i64, runtime i32 — perry-codegen/src/lower_call/ui_styling.rs:428 vs perry-runtime/src/color_parse.rs:82
  • js_is_truthy (pending_declare): return: codegen i64, runtime i32 — perry-codegen/src/lower_call/native/native_ui_appshell_branch.rs:159 vs perry-runtime/src/value/truthy.rs:16
  • js_ws_on (native_table): return: codegen i32, runtime i64 — perry-codegen/src/lower_call/native_table/ws_events.rs:30 vs perry-ui-android/src/ws.rs:339

arity

  • js_cheerio_selection_children (native_table): codegen 1, runtime 2 — perry-codegen/src/lower_call/native_table/media.rs:315 vs perry-stdlib/src/cheerio.rs:251
  • js_dgram_socket_event_names (native_table): codegen 1, runtime 2 — perry-codegen/src/lower_call/native_table/node_core/dgram_fs_os.rs:158 vs perry-runtime/src/dgram/ffi.rs:113
  • js_lodash_pad / pad_end / pad_start / random (declare): codegen 2, runtime 3 — perry-codegen/src/runtime_decls/stdlib_ffi/utilities.rs:56-59 vs perry-stdlib/src/lodash.rs
  • js_lodash_trim / trim_end / trim_start (declare): codegen 1, runtime 2 — perry-codegen/src/runtime_decls/stdlib_ffi/utilities.rs:73-75 vs perry-stdlib/src/lodash.rs
  • js_module_create_require_devirt (native_table): codegen 2, runtime 1 — …/node_core/module_sea_tls_test.rs:5 vs perry-runtime/src/module_require.rs:980
  • js_module_find_package_json (native_table): codegen 2, runtime 3 — …/node_core/module_sea_tls_test.rs:196 vs perry-runtime/src/process/node_module.rs:531
  • js_sharp_from_buffer (declare): codegen 2, runtime 1 — perry-codegen/src/runtime_decls/stdlib_ffi/third_party.rs:82 vs perry-stdlib/src/sharp.rs:50
  • js_typed_feedback_array_set_index_or_string (call): codegen 4, runtime 5 — perry-codegen/src/expr/index_set.rs:912 vs perry-runtime/src/typed_feedback.rs:2757

Reproduce: python3 scripts/runtime_abi_check.py --list class (and width, arity). Once these are fixed, those three categories can become a ratchet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions