porffor 0.58.9 โ†’ 0.58.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTRIBUTING.md CHANGED
@@ -366,13 +366,13 @@ builtins/tostring_number: impl radix
366
366
 
367
367
  ## Test262
368
368
 
369
- For the first time, ensure you run `./test262/setup.sh` (Unix) or `.\test262\setup.cmd` (Windows).
369
+ For the first time, ensure you run `git clone https://github.com/tc39/test262.git` inside of Porffor's `test262` directory.
370
370
 
371
371
  Run `node test262` to run all the tests and get an output of total overall test results.
372
372
 
373
- Warning: this will consume 1-6GB of memory and ~90% of all CPU cores while running (depending on thread count), it should take 10-30 minutes depending on machine. You can specify how many threads with `--threads=N`, it will use the number of CPU threads by default.
373
+ Warning: this will easily consume most of your system resources while running (depending on thread count), it should take 1-30 minutes depending on machine specs and how many threads you specify (which can be done with `--threads=N`).
374
374
 
375
- The main thing you want to pay attention to is the emoji summary (lol):
375
+ The main thing you want to pay attention to is the emoji summary:
376
376
  ```
377
377
  ๐Ÿงช 50005 | ๐Ÿค  7007 (-89) | โŒ 1914 (-32) | ๐Ÿ’€ 13904 (-61) | ๐Ÿ“ 23477 (-120) | โฐ 2 | ๐Ÿ— 2073 (+302) | ๐Ÿ’ฅ 1628
378
378
  ```
package/bun.lock CHANGED
@@ -4,7 +4,7 @@
4
4
  "": {
5
5
  "name": "porffor",
6
6
  "dependencies": {
7
- "acorn": "^8.14.1",
7
+ "acorn": "^8.15.0",
8
8
  "node-repl-polyfill": "github:CanadaHonk/node-repl-polyfill",
9
9
  },
10
10
  "optionalDependencies": {
@@ -16,13 +16,13 @@
16
16
  },
17
17
  },
18
18
  "packages": {
19
- "@babel/helper-string-parser": ["@babel/helper-string-parser@7.25.9", "", {}, "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA=="],
19
+ "@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
20
20
 
21
- "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.25.9", "", {}, "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ=="],
21
+ "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.27.1", "", {}, "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow=="],
22
22
 
23
- "@babel/parser": ["@babel/parser@7.26.9", "", { "dependencies": { "@babel/types": "^7.26.9" }, "bin": "./bin/babel-parser.js" }, "sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A=="],
23
+ "@babel/parser": ["@babel/parser@7.27.5", "", { "dependencies": { "@babel/types": "^7.27.3" }, "bin": "./bin/babel-parser.js" }, "sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg=="],
24
24
 
25
- "@babel/types": ["@babel/types@7.26.9", "", { "dependencies": { "@babel/helper-string-parser": "^7.25.9", "@babel/helper-validator-identifier": "^7.25.9" } }, "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw=="],
25
+ "@babel/types": ["@babel/types@7.27.6", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q=="],
26
26
 
27
27
  "@emnapi/core": ["@emnapi/core@1.4.3", "", { "dependencies": { "@emnapi/wasi-threads": "1.0.2", "tslib": "^2.4.0" } }, "sha512-4m62DuCE07lw01soJwPiBGC0nAww0Q+RY70VZ+n49yDIO13yyinhbWCeNnaob0lakDtWQzSdtNWzJeOJt2ma+g=="],
28
28
 
@@ -30,41 +30,41 @@
30
30
 
31
31
  "@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.0.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA=="],
32
32
 
33
- "@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.10", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.9.0" } }, "sha512-bCsCyeZEwVErsGmyPNSzwfwFn4OdxBj0mmv6hOFucB/k81Ojdu68RbZdxYsRQUPc9l6SU5F/cG+bXgWs3oUgsQ=="],
33
+ "@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.11", "", { "dependencies": { "@emnapi/core": "^1.4.3", "@emnapi/runtime": "^1.4.3", "@tybys/wasm-util": "^0.9.0" } }, "sha512-9DPkXtvHydrcOsopiYpUgPHpmj0HWZKMUnL2dZqpvC42lsratuBG06V5ipyno0fUek5VlFsNQ+AcFATSrJXgMA=="],
34
34
 
