Skip to content

Commit abdb8a6

Browse files
committed
Use JSON for all code size tests
1 parent e236fa3 commit abdb8a6

File tree

284 files changed

+2529
-1308
lines changed

Some content is hidden

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

284 files changed

+2529
-1308
lines changed

.prettierignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
src/lib/*.js
2+
src/audio_worklet.js
3+
src/Fetch.js
4+
src/IDBStore.js
5+
src/memoryprofiler.js
6+
src/modularize.js
7+
src/node_shell_read.js
8+
src/polyfill/bigint64array.js
9+
src/postamble*.js
10+
src/postlibrary.js
11+
src/preamble*.js
12+
src/proxy*.js
13+
src/runtime_*.js
14+
src/shell*.js
15+
src/source_map_support.js
16+
src/threadprofiler.js
17+
src/wasm_offset_converter.js
18+
src/wasm_worker.js
19+
src/wasm2js.js
20+
src/web_or_worker_shell_read.js

.vscode/c_cpp_properties.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Emscripten",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [
9+
"_DEBUG",
10+
"UNICODE",
11+
"_UNICODE"
12+
],
13+
"windowsSdkVersion": "10.0.26100.0",
14+
"compilerPath": "D:\\emsdk\\upstream\\emscripten\\emcc.bat",
15+
"cStandard": "c17",
16+
"cppStandard": "c++17",
17+
"intelliSenseMode": "windows-clang-x86"
18+
}
19+
],
20+
"version": 4
21+
}

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "node",
10+
"request": "launch",
11+
"name": "Launch Program",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
],
15+
"program": "${workspaceFolder}\\out\\test\\test_embind_val_basics.js"
16+
}
17+
]
18+
}

.vscode/settings.json

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"codeQL.createQuery.qlPackLocation": "d:\\emscripten",
3+
"typescript.tsdk": "node_modules\\typescript\\lib",
4+
"files.associations": {
5+
"*.sls": "yaml",
6+
"*.gyp": "gyp",
7+
".eslintrc": "yaml",
8+
"*.c++": "cpp",
9+
"DEPS": "python",
10+
".emscripten": "python",
11+
"*.Makefile": "makefile",
12+
"Makefile2": "makefile",
13+
"*.dw": "llvm",
14+
"*.json": "jsonc",
15+
"*.html": "html",
16+
"*.at": "shellscript",
17+
"*.la": "ini",
18+
"*.toml": "toml",
19+
"*.ejs": "ejs",
20+
".clang-tidy": "yaml",
21+
"*.wsb": "xml",
22+
"*.site": "shellscript",
23+
"*.njk": "nunjucks",
24+
"*.wast": "wat",
25+
"nuget.config": "xml",
26+
"*.csproj": "xml",
27+
"*.verified.txt": "json5",
28+
"*.props": "xml",
29+
"*.mir": "txt",
30+
".wslconfig": "ini",
31+
"*.wcs": "fits",
32+
"*.gpx": "xml",
33+
"*.make": "makefile",
34+
"algorithm": "cpp",
35+
"chrono": "cpp",
36+
"limits": "cpp",
37+
"random": "cpp",
38+
"utility": "cpp",
39+
"valarray": "cpp",
40+
"xutility": "cpp",
41+
"xstring": "cpp",
42+
"any": "cpp",
43+
"array": "cpp",
44+
"atomic": "cpp",
45+
"barrier": "cpp",
46+
"bit": "cpp",
47+
"bitset": "cpp",
48+
"cctype": "cpp",
49+
"cfenv": "cpp",
50+
"charconv": "cpp",
51+
"cinttypes": "cpp",
52+
"clocale": "cpp",
53+
"cmath": "cpp",
54+
"codecvt": "cpp",
55+
"compare": "cpp",
56+
"complex": "cpp",
57+
"concepts": "cpp",
58+
"condition_variable": "cpp",
59+
"coroutine": "cpp",
60+
"cstdarg": "cpp",
61+
"cstddef": "cpp",
62+
"cstdint": "cpp",
63+
"cstdio": "cpp",
64+
"cstdlib": "cpp",
65+
"cstring": "cpp",
66+
"ctime": "cpp",
67+
"cwchar": "cpp",
68+
"cwctype": "cpp",
69+
"deque": "cpp",
70+
"exception": "cpp",
71+
"execution": "cpp",
72+
"expected": "cpp",
73+
"filesystem": "cpp",
74+
"format": "cpp",
75+
"forward_list": "cpp",
76+
"fstream": "cpp",
77+
"functional": "cpp",
78+
"future": "cpp",
79+
"initializer_list": "cpp",
80+
"iomanip": "cpp",
81+
"ios": "cpp",
82+
"iosfwd": "cpp",
83+
"iostream": "cpp",
84+
"istream": "cpp",
85+
"iterator": "cpp",
86+
"list": "cpp",
87+
"locale": "cpp",
88+
"map": "cpp",
89+
"memory": "cpp",
90+
"memory_resource": "cpp",
91+
"mutex": "cpp",
92+
"new": "cpp",
93+
"numeric": "cpp",
94+
"optional": "cpp",
95+
"ostream": "cpp",
96+
"print": "cpp",
97+
"queue": "cpp",
98+
"ranges": "cpp",
99+
"ratio": "cpp",
100+
"regex": "cpp",
101+
"set": "cpp",
102+
"shared_mutex": "cpp",
103+
"span": "cpp",
104+
"sstream": "cpp",
105+
"stack": "cpp",
106+
"stdexcept": "cpp",
107+
"stop_token": "cpp",
108+
"streambuf": "cpp",
109+
"string": "cpp",
110+
"strstream": "cpp",
111+
"system_error": "cpp",
112+
"thread": "cpp",
113+
"tuple": "cpp",
114+
"type_traits": "cpp",
115+
"typeinfo": "cpp",
116+
"unordered_map": "cpp",
117+
"unordered_set": "cpp",
118+
"variant": "cpp",
119+
"vector": "cpp",
120+
"xfacet": "cpp",
121+
"xhash": "cpp",
122+
"xiosbase": "cpp",
123+
"xlocale": "cpp",
124+
"xlocbuf": "cpp",
125+
"xlocinfo": "cpp",
126+
"xlocmes": "cpp",
127+
"xlocmon": "cpp",
128+
"xlocnum": "cpp",
129+
"xloctime": "cpp",
130+
"xmemory": "cpp",
131+
"xtr1common": "cpp",
132+
"xtree": "cpp",
133+
"__bit_reference": "cpp",
134+
"__hash_table": "cpp",
135+
"__locale": "cpp",
136+
"__node_handle": "cpp",
137+
"__split_buffer": "cpp",
138+
"__tree": "cpp",
139+
"__verbose_abort": "cpp",
140+
"string_view": "cpp",
141+
"__config": "c",
142+
"stdlib.h": "c",
143+
"threading.h": "c",
144+
"atomic.h": "c",
145+
"threading_legacy.h": "c",
146+
"eventloop.h": "c",
147+
"*.inc": "c",
148+
"em_js.h": "c",
149+
"em_types.h": "c",
150+
"emscripten_internal.h": "c",
151+
"csignal": "cpp",
152+
"wire.h": "c"
153+
}
154+
}

ast-grep.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
id: prefer-arrow-function
2+
language: javascript
3+
rule:
4+
any:
5+
- pattern: |
6+
$PROP: function ($$$ARGS) => {
7+
$$$BODY
8+
}
9+
fix: |
10+
$PROP($$$ARGS) {
11+
$$$BODY
12+
}
13+
files:
14+
- 'src/*js'
15+
- 'src/lib/*js'

embind_test.wasm

958 KB
Binary file not shown.

system/lib/libc/emscripten_table.c

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#include <assert.h>
2+
#include <stdint.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
6+
static const char STATIC_HEADER[] = {
7+
'\0',
8+
'a',
9+
's',
10+
'm', // magic ("\0asm")
11+
0x01,
12+
0x00,
13+
0x00,
14+
0x00, // version: 1
15+
0x01, // Type section code
16+
};
17+
18+
static const char STATIC_SECTIONS[] = {
19+
0x02,
20+
0x07, // import section
21+
// (import "e" "f" (func 0 (type 0)))
22+
0x01,
23+
0x01,
24+
'e',
25+
0x01,
26+
'f',
27+
0x00,
28+
0x00,
29+
0x07,
30+
0x05, // export section
31+
// (export "f" (func 0 (type 0)))
32+
0x01,
33+
0x01,
34+
'f',
35+
0x00,
36+
0x00,
37+
};
38+
39+
typedef struct {
40+
char* data;
41+
size_t size;
42+
} wasm_module_t;
43+
44+
static void
45+
wasm_module_append(wasm_module_t* target, const char* bytes, size_t count) {
46+
char* pos = target->data + target->size;
47+
target->data = realloc(target->data, target->size += count);
48+
memcpy(pos, bytes, count);
49+
}
50+
51+
static void wasm_module_append_byte(wasm_module_t* target, char byte) {
52+
wasm_module_append(target, &byte, 1);
53+
}
54+
55+
static char* uleb128_reserve(wasm_module_t* target) {
56+
char* pos = target->data + target->size;
57+
target->data = realloc(target->data, target->size += 2);
58+
return pos;
59+
}
60+
61+
static void uleb128_encode(uint32_t n, char* target) {
62+
assert(n < 16384);
63+
target[0] = (n % 128) | 128;
64+
target[1] = n >> 7;
65+
}
66+
67+
static void generate_func_type(char* sig, wasm_module_t* target) {
68+
char *sig_end = strchr(sig, '\0');
69+
70+
char ret_count = 1;
71+
if (sig[0] == 'v') {
72+
ret_count = 0; // void, skip from signature remapping
73+
sig++;
74+
}
75+
76+
// Remap the signature characters to their corresponding type codes
77+
for (char *sig_cur = sig; sig_cur < sig_end; sig_cur++) {
78+
switch (*sig_cur) {
79+
case 'i':
80+
*sig_cur = 0x7f; // i32
81+
break;
82+
case 'j':
83+
*sig_cur = 0x7e; // i64
84+
break;
85+
case 'f':
86+
*sig_cur = 0x7d; // f32
87+
break;
88+
case 'd':
89+
*sig_cur = 0x7c; // f64
90+
break;
91+
case 'e':
92+
*sig_cur = 0x6f; // externref
93+
break;
94+
case 'p':
95+
#if __wasm64__
96+
*sig_cur = 0x7e; // i64
97+
#else
98+
*sig_cur = 0x7f; // i32
99+
#endif
100+
break;
101+
default:
102+
assert(0); // Invalid type code
103+
break;
104+
}
105+
}
106+
107+
wasm_module_append_byte(target, 0x60); // form: func
108+
109+
char *sig_params = sig + ret_count;
110+
size_t param_count = sig_end - sig_params;
111+
uleb128_encode(param_count, uleb128_reserve(target));
112+
wasm_module_append(target, sig_params, param_count);
113+
114+
wasm_module_append_byte(target, ret_count);
115+
wasm_module_append(target, sig, ret_count);
116+
}
117+
118+
wasm_module_t convert_js_function_to_wasm(char* sig) {
119+
// Build the complete module
120+
wasm_module_t result = {NULL, 0};
121+
122+
// Copy static header
123+
wasm_module_append(&result, STATIC_HEADER, sizeof(STATIC_HEADER));
124+
125+
// Reserve space for the type section length
126+
char* type_section_length = uleb128_reserve(&result);
127+
128+
size_t type_section_start = result.size;
129+
130+
// Fill the type section
131+
wasm_module_append_byte(&result, 0x01); // Count: 1
132+
generate_func_type(sig, &result);
133+
134+
// Write the overall length of the type section
135+
uleb128_encode(result.size - type_section_start, type_section_length);
136+
137+
// Copy static sections
138+
wasm_module_append(&result, STATIC_SECTIONS, sizeof(STATIC_SECTIONS));
139+
140+
return result;
141+
}

test/browser/test_small_js_flags.js.size

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)