Remove experimental continuation support (#2776)

Removes `__continuation`, `__await`, and `__run`.

In part here, the discussion was that while the feature had been useful for validating the early explorer design, it's no longer needed for that role as the explorer is now quite robust. Continuations have been experimental and, at this point, don't have an owner pushing to a proposal.

The triggering factor is that, as we push to address fuzzer issues, I ran into a crash bug in this code; basically, `fn Main() -> i32 { __await; return 0; }`. When I mentioned this, the reaction seemed to trend towards removal of the feature.
This commit is contained in:
Jon Ross-Perkins
2023-04-19 14:22:43 -07:00
committed by GitHub
parent 60059ff726
commit 39155d34ae
49 changed files with 13 additions and 2665 deletions
-45
View File
@@ -95,23 +95,6 @@ void ActionStack::MergeScope(RuntimeScope scope) {
CARBON_FATAL() << "No current scope";
}
void ActionStack::InitializeFragment(StackFragment& fragment,
Nonnull<const Statement*> body) {
std::vector<Nonnull<const RuntimeScope*>> scopes;
for (const std::unique_ptr<Action>& action : todo_) {
if (action->scope().has_value()) {
scopes.push_back(&*action->scope());
}
}
// We don't capture globals_ or constants_ because they're global.
std::vector<std::unique_ptr<Action>> reversed_todo;
reversed_todo.push_back(std::make_unique<StatementAction>(body));
reversed_todo.push_back(
std::make_unique<ScopeAction>(RuntimeScope::Capture(scopes)));
fragment.StoreReversed(std::move(reversed_todo));
}
namespace {
// The way in which FinishAction should be called for a particular kind of
// action.
@@ -268,34 +251,6 @@ auto ActionStack::UnwindPast(Nonnull<const Statement*> ast_node,
return Success();
}
auto ActionStack::Resume(Nonnull<const ContinuationValue*> continuation)
-> ErrorOr<Success> {
Action& action = *todo_.Top();
action.set_pos(action.pos() + 1);
static_cast<StackFragment&>(continuation->representation()).RestoreTo(todo_);
return Success();
}
static auto IsRunAction(const Action& action) -> bool {
const auto* statement = llvm::dyn_cast<StatementAction>(&action);
return statement != nullptr && llvm::isa<Run>(statement->statement());
}
auto ActionStack::Suspend() -> ErrorOr<Success> {
// Pause the current continuation
todo_.Pop();
std::vector<std::unique_ptr<Action>> paused;
while (!IsRunAction(*todo_.Top())) {
paused.push_back(todo_.Pop());
}
const auto& continuation =
llvm::cast<const ContinuationValue>(*todo_.Top()->results()[0]);
// Update the continuation with the paused stack.
static_cast<StackFragment&>(continuation.representation())
.StoreReversed(std::move(paused));
return Success();
}
void ActionStack::PopScopes(
std::stack<std::unique_ptr<Action>>& cleanup_stack) {
while (!todo_.IsEmpty() && llvm::isa<ScopeAction>(*todo_.Top())) {