From 884143218fad0e18f7553aaf079d52de703f7601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 27 Jan 2022 13:36:36 +0100 Subject: refactor: update runtime code for primordial checks for "instanceof" (#13497) --- ext/ffi/00_ffi.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ext/ffi') diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js index abe806cc0..b979c73d4 100644 --- a/ext/ffi/00_ffi.js +++ b/ext/ffi/00_ffi.js @@ -5,10 +5,11 @@ const core = window.Deno.core; const __bootstrap = window.__bootstrap; const { - ArrayBuffer, + ArrayBufferPrototype, Uint8Array, BigInt, Number, + ObjectPrototypeIsPrototypeOf, TypeError, } = window.__bootstrap.primordials; @@ -141,6 +142,7 @@ return this.value; } } + const UnsafePointerPrototype = UnsafePointer.prototype; function prepareArgs(types, args) { const parameters = []; @@ -152,12 +154,12 @@ if (type === "pointer") { if ( - arg?.buffer instanceof ArrayBuffer && + ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, arg?.buffer) && arg.byteLength !== undefined ) { parameters.push(buffers.length); buffers.push(arg); - } else if (arg instanceof UnsafePointer) { + } else if (ObjectPrototypeIsPrototypeOf(UnsafePointerPrototype, arg)) { parameters.push(packU64(arg.value)); buffers.push(undefined); } else if (arg === null) { -- cgit v1.2.3