Repository navigation
evalArgAt, perform, do and init run their code as frames, so it can wait - #528
Merged
Merged
Conversation
A CFunction that evaluates Io code itself did so in a nested C eval loop, where a coroutine switch can't happen; in the browser that raises "can't wait or switch coroutines here". IoState_evalInFrame_ turns the calling frame into a DO_EVAL frame instead, optionally with a fixed result (clone returns the new object after init, do returns self). Used by: call evalArgAt, perform, performWithArgList, do, and the init that clone runs. List map, Map select and foreachSlot become waitable with them. doMessage, doString and doFile now share the helper. No nested eval loop starts for these any more, so clone of an object with an init is about 2x faster and perform about 1.6x. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 20, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A CFunction that evaluates Io code itself did so in a nested C eval loop, where a coroutine switch can't happen. In the browser that raises "can't wait or switch coroutines here". The plan listed this as "
sortByand similar", but a survey of about 50 constructs showed everyday ones were affected:map,perform,do,call evalArgAt, an object'sinit,repeat,select.Change
IoState_evalInFrame_turns the calling frame into aDO_EVALframe for the code, the mechanismdoMessagealready used, with an optional fixed result (clonereturns the new object afterinit;doreturns self). It only applies when the primitive was activated straight from the eval loop; otherwise the old path runs.Now using it:
call evalArgAt,perform,performWithArgList,do, and theinitthatcloneruns. Listmap, MapselectandforeachSlotbecome waitable with them.doMessage,doStringanddoFileshare the helper.Still not waitable (listed in
Plan.mdas the next batch):repeat, Listselect/selectInPlace, Sequenceforeach, thesortByfamily,interpolate,lexicalDo.Speed
Compared with a build of master on the same machine (ms, lower is better):
Testing
return,break,continueand errors through these primitives give the same results as master (compared side by side).make check279 pass,make check-componentpass,make check-browser-node32 pass, Playwright suite 83 / 83 (run locally).🤖 Generated with Claude Code