35
- "@oxc-parser/binding-darwin-arm64": ["@oxc-parser/binding-darwin-arm64@0.72.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-+h1ukuH8AqxNq1hEyXG0gBNmPWl99qwtZ6rdZ5odXq3lHsimH2MgMETyccmSjBALVU/VKeoe/1wHL7kJj5MVqA=="],
35
+ "@oxc-parser/binding-darwin-arm64": ["@oxc-parser/binding-darwin-arm64@0.72.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-g6wgcfL7At4wHNHutl0NmPZTAju+cUSmSX5WGUMyTJmozRzhx8E9a2KL4rTqNJPwEpbCFrgC29qX9f4fpDnUpA=="],
36
36
 
37
- "@oxc-parser/binding-darwin-x64": ["@oxc-parser/binding-darwin-x64@0.72.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-v2c/L0kCuF75AAJTLBbnZ6kSfzCHR23JKqhnksf/ccB7IvssIZCxWyT28IJTkG1vGXCenRz9+kAmUbGHIUqV4A=="],
37
+ "@oxc-parser/binding-darwin-x64": ["@oxc-parser/binding-darwin-x64@0.72.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-pc+tplB2fd0AqdnXY90FguqSF2OwbxXwrMOLAMmsUiK4/ytr8Z/ftd49+d27GgvQJKeg2LfnIbskaQtY/j2tAA=="],
38
38
 
39
- "@oxc-parser/binding-freebsd-x64": ["@oxc-parser/binding-freebsd-x64@0.72.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-BeZH+f4HqLgdkC7dj7VPhoL5HpeBXQLwxgnm6McbnBJnvDRNl8bc7El1mFBRYe/w6OPcand5P3kNc9oMAfasfw=="],
39
+ "@oxc-parser/binding-freebsd-x64": ["@oxc-parser/binding-freebsd-x64@0.72.3", "", { "os": "freebsd", "cpu": "x64" }, "sha512-igBR6rOvL8t5SBm1f1rjtWNsjB53HNrM3au582JpYzWxOqCjeA5Jlm9KZbjQJC+J8SPB9xyljM7G+6yGZ2UAkQ=="],
40
40
 
41
- "@oxc-parser/binding-linux-arm-gnueabihf": ["@oxc-parser/binding-linux-arm-gnueabihf@0.72.2", "", { "os": "linux", "cpu": "arm" }, "sha512-mIu9B856olNcAdG/xdUALW5VhNoCqe3nhdsPmXNZAUQtQ/YyW3X+1zb2v74RhehsNNe7sT0eN2iOMetM+IYF+Q=="],
41
+ "@oxc-parser/binding-linux-arm-gnueabihf": ["@oxc-parser/binding-linux-arm-gnueabihf@0.72.3", "", { "os": "linux", "cpu": "arm" }, "sha512-/izdr3wg7bK+2RmNhZXC2fQwxbaTH3ELeqdR+Wg4FiEJ/C7ZBIjfB0E734bZGgbDu+rbEJTBlbG77XzY0wRX/Q=="],
42
42
 
43
- "@oxc-parser/binding-linux-arm-musleabihf": ["@oxc-parser/binding-linux-arm-musleabihf@0.72.2", "", { "os": "linux", "cpu": "arm" }, "sha512-RR74LnLVtoQ2+dErNqrczLofs9I6YG9lIt4Co/6pNcd8pCIMEHXaVtY7Gz9NSko84Que/6ESPccvolhqACXnHQ=="],
43
+ "@oxc-parser/binding-linux-arm-musleabihf": ["@oxc-parser/binding-linux-arm-musleabihf@0.72.3", "", { "os": "linux", "cpu": "arm" }, "sha512-Vz7C+qJb22HIFl3zXMlwvlTOR+MaIp5ps78060zsdeZh2PUGlYuUYkYXtGEjJV3kc8aKFj79XKqAY1EPG2NWQA=="],
44
44
 
