OOps forgot:
I also change the logic that actually moves the bytes in the compactor a bit to decrement the target from the starting location versus what was there before. Although GCC made sense of the loop and built some nice assembler, CodeWarrior for Mac Classic extruded some ugly assembler. With the change both compilers produce optimal (almost) code for moving chunks of bytes.
The Smalltalk for the GC benchmark is this ugly chunk of code.
| counter target keep | counter _ 0. Smalltalk garbageCollect. Smalltalk garbageCollect. Smalltalk garbageCollect. Smalltalk allObjectsDo: [:e | counter _ counter + 1]. target _ 1000000 - counter. keep _ OrderedCollection new: 60000. target//10 timesRepeat: [| element | element _ OrderedCollection new: 10. 10 timesRepeat: [element add: Object new]. keep add: element]. Smalltalk garbageCollect. Smalltalk garbageCollect. Smalltalk garbageCollect. counter _ 0. Smalltalk allObjectsDo: [:e | counter _ counter + 1]. Transcript show: counter;cr. 10 timesRepeat: [Transcript show: (Time millisecondsToRun: [ Smalltalk garbageCollect]);cr].
PS optimal assembler would consider cache line logic. But that's a job for a custom memory move routine. memcpy does not work well here because it has too many checks and usually we move things 4/8/12 bytes or so, so the overhead of calling memcpy is too great.
-- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===