[squeak-dev] Code duplication around unwinding

Jaromir Matas mail at jaromir.net
Tue Feb 14 22:08:39 UTC 2023


Hi,

I'm enclosing a changeset that entirely removes unwind code duplicity in Context AND at the same time fixes the "stepOver bug" still persisting in the system.

To refresh what the bug is: You cannot #stepOver '^2' when you debug;
[^2] ensure: [] "step through to ^2 and try step over --> you get BCR"

The root cause is #return:from: supplies 'firstUnwindContext' to #aboutToReturn:through: but before this gets evaluated the real first unwind context changes during simulation and that causes the bug.

Originally (prior 2012), #aboutToReturn:through: just called 'self methodReturnContext return: result' and didn't use the 'firstUnwindContext' but in 2012 the call has been replaced with 'self methodReturnContext return: result through: firstUnwindContext' and the bug was born.

In the changeset I suggest to use one common method replacing #resume:through: and #resumeEvaluating: which solves the bug as a side-effect with only a tiny change in #return:from: (simply supply nil instead of 'firstUnwindContext').

I will post the changeset to the Inbox soon.

Best,
Jaromir


--

Jaromír Matas

mail at jaromir.net


From: Jaromir Matas<mailto:mail at jaromir.net>
Sent: Thursday, February 2, 2023 15:07
To: Squeak Dev<mailto:squeak-dev at lists.squeakfoundation.org>
Subject: [squeak-dev] Code duplication around unwinding

Hi all,

When I started learning Squeak I wondered why so much code duplication around unwinding: Context>>#restart, #resume:through:, #resumeEvaluating:, #terminate and #unwindTo: all implementing the exact same algorithm. Kernel-jar.1499 suggests removing all this duplicity while keeping the current unwind semantics. All Process and Exceptions tests are green.

This changeset is the first step in my effort to reduce the "noise" around the "collection" of resume/return methods in Context and Exception. One idea is to return calling the unwind mechanism back to the Exception class, as originally implemented in Squeak 2.x up to 3.5; please let me know if you find something fundamentally wrong with this idea.

Example: I find this call sequence begging for simplification:
Exception>>resume: --> resumeUnchecked: --> resumeEvaluating: --> Context>>returnEvaluating: --> resumeEvaluating:

Best,

Jaromir


--

Jaromír Matas

mail at jaromir.net



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230214/add49654/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Context-remove_duplicities_fix bug.jar.1.cs
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230214/add49654/attachment.ksh>


More information about the Squeak-dev mailing list