Free primitive indexes
tim Rowledge
tim at rowledge.org
Fri Jul 13 23:55:19 UTC 2007
On 13-Jul-07, at 4:42 PM, sig wrote:
> Hello, squeak-dev,
>
> I found, that numeric primitive table in squeak have many gaps, filled
> with 'primitiveFail', and with comments like 'no longer used' and
> other..
> Id like to use one of the slots, but have no idea, what number is
> really safe for use?
> Any suggestions/reasoning?
You don't get to use numbered primitives. That is reserved for those
of us with god-like powers.
Seriously, unless you are doing something quite extraordinary, don't
even think about using numbered primitives. Write a simple named
primitive and put it in a plugin if at all possible. If you really
can't manage that, write a named primitive that will get left in the
vm core.
See, for example -
Interpreter>primitiveDisablePowerManager
"Pass in a non-negative value to disable the architectures
powermanager if any, zero to enable. This is a named (not numbered)
primitive in the null module (ie the VM)"
| integer |
self export: true.
integer := self stackIntegerValue: 0.
successFlag ifTrue: [
self ioDisablePowerManager: integer.
self pop: 1]. "integer; leave rcvr on stack"
and usage-
PowerManagement class>disablePowerManager: aInteger
"Disable/Enable the architectures power manager by passing in nonzero
or zero"
<primitive: 'primitiveDisablePowerManager'> "primitiveExternalCall"
^ self
There is no advantage to numbered primitives. Once the method lookup
has been done the primitive function's address is stored in the cache
so any primitive gets exactly the same treatment at that level. IF I
had the time to spare I would have had a go at removing numbered
prims altogether.
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Do files get embarrassed when they get unzipped?
More information about the Squeak-dev
mailing list
|