45
- "@oxc-parser/binding-linux-arm64-gnu": ["@oxc-parser/binding-linux-arm64-gnu@0.72.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-q+86LrcddEkRgA7ces/cmge/FyuoGpa0M2D6Xh6c60orALus39J6j0LRD0pbfh6c8YVmD4XFoOahiOD2kep4+w=="],
45
+ "@oxc-parser/binding-linux-arm64-gnu": ["@oxc-parser/binding-linux-arm64-gnu@0.72.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-nomoMe2VpVxW767jhF+G3mDGmE0U6nvvi5nw9Edqd/5DIylQfq/lEGUWL7qITk+E72YXBsnwHtpRRlIAJOMyZg=="],
46
46
 
47
- "@oxc-parser/binding-linux-arm64-musl": ["@oxc-parser/binding-linux-arm64-musl@0.72.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-mjwp4B3Yqj6Fo1KIRDRQyWkkJ7ydijReo0UQ6wdDdvQt9v3Sjw4VMlkYAc+hAEo7EX6muPwy2WtjMOtzedlzvA=="],
47
+ "@oxc-parser/binding-linux-arm64-musl": ["@oxc-parser/binding-linux-arm64-musl@0.72.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-4DswiIK5dI7hFqcMKWtZ7IZnWkRuskh6poI1ad4gkY2p678NOGtl6uOGCCRlDmLOOhp3R27u4VCTzQ6zra977w=="],
48
48
 
49
- "@oxc-parser/binding-linux-riscv64-gnu": ["@oxc-parser/binding-linux-riscv64-gnu@0.72.2", "", { "os": "linux", "cpu": "none" }, "sha512-xjbjHPIjHzew583ly/2uIR8u4YSX2fWuhJitkvqzKGBd403/wV9fOGKbgbgeFZxcqIqQlZI6WcxTU+fcmMQ5HQ=="],
49
+ "@oxc-parser/binding-linux-riscv64-gnu": ["@oxc-parser/binding-linux-riscv64-gnu@0.72.3", "", { "os": "linux", "cpu": "none" }, "sha512-R9GEiA4WFPGU/3RxAhEd6SaMdpqongGTvGEyTvYCS/MAQyXKxX/LFvc2xwjdvESpjIemmc/12aTTq6if28vHkQ=="],
50
50
 
51
- "@oxc-parser/binding-linux-s390x-gnu": ["@oxc-parser/binding-linux-s390x-gnu@0.72.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-ohZ70sS4koTbQ+LqMDWK2SOMFmhPzv9DNgC82X/PqjuvzAIDPn13Rt+rUmpMwew/Xtbpe/vPHsEdkxNqsq2XMg=="],
51
+ "@oxc-parser/binding-linux-s390x-gnu": ["@oxc-parser/binding-linux-s390x-gnu@0.72.3", "", { "os": "linux", "cpu": "s390x" }, "sha512-/sEYJQMVqikZO8gK9VDPT4zXo9du3gvvu8jp6erMmW5ev+14PErWRypJjktp0qoTj+uq4MzXro0tg7U+t5hP1w=="],
52
52
 
53
- "@oxc-parser/binding-linux-x64-gnu": ["@oxc-parser/binding-linux-x64-gnu@0.72.2", "", { "os": "linux", "cpu": "x64" }, "sha512-9lYwvYstsnRHivGpH2k8qZQPf0E/FhMr1YuZPxLqyUYzGmdiEpcU7wQbgU6dNIepLLdu/VLmYqmYYaBh86GzWQ=="],
53
+ "@oxc-parser/binding-linux-x64-gnu": ["@oxc-parser/binding-linux-x64-gnu@0.72.3", "", { "os": "linux", "cpu": "x64" }, "sha512-hlyljEZ0sMPKJQCd5pxnRh2sAf/w+Ot2iJecgV9Hl3brrYrYCK2kofC0DFaJM3NRmG/8ZB3PlxnSRSKZTocwCw=="],
54
54
 
55
- "@oxc-parser/binding-linux-x64-musl": ["@oxc-parser/binding-linux-x64-musl@0.72.2", "", { "os": "linux", "cpu": "x64" }, "sha512-4KYID/lCsXR/8m8lgynZzXQIL5zidi5J9cW1nkje2deAf+YmmG6kKm1Vhvq8DaXOkdfGmtDbYd9luYplxncWBg=="],
55
+ "@oxc-parser/binding-linux-x64-musl": ["@oxc-parser/binding-linux-x64-musl@0.72.3", "", { "os": "linux", "cpu": "x64" }, "sha512-T17S8ORqAIq+YDFMvLfbNdAiYHYDM1+sLMNhesR5eWBtyTHX510/NbgEvcNemO9N6BNR7m4A9o+q468UG+dmbg=="],
56
56
 
