[Vm-dev] Eliot's BlockClosure model questions

Henrik Johansen henrik.s.johansen at veloxit.no
Fri Aug 2 11:56:54 UTC 2013


On Aug 2, 2013, at 1:35 , Henrik Johansen <henrik.s.johansen at veloxit.no> wrote:

> 
> On Aug 1, 2013, at 10:17 , Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
>> 
>> 
>> On Thu, Aug 1, 2013 at 10:15 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>> 
>> 
>> On Thu, Aug 1, 2013 at 1:21 AM, Clément Bera <bera.clement at gmail.com> wrote:
>>  
>> Hello Eliot,
>> 
>> So I implemented clean blocks with Opal in Pharo 3. I didn't know where to put the byte code of the clean block, so I put it at the end of the method.
>> 
>> ex:
>> exampleCleanBlock
>> 	^ [ 1  + 2 ] 
>> 
>> 17 <20> pushConstant: [...]
>> 18 <7C> returnTop
>> 19 <76> pushConstant: 1
>> 20 <77> pushConstant: 2
>> 21 <B0> send: +
>> 22 <7D> blockReturn
>> 
>> having in the literal Array:
>> [ 1 + 2 ]
>> #exampleCleanBlock
>> OCOpalExamples
>> 
>> The startpc of the block is 19.
>> Its outerContext is a context with nil as receiver and the method OCOpalExamples>>#exampleCleanBlock.
>> Its numArgs is 0 and it has no copiedValues.
>> 
>> But it does not work with the JIT.
>> 
>> Thinking about it I'm pretty sure the problem is that the JIT scans for and counts pushClosure: bytecodes to know how many blocks a method contains, but clean blocks don't need pushClosure: bytecodes.  So the JIT needs to look for clean blocks, e.g. either by scanning a method's literals or by looking at the arguments of pushLiteral: bytecodes.  In any case the image will allow me to develop a fix.
> 
> Hi!
> Made a non-Opal version that works in 2.0, located at https://dl.dropboxusercontent.com/u/6751081/BlockTest.zip together with a startup script that loads the package, then crashes the image.
> Note; all three clean block version in the .zip can be #value'd from a Workspace, it's first when you try to run those made by installClean/installCleanMinimal in a loop that the image crashes.
> 
> Cheers,
> Henry
Here's some sample benchmarks, the extra jump required to make it work currently seems to have an appreciable impact on performance:

{[BlockTest normal] bench . [BlockTest normal value] bench} 
#('7,340,000 per second.' '7,090,000 per second.')
#('7,050,000 per second.' '7,130,000 per second.')

BlockTest installCleanWithClosureCreation.
{[BlockTest clean] bench . [BlockTest clean value] bench}  
#('38,900,000 per second.' '32,600,000 per second.')
#('39,000,000 per second.' '33,100,000 per second.')

BlockTest installCleanMinimal.
{[BlockTest clean] bench . 'Cannot bench without crash'} 
#('48,700,000 per second.' 'Cannot bench without crash')  
#('49,700,000 per second.' 'Cannot bench without crash')

Cheers,
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20130802/efc96a69/attachment.htm


More information about the Vm-dev mailing list