diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-03-31 16:37:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 10:37:38 -0400 |
commit | fec1b2a5a4324a7eecdfbb2471931f3b6b0139c5 (patch) | |
tree | 8a650553c2d70e047d9d7365f9ac8702ec9861a5 /core/core_test.js | |
parent | 6dc3549a818ad49b3907d18c93fd422a9cc743a5 (diff) |
refactor: new optimized op-layer using serde_v8 (#9843)
- Improves op performance.
- Handle op-metadata (errors, promise IDs) explicitly in the op-layer vs
per op-encoding (aka: out-of-payload).
- Remove shared queue & custom "asyncHandlers", all async values are
returned in batches via js_recv_cb.
- The op-layer should be thought of as simple function calls with little
indirection or translation besides the conceptually straightforward
serde_v8 bijections.
- Preserve concepts of json/bin/min as semantic groups of their
inputs/outputs instead of their op-encoding strategy, preserving these
groups will also facilitate partial transitions over to v8 Fast API for the
"min" and "bin" groups
Diffstat (limited to 'core/core_test.js')
-rw-r--r-- | core/core_test.js | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/core/core_test.js b/core/core_test.js deleted file mode 100644 index 89385a0aa..000000000 --- a/core/core_test.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -"use strict"; - -function assert(cond) { - if (!cond) { - throw Error("assert"); - } -} - -// Check overflow (corresponds to full_records test in rust) -function fullRecords(q) { - q.reset(); - const oneByte = new Uint8Array([42]); - for (let i = 0; i < q.MAX_RECORDS; i++) { - assert(q.push(1, oneByte)); - } - assert(!q.push(1, oneByte)); - const [opId, r] = q.shift(); - assert(opId == 1); - assert(r.byteLength == 1); - assert(r[0] == 42); - // Even if we shift one off, we still cannot push a new record. - assert(!q.push(1, oneByte)); -} - -function main() { - const q = Deno.core.sharedQueue; - - const h = q.head(); - assert(h > 0); - - // This record's len is not divisible by - // 4 so after pushing it to the queue, - // next record offset should be aligned to 4. - let r = new Uint8Array([1, 2, 3, 4, 5]); - const len = r.byteLength + h; - assert(q.push(1, r)); - // Record should be aligned to 4 bytes - assert(q.head() == len + 3); - - r = new Uint8Array([6, 7]); - assert(q.push(1, r)); - - r = new Uint8Array([8, 9, 10, 11]); - assert(q.push(1, r)); - assert(q.numRecords() == 3); - assert(q.size() == 3); - - let opId; - [opId, r] = q.shift(); - assert(r.byteLength == 5); - assert(r[0] == 1); - assert(r[1] == 2); - assert(r[2] == 3); - assert(r[3] == 4); - assert(r[4] == 5); - assert(q.numRecords() == 3); - assert(q.size() == 2); - - [opId, r] = q.shift(); - assert(r.byteLength == 2); - assert(r[0] == 6); - assert(r[1] == 7); - assert(q.numRecords() == 3); - assert(q.size() == 1); - - [opId, r] = q.shift(); - assert(opId == 1); - assert(r.byteLength == 4); - assert(r[0] == 8); - assert(r[1] == 9); - assert(r[2] == 10); - assert(r[3] == 11); - assert(q.numRecords() == 0); - assert(q.size() == 0); - - assert(q.shift() == null); - assert(q.shift() == null); - assert(q.numRecords() == 0); - assert(q.size() == 0); - - fullRecords(q); - - Deno.core.print("shared_queue_test.js ok\n"); - q.reset(); -} - -main(); |