57
- "@oxc-parser/binding-wasm32-wasi": ["@oxc-parser/binding-wasm32-wasi@0.72.2", "", { "dependencies": { "@napi-rs/wasm-runtime": "^0.2.10" }, "cpu": "none" }, "sha512-ng+OJ+4MOsdJVt2a7VpcornkYFLu9Faos77UXogJg+HM5NnH1L+8rraGvxzJWf8OhYkwlQCIvLuqkncfPap4RA=="],
57
+ "@oxc-parser/binding-wasm32-wasi": ["@oxc-parser/binding-wasm32-wasi@0.72.3", "", { "dependencies": { "@napi-rs/wasm-runtime": "^0.2.10" }, "cpu": "none" }, "sha512-x0Ojn/jyRUk6MllvVB/puSvI2tczZBIYweKVYHNv1nBatjPRiqo+6/uXiKrZwSfGLkGARrKkTuHSa5RdZBMOdA=="],
58
58
 
59
- "@oxc-parser/binding-win32-arm64-msvc": ["@oxc-parser/binding-win32-arm64-msvc@0.72.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-0FSLOzfB7mg1+csZjbo3i5tjLIKGu86vB5ldui5o3QNoxWg+TdRhH0cbxfXZANo3eHTLu5GPtrqaZ0pgB4Pvgw=="],
59
+ "@oxc-parser/binding-win32-arm64-msvc": ["@oxc-parser/binding-win32-arm64-msvc@0.72.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-kRVAl87ugRjLZTm9vGUyiXU50mqxLPHY81rgnZUP1HtNcqcmTQtM/wUKQL2UdqvhA6xm6zciqzqCgJfU+RW8uA=="],
60
60
 
61
- "@oxc-parser/binding-win32-x64-msvc": ["@oxc-parser/binding-win32-x64-msvc@0.72.2", "", { "os": "win32", "cpu": "x64" }, "sha512-mmO/7xfszYE0Q6zAwqOooQrq/0f4ZjtYOoOqvoNCBZ6YqdlwiMSWD3M0ylVfeungyKog2wfJbruabKKt5QbVNw=="],
61
+ "@oxc-parser/binding-win32-x64-msvc": ["@oxc-parser/binding-win32-x64-msvc@0.72.3", "", { "os": "win32", "cpu": "x64" }, "sha512-vpVdoGAP5iGE5tIEPJgr7FkQJZA+sKjMkg5x1jarWJ1nnBamfGsfYiZum4QjCfW7jb+pl42rHVSS3lRmMPcyrQ=="],
62
62
 
63
- "@oxc-project/types": ["@oxc-project/types@0.72.2", "", {}, "sha512-il5RF8AP85XC0CMjHF4cnVT9nT/v/ocm6qlZQpSiAR9qBbQMGkFKloBZwm7PcnOdiUX97yHgsKM7uDCCWCu3tg=="],
63
+ "@oxc-project/types": ["@oxc-project/types@0.72.3", "", {}, "sha512-CfAC4wrmMkUoISpQkFAIfMVvlPfQV3xg7ZlcqPXPOIMQhdKIId44G8W0mCPgtpWdFFAyJ+SFtiM+9vbyCkoVng=="],
64
64
 
65
65
  "@tybys/wasm-util": ["@tybys/wasm-util@0.9.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw=="],
66
66
 
