[Pharo-dev] Improved Inspectors for Blocks

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. 


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

[Meta] Steps needed for CleanBlocks #11195



[Pharo-dev] This week (47/2022) on the Pharo Issue Tracker.

We merge 33 PRs this week.

Features / Enhancements

– Introducing new icons #11896

– Enhancement: PackageManifest with an own system icon #11956

– ReNotOptimizedIfNilRule #11932

– Sync #basicInspect and inspect #11899

Blocks / Compiler

Constant blocks now implement correct error handling wrt to number of arguments, we now have an option to enable compiling constant block (#optionConstantBlockClosure) and can recompile the whole system with compiling constant blocks.

– 11912-Compiler-add-option-for-constant-blocks #11927

– Blocks: pcInOuter-not-Debugging #11951

– Class comments for Compiler classes (mostly exceptions) #11948

– Some smaller fixes/cleanups related to Blocks #11936

– Context-print-no-isClean-check #11922

– 11901-ConstantBlockClosure-raise-error-if-called-with-wrong-number-of-args #11919

– Better-CompiledCode-Inspector: highlight in source #436

– Inspect-CompiledBlock-IR #435


– fix OSWIndowDriver shutdown while saving #11831

– do not rebuild all Calypso tools at each selection change #11952

– EpHasImpactVisitor>>visitProtocolRemoval: handle protocols that only contain trait methods. #11942

– RubTextEditor: Bind the MENU key to open the context menu #11659

– Fixes #11925, ExternalBrowser does not show class definition from ST files Bug #11929

– 11762 cannot view st file content with code file browser #11924

– Fix debugger to update debugger extensions when a context is selected in the stack + fixing bytecode extension #405

Git Support

– Forget repository iceberg error on windows #1633

– Fixing the error handling. #1631

– Migrate GT inspector extensions to new tools model #1630

CI Setup

– Fixing runKernelTests to make it work with alternating VMs #11935

– Improve bootstrap.sh #11824


– Remove old comment editors #11945

– Cleanup on The package TestRunner #11509

Trivial Cleanups

– Cleanup TypingVisitor>>#initialize method category #11958

– Clenaup MemoryLogger>>#initialize #11962

– Cleanup: Fix lint TFTestCallbackExceptionHandler>>#initialize #11960

– simplify some users of #ifNil:ifNotNil: to use not nil arg #11930

– Use-optimizable-ifTrue #11923

– remove the unused <return:> pragma in spotter #434

– avoid #asSymbol for the defaultFont. fixes #1329 #1330

Bloc update

Hello! this is another update on activities the Bloc project.


Last week, I debugged an issue on Bloc animations, and discovered some issues more:

I’m in the middle of a change on the relevant package. This includes adding tests and comments, and cleaning up code.

Text rendering

Renames finished

Last week, I removed prim prefix from Cairo bindings methods, but Freetype and Harfbuzz were still missing. This is done now.

Debug combined emoji glyphs

We detected an issue rendering text with Zero-width joiner sequences. What is that? Fonts can specify a glyph for certain sequence of characters. This is the case of the following example, where the same Unicode sequence is rendered on first row using only Cairo, and the second row using Harfbuzz before Cairo:

The sequence can be generated in this way:

WideString streamContents: [ :stream |
    #( 16r1F468 16r1F469 16r1F467 16r1F466 ) "<-- individual faces"
        do: [ :each |  stream nextPut: (Unicode value: each) ]
        separatedBy: [ stream nextPut: Unicode zeroWidthSeparator ]]

The Noto Color Emoji font has a specific glyph for that sequence: the family shown in the second row of the screen capture. Without Harfbuzz to apply the font rule, we can only render the individual characters of the sequence (as in the first row of the capture).

The bug: Some times the family glyph is not rendered… that portion of the image is just white. Good news is that this is reproducible, not random. This example can be found in: AeHarfbuzzRenderExample class>>#example6Emoji, but should become a test.

Thanks for reading!

Regards, Martín

Tagged , ,

[Pharo-dev] This week (46/2022) on the Pharo Issue Tracker

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 improvements for isClean:
– unify between AST and BlockClosure
– more tests
– inlined blocks can be clean, important as it is recursive: [true ifTrue: []] should be clean
– cleanup code in CleanBlock, receiver is known to be nil

Compiler support for ConstantBlockClosure:
– We can specialize clean blocks of the kind [#justSomeLiteral] to execute faster
– add ConstantBlockClosure, add compiler support, active when compiling with clean blocks enabled

Compiler support for full block without outer context:
– we only need the outerContext for non-local returns. 
– add support to IRBuilder for full blocks without outer context
– implement compiler support (option #optionBlockClosureOptionalOuter, false for now)

Quick return for Blocks:
– Compile quickreturn for CompiledBlock, just like CompiledMethod (e.g. for [^1]).
– speeds up execution a little (but of course not creation)

Block Closures

– AST: add a recursive #hasNonLocalReturn and #isConstant #11882

– add #numArgs to RBBlockNode #11902

– CleanBlock cleanup code: there should be no receiver ivar #11884

– 11881-RBBlockNodeisClean-takes-every-optimized-block-to-be-not-clean #11890

– 1883-CleanBlockChecker-does-not-recurse-into-the-blocks #11900

– ConstantBlockClosure: active when compiling with clean blocks enabled #11894

– CompiledBlocks: compile quick returns #11907

– IRBuilder: add support for outerContext flag for Closure creation #11905

– 11911-Compiler-add-compiler-option-for-outerContextNeeded #11917


– Register-as-basicInspector #431

– 11803 return value of inspect should be the receiver and not a sp window presenter #11886

– Fixes #429, VersionBrowser: left pane empty #430

– Turn off ReLongMethodsRule for test methods #11892

– ClassParser: Implement #asSlot to return a correct Slot instances for complex slots #11898

– Fixes #11802 – Adds full consistency checks to class Time #11891

– Fixing to correctly get the VM for running the tests #11897

– Fixes #429, VersionBrowser: left pane empty #430

– 11810-FT2Handle-classstartUp-compiled-code-on-image-startup #11811


– fixing comments in package Regex #11888

Bloc update

This is Martín Dias communicating the activity in the Bloc project in last two weeks.

Clipping nested elements

We detected and fixed an issue on rendering clipping nested elements on the Alexandrie canvas.

The following example shows the issue:

  • Each circle contains two children of half-size of the container
  • Green circles have clipChildren:true, red circles have clipChildren:false.

The output should look as on the right, but was actually rendering as on the left:

Clipping bug
Actual and expected rendering (left and right, respectively)

Improve test coverage

We already counted with AePixelMatchTest hierarchy to detect rendering regressions, but we needed to add tests for each combination of:

  • border outskirts (inside, center, outside)
  • background type (none, translucent, opaque)

A visual introduction to such combinations:

Outskirts and background examples
Three nested elements set up with multiple visual options. The larger circle has clipChildren:false, and contains a green circle with clipChildren:true, and contains the smaller red circle.

Draft performance analysis

After writing and running some benchmarks, we have a notion about these questions:

Did the above fix affect performance? A benchmark showed no change in general, BUT elements with Outside outskirt border with either transparent or translucent background did show a 20% slowdown (no change when background is opaque).

Does the chosen outskirt of an element affect animation performance? Yes, and it depends also on the background opacity. Centered outskirts are always the fastest. Next table shows the difference between Centered against other outskirts options:

There are ways to improve the bad performances of outside-outskirts border. One is taking into account each geometry and doing some simple math. Might explain better in another week update.

Pixel-match regression testing: an improvement

We already counted with AePixelMatchTest hierarchy to detect rendering regressions (or just changes), but had a weakness: if several forms had a regression, they were all detected in a single test failure (AePixelMatchTest>>testAllForms).

This is now reported as individual failures, inspired in ParametrizedTestCase, printing the “render” selector as suffix:

Graphics libraries: update VM, test and benchmark

As you may know, Pharo has FFI bindings to Freetype, Cairo (via Athens) and SDL (via OSWindow). Such bindings call dynamic libraries that are are files located on the filesystem. Bloc and the Alexandrie canvas use such library files. In general, such files are inside the PharoVM directory, but there not always:

  • The Mac VM provides dylibs for all of them.
  • The Win VM provides dlls
  • The Linux VM does provide a .so for SDL, but doesn’t for Freetype and Cairo. In such cases, Pharo looks at system’s shared libraries.

In particular, the Mac’s PharoVM comes with a set of graphics libraries that is too old. With an update, the performance speedup is awesome. The key library updates were:

  • Cairo: 1.15.4 -> 1.17.4
  • Freetype: 2.9.1 -> 2.12.1
  • SDL: 2.0.18 -> 2.24.1

Our goal is having the same library versions on all platforms. Pablo worked on the update for Windows VM, however versions are more recent there. On Linux, it depends on the distribution (as explained before). On Debian/Ubuntu, cairo is 1.16.0 and performance didn’t change that much in preliminar benchmarks. On Arch, it should be more recent.

Huge speedup on Mac

Next table shows the improvement in frames per second on 18 variations of a benchmark (see it at the end of the post). The only change between Old and New column is that the image was opened with VMs with outdated or updated library versions, respectivaly.

Graphic library update benchmarks

Each row of the table is a benchmark that on each frame draws 300 rounded rectangles, with a small square on top-left that may be clipped or not. They look like this:

Rename FFI binding methods

Before this commit, the convention for method names in Alexandrie’s FFI bindings was to always use a prim prefix. For example, the Cairo function cairo_matrix_invert was mapping as

AeCairoMatrix >>
^ self ffiCall: #( AeCairoStatus cairo_matrix_invert ( self ) )

Now, this method is renamed as just invert.

We decided to use a distinctive prefix in selector only in certain cases. For example, for C functions that are typically used on instance creation, where the message sender has the responsibility to, at some point, call a free function to avoid a memory leak.

Fix rendering of annulus sector

Bloc counts with a BlAnnulusSectorGeometry, described as “I am a sector of an annulus. In mathematics, an annulus […] is a ring-shaped object, a region bounded by two concentric circles.” by its class-comment. An instance has a startAngle and endAngle to specify a sector. The meaning of the angles are:

  • An angle of 0.0 is in the direction of the positive X axis.
  • An angle of 90 degrees is in the direction of the positive Y axis.
  • Angles increase in the direction from the positive X axis toward the positive Y axis.

Visually, it can be presented like:

The issue: ambiguity in the meaning of the start and end angle

There is a difference in how Sparta-Cairo and Alexandrie canvas render this geometry. For example:

BlAnnulusSectorGeometry new
	startAngle: 180;
	endAngle: 120;
	innerRadius: 0.0;
	outerRadius: 1.0;

is rendered either as a sector from 120º to 180º or as a sector from 180º to 120º:

This discrepancy is confusing for users. It was reported in this issue and the pull request is waiting for discussion / merge. Basically, we agree that the second option is the right one.

I hope that you liked this little report on the current activity to make Bloc working great.

Regards, Martín.

Tagged , ,

3180 tweets and 1801 followers later…

It was not the official Pharo account but mine and I wanted to thank you for having follow this account since 2010.

Have fun and Pharo is getting better and better.

Now at https://pouet.chapril.org/web/@stepharo/

[Pharo-dev] This week (45/2022) on the Pharo Issue Tracker

We merged 17 PRs this week:

Code Coverage

– Package ‘Coverage’ as a higher level API for code coverage #11830

– Coverage: add static callgraphs #11866

Refactoring Engine

– Transition deprecate method refactoring to use driver #11851

– Fix: #11868 generate hash and printOn: are NOT refactoring so indicat… #11869

– Fixes #11872 adding abstract method and improving generate accessors #11873

– Fixes #11874: Remove new method to class side #11875

– fix #11877: Cleaning Replace Calls Transformation #11878


– Fix #11843 renaming a manifest breaks. #11857

– 11842-Context-menu-on-class-variables-opens-debug-menu #11864

– Fixes the problem related to backwards selection. Closes #11848 #11849

– Fix the printString of sequences including the same modifier. #11865


– Fix: #11852 one less obsolete pragma #11856

– Fix: #11854 removing useless code and obsolete pragmas! #11855

– Clean blocks simpler checks #11879

– #instVarNamed: does not need to send #asSymbol to the name #11860

– Make drtests spec2 compatible #11859


– [improvement] backport of #11487: Underscore in class name breaks text completion #11837

[Pharo-dev] This week (44/2022) on the Pharo Issue Tracker

We merged 7 PRs this week


– 11727 double click and drag does not select whole words #11838

– ClassParser: CDVariableNode should use AST of the variable definition #11788

– Closes #11817. The class creation text suggestion in Calypso now uses the current cl… #11846

– fixing OCBcToASTCache so that pcsForNode: gives the bytecode offsets associated to a node, in the ascending order #11847

– Change extract method shortcut to cmd e, cmd m #11839

– Fix #11794: Enhance CI to use the right VM version #11795

Refactoring Engine

– Transition MoveMethodToClassSide refactoring to use driver object #11825

[Ann] Bye bye Twitter…


This blog was connected to my personal twitter account and I decided that what is happening to Twitter with the arrival of Elon Musk is just too much for me. So I closed my twitter account. I’m fed up with arrogant and free speech promotors. Our world needs more serenity and not amplifying crazy people.

For the fun, the idea that programmers writing less lines of code would be fired is the last drop.

Not only it shows that this person is highly incompetent but not surprisingly it shows that even when he does not get anything to a domain he can have a position. Not commenting his “advices” to solve the war in Ukraine and more. Elon Musk should cut his right arm to see what it is. So people should continue to buy Telsa and feel good about been marketed.

Now time for alternatives: https://mastodon.social/@pharoproject

Stéphane Ducasse

PS: I will discuss with the Pharo board to see if we continue to use this bad media. Personally I do not want to be associated with it anymore.

[Ann] ESUG 2023 :)

  • A great conference (call for presentation will follow)
  • Super nice city wikipedia/Lyon Trip advisor Lyon
  • Easy to reach (2 hours from Paris Charles de Gaulle)
  • Gastronomic food

ESUG will be held at Lyon from Monday 28th August to Friday 1st of September 2023