[Vm-dev] de-dup refactoring,
readImageFromFile:HeapSize:StartingAt:
Ben Coman
btc at openinworld.com
Wed Jun 15 23:19:27 UTC 2016
On Wed, Jun 15, 2016 at 11:24 PM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
> Hi Ben,
>
> if you have energy for this go for it. I'm happy to integrate.
Okay. I'll have a go.
cheers -ben
> For the moment let's stick to change sets.
>
> _,,,^..^,,,_ (phone)
>
>> On Jun 15, 2016, at 6:08 AM, Ben Coman <btc at openinworld.com> wrote:
>>
>>
>> Just an observation while I was comparing StackIntepreter and CoIntepreter
>> implementations of #readImageFromFile:HeapSize:StartingAt:
>> here.... https://www.diffchecker.com/ojepiwfn
>>
>> These methods are long and have a lot of duplicated code.
>> Would it be worthwhile to...
>> in CoInterpreter>>readImageFromFile:HeapSize:StartingAt:
>> rename variable /cogCodeSize/ to /extraHeapSize/
>> and then copy the method to...
>> StackInterpreter>>readImageFromFile: f HeapSize:
>> desiredHeapSize ExtraHeapSize: extraHeapSize StartingAt:
>> imageOffset
>>
>>
>> Then the duplication might(?) be eliminated by...
>>
>> StackInterpreter>>readImageFromFile: f HeapSize: desiredHeapSize
>> StartingAt: imageOffset
>> ^self readImageFromFile: f
>> HeapSize: desiredHeapSize
>> ExtraHeapSize: 0
>> StartingAt: imageOffset
>>
>>
>> CoInterpreter>>readImageFromFile: f HeapSize: desiredHeapSize
>> StartingAt: imageOffset
>> | hdrCogCodeSize dataSize |
>> hdrCogCodeSize := (self getShortFromFile: f swap: swapBytes) * 1024.
>> cogCodeSize := desiredCogCodeSize ~= 0
>> ifTrue: [desiredCogCodeSize]
>> ifFalse:
>> [hdrCogCodeSize = 0
>> ifTrue: [cogit defaultCogCodeSize]
>> ifFalse: [hdrCogCodeSize]].
>> ^dataSize := self readImageFromFile: f
>> HeapSize: desiredHeapSize
>> ExtraHeapSize: cogCodeSize
>> StartingAt: imageOffset.
>> self initializeCodeGenerator.
>> ^dataSize
>>
>> ??
>> cheers -ben
More information about the Vm-dev
mailing list