1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

BREAKING(unstable/ffi): remove callback reentrant flag (#24367)

Closes https://github.com/denoland/deno/issues/22947

This option is no longer needed as fast calls are now allowed to
re-enter the isolate
This commit is contained in:
Divy Srivastava 2024-06-30 21:06:33 -07:00 committed by GitHub
parent bc8a0e6e68
commit cd4a0072dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 2 additions and 20 deletions

View file

@ -371,11 +371,6 @@ declare namespace Deno {
/** When `true`, function calls will run on a dedicated blocking thread and /** When `true`, function calls will run on a dedicated blocking thread and
* will return a `Promise` resolving to the `result`. */ * will return a `Promise` resolving to the `result`. */
nonblocking?: NonBlocking; nonblocking?: NonBlocking;
/** When `true`, function calls can safely callback into JavaScript or
* trigger a garbage collection event.
*
* @default {false} */
callback?: boolean;
/** When `true`, dlopen will not fail if the symbol is not found. /** When `true`, dlopen will not fail if the symbol is not found.
* Instead, the symbol will be set to `null`. * Instead, the symbol will be set to `null`.
* *

View file

@ -60,18 +60,11 @@ pub struct ForeignFunction {
pub result: NativeType, pub result: NativeType,
#[serde(rename = "nonblocking")] #[serde(rename = "nonblocking")]
non_blocking: Option<bool>, non_blocking: Option<bool>,
#[serde(rename = "callback")]
#[serde(default = "default_callback")]
callback: bool,
#[serde(rename = "optional")] #[serde(rename = "optional")]
#[serde(default = "default_optional")] #[serde(default = "default_optional")]
optional: bool, optional: bool,
} }
fn default_callback() -> bool {
false
}
fn default_optional() -> bool { fn default_optional() -> bool {
false false
} }
@ -191,7 +184,6 @@ where
ptr, ptr,
parameter_types: foreign_fn.parameters, parameter_types: foreign_fn.parameters,
result_type: foreign_fn.result, result_type: foreign_fn.result,
can_callback: foreign_fn.callback,
}); });
resource.symbols.insert(symbol_key, sym.clone()); resource.symbols.insert(symbol_key, sym.clone());

View file

@ -70,7 +70,6 @@ pub struct Symbol {
pub ptr: libffi::middle::CodePtr, pub ptr: libffi::middle::CodePtr,
pub parameter_types: Vec<NativeType>, pub parameter_types: Vec<NativeType>,
pub result_type: NativeType, pub result_type: NativeType,
pub can_callback: bool,
} }
#[allow(clippy::non_send_fields_in_send_ty)] #[allow(clippy::non_send_fields_in_send_ty)]

View file

@ -18,8 +18,7 @@ pub(crate) fn is_compatible(sym: &Symbol) -> bool {
all(target_arch = "x86_64", target_family = "unix"), all(target_arch = "x86_64", target_family = "unix"),
all(target_arch = "x86_64", target_family = "windows"), all(target_arch = "x86_64", target_family = "windows"),
all(target_arch = "aarch64", target_vendor = "apple") all(target_arch = "aarch64", target_vendor = "apple")
)) && !sym.can_callback )) && !matches!(sym.result_type, NativeType::Struct(_))
&& !matches!(sym.result_type, NativeType::Struct(_))
&& !sym && !sym
.parameter_types .parameter_types
.iter() .iter()
@ -1437,7 +1436,6 @@ mod tests {
ptr: libffi::middle::CodePtr(null_mut()), ptr: libffi::middle::CodePtr(null_mut()),
parameter_types: parameters, parameter_types: parameters,
result_type: ret, result_type: ret,
can_callback: false,
} }
} }

View file

@ -5,7 +5,7 @@
const remote = Deno.dlopen( const remote = Deno.dlopen(
"dummy_lib.so", "dummy_lib.so",
{ {
method1: { parameters: ["usize", "bool"], result: "void", callback: true }, method1: { parameters: ["usize", "bool"], result: "void" },
method2: { parameters: [], result: "void" }, method2: { parameters: [], result: "void" },
method3: { parameters: ["usize"], result: "void" }, method3: { parameters: ["usize"], result: "void" },
method4: { parameters: ["isize"], result: "void" }, method4: { parameters: ["isize"], result: "void" },

View file

@ -214,12 +214,10 @@ const dylib = Deno.dlopen(libPath, {
call_stored_function: { call_stored_function: {
parameters: [], parameters: [],
result: "void", result: "void",
callback: true,
}, },
call_stored_function_2: { call_stored_function_2: {
parameters: ["u8"], parameters: ["u8"],
result: "void", result: "void",
callback: true,
}, },
log_many_parameters: { log_many_parameters: {
parameters: ["u8", "u16", "u32", "u64", "f64", "f32", "i64", "i32", "i16", "i8", "isize", "usize", "f64", "f32", "f64", "f32", "f64", "f32", "f64"], parameters: ["u8", "u16", "u32", "u64", "f64", "f32", "i64", "i32", "i16", "i8", "isize", "usize", "f64", "f32", "f64", "f32", "f64", "f32", "f64"],