Skip to content

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 25, 2025

A return call is a form of control flow, so we need to handle it. Specifically,
the original function is unwound before calling the next one, so when we
resume, we should just call the next one. To do that, save the call target
along with the locals during unwinding.

@kripken kripken requested a review from tlively August 25, 2025 17:04
Comment on lines 48 to 49
(return_call $sub)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding another log after the return_call to test that it is never reached. It also might be worth adding a resume in the original function as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 54 to 55
(call $log (i32.const 300))
(i32.const 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth having the tail-callee tail call yet another function that suspends to show that it works for more than one tail callee.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

;; CHECK-NEXT: [LoggingExternalInterface logging 100]
;; CHECK-NEXT: [LoggingExternalInterface logging 200]
;; CHECK-NEXT: [LoggingExternalInterface logging 300]
;; CHECK-NEXT: [LoggingExternalInterface logging 400]
;; CHECK-NEXT: [LoggingExternalInterface logging 500]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add logging to the main function to show that the suspends actually happen as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@kripken kripken enabled auto-merge (squash) August 28, 2025 22:16
@kripken kripken merged commit b9d5c23 into WebAssembly:main Aug 28, 2025
16 checks passed
@kripken kripken deleted the cont.return_call branch August 28, 2025 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants