Skip to content

Truly independent web browser

LibJS: Return intrinsic accessor values via out parameters on Windows

Zaggy1024039a77d2139e
diff --git a/Libraries/LibJS/Rust/src/embedding/object.rs b/Libraries/LibJS/Rust/src/embedding/object.rs
index 174cc0a7b16..260ff2f57ac 100644
--- a/Libraries/LibJS/Rust/src/embedding/object.rs
+++ b/Libraries/LibJS/Rust/src/embedding/object.rs
@@ -227,12 +227,28 @@ fn integrity_level_from_abi(level: u8) -> IntegrityLevel {
/// Computes the value of a property that an intrinsic accessor defines, when it is first read: given the realm of the
/// object, returns the value, which the runtime then stores in the property.
+#[cfg(not(target_os = "windows"))]
pub type JSIntrinsicAccessor = Option<unsafe extern "C" fn(realm: *mut JSRealm) -> JSValue>;
+/// Computes the value of a property that an intrinsic accessor defines, when it is first read: given the realm of the
+/// object, returns the value, which the runtime then stores in the property.
+#[cfg(target_os = "windows")]
+pub type JSIntrinsicAccessor = Option<unsafe extern "C" fn(result: *mut JSValue, realm: *mut JSRealm)>;
+
pub fn call_host_intrinsic_accessor(accessor: HostIntrinsicAccessor, realm: Gc<Realm>) -> Value {
+ let realm = cell_into_abi::<JSRealm>(realm);
// SAFETY: The embedder defined the accessor for a property of an object of this runtime, and computes its value in
// the realm of that object.
- Value(unsafe { accessor(cell_into_abi::<JSRealm>(realm)) })
+ #[cfg(not(target_os = "windows"))]
+ let value = unsafe { accessor(realm) };
+ #[cfg(target_os = "windows")]
+ let value = {
+ let mut value = 0;
+ // SAFETY: As above.
+ unsafe { accessor(&mut value, realm) };
+ value
+ };
+ Value(value)
}
// Creating objects
diff --git a/Libraries/LibJS/Rust/src/runtime/object.rs b/Libraries/LibJS/Rust/src/runtime/object.rs
index ddceef47b48..a950459d0d7 100644
--- a/Libraries/LibJS/Rust/src/runtime/object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object.rs
@@ -452,8 +452,13 @@ pub enum IntrinsicAccessor {
pub type NativeIntrinsicAccessor = fn(&Vm, Gc<Realm>) -> Value;
/// An intrinsic accessor that an embedder defines through the C ABI, which returns the encoded value.
+#[cfg(not(target_os = "windows"))]
pub type HostIntrinsicAccessor = unsafe extern "C" fn(realm: *mut JSRealm) -> JSValue;
+/// An intrinsic accessor that an embedder defines through the C ABI, which returns the encoded value.
+#[cfg(target_os = "windows")]
+pub type HostIntrinsicAccessor = unsafe extern "C" fn(result: *mut JSValue, realm: *mut JSRealm);
+
impl IntrinsicAccessor {
fn compute_value(self, vm: &Vm, realm: Gc<Realm>) -> Value {
match self {