aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-17 22:37:02 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-17 22:37:24 -0700
commita17221258d08d5077cb97a5650748916cf16da91 (patch)
treeec6c37ec6a75573cc8c7fcfba3a9c68915fffb7d
parenta00380c7c2a8edf93370d17eb583e5fe98ea3167 (diff)
downloadbun-a17221258d08d5077cb97a5650748916cf16da91.tar.gz
bun-a17221258d08d5077cb97a5650748916cf16da91.tar.zst
bun-a17221258d08d5077cb97a5650748916cf16da91.zip
Fixes https://github.com/oven-sh/bun/issues/769
Not tested
-rw-r--r--src/bun.js/ffi.exports.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bun.js/ffi.exports.js b/src/bun.js/ffi.exports.js
index 1617ffc52..217e208b6 100644
--- a/src/bun.js/ffi.exports.js
+++ b/src/bun.js/ffi.exports.js
@@ -160,6 +160,13 @@ ffiWrappers[FFIType.bool] = function bool(val) {
return !!val;
};
+// This prevents an extra property getter in potentially hot code
+Object.defineProperty(globalThis, "__GlobalBunFFIPtrFunctionForWrapper", {
+ value: ptr,
+ enumerable: false,
+ configurable: true,
+});
+
ffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = function pointer(
val
) {
@@ -169,7 +176,7 @@ ffiWrappers[FFIType.cstring] = ffiWrappers[FFIType.pointer] = function pointer(
}
if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {
- return ptr(val);
+ return __GlobalBunFFIPtrFunctionForWrapper(val);
}
if (typeof val === "string") {