[squeak-dev] The Primitive: I am not a number- I am a named prim! - SqueakPeople article

Eliot Miranda eliot.miranda at gmail.com
Tue Jul 1 19:25:08 UTC 2008


Sorry to reply to Steph's reply to Tim's original.  I didn't get the
original (because I had Anouncements checked by mistake inj my squeak-dev
mail settings).  I'm really replying to Tim's message here.

On Tue, Jul 1, 2008 at 9:27 AM, stephane ducasse <stephane.ducasse at free.fr>
wrote:

>
>>>
>> It's just a prim, ie a function somewhere.
>>
>> I'm proposing that we name all those prims that are currently numbered -
>> primitive 1 would become "primitiveAdd" in a similar manner to say
>> "primitiveDisablePowerManager".  This would allow all prims to be built as
>> plugin components, thereby allowing on the fly replacement of those plugins
>> (making due allowance for handling retained state etc, of course). (It's
>> sometihng I've been wanting to see done since 1988; I had discussions with
>> Alan Schiffman & Peter Deutsch about it way before I even move to
>> ParcPlace). We would lose the primitive table, saving a 8 kb or so. Oh and
>> the *really* obsoleteIndexPrimitiveTable, saving another 8Kb or so.
>
>
Gettng rid of both obsolete tables is a really good thing (and I've already
done it).

Getting rid of indexed primitives for the core does not save anything.
 There still has to be a table somewhere that maps the primitive name to the
primitive function.  All you do is replace a table mapping indices to
functions with one mapping strings to functions. You can't reply on the OS
to do the lookup because you won't be able to strip VM executables if you do
and that really costs space.

But more importantly I think its pointless.  The bulk of primitives in the
system are named, and they're in plugins and that all works fine, even
though lookup is a little involved and slow.  But I see nothing wrong with
the core language primitives being indexed.  They are pretty well fixed with
unchanged semantics and unchanged references in the system (e.g.
SmallInteger>>#+ is where you find <primitive: 1> and has always been where
you find it).  The table is quick to index and simple.

That said I think its worth cutting down the set of indexed primitives to a
minimum:

Object primtives (class, ==, ~~, become:
Control primitives (blocks, perform, executeMethod, findUnwind, terminateTo)
Process primitives (signal, wait, resume, suspend, yield)
Accessing primitives (at:, at:put:, size, instVarAt:, instVarAt:put:)
Instantiation primitives (new, new:, shallowCopy)
SmallInteger primitives, Float primitives, LargeInteger primitives (although
LargeInteger prims are arguable)
Mirror primitives (_object:instVarAt:, _objectClass: etc which the executuon
simulation machinery needs to use instead of instVarAt: & class etc to be
able to simulate proxy execution correctly)

Primitives that absolutely should not be indexed primitives include things
like
(90 primitiveMousePoint)
(91 primitiveTestDisplayDepth) "Blue Book: primitiveCursorLocPut"
(92 primitiveSetDisplayMode) "Blue Book: primitiveCursorLink"
(93 primitiveInputSemaphore)
(94 primitiveGetNextEvent) "Blue Book: primitiveSampleInterval"
(95 primitiveInputWord)
(98 primitiveStoreImageSegment)
(99 primitiveLoadImageSegment)
(101 primitiveBeCursor)
(102 primitiveBeDisplay)
(103 primitiveScanCharacters)
(105 primitiveStringReplace)
(106 primitiveScreenSize)
(107 primitiveMouseButtons)
(108 primitiveKbdNext)
(109 primitiveKbdPeek)
(126 primitiveDeferDisplayUpdates)
(127 primitiveShowDisplayRect)
(133 primitiveSetInterruptKey)
(134 primitiveInterruptSemaphore)
(140 primitiveBeep)
(141 primitiveClipboardText)
(142 primitiveVMPath)
(231 primitiveForceDisplayUpdate)
(232 primitiveFormPrint)
(233 primitiveSetFullScreen)

as these are to do with the broader context, not the core execution engine.

I would go further and rip out support for named primitives from the VM and
put it up in the image where it belongs.  I would build the machinery for
looking up named primitives in the image and have a primitive that allowed
one to slam a function address into a method.

For me the VM should include an execution engine, a small and fast FFI and
nothing else.  One needs some VM support to bootstrap the FFI.  i.e. the VM
must include a primitive to load a platform library and another to lookup a
name in it.  But other than that everything can be up in the image.  When
one invokes a method with a primitive that has not been bound to a function
yet then the primitive fails and the image's primitive failure code looks up
the primitive's name and retries the call or reports an error if the library
or name can't be found.

The indexed primitive table should then come down to under 256 entries, (512
if you include primitiveLoadInstVar) leaving those bits to be used for more
useful things like a larger literal range.

But that's just my opinion.



>>
> So do it.
>
> Stef
>
>>
>>
>> Some code gets simplified, some space is saved, some flexibility is added,
>> some bits are freed up in the CM header. THe downside is someone has to do
>> some work.
>
>
:)  back to my day job...



>
>>
>> tim
>> --
>> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
>> Advanced design: Upper management doesn't understand it.
>>
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080701/e72ec97c/attachment.htm


More information about the Squeak-dev mailing list