-
Notifications
You must be signed in to change notification settings - Fork 760
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
[Strings] Make string a subtype of ext, not any #7373
base: main
Are you sure you want to change the base?
Changes from all commits
8799f09
5e5b7f5
e8208c6
69b2d4c
7a43386
1acdb17
8c98ef3
e9d70b4
8843f01
3029317
cb59d41
2a8328f
a9d56ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,6 +403,11 @@ std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a, | |
HeapType lubUnshared; | ||
switch (HeapType(a).getBasic(Unshared)) { | ||
case HeapType::ext: | ||
if (bUnshared != HeapType::string) { | ||
return std::nullopt; | ||
} | ||
lubUnshared = HeapType::ext; | ||
break; | ||
case HeapType::func: | ||
case HeapType::cont: | ||
case HeapType::exn: | ||
|
@@ -433,15 +438,17 @@ std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a, | |
} | ||
break; | ||
case HeapType::array: | ||
case HeapType::string: | ||
lubUnshared = HeapType::any; | ||
break; | ||
case HeapType::string: | ||
case HeapType::none: | ||
case HeapType::noext: | ||
case HeapType::nofunc: | ||
case HeapType::nocont: | ||
case HeapType::noexn: | ||
// Bottom types already handled. | ||
// Bottom types already handled (including string as the switch value, | ||
// which implies the other value is bottom, which again would have been | ||
// handled). | ||
WASM_UNREACHABLE("unexpected basic type"); | ||
} | ||
auto share = HeapType(a).getShared(); | ||
|
@@ -949,8 +956,9 @@ std::optional<HeapType> HeapType::getSuperType() const { | |
case none: | ||
case exn: | ||
case noexn: | ||
case string: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes! This doesn't look like it was correct before, since it should have returned |
||
return {}; | ||
case string: | ||
return HeapType(ext).getBasic(share); | ||
case eq: | ||
return HeapType(any).getBasic(share); | ||
case i31: | ||
|
@@ -997,12 +1005,12 @@ size_t HeapType::getDepth() const { | |
case HeapType::exn: | ||
break; | ||
case HeapType::eq: | ||
case HeapType::string: | ||
depth++; | ||
break; | ||
case HeapType::i31: | ||
case HeapType::struct_: | ||
case HeapType::array: | ||
case HeapType::string: | ||
depth += 2; | ||
break; | ||
case HeapType::none: | ||
|
@@ -1046,9 +1054,9 @@ HeapType::BasicHeapType HeapType::getUnsharedBottom() const { | |
case i31: | ||
case struct_: | ||
case array: | ||
case string: | ||
case none: | ||
return none; | ||
case string: | ||
case noext: | ||
return noext; | ||
case nofunc: | ||
|
@@ -1496,8 +1504,9 @@ bool SubTyper::isSubType(HeapType a, HeapType b) { | |
aUnshared == HeapType::struct_ || aUnshared == HeapType::array || | ||
a.isStruct() || a.isArray(); | ||
case HeapType::i31: | ||
case HeapType::string: | ||
return aUnshared == HeapType::none; | ||
case HeapType::string: | ||
return aUnshared == HeapType::noext; | ||
case HeapType::struct_: | ||
return aUnshared == HeapType::none || a.isStruct(); | ||
case HeapType::array: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,24 +476,6 @@ | |
(string.const "five!") | ||
) | ||
) | ||
|
||
;; CHECK: [fuzz-exec] calling extern | ||
;; CHECK-NEXT: [fuzz-exec] note result: extern => string("string") | ||
(func $extern (export "extern") (result externref) | ||
(extern.convert_any | ||
(string.const "string") | ||
) | ||
) | ||
|
||
;; CHECK: [fuzz-exec] calling extern-intern | ||
;; CHECK-NEXT: [fuzz-exec] note result: extern-intern => string("string") | ||
(func $extern-intern (export "extern-intern") (result anyref) | ||
(any.convert_extern | ||
(extern.convert_any | ||
(string.const "string") | ||
Comment on lines
-491
to
-493
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might still be useful to test |
||
) | ||
) | ||
) | ||
) | ||
;; CHECK: [fuzz-exec] calling new_wtf16_array | ||
;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") | ||
|
@@ -623,11 +605,6 @@ | |
;; CHECK: [fuzz-exec] calling string.measure | ||
;; CHECK-NEXT: [fuzz-exec] note result: string.measure => 5 | ||
|
||
;; CHECK: [fuzz-exec] calling extern | ||
;; CHECK-NEXT: [fuzz-exec] note result: extern => string("string") | ||
|
||
;; CHECK: [fuzz-exec] calling extern-intern | ||
;; CHECK-NEXT: [fuzz-exec] note result: extern-intern => string("string") | ||
;; CHECK-NEXT: [fuzz-exec] comparing compare.1 | ||
;; CHECK-NEXT: [fuzz-exec] comparing compare.10 | ||
;; CHECK-NEXT: [fuzz-exec] comparing compare.2 | ||
|
@@ -648,8 +625,6 @@ | |
;; CHECK-NEXT: [fuzz-exec] comparing eq.3 | ||
;; CHECK-NEXT: [fuzz-exec] comparing eq.4 | ||
;; CHECK-NEXT: [fuzz-exec] comparing eq.5 | ||
;; CHECK-NEXT: [fuzz-exec] comparing extern | ||
;; CHECK-NEXT: [fuzz-exec] comparing extern-intern | ||
;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit | ||
;; CHECK-NEXT: [fuzz-exec] comparing invalid_code_point | ||
;; CHECK-NEXT: [fuzz-exec] comparing isolated_high_code_point | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,8 @@ | |
(if (result stringref) | ||
(i32.const 0) | ||
(then | ||
(ref.null none) ;; this will turn into noextern | ||
(ref.null noextern) ;; The change from stringref to externref does not | ||
;; cause problems here, nothing needs to change. | ||
Comment on lines
+239
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this unlock any potential code simplifications in StringLowering.cpp? |
||
) | ||
(else | ||
(local.get $ref) | ||
|
@@ -263,7 +264,7 @@ | |
(local.get $ref) | ||
) | ||
(else | ||
(ref.null none) | ||
(ref.null noextern) | ||
) | ||
) | ||
) | ||
|
@@ -378,10 +379,13 @@ | |
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
(func $struct-of-string | ||
;; Test lowering of struct fields from stringref to externref. | ||
;; Test lowering of struct fields from stringref to externref. This was more | ||
;; useful of a test when stringref was a subtype of anyref, but it is still | ||
;; useful to verify nothing here goes wrong. (Now we convert stringref to | ||
;; externref, a supertype, which is much simpler - same bottom type, etc.) | ||
(drop | ||
(struct.new $struct-of-string | ||
(ref.null none) ;; This null must be fixed to be ext. | ||
(ref.null noextern) ;; This null is already of the right type. | ||
(i32.const 10) | ||
(ref.null none) ;; Nothing to do here (field remains anyref). | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the addition to this comment.
string
isn't a bottom type, so why is it included in the bottom types already having been handled?