Color your methods when they are executed [was: instrumenting send on squeak-dev]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Color your methods when they are executed [was: instrumenting send on squeak-dev]

Klaus D. Witzel
I've uploaded a new package Goya (to SqSource and SqMap) which paints  
methods with up to 25 colors, at the time they are executed. The changed  
VM (3.7.1, gcc 2.95.2) does

  0 tinyBenchmarks '288939051 bytecodes/sec; 6979361 sends/sec'

and the unchanged VM (also compiled by me) does

  0 tinyBenchmarks '289429055 bytecodes/sec; 8627664 sends/sec'

Methods can be colored dynamically in the running image (coloring survives  
snapshots). The implementation implants a "coloring" instance of a  
subclass of Association into the method's literal frame (same slot as the  
methodClass for super sends). This can be checked by the VM in O(1) time.

If the VM finds that a colored method sends to a colored implementor, the  
coloring information is bitOr:'ed into the sender's and the receiver's  
"coloring" association. This is like edge coloring of a graph.

Following the discussion of method coloring at Friday's Bern Smalltalk  
Gathering I also made a GoyaBrowser which views only those methods (and  
their respective classes and system categories) which satisfy some  
coloring condition, dynamically, depending on which colored methods are  
effectively executed.

With Goya I found that besides of SmallInteger and LargePositiveInteger and

  Array>>#replaceFrom:to:with:startingAt:
  ByteArray>>#replaceFrom:to:with:startingAt:

three other primitives fail and run their bytecode instead

  BitBlt>>#copyBits
  BitBlt>>#primDisplayString:from:to:map:xTable:kern:
  CharacterScanner>>#scanCharactersFrom:to:in:rightX:stopConditions:kern:

The initial Goya package includes some examples on FileStream, Morph,  
System-Compiler and instance creation for illustrating the implementation.

Note that I first tried to implement method coloring as an optional plugin  
but that would need to know the sending as well as the implementing method  
at the same time, which is apparently not available in the  
interpreterProxy interface. I am aware that I do open heart surgery and  
would appreciate any comment, critique and suggestion.

A developer has already emailed me for making the changed VM available or  
else get rid of the VM changes (currently do my work on Win32 but am about  
to add Debian Sarge) but first I would like to receive some advise from  
the experts. Thank you in advance.

/Klaus