67
- "acorn": ["acorn@8.14.1", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg=="],
67
+ "acorn": ["acorn@8.15.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="],
68
68
 
69
69
  "hermes-estree": ["hermes-estree@0.18.2", "", {}, "sha512-KoLsoWXJ5o81nit1wSyEZnWUGy9cBna9iYMZBR7skKh7okYAYKqQ9/OczwpMHn/cH0hKDyblulGsJ7FknlfVxQ=="],
70
70
 
@@ -74,7 +74,7 @@
74
74
 
75
75
  "node-repl-polyfill": ["node-repl-polyfill@github:CanadaHonk/node-repl-polyfill#8d8a080", {}, "CanadaHonk-node-repl-polyfill-8d8a080"],
76
76
 
77
- "oxc-parser": ["oxc-parser@0.72.2", "", { "dependencies": { "@oxc-project/types": "^0.72.2" }, "optionalDependencies": { "@oxc-parser/binding-darwin-arm64": "0.72.2", "@oxc-parser/binding-darwin-x64": "0.72.2", "@oxc-parser/binding-freebsd-x64": "0.72.2", "@oxc-parser/binding-linux-arm-gnueabihf": "0.72.2", "@oxc-parser/binding-linux-arm-musleabihf": "0.72.2", "@oxc-parser/binding-linux-arm64-gnu": "0.72.2", "@oxc-parser/binding-linux-arm64-musl": "0.72.2", "@oxc-parser/binding-linux-riscv64-gnu": "0.72.2", "@oxc-parser/binding-linux-s390x-gnu": "0.72.2", "@oxc-parser/binding-linux-x64-gnu": "0.72.2", "@oxc-parser/binding-linux-x64-musl": "0.72.2", "@oxc-parser/binding-wasm32-wasi": "0.72.2", "@oxc-parser/binding-win32-arm64-msvc": "0.72.2", "@oxc-parser/binding-win32-x64-msvc": "0.72.2" } }, "sha512-uoiphvClzsbf5NKgV1urQ7GfxIO+3YopmBWK465AiAURp0K/77udIWeZWdLCspxW+2CR5PhUpd1XocjANliKYw=="],
77
+ "oxc-parser": ["oxc-parser@0.72.3", "", { "dependencies": { "@oxc-project/types": "^0.72.3" }, "optionalDependencies": { "@oxc-parser/binding-darwin-arm64": "0.72.3", "@oxc-parser/binding-darwin-x64": "0.72.3", "@oxc-parser/binding-freebsd-x64": "0.72.3", "@oxc-parser/binding-linux-arm-gnueabihf": "0.72.3", "@oxc-parser/binding-linux-arm-musleabihf": "0.72.3", "@oxc-parser/binding-linux-arm64-gnu": "0.72.3", "@oxc-parser/binding-linux-arm64-musl": "0.72.3", "@oxc-parser/binding-linux-riscv64-gnu": "0.72.3", "@oxc-parser/binding-linux-s390x-gnu": "0.72.3", "@oxc-parser/binding-linux-x64-gnu": "0.72.3", "@oxc-parser/binding-linux-x64-musl": "0.72.3", "@oxc-parser/binding-wasm32-wasi": "0.72.3", "@oxc-parser/binding-win32-arm64-msvc": "0.72.3", "@oxc-parser/binding-win32-x64-msvc": "0.72.3" } }, "sha512-JYQeJKDcUTTZ/uTdJ+fZBGFjAjkLD1h0p3Tf44ZYXRcoMk+57d81paNPFAAwzrzzqhZmkGvKKXDxwyhJXYZlpg=="],
78
78
 
79
79
  "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
80
80
  }
@@ -1,6 +1,358 @@
1
1
  // @porf --valtype=i32
2
2
  import type {} from './porffor.d.ts';
3
3
 
