@@ -3991,24 +3991,27 @@ void FunctionValidator::visitContBind(ContBind* curr) {
39913991 curr,
39923992 " cont.bind requires stack-switching [--enable-stack-switching]" );
39933993
3994+ if (curr->cont ->type .isRef () &&
3995+ curr->cont ->type .getHeapType ().isMaybeShared (HeapType::nocont)) {
3996+ return ;
3997+ }
3998+
3999+ if (curr->type == Type::unreachable) {
4000+ return ;
4001+ }
4002+
39944003 shouldBeTrue (
3995- (curr->cont ->type .isContinuation () &&
3996- curr->cont ->type .getHeapType ().getContinuation ().type .isSignature ()) ||
3997- curr->cont ->type == Type::unreachable,
4004+ curr->cont ->type .isContinuation () &&
4005+ curr->cont ->type .getHeapType ().getContinuation ().type .isSignature (),
39984006 curr,
39994007 " the first type annotation on cont.bind must be a continuation type" );
40004008
40014009 shouldBeTrue (
4002- (curr->type .isContinuation () &&
4003- curr->type .getHeapType ().getContinuation ().type .isSignature ()) ||
4004- curr->type == Type::unreachable,
4010+ curr->type .isContinuation () &&
4011+ curr->type .getHeapType ().getContinuation ().type .isSignature (),
40054012 curr,
40064013 " the second type annotation on cont.bind must be a continuation type" );
40074014
4008- if (curr->type == Type::unreachable) {
4009- return ;
4010- }
4011-
40124015 if (!shouldBeTrue (curr->type .isNonNullable (),
40134016 curr,
40144017 " cont.bind should have a non-nullable reference type" )) {
@@ -4035,6 +4038,11 @@ void FunctionValidator::visitResume(Resume* curr) {
40354038 curr,
40364039 " sentTypes cache in resume instruction has not been initialized" );
40374040
4041+ if (curr->cont ->type .isRef () &&
4042+ curr->cont ->type .getHeapType ().isMaybeShared (HeapType::nocont)) {
4043+ return ;
4044+ }
4045+
40384046 shouldBeTrue (
40394047 (curr->cont ->type .isContinuation () &&
40404048 curr->cont ->type .getHeapType ().getContinuation ().type .isSignature ()) ||
@@ -4057,17 +4065,22 @@ void FunctionValidator::visitResumeThrow(ResumeThrow* curr) {
40574065 curr,
40584066 " sentTypes cache in resume_throw instruction has not been initialized" );
40594067
4068+ auto * tag = getModule ()->getTagOrNull (curr->tag );
4069+ if (!shouldBeTrue (!!tag, curr, " resume_throw exception tag must exist" )) {
4070+ return ;
4071+ }
4072+
4073+ if (curr->cont ->type .isRef () &&
4074+ curr->cont ->type .getHeapType ().isMaybeShared (HeapType::nocont)) {
4075+ return ;
4076+ }
4077+
40604078 shouldBeTrue (
40614079 (curr->cont ->type .isContinuation () &&
40624080 curr->cont ->type .getHeapType ().getContinuation ().type .isSignature ()) ||
40634081 curr->type == Type::unreachable,
40644082 curr,
40654083 " resume_throw must be annotated with a continuation type" );
4066-
4067- auto * tag = getModule ()->getTagOrNull (curr->tag );
4068- if (!shouldBeTrue (!!tag, curr, " resume_throw must be annotated with a tag" )) {
4069- return ;
4070- }
40714084}
40724085
40734086void FunctionValidator::visitStackSwitch (StackSwitch* curr) {
@@ -4076,17 +4089,22 @@ void FunctionValidator::visitStackSwitch(StackSwitch* curr) {
40764089 curr,
40774090 " switch requires stack-switching [--enable-stack-switching]" );
40784091
4092+ auto * tag = getModule ()->getTagOrNull (curr->tag );
4093+ if (!shouldBeTrue (!!tag, curr, " switch tag must exist" )) {
4094+ return ;
4095+ }
4096+
4097+ if (curr->cont ->type .isRef () &&
4098+ curr->cont ->type .getHeapType ().isMaybeShared (HeapType::nocont)) {
4099+ return ;
4100+ }
4101+
40794102 shouldBeTrue (
40804103 (curr->cont ->type .isContinuation () &&
40814104 curr->cont ->type .getHeapType ().getContinuation ().type .isSignature ()) ||
40824105 curr->type == Type::unreachable,
40834106 curr,
40844107 " switch must be annotated with a continuation type" );
4085-
4086- auto * tag = getModule ()->getTagOrNull (curr->tag );
4087- if (!shouldBeTrue (!!tag, curr, " switch must be annotated with a tag" )) {
4088- return ;
4089- }
40904108}
40914109
40924110void FunctionValidator::visitFunction (Function* curr) {
0 commit comments