Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StringLowering] Lower stringview_wtf16.get_codeunit to charCodeAt #6353

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/passes/StringLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct StringLowering : public StringGathering {
Name equalsImport;
Name compareImport;
Name lengthImport;
Name codePointAtImport;
Name charCodeAtImport;
Name substringImport;

// The name of the module to import string functions from.
Expand Down Expand Up @@ -334,8 +334,8 @@ struct StringLowering : public StringGathering {
// string.length: string -> i32
lengthImport = addImport(module, "length", nullExt, Type::i32);
// string.codePointAt: string, offset -> i32
codePointAtImport =
addImport(module, "codePointAt", {nullExt, Type::i32}, Type::i32);
charCodeAtImport =
addImport(module, "charCodeAt", {nullExt, Type::i32}, Type::i32);
// string.substring: string, start, end -> string
substringImport =
addImport(module, "substring", {nullExt, Type::i32, Type::i32}, nnExt);
Expand Down Expand Up @@ -425,7 +425,7 @@ struct StringLowering : public StringGathering {
void visitStringWTF16Get(StringWTF16Get* curr) {
Builder builder(*getModule());
replaceCurrent(builder.makeCall(
lowering.codePointAtImport, {curr->ref, curr->pos}, Type::i32));
lowering.charCodeAtImport, {curr->ref, curr->pos}, Type::i32));
}

void visitStringSliceWTF(StringSliceWTF* curr) {
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/string-gathering.wast
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

;; LOWER: (import "wasm:js-string" "length" (func $length (type $6) (param externref) (result i32)))

;; LOWER: (import "wasm:js-string" "codePointAt" (func $codePointAt (type $7) (param externref i32) (result i32)))
;; LOWER: (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $7) (param externref i32) (result i32)))

;; LOWER: (import "wasm:js-string" "substring" (func $substring (type $8) (param externref i32 i32) (result (ref extern))))

Expand Down Expand Up @@ -182,7 +182,7 @@

;; LOWER: (import "wasm:js-string" "length" (func $length (type $5) (param externref) (result i32)))

;; LOWER: (import "wasm:js-string" "codePointAt" (func $codePointAt (type $6) (param externref i32) (result i32)))
;; LOWER: (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $6) (param externref i32) (result i32)))

;; LOWER: (import "wasm:js-string" "substring" (func $substring (type $7) (param externref i32 i32) (result (ref extern))))

Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/string-lowering-instructions.wast
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

;; CHECK: (import "wasm:js-string" "length" (func $length (type $23) (param externref) (result i32)))

;; CHECK: (import "wasm:js-string" "codePointAt" (func $codePointAt (type $24) (param externref i32) (result i32)))
;; CHECK: (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $24) (param externref i32) (result i32)))

;; CHECK: (import "wasm:js-string" "substring" (func $substring (type $25) (param externref i32 i32) (result (ref extern))))

Expand Down Expand Up @@ -245,7 +245,7 @@
)

;; CHECK: (func $string.get_codeunit (type $15) (param $ref externref) (result i32)
;; CHECK-NEXT: (call $codePointAt
;; CHECK-NEXT: (call $charCodeAt
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: )
Expand Down
Loading