Skip to content

Commit 8a820e6

Browse files
authored
Merge branch 'main' into wasm64-pthreads
2 parents e3772e8 + 02e8ce3 commit 8a820e6

140 files changed

Lines changed: 428 additions & 350 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ jobs:
5252

5353
# Upload the results to GitHub's code scanning dashboard.
5454
- name: "Upload to code-scanning"
55-
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
55+
uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4
5656
with:
5757
sarif_file: results.sarif

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.45 (in development)
2222
-----------------------
23+
- The function used to add symbols the JS library has been renamed from
24+
`mergeInto`, to the more specific `addToLibrary`. This new function does not
25+
require the passing of `LibraryManager.library` as a first argument. The old
26+
`mergeInto` continues to exist for backwards compat.
2327

2428
3.1.44 - 07/25/23
2529
-----------------

docs/emcc.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,9 @@ Options that are modified or new in *emcc* are listed below:
408408
"--embind-emit-tsd <path>"
409409
[link] Generate a TypeScript definition file from the exported
410410
embind bindings. The program will be instrumented and run in node
411-
in order to to generate the file. Note: the program will need to be
412-
rebuilt without this flag to be executed normally.
411+
in order to to generate the file. Note that the program itself will
412+
not be generated when this flag is used. You will need to be
413+
rebuild without this flag to build the program itself.
413414

