Commit 49051b3e16dc9927b3bbcfe2f7a8af88ccc8a232
docs and small fixes
Norton Wang committed on 3/5/2018, 3:45:29 AMParent: 21960d62467278cd5659e2eb5f80cc6ddd87e663
Files changed
.gitignore | changed |
customTypes.js | changed |
docs/actor.md | changed |
docs/hypervisor.md | changed |
docs/index.md | changed |
docs/scheduler.md | changed |
package.json | changed |
tests/wasmContainer.js | changed |
wasmContainer.js | changed |
customTypes.js | ||
---|---|---|
@@ -193,19 +193,21 @@ | ||
193 | 193 | |
194 | 194 | const {value: type} = iterator.next() |
195 | 195 | const {value: imports = {entries: []}} = iterator.next() |
196 | 196 | const {value: functions} = iterator.next() |
197 | - functions.entries.forEach((typeIndex, funcIndex) => { | |
198 | - let customIndex = mappedFuncs.get(funcIndex) | |
199 | - if (customIndex === undefined) { | |
200 | - customIndex = mappedTypes.get(typeIndex) | |
201 | - } | |
202 | - if (customIndex === undefined) { | |
203 | - customIndex = result.types.push(type.entries[typeIndex]) - 1 | |
204 | - mappedTypes.set(typeIndex, customIndex) | |
205 | - } | |
206 | - result.indexes[funcIndex + imports.entries.length] = customIndex | |
207 | - }) | |
197 | + if (functions) { | |
198 | + functions.entries.forEach((typeIndex, funcIndex) => { | |
199 | + let customIndex = mappedFuncs.get(funcIndex) | |
200 | + if (customIndex === undefined) { | |
201 | + customIndex = mappedTypes.get(typeIndex) | |
202 | + } | |
203 | + if (customIndex === undefined) { | |
204 | + customIndex = result.types.push(type.entries[typeIndex]) - 1 | |
205 | + mappedTypes.set(typeIndex, customIndex) | |
206 | + } | |
207 | + result.indexes[funcIndex + imports.entries.length] = customIndex | |
208 | + }) | |
209 | + } | |
208 | 210 | |
209 | 211 | const {value: exports = {entries: []}} = iterator.next() |
210 | 212 | exports.entries.forEach(entry => { |
211 | 213 | if (entry.kind === 'function') { |
docs/actor.md | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 | |
3 | 3 | ### Table of Contents |
4 | 4 | |
5 | 5 | - [constructor](#constructor) |
6 | -- [queue](#queue) | |
7 | 6 | - [shutdown](#shutdown) |
8 | 7 | - [startup](#startup) |
9 | 8 | - [runMessage](#runmessage) |
10 | 9 | - [incrementTicks](#incrementticks) |
@@ -12,9 +11,9 @@ | ||
12 | 11 | - [send](#send) |
13 | 12 | |
14 | 13 | ## constructor |
15 | 14 | |
16 | -[actor.js:15-25](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L15-L25 "Source code on GitHub") | |
15 | +[actor.js:11-18](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L11-L18 "Source code on GitHub") | |
17 | 16 | |
18 | 17 | the Actor manages the varous message passing functions and provides |
19 | 18 | an interface for the containers to use |
20 | 19 | |
@@ -25,34 +24,23 @@ | ||
25 | 24 | - `opts.state` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the state of the container |
26 | 25 | - `opts.hypervisor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the instance of the hypervisor |
27 | 26 | - `opts.container` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the container constuctor and argments |
28 | 27 | |
29 | -## queue | |
30 | - | |
31 | -[actor.js:32-39](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L32-L39 "Source code on GitHub") | |
32 | - | |
33 | -adds a message to this actor's message queue | |
34 | - | |
35 | -**Parameters** | |
36 | - | |
37 | -- `message` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | |
38 | -- `portName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | |
39 | - | |
40 | 28 | ## shutdown |
41 | 29 | |
42 | -[actor.js:89-92](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L89-L92 "Source code on GitHub") | |
30 | +[actor.js:23-29](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L23-L29 "Source code on GitHub") | |
43 | 31 | |
44 | 32 | Runs the shutdown routine for the actor |
45 | 33 | |
46 | 34 | ## startup |
47 | 35 | |
48 | -[actor.js:97-99](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L97-L99 "Source code on GitHub") | |
36 | +[actor.js:34-36](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L34-L36 "Source code on GitHub") | |
49 | 37 | |
50 | 38 | Runs the startup routine for the actor |
51 | 39 | |
52 | 40 | ## runMessage |
53 | 41 | |
54 | -[actor.js:107-114](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L107-L114 "Source code on GitHub") | |
42 | +[actor.js:44-56](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L44-L56 "Source code on GitHub") | |
55 | 43 | |
56 | 44 | run the Actor with a given message |
57 | 45 | |
58 | 46 | **Parameters** |
@@ -63,9 +51,9 @@ | ||
63 | 51 | Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** |
64 | 52 | |
65 | 53 | ## incrementTicks |
66 | 54 | |
67 | -[actor.js:120-123](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L120-L123 "Source code on GitHub") | |
55 | +[actor.js:62-64](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L62-L64 "Source code on GitHub") | |
68 | 56 | |
69 | 57 | updates the number of ticks that the actor has run |
70 | 58 | |
71 | 59 | **Parameters** |
@@ -73,9 +61,9 @@ | ||
73 | 61 | - `count` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks to add |
74 | 62 | |
75 | 63 | ## createActor |
76 | 64 | |
77 | -[actor.js:130-133](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L130-L133 "Source code on GitHub") | |
65 | +[actor.js:71-74](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L71-L74 "Source code on GitHub") | |
78 | 66 | |
79 | 67 | creates an actor |
80 | 68 | |
81 | 69 | **Parameters** |
@@ -85,9 +73,9 @@ | ||
85 | 73 | - `message` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an intial [message](https://github.com/primea/js-primea-message) to send newly created actor |
86 | 74 | |
87 | 75 | ## send |
88 | 76 | |
89 | -[actor.js:150-155](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L150-L155 "Source code on GitHub") | |
77 | +[actor.js:91-96](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L91-L96 "Source code on GitHub") | |
90 | 78 | |
91 | 79 | sends a message to a given port |
92 | 80 | |
93 | 81 | **Parameters** |
docs/hypervisor.md | ||
---|---|---|
@@ -3,16 +3,15 @@ | ||
3 | 3 | ### Table of Contents |
4 | 4 | |
5 | 5 | - [constructor](#constructor) |
6 | 6 | - [send](#send) |
7 | -- [getActor](#getactor) | |
8 | 7 | - [createActor](#createactor) |
9 | 8 | - [createStateRoot](#createstateroot) |
10 | 9 | - [registerContainer](#registercontainer) |
11 | 10 | |
12 | 11 | ## constructor |
13 | 12 | |
14 | -[index.js:10-15](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L10-L15 "Source code on GitHub") | |
13 | +[index.js:12-17](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L12-L17 "Source code on GitHub") | |
15 | 14 | |
16 | 15 | The Hypervisor manages the container instances by instantiating them and |
17 | 16 | destorying them when possible. It also facilitates localating Containers |
18 | 17 | |
@@ -22,34 +21,23 @@ | ||
22 | 21 | - `nonce` (optional, default `0`) |
23 | 22 | |
24 | 23 | ## send |
25 | 24 | |
26 | -[index.js:23-27](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L23-L27 "Source code on GitHub") | |
25 | +[index.js:25-30](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L25-L30 "Source code on GitHub") | |
27 | 26 | |
28 | 27 | sends a message |
29 | 28 | |
30 | 29 | **Parameters** |
31 | 30 | |
31 | +- `messages` | |
32 | +- `cap` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the capabilitly used to send the message | |
32 | 33 | - `message` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the [message](https://github.com/primea/js-primea-message) to send |
33 | -- `cap` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the capabilitly used to send the message | |
34 | 34 | |
35 | 35 | Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** a promise that resolves once the receiving container is loaded |
36 | 36 | |
37 | -## getActor | |
38 | - | |
39 | -[index.js:55-63](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L55-L63 "Source code on GitHub") | |
40 | - | |
41 | -gets an existsing actor | |
42 | - | |
43 | -**Parameters** | |
44 | - | |
45 | -- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the actor's ID | |
46 | - | |
47 | -Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** | |
48 | - | |
49 | 37 | ## createActor |
50 | 38 | |
51 | -[index.js:71-85](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L71-L85 "Source code on GitHub") | |
39 | +[index.js:65-83](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L65-L83 "Source code on GitHub") | |
52 | 40 | |
53 | 41 | creates an instance of an Actor |
54 | 42 | |
55 | 43 | **Parameters** |
@@ -60,22 +48,22 @@ | ||
60 | 48 | - `message` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an intial [message](https://github.com/primea/js-primea-message) to send newly created actor |
61 | 49 | |
62 | 50 | ## createStateRoot |
63 | 51 | |
64 | -[index.js:98-101](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L98-L101 "Source code on GitHub") | |
52 | +[index.js:98-104](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L98-L104 "Source code on GitHub") | |
65 | 53 | |
66 | 54 | creates a state root starting from a given container and a given number of |
67 | 55 | ticks |
68 | 56 | |
69 | 57 | **Parameters** |
70 | 58 | |
71 | -- `ticks` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks at which to create the state root (optional, default `Infinity`) | |
59 | +- `ticks` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks at which to create the state root | |
72 | 60 | |
73 | 61 | Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** |
74 | 62 | |
75 | 63 | ## registerContainer |
76 | 64 | |
77 | -[index.js:109-111](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L109-L111 "Source code on GitHub") | |
65 | +[index.js:112-114](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L112-L114 "Source code on GitHub") | |
78 | 66 | |
79 | 67 | regirsters a container with the hypervisor |
80 | 68 | |
81 | 69 | **Parameters** |
docs/index.md | ||
---|---|---|
@@ -1,7 +1,6 @@ | ||
1 | 1 | # API |
2 | 2 | - [Hypervisor](./hypervisor.md) |
3 | -- [Kernel](./kernel.md) | |
4 | -- [PortManager](./portManager.md) | |
3 | +- [Actor](./actor.md) | |
5 | 4 | |
6 | -## internal API's | |
5 | +## Internal APIs | |
7 | 6 | - [Scheduler](./scheduler.md) |
docs/scheduler.md | ||
---|---|---|
@@ -2,87 +2,15 @@ | ||
2 | 2 | |
3 | 3 | ### Table of Contents |
4 | 4 | |
5 | 5 | - [constructor](#constructor) |
6 | -- [lock](#lock) | |
7 | -- [update](#update) | |
8 | -- [getInstance](#getinstance) | |
9 | -- [done](#done) | |
10 | -- [wait](#wait) | |
11 | -- [leastNumberOfTicks](#leastnumberofticks) | |
12 | 6 | |
13 | 7 | ## constructor |
14 | 8 | |
15 | -[scheduler.js:13-17](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L13-L17 "Source code on GitHub") | |
9 | +[scheduler.js:19-26](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/scheduler.js#L19-L26 "Source code on GitHub") | |
16 | 10 | |
17 | 11 | The Scheduler manages the actor instances and tracks how many "ticks" they |
18 | 12 | have ran. |
19 | 13 | |
20 | -## lock | |
21 | - | |
22 | -[scheduler.js:24-34](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L24-L34 "Source code on GitHub") | |
23 | - | |
24 | -locks the scheduler from clearing waits untill the lock is resolved | |
25 | - | |
26 | 14 | **Parameters** |
27 | 15 | |
28 | -- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | |
29 | - | |
30 | -Returns **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** the resolve function to call once it to unlock | |
31 | - | |
32 | -## update | |
33 | - | |
34 | -[scheduler.js:40-44](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L40-L44 "Source code on GitHub") | |
35 | - | |
36 | -updates an instance with a new tick count | |
37 | - | |
38 | -**Parameters** | |
39 | - | |
40 | -- `instance` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an actor instance | |
41 | - | |
42 | -## getInstance | |
43 | - | |
44 | -[scheduler.js:56-59](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L56-L59 "Source code on GitHub") | |
45 | - | |
46 | -returns an Actor instance | |
47 | - | |
48 | -**Parameters** | |
49 | - | |
50 | -- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | |
51 | - | |
52 | -Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | |
53 | - | |
54 | -## done | |
55 | - | |
56 | -[scheduler.js:65-70](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L65-L70 "Source code on GitHub") | |
57 | - | |
58 | -deletes an instance from the scheduler | |
59 | - | |
60 | -**Parameters** | |
61 | - | |
62 | -- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the containers id | |
63 | - | |
64 | -## wait | |
65 | - | |
66 | -[scheduler.js:79-93](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L79-L93 "Source code on GitHub") | |
67 | - | |
68 | -returns a promise that resolves once all containers have reached the given | |
69 | -number of ticks | |
70 | - | |
71 | -**Parameters** | |
72 | - | |
73 | -- `ticks` **interger** the number of ticks to wait | |
74 | -- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** optional id of the container that is waiting | |
75 | - | |
76 | -Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** | |
77 | - | |
78 | -## leastNumberOfTicks | |
79 | - | |
80 | -[scheduler.js:99-109](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L99-L109 "Source code on GitHub") | |
81 | - | |
82 | -returns the oldest container's ticks | |
83 | - | |
84 | -**Parameters** | |
85 | - | |
86 | -- `exclude` | |
87 | - | |
88 | -Returns **integer** | |
16 | +- `hypervisor` |
package.json | ||
---|---|---|
@@ -5,13 +5,14 @@ | ||
5 | 5 | "scripts": { |
6 | 6 | "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", |
7 | 7 | "coverage": "nyc npm test", |
8 | 8 | "lint": "standard", |
9 | - "build:docs": "npm run build:docs:hypervisor && npm run build:docs:actor && npm run build:docs:scheduler && npm run build:docs:capsStore && npm run build:docs:inbox", | |
9 | + "build:docs": "npm run build:docs:hypervisor && npm run build:docs:actor && npm run build:docs:scheduler", | |
10 | 10 | "build:docs:hypervisor": "documentation build ./index.js --github --shallow --sort-order source -f md > ./docs/hypervisor.md", |
11 | 11 | "build:docs:actor": "documentation build ./actor.js --github --shallow --sort-order source -f md > ./docs/actor.md", |
12 | - "build:docs:capsStore": "documentation build ./capsStore.js --github --shallow --sort-order source -f md > ./docs/capsStore.md", | |
13 | - "test": "node ./tests/index.js" | |
12 | + "build:docs:scheduler": "documentation build ./scheduler.js --github --shallow --sort-order source -f md > ./docs/scheduler.md", | |
13 | + "test": "node ./tests/index.js", | |
14 | + "test:wasm": "node ./tests/wasmContainer.js" | |
14 | 15 | }, |
15 | 16 | "repository": { |
16 | 17 | "type": "git", |
17 | 18 | "url": "git+https://github.com/primea/js-primea-hypervisor.git" |
tests/wasmContainer.js | ||
---|---|---|
@@ -1,14 +1,17 @@ | ||
1 | 1 | const tape = require('tape') |
2 | 2 | const fs = require('fs') |
3 | +const path = require('path') | |
3 | 4 | const Message = require('../message.js') |
4 | 5 | const Hypervisor = require('../') |
5 | 6 | const WasmContainer = require('../wasmContainer.js') |
6 | 7 | |
7 | 8 | const level = require('level-browserify') |
8 | 9 | const RadixTree = require('dfinity-radix-tree') |
9 | 10 | const db = level('./testdb') |
10 | 11 | |
12 | +const WASM_PATH = path.join(__dirname, 'wasm') | |
13 | + | |
11 | 14 | let tester |
12 | 15 | |
13 | 16 | class TestWasmContainer extends WasmContainer { |
14 | 17 | constructor (actor) { |
@@ -41,9 +44,9 @@ | ||
41 | 44 | const tree = new RadixTree({ |
42 | 45 | db |
43 | 46 | }) |
44 | 47 | |
45 | - const wasm = fs.readFileSync('./wasm/reciever.wasm') | |
48 | + const wasm = fs.readFileSync(WASM_PATH + '/reciever.wasm') | |
46 | 49 | |
47 | 50 | const hypervisor = new Hypervisor(tree) |
48 | 51 | hypervisor.registerContainer(TestWasmContainer) |
49 | 52 | |
@@ -68,10 +71,10 @@ | ||
68 | 71 | } |
69 | 72 | |
70 | 73 | const tree = new RadixTree({db}) |
71 | 74 | |
72 | - const recieverWasm = fs.readFileSync('./wasm/reciever.wasm') | |
73 | - const callerWasm = fs.readFileSync('./wasm/caller.wasm') | |
75 | + const recieverWasm = fs.readFileSync(WASM_PATH + '/reciever.wasm') | |
76 | + const callerWasm = fs.readFileSync(WASM_PATH + '/caller.wasm') | |
74 | 77 | |
75 | 78 | const hypervisor = new Hypervisor(tree) |
76 | 79 | hypervisor.registerContainer(TestWasmContainer) |
77 | 80 | |
@@ -101,10 +104,10 @@ | ||
101 | 104 | const tree = new RadixTree({ |
102 | 105 | db |
103 | 106 | }) |
104 | 107 | |
105 | - const recieverWasm = fs.readFileSync('./wasm/funcRef_reciever.wasm') | |
106 | - const callerWasm = fs.readFileSync('./wasm/funcRef_caller.wasm') | |
108 | + const recieverWasm = fs.readFileSync(WASM_PATH + '/funcRef_reciever.wasm') | |
109 | + const callerWasm = fs.readFileSync(WASM_PATH + '/funcRef_caller.wasm') | |
107 | 110 | |
108 | 111 | const hypervisor = new Hypervisor(tree) |
109 | 112 | hypervisor.registerContainer(TestWasmContainer) |
110 | 113 | |
@@ -136,10 +139,10 @@ | ||
136 | 139 | const tree = new RadixTree({ |
137 | 140 | db |
138 | 141 | }) |
139 | 142 | |
140 | - const recieverWasm = fs.readFileSync('./wasm/funcRef_reciever.wasm') | |
141 | - const callerWasm = fs.readFileSync('./wasm/private_caller.wasm') | |
143 | + const recieverWasm = fs.readFileSync(WASM_PATH + '/funcRef_reciever.wasm') | |
144 | + const callerWasm = fs.readFileSync(WASM_PATH + '/private_caller.wasm') | |
142 | 145 | |
143 | 146 | const hypervisor = new Hypervisor(tree) |
144 | 147 | hypervisor.registerContainer(TestWasmContainer) |
145 | 148 | |
@@ -167,9 +170,9 @@ | ||
167 | 170 | const tree = new RadixTree({ |
168 | 171 | db |
169 | 172 | }) |
170 | 173 | |
171 | - const wasm = fs.readFileSync('./wasm/memory.wasm') | |
174 | + const wasm = fs.readFileSync(WASM_PATH + '/memory.wasm') | |
172 | 175 | |
173 | 176 | const hypervisor = new Hypervisor(tree) |
174 | 177 | hypervisor.registerContainer(TestWasmContainer) |
175 | 178 | |
@@ -191,9 +194,9 @@ | ||
191 | 194 | const tree = new RadixTree({ |
192 | 195 | db |
193 | 196 | }) |
194 | 197 | |
195 | - const wasm = fs.readFileSync('./wasm/table.wasm') | |
198 | + const wasm = fs.readFileSync(WASM_PATH + '/table.wasm') | |
196 | 199 | const hypervisor = new Hypervisor(tree) |
197 | 200 | hypervisor.registerContainer(TestWasmContainer) |
198 | 201 | |
199 | 202 | const {module} = await hypervisor.createActor(TestWasmContainer.typeId, wasm) |
@@ -215,9 +218,9 @@ | ||
215 | 218 | const tree = new RadixTree({ |
216 | 219 | db |
217 | 220 | }) |
218 | 221 | |
219 | - const wasm = fs.readFileSync('./wasm/globals.wasm') | |
222 | + const wasm = fs.readFileSync(WASM_PATH + '/globals.wasm') | |
220 | 223 | |
221 | 224 | const hypervisor = new Hypervisor(tree) |
222 | 225 | hypervisor.registerContainer(TestWasmContainer) |
223 | 226 | |
@@ -255,9 +258,9 @@ | ||
255 | 258 | const tree = new RadixTree({ |
256 | 259 | db |
257 | 260 | }) |
258 | 261 | |
259 | - const wasm = fs.readFileSync('./hi.wasm') | |
262 | + const wasm = fs.readFileSync(WASM_PATH + '.wasm') | |
260 | 263 | const hypervisor = new Hypervisor(tree) |
261 | 264 | hypervisor.registerContainer(TestWasmContainer) |
262 | 265 | |
263 | 266 | const {module} = await hypervisor.createActor(TestWasmContainer.typeId, wasm) |
wasmContainer.js | ||
---|---|---|
@@ -191,9 +191,9 @@ | ||
191 | 191 | }, |
192 | 192 | internalize: (elemRef, srcOffset, sinkOffset, length) => { |
193 | 193 | let table = this.refs.get(elemRef, 'elem') |
194 | 194 | const buf = table.slice(srcOffset, srcOffset + length).map(obj => this.refs.add(obj)) |
195 | - const mem = new Uint32Array(this.instance.exports.memory.buffer, sinkOffset, length) | |
195 | + const mem = this.getMemory(sinkOffset, length) | |
196 | 196 | mem.set(buf) |
197 | 197 | }, |
198 | 198 | length (elemRef) { |
199 | 199 | let elem = this.refs.get(elemRef, 'elem') |
@@ -260,9 +260,9 @@ | ||
260 | 260 | numOfGlobals = this.json.globals.length |
261 | 261 | if (numOfGlobals) { |
262 | 262 | this.actor.storage = [] |
263 | 263 | this.instance.exports.getter_globals() |
264 | - const mem = new Uint32Array(this.instance.exports.memory.buffer, 0, numOfGlobals) | |
264 | + const mem = this.getMemory(0, numOfGlobals) | |
265 | 265 | while (numOfGlobals--) { |
266 | 266 | const ref = mem[numOfGlobals] |
267 | 267 | this.actor.storage.push(this.refs.get(ref, this.json.globals[numOfGlobals].type)) |
268 | 268 | } |
Built with git-ssb-web