This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Improve handling of nested continuations #54
Merged
dhil
merged 19 commits into
effect-handlers:typed-continuations
from
frank-emrich:nested_testing
Aug 16, 2023
Merged
Improve handling of nested continuations #54
dhil
merged 19 commits into
effect-handlers:typed-continuations
from
frank-emrich:nested_testing
Aug 16, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dhil
reviewed
Aug 16, 2023
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.
LGTM.
@@ -347,10 +368,24 @@ pub fn resume( | |||
// entry of the payload store by virtue of using the array | |||
// calling trampoline to execute it. | |||
|
|||
// Restore tsp pointer in instance | |||
let _tsp = TopOfStackPointer::as_raw(instance.tsp()); |
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.
Does this perform any side-effects? Can we remove it?
dhil
reviewed
Aug 16, 2023
crates/runtime/src/continuation.rs
Outdated
let parent = unsafe { (*(*contobj).fiber).stack().parent() }; | ||
instance.set_tsp(TopOfStackPointer::from_raw(parent)); | ||
|
||
debug_println!("Continuation @ {:p} returned normally, setting tsp from {:p} to {:p}", contobj, tsp, parent); | ||
debug_println!("Continuation @ {:p} returned normally, setting tsp from {:p} to {:p}", contobj, _tsp, parent); |
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.
ah it is used here...
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the handling of nested continuations (i.e., invoking continuations within continuations).
It fixes two bugs:
FuncEnvironment::typed_continuations_load_continuation_object
, we were incorrectly setting thereadonly
flag, which meant that multiple loads to the continuation object slot in theVMContext
were sometimes combined into one, even though the slot was overwritten in between.continuation::resume
, we were not updating the top of stack (TSP) pointer in theVMInstance
after returning from a continuation.This PR also adds debug printing to certain functions in
continuation.rs
. Printing only happens in debug builds AND if the variableENABLE_DEBUG_PRINTING
in the same file is manually set to true. The printing goes through a macro to ensure that there is no chance of it affecting performance in release builds.This PR also adds various tests for nested uses of continuations, which also cover the two bugs mentioned earlier.