> On 18 Nov 2022, at 08:15, Marcus Denker <[email protected]> wrote: > > We merged 18 PRs > > Lots of improvements related to BlockClosures this week. > > First some helper methods on the AST: > - #hasNonLocalReturn: check if there is a non-local return > - #isConstant: Blocks of the kind [#justSomeLiteral] > - #constantValue: return that literal (and nil for empty [] ) > - #numArgs for RBBlockNode, as we have already for BlockClosure "[:a | ] > sourceNode numArgs” >
Some numbers: "there are lots of blocks" allBlocks := Smalltalk globals allMethods flatCollect: [:meth | meth ast blockNodes ]. allBlocks size. "100140" "but many are compiled inline (eg argunments of #ifTrue:)" currentFullBlocks := allBlocks select: [:blockNode | blockNode isInlined not]. currentFullBlocks size. "45193" "What we could compile as CleanBlockClosure" cleanBlocks := currentFullBlocks select: [:blockNode | blockNode isClean]. cleanBlocks size. "11090" "many clean blocks are actually constant" constantBlocks := cleanBlocks select: [:blockNode | blockNode isConstant]. constantBlocks size. "3200" "FullBlocks that need the outerContext to return" fullBocksWithReturn := currentFullBlocks select: [ :each | each hasNonLocalReturn ]. fullBocksWithReturn size “3816” We can inspect the collections and then use the inspector to browse the code (with the block that you look at hightlighted), to get a feel where these are used, e.g. for constant:
