MCPcopy Create free account
hub / github.com/nodejs/node / workerCode

Function workerCode

deps/v8/test/mjsunit/wasm/log-code-after-post-message.js:7–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
6
7function workerCode() {
8 function WorkerOnProfileEnd(profile) {
9 postMessage(profile.indexOf('foo'));
10 }
11
12 onmessage = ({data:wasm_module}) => {
13 WebAssembly.instantiate(wasm_module, {q: {func: d8.profiler.triggerSample}})
14 .then(instance => {
15 instance.exports.foo();
16 console.profileEnd();
17 });
18 };
19
20 d8.profiler.setOnProfileEndListener(WorkerOnProfileEnd);
21 // Code logging happens for all code objects when profiling gets started,
22 // and when new code objects appear after profiling has started. We want to
23 // test the second scenario here. As new code objects appear as the
24 // parameter of {OnMessage}, we have to start profiling already here before
25 // {onMessage} is called.
26 console.profile();
27 postMessage('Starting worker');
28}
29
30const worker = new Worker(workerCode, {type: 'function'});
31

Callers

nothing calls this directly

Calls 4

profileMethod · 0.80
thenMethod · 0.45
instantiateMethod · 0.45
fooMethod · 0.45

Tested by

no test coverage detected