4
+ export const __Porffor_strcmp = (a: any, b: any): boolean => {
5
+ // a and b must be string or bytestring
6
+ // fast path: check if pointers are equal
7
+ if (Porffor.wasm`local.get ${a}` == Porffor.wasm`local.get ${b}`) return true;
8
+
9
+ let al: i32 = Porffor.wasm.i32.load(a, 0, 0);
10
+ let bl: i32 = Porffor.wasm.i32.load(b, 0, 0);
11
+
12
+ // fast path: check if lengths are inequal
13
+ if (al != bl) return false;
14
+
15
+ if (Porffor.wasm`local.get ${a+1}` == Porffor.TYPES.bytestring) {
16
+ if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
17
+ // bytestring, bytestring
18
+ // this path is hyper-optimized as it is by far the most common and (perf) important
19
+
20
+ let ap32: i32 = a - 28;
21
+ let bp32: i32 = b - 28;
22
+ let ap8: i32 = a - 4;
23
+ let bp8: i32 = b - 4;
24
+ Porffor.wasm`
25
+ ;; load in 2 i64x2 chunks while length >= 32
26
+ local.get ${al}
27
+ i32.const 32
28
+ i32.ge_s
29
+ if 64
30
+ loop 64
31
+ local.get ${ap32}
32
+ local.get ${al}
33
+ i32.add
34
+ v128.load 0 0
35
+
36
+ local.get ${bp32}
37
+ local.get ${al}
38
+ i32.add
39
+ v128.load 0 0
40
+ v128.xor
41
+
42
+ local.get ${ap32}
43
+ local.get ${al}
44
+ i32.add
45
+ v128.load 0 16
46
+
47
+ local.get ${bp32}
48
+ local.get ${al}
49
+ i32.add
50
+ v128.load 0 16
51
+ v128.xor
52
+
53
+ v128.or
54
+ v128.any_true
55
+ if 64
56
+ i32.const 0
57
+ return
58
+ end
59
+
60
+ local.get ${al}
61
+ i32.const 32
62
+ i32.sub
63
+ local.tee ${al}
64
+ i32.const 32
65
+ i32.ge_s
66
+ br_if 0
67
+ end
68
+ end
69
+
70
+ ;; load in i64 chunks while length >= 8
71
+ local.get ${al}
72
+ i32.const 8
73
+ i32.ge_s
74
+ if 64
75
+ loop 64
76
+ local.get ${ap8}
77
+ local.get ${al}
78
+ i32.add
79
+ i64.load 0 0
80
+
81
+ local.get ${bp8}
82
+ local.get ${al}
83
+ i32.add
84
+ i64.load 0 0
85
+
86
+ i64.ne
87
+ if 64
88
+ i32.const 0
89
+ return
90
+ end
91
+
92
+ local.get ${al}
93
+ i32.const 8
94
+ i32.sub
95
+ local.tee ${al}
96
+ i32.const 8
97
+ i32.ge_s
98
+ br_if 0
99
+ end
100
+ end
101
+
102
+ ;; load in u16 chunks while length >= 2
103
+ local.get ${al}
104
+ i32.const 2
105
+ i32.ge_s
106
+ if 64
107
+ loop 64
108
+ local.get ${a}
109
+ local.get ${al}
110
+ i32.add
111
+ i32.load16_u 0 2
112
+
113
+ local.get ${b}
114
+ local.get ${al}
115
+ i32.add
116
+ i32.load16_u 0 2
117
+
118
+ i32.ne
119
+ if 64
120
+ i32.const 0
121
+ return
122
+ end
123
+
124
+ local.get ${al}
125
+ i32.const 2
126
+ i32.sub
127
+ local.tee ${al}
128
+ i32.const 2
129
+ i32.ge_s
130
+ br_if 0
131
+ end
132
+ end`;
133
+
134
+ // check bonus char if exists
135
+ if (al == 1) {
136
+ if (Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${a}`, 0, 4) !=
137
+ Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${b}`, 0, 4)) return false;
138
+ }
139
+ return true;
140
+ } else {
141
+ // bytestring, string
142
+ for (let i: i32 = 0; i < al; i++) {
143
+ if (Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${a}` + i, 0, 4) !=
144
+ Porffor.wasm.i32.load16_u(Porffor.wasm`local.get ${b}` + i*2, 0, 4)) return false;
145
+ }
146
+ return true;
147
+ }
148
+ } else {
149
+ if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
150
+ // string, bytestring
151
+ for (let i: i32 = 0; i < al; i++) {
152
+ if (Porffor.wasm.i32.load16_u(Porffor.wasm`local.get ${a}` + i*2, 0, 4) !=
153
+ Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${b}` + i, 0, 4)) return false;
154
+ }
155
+ return true;
156
+ } else {
157
+ // string, string
158
+ // change char lengths to byte lengths
159
+ al *= 2;
160
+ bl *= 2;
161
+
162
+ // copied from bytestring, bytestring
163
+ let ap32: i32 = a - 28;
164
+ let bp32: i32 = b - 28;
165
+ let ap8: i32 = a - 4;
166
+ let bp8: i32 = b - 4;
167
+ Porffor.wasm`
168
+ ;; load in 2 i64x2 chunks while length >= 32
169
+ local.get ${al}
170
+ i32.const 32
171
+ i32.ge_s
172
+ if 64
173
+ loop 64
174
+ local.get ${ap32}
175
+ local.get ${al}
176
+ i32.add
177
+ v128.load 0 0
178
+
179
+ local.get ${bp32}
180
+ local.get ${al}
181
+ i32.add
182
+ v128.load 0 0
183
+ v128.xor
184
+
185
+ local.get ${ap32}
186
+ local.get ${al}
187
+ i32.add
188
+ v128.load 0 16
189
+
190
+ local.get ${bp32}
191
+ local.get ${al}
192
+ i32.add
193
+ v128.load 0 16
194
+ v128.xor
195
+
196
+ v128.or
197
+ v128.any_true
198
+ if 64
199
+ i32.const 0
200
+ return
201
+ end
202
+
203
+ local.get ${al}
204
+ i32.const 32
205
+ i32.sub
206
+ local.tee ${al}
207
+ i32.const 32
208
+ i32.ge_s
209
+ br_if 0
210
+ end
211
+ end
212
+
213
+ ;; load in i64 chunks while length >= 8
214
+ local.get ${al}
215
+ i32.const 8
216
+ i32.ge_s
217
+ if 64
218
+ loop 64
219
+ local.get ${ap8}
220
+ local.get ${al}
221
+ i32.add
222
+ i64.load 0 0
223
+
224
+ local.get ${bp8}
225
+ local.get ${al}
226
+ i32.add
227
+ i64.load 0 0
228
+
229
+ i64.ne
230
+ if 64
231
+ i32.const 0
232
+ return
233
+ end
234
+
235
+ local.get ${al}
236
+ i32.const 8
237
+ i32.sub
238
+ local.tee ${al}
239
+ i32.const 8
240
+ i32.ge_s
241
+ br_if 0
242
+ end
243
+ end
244
+
245
+ ;; load in u16 chunks while length >= 2
246
+ local.get ${al}
247
+ i32.const 2
248
+ i32.ge_s
249
+ if 64
250
+ loop 64
251
+ local.get ${a}
252
+ local.get ${al}
253
+ i32.add
254
+ i32.load16_u 0 2
255
+
256
+ local.get ${b}
257
+ local.get ${al}
258
+ i32.add
259
+ i32.load16_u 0 2
260
+
261
+ i32.ne
262
+ if 64
263
+ i32.const 0
264
+ return
265
+ end
266
+
267
+ local.get ${al}
268
+ i32.const 2
269
+ i32.sub
270
+ local.tee ${al}
271
+ i32.const 2
272
+ i32.ge_s
273
+ br_if 0
274
+ end
275
+ end`;
276
+ return true;
277
+ }
278
+ }
279
+ };
280
+
281
+ export const __Porffor_strcat = (a: any, b: any): any => {
282
+ // a and b must be string or bytestring
283
+
284
+ const al: i32 = Porffor.wasm.i32.load(a, 0, 0);
285
+ const bl: i32 = Porffor.wasm.i32.load(b, 0, 0);
286
+
287
+ if (Porffor.wasm`local.get ${a+1}` == Porffor.TYPES.bytestring) {
288
+ if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
289
+ // bytestring, bytestring
290
+ const out: bytestring = Porffor.allocateBytes(4 + al + bl);
291
+
292
+ // out.length = a.length + b.length
293
+ Porffor.wasm.i32.store(out, al + bl, 0, 0);
294
+
295
+ // copy left (fast memcpy)
296
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4, Porffor.wasm`local.get ${a}` + 4, al, 0, 0);
297
+
298
+ // copy right (fast memcpy)
299
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4 + al, Porffor.wasm`local.get ${b}` + 4, bl, 0, 0);
300
+
301
+ return out;
302
+ } else {
303
+ // bytestring, string
304
+ const out: string = Porffor.allocateBytes(4 + (al + bl) * 2);
305
+
306
+ // out.length = a.length + b.length
307
+ Porffor.wasm.i32.store(out, al + bl, 0, 0);
308
+
309
+ // copy left (slow bytestring -> string)
310
+ for (let i: i32 = 0; i < al; i++) {
311
+ Porffor.wasm.i32.store16(Porffor.wasm`local.get ${out}` + i*2, Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${a}` + i, 0, 4), 0, 4);
312
+ }
313
+
314
+ // copy right (fast memcpy)
315
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4 + al*2, Porffor.wasm`local.get ${b}` + 4, bl * 2, 0, 0);
316
+
317
+ return out;
318
+ }
319
+ } else {
320
+ if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
321
+ // string, bytestring
322
+ const out: string = Porffor.allocateBytes(4 + (al + bl) * 2);
323
+
324
+ // out.length = a.length + b.length
325
+ Porffor.wasm.i32.store(out, al + bl, 0, 0);
326
+
327
+ // copy left (fast memcpy)
328
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4, Porffor.wasm`local.get ${a}` + 4, al * 2, 0, 0);
329
+
330
+ // copy right (slow bytestring -> string)
331
+ let ptr: i32 = Porffor.wasm`local.get ${out}` + al*2;
332
+ for (let i: i32 = 0; i < bl; i++) {
333
+ Porffor.wasm.i32.store16(ptr + i*2, Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${b}` + i, 0, 4), 0, 4);
334
+ }
335
+
336
+ return out;
337
+ } else {
338
+ // string, string
339
+ const out: string = Porffor.allocateBytes(4 + (al + bl) * 2);
340
+
341
+ // out.length = a.length + b.length
342
+ Porffor.wasm.i32.store(out, al + bl, 0, 0);
343
+
344
+ // copy left (fast memcpy)
345
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4, Porffor.wasm`local.get ${a}` + 4, al * 2, 0, 0);
346
+
347
+ // copy right (fast memcpy)
348
+ Porffor.wasm.memory.copy(Porffor.wasm`local.get ${out}` + 4 + al*2, Porffor.wasm`local.get ${b}` + 4, bl * 2, 0, 0);
349
+
350
+ return out;
351
+ }
352
+ }
353
+ };
354
+
355
+
4
356
  export const __String_prototype_toUpperCase = (_this: string) => {
5
357
  // todo: unicode not just ascii
6
358
  const len: i32 = _this.length;
@@ -1,5 +1,50 @@
1
1
  import type {} from './porffor.d.ts';
2
2
 
3
+ export const __Porffor_compareStrings = (a: any, b: any): boolean => {
4
+ if ((Porffor.type(a) | 0b10000000) != Porffor.TYPES.bytestring) {
5
+ // a is not string or bytestring
6
+ // check if it is bad type or value
7
+ if (Porffor.fastOr(
8
+ a == null,
9
+
10
+ Porffor.type(a) == Porffor.TYPES.symbol,
11
+ Porffor.type(a) == Porffor.TYPES.boolean
12
+ )) return false;
13
+
14
+ a = ecma262.ToString(a);
15
+ }
16
+
17
+ if ((Porffor.type(b) | 0b10000000) != Porffor.TYPES.bytestring) {
18
+ // b is not string or bytestring
19
+ // check if it is bad type or value
20
+ if (Porffor.fastOr(
21
+ b == null,
22
+
23
+ Porffor.type(b) == Porffor.TYPES.symbol,
24
+ Porffor.type(b) == Porffor.TYPES.boolean
25
+ )) return false;
26
+
27
+ b = ecma262.ToString(b);
28
+ }
29
+
30
+ return Porffor.strcmp(a, b);
31
+ };
32
+
33
+ export const __Porffor_concatStrings = (a: any, b: any): any => {
34
+ if ((Porffor.type(a) | 0b10000000) != Porffor.TYPES.bytestring) {
35
+ // a is not string or bytestring
36
+ a = ecma262.ToString(a);
37
+ }
38
+
39
+ if ((Porffor.type(b) | 0b10000000) != Porffor.TYPES.bytestring) {
40
+ // b is not string or bytestring
41
+ b = ecma262.ToString(b);
42
+ }
43
+
44
+ return Porffor.strcat(a, b);
45
+ };
46
+
47
+
3
48
  // 22.1.1.1 String (value)
4
49
  // https://tc39.es/ecma262/#sec-string-constructor-string-value
5
50
  export const String = function (...args: any[]): string|bytestring|StringObject {