Improved Inspectors for Blocks

MD
Marcus Denker
Fri, Nov 25, 2022 10:58 AM

The inspectors for blocks are now a bit improved:

  1. CompiledBlock. This now is more in sync with CompiledMethod and shows
  • the homew method code with the block highlighted
  • the AST of the block
  • the IR if the block

Currently, we compile every non-optimized block to a full block that created by a bytecode from a CompiledBlock (which
itself is stored as a literal).

inspect “CompiledBlock allInstances” to see the new inspector:

  1. BlockClosure itself, e.g inspect  some block in the workspace. This gets more important as we soon will have pre-compiled
    subclasses of BlockClosure as method literals (and then just execute pushLiteral: to “create” the block).

A nice way to play with these is:

CompilationContext optionConstantBlockClosure: true.
OpalCompiler recompileAll.

some 2500 of the blocks are now compiled statically.

Inspect:

ConstantBlockClosure allSubInstances

The inspector shows the same (home method with highlight, IR, AST)

But we can do even better:

CompilationContext optionCleanBlockClosure: true.
OpalCompiler recompileAll.

Another 7500 blocks can be statically compiled, inspect

CleanBlockClosure allInstances

These are not yet the default, as we have to carefully analyse the places where we now assume that blocks know the outerContext
and receiver. (in the example above you see one of these: Announcements…).

You can follow these issues to see what still needs to be done:

[Meta] Steps needed for ConstantBlocks #11933
https://github.com/pharo-project/pharo/issues/11933

[Meta] Steps needed for CleanBlocks #11195
https://github.com/pharo-project/pharo/issues/11195

Marcus

The inspectors for blocks are now a bit improved: 1) CompiledBlock. This now is more in sync with CompiledMethod and shows - the homew method code with the block highlighted - the AST of the block - the IR if the block Currently, we compile every non-optimized block to a full block that created by a bytecode from a CompiledBlock (which itself is stored as a literal). inspect “CompiledBlock allInstances” to see the new inspector: 2) BlockClosure itself, e.g inspect some block in the workspace. This gets more important as we soon will have pre-compiled subclasses of BlockClosure as method literals (and then just execute pushLiteral: to “create” the block). A nice way to play with these is: CompilationContext optionConstantBlockClosure: true. OpalCompiler recompileAll. some 2500 of the blocks are now compiled statically. Inspect: ConstantBlockClosure allSubInstances The inspector shows the same (home method with highlight, IR, AST) But we can do even better: CompilationContext optionCleanBlockClosure: true. OpalCompiler recompileAll. Another 7500 blocks can be statically compiled, inspect CleanBlockClosure allInstances These are not yet the default, as we have to carefully analyse the places where we now assume that blocks know the outerContext and receiver. (in the example above you see one of these: Announcements…). You can follow these issues to see what still needs to be done: [Meta] Steps needed for ConstantBlocks #11933 https://github.com/pharo-project/pharo/issues/11933 [Meta] Steps needed for CleanBlocks #11195 https://github.com/pharo-project/pharo/issues/11195 Marcus