From 0e1ebc3eb390e29ed31b2b9f2e8781e5824fe95f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 19 Nov 2017 04:18:31 -0800 Subject: 4130 --- 076continuation.cc | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/076continuation.cc b/076continuation.cc index 79ee0dcd..8cfda4a3 100644 --- a/076continuation.cc +++ b/076continuation.cc @@ -222,6 +222,40 @@ if (is_mu_continuation(current_instruction().ingredients.at(0))) { break; // record results of resuming 'return-continuation-until-mark' instruction } +:(scenario continuations_can_return_values) +def main [ + local-scope + k:continuation, 1:num/raw <- call-with-continuation-mark f +] +def f [ + local-scope + g +] +def g [ + local-scope + return-continuation-until-mark 34 + stash [continuation called] +] +# entering main ++mem: new alloc: 1000 ++run: {k: "continuation"}, {1: "number", "raw": ()} <- call-with-continuation-mark {f: "recipe-literal"} +# entering f ++mem: new alloc: 1004 +# entering g ++mem: new alloc: 1007 +# return control to main ++run: return-continuation-until-mark {34: "literal"} +# no allocs abandoned yet ++mem: storing 34 in location 1 +# end of main +# make sure no memory leaks.. ++mem: trying to reclaim local k:continuation ++mem: automatically abandoning 1007 ++mem: automatically abandoning 1004 ++mem: automatically abandoning 1000 +# ..even though we never called the continuation +-app: continuation called + //: Ensure that the presence of a continuation keeps its stack frames from being reclaimed. :(scenario continuations_preserve_local_scopes) @@ -283,37 +317,3 @@ bool is_mu_continuation(reagent/*copy*/ x) { canonize_type(x); return x.type && x.type->atom && x.type->value == get(Type_ordinal, "continuation"); } - -:(scenario continuations_can_return_values) -def main [ - local-scope - k:continuation, 1:num/raw <- call-with-continuation-mark f -] -def f [ - local-scope - g -] -def g [ - local-scope - return-continuation-until-mark 34 - stash [continuation called] -] -# entering main -+mem: new alloc: 1000 -+run: {k: "continuation"}, {1: "number", "raw": ()} <- call-with-continuation-mark {f: "recipe-literal"} -# entering f -+mem: new alloc: 1004 -# entering g -+mem: new alloc: 1007 -# return control to main -+run: return-continuation-until-mark {34: "literal"} -# no allocs abandoned yet -+mem: storing 34 in location 1 -# end of main -# make sure no memory leaks.. -+mem: trying to reclaim local k:continuation -+mem: automatically abandoning 1007 -+mem: automatically abandoning 1004 -+mem: automatically abandoning 1000 -# ..even though we never called the continuation --app: continuation called -- cgit 1.4.1-2-gfad0