414415
"--ignore-dynamic-linking"
415416
[link] Tells the compiler to ignore dynamic linking (the user will

emcc.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class EmccOptions:
250250
def __init__(self):
251251
self.target = ''
252252
self.output_file = None
253+
self.no_minify = False
253254
self.post_link = False
254255
self.executable = False
255256
self.compiler_wrapper = None
@@ -1844,6 +1845,13 @@ def phase_linker_setup(options, state, newargs):
18441845
logger.warning('disabling source maps because a js transform is being done')
18451846
settings.GENERATE_SOURCE_MAP = 0
18461847

1848+
if options.embind_emit_tsd:
1849+
# Ignore any -o command line arguments when running in --embind-emit-tsd
1850+
# With this option we don't actually output the program itself only the
1851+
# TS bindings.
1852+
options.output_file = in_temp('a.out.js')
1853+
settings.INVOKE_RUN = False
1854+
18471855
# options.output_file is the user-specified one, target is what we will generate
18481856
if options.output_file:
18491857
target = options.output_file
@@ -2946,7 +2954,7 @@ def get_full_import_name(name):
29462954
settings.PRE_JS_FILES = [os.path.abspath(f) for f in options.pre_js]
29472955
settings.POST_JS_FILES = [os.path.abspath(f) for f in options.post_js]
29482956

2949-
settings.MINIFY_WHITESPACE = settings.OPT_LEVEL >= 2 and settings.DEBUG_LEVEL == 0
2957+
settings.MINIFY_WHITESPACE = settings.OPT_LEVEL >= 2 and settings.DEBUG_LEVEL == 0 and not options.no_minify
29502958

29512959
return target, wasm_target
29522960

@@ -3444,7 +3452,7 @@ def consume_arg_file():
34443452
arg = consume_arg()
34453453
if arg != '0':
34463454
exit_with_error('0 is the only supported option for --minify; 1 has been deprecated')
3447-
settings.DEBUG_LEVEL = max(1, settings.DEBUG_LEVEL)
3455+
options.no_minify = True
34483456
elif arg.startswith('-g'):
34493457
options.requested_debug = arg
34503458
requested_level = removeprefix(arg, '-g') or '3'
@@ -3525,7 +3533,6 @@ def consume_arg_file():
35253533
options.source_map_base = consume_arg()
35263534
elif check_arg('--embind-emit-tsd'):
35273535
options.embind_emit_tsd = consume_arg()
3528-
settings.INVOKE_RUN = False
35293536
elif check_flag('--no-entry'):
35303537
options.no_entry = True
35313538
elif check_arg('--js-library'):

site/source/docs/getting_started/downloads.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GitHub and set them as :term:`active <Active Tool/SDK>`:
5252
# Activate PATH and other environment variables in the current terminal
5353
source ./emsdk_env.sh
5454

55-
.. note:: On Windows, run ``emsdk`` instead of ``./emsdk``, and ``emsdk_env.bat`` instead of ``source ./emsdk_env.sh``.
55+
.. note:: On Windows, run ``emsdk.bat`` instead of ``./emsdk``, and ``emsdk_env.bat`` instead of ``source ./emsdk_env.sh``.
5656

5757
.. note:: On Windows, if you use the ``activate`` command, the step of ``emsdk_env.bat`` is optional. If you want to know more, see :ref:`activate SDK version <emsdk-set-active-tools>`.
5858

site/source/docs/optimizing/Module-Splitting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Multithreaded Programs
222222

223223
By default, the data gathered by the wasm-split instrumentation is stored in
224224
Wasm globals, so it is thread local. But in a multithreaded program, it is
225-
important to collect profile information from all threads. To do so, you can can
225+
important to collect profile information from all threads. To do so, you can
226226
tell wasm-split to collect shared profile information in shared memory using the
227227
``--in-memory`` wasm-split flag. This will use memory starting at address zero
228228
to store the profile information, so you must also pass ``-sGLOBAL_BASE=N`` to

site/source/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ If you add it to your own file, you should write something like
412412

413413
.. code-block:: javascript
414414
415-
mergeInto(LibraryManager.library, {
415+
addToLibrary({
416416
my_js: function() {
417417
alert('hi');
418418
},
419419
});
420420
421-
``mergeInto`` just copies the properties on the second parameter onto the
422-
first, so this add ``my_js`` onto ``LibraryManager.library``, the global
423-
object where all JavaScript library code should be.
421+
``addToLibrary`` copies the properties of the input object into
422+
``LibraryManager.library`` (the global object where all JavaScript library code
423+
lives). In this case its adds a function called ``my_js`` onto this object.
424424

425425
JavaScript limits in library files
426426
----------------------------------
@@ -438,7 +438,7 @@ that you can't use a closure directly, for example, as ``toString``
438438
isn't compatible with that - just like when using a string to create
439439
a Web Worker, where you also can't pass a closure. (Note that this
440440
limitation is just for the values for the keys of the object
441-
passes to ``mergeInto`` in the JS library, that is, the toplevel
441+
passes to ``addToLibrary`` in the JS library, that is, the toplevel
442442
key-value pairs are special. Interior code inside a function can
443443
have arbitrary JS, of course).
444444

@@ -453,7 +453,7 @@ initialization.
453453

454454
.. code-block:: javascript
455455
456-
mergeInto(LibraryManager.library, {
456+
addToLibrary({
457457
458458
// Solution for bind or referencing other functions directly
459459
good_02__postset: '_good_02();',
@@ -511,7 +511,7 @@ various methods to the functions we actually want.
511511

512512
.. code-block:: javascript
513513
514-
mergeInto(LibraryManager.library, {
514+
addToLibrary({
515515
$method_support: {},
516516
$method_support__postset: [
517517
'(function() { ',
@@ -554,7 +554,7 @@ a function,
554554

555555
.. code-block:: javascript
556556
557-
mergeInto(LibraryManager.library, {
557+
addToLibrary({
558558
$method_support__postset: 'method_support();',
559559
$method_support: function() {
560560
var SomeLib = function() {
@@ -601,7 +601,7 @@ See the `library_*.js`_ files for other examples.
601601
This is useful when all the implemented methods use a JavaScript
602602
singleton containing helper methods. See ``library_webgl.js`` for
603603
an example.
604-
- The keys passed into `mergeInto` generate functions that are prefixed
604+
- The keys passed into `addToLibrary` generate functions that are prefixed
605605
by ``_``. In other words ``my_func: function() {},`` becomes
606606
``function _my_func() {}``, as all C methods in emscripten have a ``_`` prefix. Keys starting with ``$`` have the ``$``
607607
stripped and no underscore added.

site/source/docs/tools_reference/emcc.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ Options that are modified or new in *emcc* are listed below:
386386

387387
``--embind-emit-tsd <path>``
388388
[link]
389-
Generate a TypeScript definition file from the exported embind bindings. The program will be instrumented and run in node in order to to generate the file. Note: the program will need to be rebuilt without this flag to be executed normally.
389+
Generate a TypeScript definition file from the exported embind bindings. The
390+
program will be instrumented and run in node in order to to generate the file.
391+
Note that the program itself will not be generated when this flag is
392+
used. You will need to be rebuild without this flag to build the program
393+
itself.
390394

391395
``--ignore-dynamic-linking``
392396
[link]

src/audio_worklet.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ function createWasmAudioWorkletProcessor(audioParams) {
4949
didProduceAudio, paramArray;
5050

5151
// Calculate how much stack space is needed.
52-
for(i of inputList) stackMemoryNeeded += i.length * 512;
53-
for(i of outputList) stackMemoryNeeded += i.length * 512;
54-
for(i in parameters) stackMemoryNeeded += parameters[i].byteLength + 8, ++numParams;
52+
for (i of inputList) stackMemoryNeeded += i.length * 512;
53+
for (i of outputList) stackMemoryNeeded += i.length * 512;
54+
for (i in parameters) stackMemoryNeeded += parameters[i].byteLength + 8, ++numParams;
5555

5656
// Allocate the necessary stack space.
5757
inputsPtr = stackAlloc(stackMemoryNeeded);
5858

5959
// Copy input audio descriptor structs and data to Wasm
6060
k = inputsPtr >> 2;
6161
dataPtr = inputsPtr + numInputs * 8;
62-
for(i of inputList) {
62+
for (i of inputList) {
6363
// Write the AudioSampleFrame struct instance
6464
HEAPU32[k++] = i.length;
6565
HEAPU32[k++] = dataPtr;
6666
// Marshal the input audio sample data for each audio channel of this input
67-
for(j of i) {
67+
for (j of i) {
6868
HEAPF32.set(j, dataPtr>>2);
6969
dataPtr += 512;
7070
}
@@ -74,7 +74,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
7474
outputsPtr = dataPtr;
7575
k = outputsPtr >> 2;
7676
outputDataPtr = (dataPtr += numOutputs * 8) >> 2;
77-
for(i of outputList) {
77+
for (i of outputList) {
7878
// Write the AudioSampleFrame struct instance
7979
HEAPU32[k++] = i.length;
8080
HEAPU32[k++] = dataPtr;
@@ -86,7 +86,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
8686
paramsPtr = dataPtr;
8787
k = paramsPtr >> 2;
8888
dataPtr += numParams * 8;
89-
for(i = 0; paramArray = parameters[i++];) {
89+
for (i = 0; paramArray = parameters[i++];) {
9090
// Write the AudioParamFrame struct instance
9191
HEAPU32[k++] = paramArray.length;
9292
HEAPU32[k++] = dataPtr;
@@ -100,9 +100,9 @@ function createWasmAudioWorkletProcessor(audioParams) {
100100
// Read back the produced audio data to all outputs and their channels.
101101
// (A garbage-free function TypedArray.copy(dstTypedArray, dstOffset, srcTypedArray, srcOffset, count) would sure be handy..
102102
// but web does not have one, so manually copy all bytes in)
103-
for(i of outputList) {
104-
for(j of i) {
105-
for(k = 0; k < 128; ++k) {
103+
for (i of outputList) {
104+
for (j of i) {
105+
for (k = 0; k < 128; ++k) {
106106
j[k] = HEAPF32[outputDataPtr++];
107107
}
108108
}

src/base64Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function intArrayFromBase64(s) {
1414
#if ENVIRONMENT_MAY_BE_NODE
1515
if (typeof ENVIRONMENT_IS_NODE != 'undefined' && ENVIRONMENT_IS_NODE) {
1616
var buf = Buffer.from(s, 'base64');
17-
return new Uint8Array(buf['buffer'], buf['byteOffset'], buf['byteLength']);
17+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
1818
}
1919
#endif
2020

0 commit comments

Comments
 (0)