[Vm-dev] VM Maker: VMMaker.oscog-dtl.1730.mcz

David T. Lewis lewis at mail.msen.com
Thu Mar 17 15:01:38 UTC 2016


Hi Levente,

I am away and cannot check it right now, but the primitive is supposed to
be doing exactly what you say. It should accept zero or one arguments, and
fail otherwise. If the argument is provided, it must be an object with
room to store two or more pointers, otherwise the primitive should fail.
If either of these is not happening, it's a bug.

VMMaker.oscog-dtl.1730.mcz is an update to the oscog branch that should
add the ability to accept the optional parameter for Cog/Spur. Hopefully I
got the update right, I'm not sure I tested it as well as I should have
last night.

If we want to add a variant of the primitive that answers time relative to
Smalltalk epoch then yes, now would be a good time to do it.

Dave

>
> Hi Dave,
>
> Wouldn't it be better if the primitive were failing for more than one
> argument?
> Also, I liked Bert's idea to use the Squeak epoch, and I understand that
> you want to keep this primitive to use the Unix epoch, but in my opinion
> this is the best time to add the new primitive for the other variant.
> Are these changes going to appear in the Cog branch too?
>
> Levente
>
> On Thu, 17 Mar 2016, commits at source.squeak.org wrote:
>
>>
>> David T. Lewis uploaded a new version of VMMaker to project VM Maker:
>> http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.1730.mcz
>>
>> ==================== Summary ====================
>>
>> Name: VMMaker.oscog-dtl.1730
>> Author: dtl
>> Time: 16 March 2016, 9:06:26.74934 pm
>> UUID: ad4e53e1-bdbc-4cb9-b5fb-f1229ca4e19f
>> Ancestors: VMMaker.oscog-nice.1729
>>
>> Allow primitiveUtcWithOffset to accept an optional parameter with an
>> array or object with two or more slots to store UTC posix microseconds
>> and time zone offset in seconds. Compatibility with VMM trunk. Note,
>> consider incorporating ioUtcWithOffset from SVN trunk to provide true
>> atomic primitive.
>>
>> =============== Diff against VMMaker.oscog-nice.1729 ===============
>>
>> Item was changed:
>>  ----- Method: InterpreterPrimitives>>primitiveUtcWithOffset (in
>> category 'system control primitives') -----
>>  primitiveUtcWithOffset
>> + 	"Answer an array with UTC microseconds since the Posix epoch and the
>> + 	current seconds offset from GMT in the local time zone. An empty two
>> + 	element array (or any object with two or more slots) may be supplied
>> + 	as a parameter.
>> - 	"Answer an array with UTC microseconds since the Posix epoch and
>> - 	the current seconds offset from GMT in the local time zone.
>>  	This is a named (not numbered) primitive in the null module (ie the
>> VM)"
>>  	| epochDelta offset resultArray utcMicroseconds |
>>
>>  	<export: true>
>>  	<var: #epochDelta declareC: 'static usqLong epochDelta=
>> 2177452800000000ULL'>
>>  	<var: #utcMicroseconds type: #usqLong>
>>  	<var: #offset type: #sqLong>
>> + 	argumentCount > 1 ifTrue: [^self primitiveFailFor:
>> PrimErrBadNumArgs].
>>  	self cCode: '' inSmalltalk: [epochDelta := 2177452800000000].
>>  	utcMicroseconds := self ioUTCMicroseconds.
>>  	offset := self ioLocalMicroseconds - utcMicroseconds.
>>  	offset := offset / 1000000.
>>  	objectMemory pushRemappableOop: (self positive64BitIntegerFor:
>> utcMicroseconds - epochDelta).
>> + 	argumentCount > 0
>> + 		ifTrue: [resultArray := self popStack.
>> + 			((objectMemory isPointers: resultArray)
>> + 				and: [(objectMemory lengthOf: resultArray) >= 2])
>> + 					ifFalse: [^self primitiveFailFor: PrimErrBadArgument]]
>> + 		ifFalse: [resultArray := objectMemory instantiateClass: objectMemory
>> classArray indexableSize: 2].
>> - 	resultArray := objectMemory instantiateClass: objectMemory classArray
>> indexableSize: 2.
>>  	objectMemory storePointer: 0 ofObject: resultArray withValue:
>> objectMemory popRemappableOop.
>>  	objectMemory storePointerUnchecked: 1 ofObject: resultArray withValue:
>> (objectMemory integerObjectOf: offset).
>>  	self pop: 1 thenPush: resultArray
>>  !
>>
>>
>




More information about the Vm-dev mailing list