Skip to content

Commit 3e0c44e

Browse files
committed
Move runtime_strings.js code into library_strings.js
1 parent af217b3 commit 3e0c44e

Some content is hidden

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

45 files changed

+340
-305
lines changed

ChangeLog.md

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

2121
3.1.35 (in development)
2222
-----------------------
23+
- The following JavaScript runtime functions were converted to JavaScript
24+
library functions:
25+
- UTF8ArrayToString
26+
- UTF8ToString
27+
- stringToUTF8Array
28+
- stringToUTF8
29+
- lengthBytesUTF8
30+
If you use any of these functions in your JS code you will now need to include
31+
them explictly in one of the following ways:
32+
- Add them to a `__deps` entry your JS library file ((with leading $)
33+
- Add them to `DEFAULT_LIBRARY_FUNCS_TO_INCLUDE` (with leading $)
34+
- Add them to `EXPORTED_FUNCTIONS` (without leading $)
35+
- Set `-sLEGACY_RUNTIME` to include all of them at once.
2336
- `allocateUTF8` and `allocateUTF8OnStack` library function moved to
2437
`library_legacy.js`. Prefer the more accurately named `stringToNewUTF8` and
2538
`stringToNewUTF8OnStack`. (#19089)

src/embind/embind.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,8 @@ var LibraryEmbind = {
656656
_embind_register_std_string__sig: 'vpp',
657657
_embind_register_std_string__deps: [
658658
'$readLatin1String', '$registerType',
659-
'$simpleReadValueFromPointer', '$throwBindingError'],
659+
'$simpleReadValueFromPointer', '$throwBindingError',
660+
'$stringToUTF8', '$lengthBytesUTF8'],
660661
_embind_register_std_string: function(rawType, name) {
661662
name = readLatin1String(name);
662663
var stdStringIsUTF8

src/jsifier.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ function ${name}(${args}) {
203203
'getWasmTableEntry',
204204
'runtimeKeepalivePush',
205205
'runtimeKeepalivePop',
206+
'UTF8ToString',
206207
];
207208
for (const dep of autoDeps) {
208209
if (snippet.includes(dep + '(')) {

src/library.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ mergeInto(LibraryManager.library, {
20272027
return 0;
20282028
},
20292029

2030-
getnameinfo__deps: ['$Sockets', '$DNS', '$readSockaddr'],
2030+
getnameinfo__deps: ['$Sockets', '$DNS', '$readSockaddr', '$stringToUTF8'],
20312031
getnameinfo: function (sa, salen, node, nodelen, serv, servlen, flags) {
20322032
var info = readSockaddr(sa, salen);
20332033
if (info.errno) {
@@ -2305,6 +2305,7 @@ mergeInto(LibraryManager.library, {
23052305
// Mark as `noleakcheck` otherwise lsan will report the last returned string
23062306
// as a leak.
23072307
emscripten_run_script_string__noleakcheck: true,
2308+
emscripten_run_script_string__deps: ['$lengthBytesUTF8', '$stringToUTF8', 'malloc'],
23082309
emscripten_run_script_string: function(ptr) {
23092310
{{{ makeEval("var s = eval(UTF8ToString(ptr));") }}}
23102311
if (s == null) {
@@ -2565,7 +2566,7 @@ mergeInto(LibraryManager.library, {
25652566
return callstack;
25662567
},
25672568

2568-
emscripten_get_callstack__deps: ['$getCallstack'],
2569+
emscripten_get_callstack__deps: ['$getCallstack', '$lengthBytesUTF8', '$stringToUTF8'],
25692570
emscripten_get_callstack: function(flags, str, maxbytes) {
25702571
// Use explicit calls to from64 rather then using the __sig
25712572
// magic here. This is because the __sig wrapper uses arrow function
@@ -2647,6 +2648,7 @@ mergeInto(LibraryManager.library, {
26472648
debugger;
26482649
},
26492650

2651+
emscripten_print_double__deps: ['$stringToUTF8', '$lengthBytesUTF8'],
26502652
emscripten_print_double: function(x, to, max) {
26512653
var str = x + '';
26522654
if (to) return stringToUTF8(str, to, max);
@@ -2887,6 +2889,7 @@ mergeInto(LibraryManager.library, {
28872889
return result ? result.column || 0 : 0;
28882890
},
28892891

2892+
emscripten_get_module_name__deps: ['$stringToUTF8'],
28902893
emscripten_get_module_name: function(buf, length) {
28912894
#if MINIMAL_RUNTIME
28922895
return stringToUTF8('{{{ TARGET_BASENAME }}}.wasm', buf, length);
@@ -3363,6 +3366,9 @@ mergeInto(LibraryManager.library, {
33633366

33643367
// Use program_invocation_short_name and program_invocation_name in compiled
33653368
// programs. This function is for implementing them.
3369+
#if !MINIMAL_RUNTIME
3370+
_emscripten_get_progname__deps: ['$stringToUTF8'],
3371+
#endif
33663372
_emscripten_get_progname: function(str, len) {
33673373
#if !MINIMAL_RUNTIME
33683374
#if ASSERTIONS
@@ -3723,5 +3729,10 @@ DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push(
37233729
'$ccall',
37243730
'$cwrap',
37253731
'$ExitStatus',
3732+
'$UTF8ArrayToString',
3733+
'$UTF8ToString',
3734+
'$stringToUTF8Array',
3735+
'$stringToUTF8',
3736+
'$lengthBytesUTF8',
37263737
);
37273738
#endif

src/library_dylink.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ var LibraryDylink = {
370370

371371
// returns the side module metadata as an object
372372
// { memorySize, memoryAlign, tableSize, tableAlign, neededDynlibs}
373+
$getDylinkMetadata__deps: ['$UTF8ArrayToString'],
373374
$getDylinkMetadata__internal: true,
374375
$getDylinkMetadata: function(binary) {
375376
var offset = 0;

src/library_fs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66

77
mergeInto(LibraryManager.library, {
8-
$FS__deps: ['$randomFill', '$PATH', '$PATH_FS', '$TTY', '$MEMFS', '$asyncLoad', '$intArrayFromString',
8+
$FS__deps: ['$randomFill', '$PATH', '$PATH_FS', '$TTY', '$MEMFS', '$asyncLoad',
9+
'$intArrayFromString',
10+
'$stringToUTF8Array',
11+
'$lengthBytesUTF8',
912
#if LibraryManager.has('library_idbfs.js')
1013
'$IDBFS',
1114
#endif

0 commit comments

Comments
 (0)