[squeak-dev] Time primitives

Levente Uzonyi leves at elte.hu
Tue Apr 7 21:42:21 UTC 2015


On Tue, 7 Apr 2015, David T. Lewis wrote:

> I am away and cannot double check the code right now, but the primitives
> should be consistent across Cog and the interpreter VM. There had been
> some confusion due to the early fork between trunk and oscog, but I
> believe that Eliot and I got it sorted out quite a while ago.

I can confirm this, but the primitives don't work correctly on the 
Interpreter VM (4.10.2.2614 on linux from squeakvm.org):

Time primUTCMicrosecondClock. "==> 2177453298247316"
Time primPosixMicrosecondClockWithOffset. "==> #(519745201 7200)"
DateAndTime now. "==> 2015-04-07T23:30:28.665+01:00"

The same with CogVM:

Time primUTCMicrosecondClock. "==> 3605895086935548"
Time primPosixMicrosecondClockWithOffset. "==> #(1428442289746346 7200)"
DateAndTime now. "==> 2015-04-07T23:31:32.962+01:00"

>
> These are not necessarily set up as numbered primitives, but the
> implementations are there, and they can be called as named primitives in
> Cog/Spur and interpreter VMs.
>
> I don't know about the Pharo fork, it's quite possible that things have
> gotten renamed there.

The primitives are the same, but the method names in the image are not, 
and the latter is what matters for me. It's a pain to keep code running in 
both branches.

>
> Note, the UTC with offset primitive is important to me because of
> UTCDateAndTime (http://wiki.squeak.org/squeak/6197), which is designed
> around the notion of a single primitive answering UTC time and local
> offset as an atomic call to the VM.

It seems like this primitive caches the time zone offset, which is bad 
when there are daylight savings changes (or when the machine goes to a 
different time zone). Here's the current value from a long running image:

Time primPosixMicrosecondClockWithOffset. "==> #(1428442620344927 3600)"

But the LocalePlugin's primitives seem like they know the truth:

Locale current primTimezone. "==> 120"
Locale current primDST. "==> true"


Levente

>
> Dave
>
>> Hi All,
>>
>> CogVM has two really nice time primitives 240 and 241. These are available
>> via Time class >> #primUTCMicrosecondClock and Time class >>
>> #primLocalMicrosecondClock.
>>
>> But there are two problems with them.
>> 1. They are not available in the Interpreter VM (It has a similar named
>> primitive - primitiveUtcWithOffset - available as Time class >>
>> #primPosixMicrosecondClockWithOffset, but that's not supported in Cog, and
>> I'd like to see its behavior changed slightly*)
>> 2. Primitive 240 is available in Pharo under a similar, but slightly
>> different name: #primUTCMicrosecondsClock. There are also derived
>> "primitive" methods: #primUTCSecondsClock and #primUTCMillisecondsClock.
>>
>> Questions:
>> - Which name should we use?
>>   - #primUTCMicrosecondClock
>>   - #primUTCMicrosecondsClock
>>   - something else
>>
>> - Can/should the interpreter VM support primitive 240 and 241?
>>
>> - Can/should CogVM support the name primitive primitiveUtcWithOffset?
>>
>> - Do we want the derived "primitives" #primUTCSecondsClock and
>> #primUTCMillisecondsClock in Squeak?
>>
>>
>> Levente
>>
>> * The primitive could accept an array as argument and fill that with the
>> values if present. This could prevent frequent GCs when the primitive is
>> used repeatedly.
>>
>
>
>
>


More information about the Squeak-dev mailing list