summaryrefslogtreecommitdiff
path: root/ext/web/09_file.js
diff options
context:
space:
mode:
authorAapo Alasuutari <aapo.alasuutari@gmail.com>2022-08-11 16:56:56 +0300
committerGitHub <noreply@github.com>2022-08-11 15:56:56 +0200
commit2164f6b1eb7216c1045d547c94f26fe3ceaa9403 (patch)
tree056e3d6540ebd0e755650765adcff6b5cc173db8 /ext/web/09_file.js
parent883269f1f183428f60c54223135d8dd25977b3cd (diff)
perf(ops): Monomorphic sync op calls (#15337)
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params). Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple: ``` opSync("op_foo", param1, param2); // -> turns to ops.op_foo(param1, param2); ``` This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path. Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
Diffstat (limited to 'ext/web/09_file.js')
-rw-r--r--ext/web/09_file.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/web/09_file.js b/ext/web/09_file.js
index 50cce9004..d01858c92 100644
--- a/ext/web/09_file.js
+++ b/ext/web/09_file.js
@@ -13,6 +13,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const webidl = window.__bootstrap.webidl;
const {
ArrayBufferPrototype,
@@ -505,7 +506,7 @@
// A finalization registry to deallocate a blob part when its JS reference is
// garbage collected.
const registry = new FinalizationRegistry((uuid) => {
- core.opSync("op_blob_remove_part", uuid);
+ ops.op_blob_remove_part(uuid);
});
// TODO(lucacasonato): get a better stream from Rust in BlobReference#stream
@@ -533,7 +534,7 @@
* @returns {BlobReference}
*/
static fromUint8Array(data) {
- const id = core.opSync("op_blob_create_part", data);
+ const id = ops.op_blob_create_part(data);
return new BlobReference(id, data.byteLength);
}
@@ -548,7 +549,7 @@
*/
slice(start, end) {
const size = end - start;
- const id = core.opSync("op_blob_slice_part", this._id, {
+ const id = ops.op_blob_slice_part(this._id, {
start,
len: size,
});
@@ -588,7 +589,7 @@
* @returns {Blob | null}
*/
function blobFromObjectUrl(url) {
- const blobData = core.opSync("op_blob_from_object_url", url);
+ const blobData = ops.op_blob_from_object_url(url);
if (blobData === null) {
return null;
}