Commit 0b882b9 1 parent 795cf28 commit 0b882b9 Copy full SHA for 0b882b9
File tree 2 files changed +45
-12
lines changed
2 files changed +45
-12
lines changed Original file line number Diff line number Diff line change @@ -147,18 +147,11 @@ struct SignatureRefining : public Pass {
147
147
}
148
148
}
149
149
150
- // We cannot alter the signature of an exported function, as the outside may
151
- // notice us doing so. For example, if we turn a parameter from nullable
152
- // into non-nullable then callers sending a null will break. Put another
153
- // way, we need to see all callers to refine types, and for exports we
154
- // cannot do so.
155
- // TODO If a function type is passed we should also mark the types used
156
- // there, etc., recursively. For now this code just handles the top-
157
- // level type, which is enough to keep the fuzzer from erroring. More
158
- // generally, we need to decide about adding a "closed-world" flag of
159
- // some kind.
160
- for (auto * exportedFunc : ExportUtils::getExportedFunctions (*module)) {
161
- allInfo[exportedFunc->type ].canModify = false ;
150
+ // Find the public types, which we must not modify.
151
+ for (auto type : ModuleUtils::getPublicHeapTypes (*module)) {
152
+ if (type.isFunction ()) {
153
+ allInfo[type].canModify = false ;
154
+ }
162
155
}
163
156
164
157
// For now, do not optimize types that have subtypes. When we modify such a
Original file line number Diff line number Diff line change 1119
1119
;; (see tests above for how we handle refining of return values).
1120
1120
)
1121
1121
)
1122
+
1123
+ ;; Visibility: The type we'd like to refine, $sig, is in a rec group with a
1124
+ ;; public type, so do not optimize.
1125
+ (module
1126
+ (rec
1127
+ ;; CHECK: (rec
1128
+ ;; CHECK-NEXT: (type $sig (sub (func (param anyref))))
1129
+ (type $sig (sub (func (param anyref ))))
1130
+
1131
+ ;; CHECK: (type $struct (struct))
1132
+ (type $struct (struct ))
1133
+ )
1134
+
1135
+ ;; Export a global with $struct to make it public.
1136
+ ;; CHECK: (type $2 (func))
1137
+
1138
+ ;; CHECK: (global $struct (ref $struct) (struct.new_default $struct))
1139
+ (global $struct (ref $struct ) (struct.new $struct ))
1140
+
1141
+ ;; CHECK: (export "struct" (global $struct))
1142
+ (export " struct" (global $struct ))
1143
+
1144
+ ;; CHECK: (func $func (type $sig) (param $x anyref)
1145
+ ;; CHECK-NEXT: (nop)
1146
+ ;; CHECK-NEXT: )
1147
+ (func $func (type $sig ) (param $x anyref )
1148
+ )
1149
+
1150
+ ;; CHECK: (func $caller (type $2)
1151
+ ;; CHECK-NEXT: (call $func
1152
+ ;; CHECK-NEXT: (struct.new_default $struct)
1153
+ ;; CHECK-NEXT: )
1154
+ ;; CHECK-NEXT: )
1155
+ (func $caller
1156
+ (call $func
1157
+ (struct.new $struct )
1158
+ )
1159
+ )
1160
+ )
1161
+
You can’t perform that action at this time.
0 commit comments