@@ -502,7 +502,7 @@ struct FunctionValidator : public WalkerPass<PostWalker<FunctionValidator>> {
502
502
void visitStructRMW (StructRMW* curr);
503
503
void visitStructCmpxchg (StructCmpxchg* curr);
504
504
void visitArrayNew (ArrayNew* curr);
505
- template <typename ArrayNew> void visitArrayNew (ArrayNew* curr);
505
+ template <typename ArrayNew> void visitArrayNewSegment (ArrayNew* curr);
506
506
void visitArrayNewData (ArrayNewData* curr);
507
507
void visitArrayNewElem (ArrayNewElem* curr);
508
508
void visitArrayNewFixed (ArrayNewFixed* curr);
@@ -2375,6 +2375,8 @@ void FunctionValidator::visitRefFunc(RefFunc* curr) {
2375
2375
shouldBeTrue (func->type == curr->type .getHeapType (),
2376
2376
curr,
2377
2377
" function reference type must match referenced function type" );
2378
+ shouldBeTrue (
2379
+ curr->type .isExact (), curr, " function reference should be exact" );
2378
2380
}
2379
2381
2380
2382
void FunctionValidator::visitRefEq (RefEq* curr) {
@@ -3022,6 +3024,7 @@ void FunctionValidator::visitStructNew(StructNew* curr) {
3022
3024
" struct.new should have a non-nullable reference type" )) {
3023
3025
return ;
3024
3026
}
3027
+ shouldBeTrue (curr->type .isExact (), curr, " struct.new should be exact" );
3025
3028
auto heapType = curr->type .getHeapType ();
3026
3029
if (!shouldBeTrue (
3027
3030
heapType.isStruct (), curr, " struct.new heap type must be struct" )) {
@@ -3260,6 +3263,7 @@ void FunctionValidator::visitArrayNew(ArrayNew* curr) {
3260
3263
" array.new should have a non-nullable reference type" )) {
3261
3264
return ;
3262
3265
}
3266
+ shouldBeTrue (curr->type .isExact (), curr, " array.new* should be exact" );
3263
3267
auto heapType = curr->type .getHeapType ();
3264
3268
if (!shouldBeTrue (
3265
3269
heapType.isArray (), curr, " array.new heap type must be array" )) {
@@ -3284,7 +3288,7 @@ void FunctionValidator::visitArrayNew(ArrayNew* curr) {
3284
3288
}
3285
3289
3286
3290
template <typename ArrayNew>
3287
- void FunctionValidator::visitArrayNew (ArrayNew* curr) {
3291
+ void FunctionValidator::visitArrayNewSegment (ArrayNew* curr) {
3288
3292
shouldBeTrue (getModule ()->features .hasGC (),
3289
3293
curr,
3290
3294
" array.new_{data, elem} requires gc [--enable-gc]" );
@@ -3307,6 +3311,8 @@ void FunctionValidator::visitArrayNew(ArrayNew* curr) {
3307
3311
" array.new_{data, elem} type should be an array reference" )) {
3308
3312
return ;
3309
3313
}
3314
+ shouldBeTrue (
3315
+ curr->type .isExact (), curr, " array.new_{data, elem} should be exact" );
3310
3316
auto heapType = curr->type .getHeapType ();
3311
3317
if (!shouldBeTrue (
3312
3318
heapType.isArray (),
@@ -3317,7 +3323,7 @@ void FunctionValidator::visitArrayNew(ArrayNew* curr) {
3317
3323
}
3318
3324
3319
3325
void FunctionValidator::visitArrayNewData (ArrayNewData* curr) {
3320
- visitArrayNew (curr);
3326
+ visitArrayNewSegment (curr);
3321
3327
3322
3328
shouldBeTrue (
3323
3329
getModule ()->features .hasBulkMemory (),
@@ -3340,7 +3346,7 @@ void FunctionValidator::visitArrayNewData(ArrayNewData* curr) {
3340
3346
}
3341
3347
3342
3348
void FunctionValidator::visitArrayNewElem (ArrayNewElem* curr) {
3343
- visitArrayNew (curr);
3349
+ visitArrayNewSegment (curr);
3344
3350
3345
3351
if (!shouldBeTrue (getModule ()->getElementSegment (curr->segment ),
3346
3352
curr,
@@ -3363,21 +3369,22 @@ void FunctionValidator::visitArrayNewElem(ArrayNewElem* curr) {
3363
3369
void FunctionValidator::visitArrayNewFixed (ArrayNewFixed* curr) {
3364
3370
shouldBeTrue (getModule ()->features .hasGC (),
3365
3371
curr,
3366
- " array.init requires gc [--enable-gc]" );
3372
+ " array.new_fixed requires gc [--enable-gc]" );
3367
3373
if (curr->type == Type::unreachable) {
3368
3374
return ;
3369
3375
}
3376
+ shouldBeTrue (curr->type .isExact (), curr, " array.new_fixed should be exact" );
3370
3377
auto heapType = curr->type .getHeapType ();
3371
3378
if (!shouldBeTrue (
3372
- heapType.isArray (), curr, " array.init heap type must be array" )) {
3379
+ heapType.isArray (), curr, " array.new_fixed heap type must be array" )) {
3373
3380
return ;
3374
3381
}
3375
3382
const auto & element = heapType.getArray ().element ;
3376
3383
for (auto * value : curr->values ) {
3377
3384
shouldBeSubType (value->type ,
3378
3385
element.type ,
3379
3386
curr,
3380
- " array.init value must have proper type" );
3387
+ " array.new_fixed value must have proper type" );
3381
3388
}
3382
3389
}
3383
3390
@@ -3699,6 +3706,7 @@ void FunctionValidator::visitContNew(ContNew* curr) {
3699
3706
" cont.new should have a non-nullable reference type" )) {
3700
3707
return ;
3701
3708
}
3709
+ shouldBeTrue (curr->type .isExact (), curr, " cont.new should be exact" );
3702
3710
3703
3711
shouldBeTrue (curr->type .isContinuation () &&
3704
3712
curr->type .getHeapType ().getContinuation ().type .isSignature (),
@@ -3735,6 +3743,7 @@ void FunctionValidator::visitContBind(ContBind* curr) {
3735
3743
" cont.bind should have a non-nullable reference type" )) {
3736
3744
return ;
3737
3745
}
3746
+ shouldBeTrue (curr->type .isExact (), curr, " cont.bind should be exact" );
3738
3747
}
3739
3748
3740
3749
void FunctionValidator::visitSuspend (Suspend* curr) {
0 commit comments