[Vm-dev] VMMaker small problem for pharo developper
henrik.s.johansen at veloxit.no
Thu Mar 18 13:08:36 UTC 2010
On Mar 18, 2010, at 1:26 10PM, Jean Baptiste Arnaud wrote:
> Then what is the solution ? We could have a Pharo immutability bit VM, but that it can be better to share with squeak. (which should be easy, if these differences are fixed ).
One solution for the case I mentioned is to not hardcode where the primitives in such cases as MiscPrimitivePlugin are defined, but instead discover them in the image VMMaker is loaded into.
Thus you remove the link between VMMaker, and the image it's loaded into defining primitives in certain places, so the same VMMaker can work for both Squeak and Pharo as described.
F.ex. like this:
oc := OrderedCollection new.
CompiledMethod allInstancesDo: [:each |
(each pragmaAt: #primitive:module:) ifNotNil: [:prag |
((prag argumentAt: 2) = 'MiscPrimitivePlugin' and: [each literals includes: #var:declareC:])
ifTrue: [ oc add: (Array with: each methodClass name with: each selector)]]].
This assumes the method defining the primitive will include the primitive pragma, which should always be the case.
The "each literals includes: #var:declareC:" is a bit of a hack for disambiguating the CompiledMethod defining the primitive from other callers.
AFAIK, hints like that are required if the method is to be translated, and you are unlikely to find it in other callers. If anyone has a better idea, I'd appreciate it.
More information about the Vm-dev