|
Hello,
i'd like to improve this thing, and here my thoughts.
The main purpose of these changes is to disallow the outer layers to
deal with uninformal byte arrays and poke with
pure data bytes, instead, they should always know what they dealing
with (either source pointer or temp names).
Other forms should be prohibited from use (by now), but we should
leave space for extensions,
so it should be easy to add a new meanings of trailer bytes in future.
So, here my thoughts:
- create a new class, CompiledMethodTrailer , which will be the ONLY
tool responsible for converting a meaningful value(s) to/from byte
array.
It should free the outer layers from need of dealing with raw bytes,
but instead provide a protocol which converting the informal values
(source pointer/temp names etc) into trailing bytes, which then could
be attached to compiled method.
No other tools or generator(s) should talk directly with
CompiledMethod and allowed to poke with raw data bytes.
Working with existing methods:
CompiledMethod>>getTrailer
"Answer the instance of CompiledMethodTrailer"
^ CompiledMethodTrailer method: self
CompiledMethod>>trailer "deprecate this"
^ self getTrailer bytes
CompiledMethod>>sourcePointer "deprecate it, use 'method getTrailer
sourcePointer'"
^ self getTrailer sourcePointer
Creating a new methods:
trailer := CompiledMethodTrailer new.
Accessing:
CompiledMethodTrailer >> sourcePointer:
CompiledMethodTrailer >> sourcePointer
CompiledMethodTrailer >> tempNames
CompiledMethodTrailer >> tempNames:
Testing:
CompiledMethodTrailer>>hasSourcePointer
CompiledMethodTrailer>>hasTempNames
CompiledMethodTrailer>>isEmpty "no trailer at all"
Visiting:
CompiledMethodTrailer>>visitWith: visitor
which sends one of #sourcePointer: #tempNames: #empty messages to a visitor.
Deprecate:
CompiledMethod class>>newBytes: numberOfBytes trailerBytes: trailer
nArgs: nArgs nTemps: nTemps nStack: stackSize nLits: nLits primitive:
primitiveIndex
Replace with:
CompiledMethod class>>newBytes: numberOfBytes trailer: trailer nArgs:
nArgs nTemps: nTemps nStack: stackSize nLits: nLits primitive:
primitiveIndex
- cleanup all the stuff which dealing with raw bytes, i.e.
methodNode generate: #(0 0 0 0).
-now, since CompiledMethodTrailer is the only class, responsible for
conversion, we can easily put extensions there at any moment, or
change the way how to encode
trailing bytes for existing methods.
--
Best regards,
Igor Stasenko AKA sig.
|