()
| 5 | d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); |
| 6 | |
| 7 | function 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 | |
| 30 | const worker = new Worker(workerCode, {type: 'function'}); |
| 31 |
nothing calls this directly
no test coverage detected