From b1245577ba92b77a97e266cf4c7f7cd15e6e7f28 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 15 Apr 2024 14:02:24 -0700 Subject: [Strings] Add a string lowering pass using magic imports (#6497) The latest idea for efficient string constants is to encode the constants in the import names of their globals and implement fast paths in the engines for materializing those constants at instantiation time without needing to parse anything in JS. This strategy only works for valid strings (i.e. strings without unpaired surrogates) because only valid strings can be used as import names in the WebAssembly syntax. Add a new configuration of the StringLowering pass that encodes valid string contents in import names, falling back to the JSON custom section approach for invalid strings. To test this chang, update the printer to escape import and export names properly and update the legacy parser to parse escapes in import and export names properly. As a drive-by, remove the incorrect check in the parser that the import module and base names are non-empty. --- test/lit/help/wasm2js.test | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/lit/help/wasm2js.test') diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index 3ab4099de..493542135 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -432,6 +432,10 @@ ;; CHECK-NEXT: --string-lowering lowers wasm strings and ;; CHECK-NEXT: operations to imports ;; CHECK-NEXT: +;; CHECK-NEXT: --string-lowering-magic-imports same as string-lowering, but +;; CHECK-NEXT: encodes well-formed strings as +;; CHECK-NEXT: magic imports +;; CHECK-NEXT: ;; CHECK-NEXT: --strip deprecated; same as strip-debug ;; CHECK-NEXT: ;; CHECK-NEXT: --strip-debug strip debug info (including the -- cgit v1.2.3