summaryrefslogtreecommitdiff
path: root/core/serialize_deserialize_test.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 /core/serialize_deserialize_test.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 'core/serialize_deserialize_test.js')
-rw-r--r--core/serialize_deserialize_test.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/core/serialize_deserialize_test.js b/core/serialize_deserialize_test.js
index cd7aa69b1..724239fcb 100644
--- a/core/serialize_deserialize_test.js
+++ b/core/serialize_deserialize_test.js
@@ -21,12 +21,11 @@ function main() {
const emptyString = "";
const emptyStringSerialized = [255, 15, 34, 0];
assertArrayEquals(
- Deno.core.opSync("op_serialize", emptyString),
+ Deno.core.ops.op_serialize(emptyString),
emptyStringSerialized,
);
assert(
- Deno.core.opSync(
- "op_deserialize",
+ Deno.core.ops.op_deserialize(
new Uint8Array(emptyStringSerialized),
) ===
emptyString,
@@ -39,13 +38,12 @@ function main() {
34, 1, 97, 48, 95, 36, 0, 4,
];
assertArrayEquals(
- Deno.core.opSync("op_serialize", primitiveValueArray),
+ Deno.core.ops.op_serialize(primitiveValueArray),
primitiveValueArraySerialized,
);
assertArrayEquals(
- Deno.core.opSync(
- "op_deserialize",
+ Deno.core.ops.op_deserialize(
new Uint8Array(primitiveValueArraySerialized),
),
primitiveValueArray,
@@ -63,12 +61,11 @@ function main() {
];
assertArrayEquals(
- Deno.core.opSync("op_serialize", circularObject),
+ Deno.core.ops.op_serialize(circularObject),
circularObjectSerialized,
);
- const deserializedCircularObject = Deno.core.opSync(
- "op_deserialize",
+ const deserializedCircularObject = Deno.core.ops.op_deserialize(
new Uint8Array(circularObjectSerialized),
);
assert(deserializedCircularObject.test == deserializedCircularObject);