Hello squeakers,
Of the long and exiting list of things that are in consideration for 3.9a, one is MethodAnnotations. This is a changeset that was done by Andreas long time ago (2002, I think) and it's used extensively in Tweak. At SCG, we have used it for ByteSurgeon and are using it for another ongoing project.
What are MethodAnnotations? ---------------------------------------
MethodAnnotations can be seen from two perspectives:
1) storing state in CompiledMethod objects.
In Squeak, CompiledMethod is a strange class. One thing you can't do is adding an instance variable. This makes experimentation awfully complicated, e.g. people made hacks to store state in the literalFrame or in class vars... see MethodWrappers for an example.
MethodAnnotations just provides a general, nice and easy way to store stuff in compiledMethods, no need for hacks anymore.
e.g. store:
(Object>>#halt) setProperty: #hello toValue: 5.
and read:
(Object>>#halt) valueOfProperty: #value;
2) Syntax for Method Annotations.
We can set annoations to methods using the syntax we already know for primitives (which are, in a sense, just an annotation):
Object>>mumble <hello: 4>
Tweak uses these annotations to describe when a method should be activated.
How are they implemented? -------------------------------------- Andreas' orginal implemention used a big WeakIdentityKeyDictionary in a class var of CompiledMethods to store the IdentityDictionary for each method. This turns out to have some nice properties (no space is used for non-annotated methods) and a bad one: Performance. For ByteSurgeon, after annotation all methods (40.000), it was unusably slow.
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives, the last one encodes the class in the case that there is a supersend in the method.
So if we use the last entry to store the class for each method (supered or not), we can put the annoations in the one before and don't need to test for anything. Putting the class (or Trait) in the last litereal has the nice side-effect of making a fast #who possible.
The changesets attached are a first step: We are right now adding the class binding to all methods but quickmethods (need to fix that), the second last literal is initialized with nil and will lazy initalize the property dictionary if it's accessed.
Please note that the attached changesets need to be files in in-order and the first one will recompile the whole image.
Filling the last literal with the class (or trait) for all methods will be done in an addional step after the annotation cs is in 3.9. Then we will change the implementation of compiledMethod>>who to use this information.
Any comments? Does anyone see a problem with the annotations itself or the implementation?
Marcus
Hello Marcus, and all;
The properties can be implemented for all objects (e.g. Digitalk's Smalltalk saga has had implemented for +10years, and it is proved to be helpfull). If done this way, CompiledMethods will not be "special objects"... with properties :-)
e.g. store: (Object>>#halt) setProperty: #hello toValue: 5. and read: (Object>>#halt) valueOfProperty: #value;
Please use messages like: anObject properties "returns the properties dictionary" anObject propertyAt: aSymbol "returns th eproperty aSymbol or nil" anObject propertyAt: aSymbol ifAbsent: aBlock anObject propertyAt: aSymbol ifAbsentPut: aBlock
The only situation I think the messages like #setxxx:toValue: is if you have a class named #Value... It is like calling "instance variables" for object collaborator's names when we have no class named #Variable it is used only for historial reasons but we must try to not continue doing the same error to not confuse novices (people that already think in languages and an object "Oriented" way... they see objects as dynamic/extensible variables to hold values of any "type"...)
Remember to consider properties when saving/loading objects from streams (if not implemented in the object, the registry must be considered while storing). Any subclass can implement the #properties message to change the mechanism or store the dictionary in the object itself.
- Syntax for Method Annotations. We can set annoations to methods using the syntax we already
know for primitives (which are, in a sense, just an annotation):
Object>>mumble <hello: 4>
Tweak uses these annotations to describe when a method should be activated.
mmm... why to use a "primitive" mechanism?
mumble ^thisContext method propertyAt: #hello (or something like this using only objects and no syntax/architecture sugar)
How are they implemented?
Andreas' orginal implemention used a big WeakIdentityKeyDictionary in a class var of CompiledMethods to store the IdentityDictionary for each method.
This is the way it was implemented in VisualSmalltalk, but for Object class. Doing that way you can have properties for all objects.
This turns out to have some nice properties (no space is used for non-annotated methods) and a bad one: Performance. For ByteSurgeon, after annotation all methods (40.000), it was unusably slow.
Under optimized VMs (jitter?) the perfomance penalty is really low.
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives, the last one encodes the class in the case that there is a supersend in the method.
The literal index can be codified in the compiledMethod's header if bits are free... (or can be extended) It can also be detected by detecting more literals than the header informs and/or having a "special class" to detect your addition (for example, a TweakLiteral) to detect what literal's you added (the original/old literal and another interesting information; e.g.: if you want to put a silent cookie to parasityze in a method as a proxy for protection or use count/metrics)
So if we use the last entry to store the class for each method (supered or not), we can put the annoations in the one before and don't need to test for anything. Putting the class (or Trait) in the last litereal has the nice side-effect of making a fast #who possible.
I prefer a specialized literal detectable by it's species (don't care about the literal position).
Any comments? Does anyone see a problem with the annotations itself or the implementation?
I see no problems, it is a well known and comfortable mechanism to annotate objects and has been used from long time ago.
best, Ale.
----- Original Message ----- From: "Marcus Denker" denker@iam.unibe.ch To: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Sent: Sunday, August 28, 2005 2:41 PM Subject: Request for Comment: MethodAnnotations for 3.9alpha
Hello squeakers,
Of the long and exiting list of things that are in consideration for 3.9a, one is MethodAnnotations. This is a changeset that was done by Andreas long time ago (2002, I think) and it's used extensively in Tweak. At SCG, we have used it for ByteSurgeon and are using it for another ongoing project.
What are MethodAnnotations?
MethodAnnotations can be seen from two perspectives:
- storing state in CompiledMethod objects.
In Squeak, CompiledMethod is a strange class. One thing you can't do is adding an instance variable. This makes experimentation awfully complicated, e.g. people made hacks to store state in the literalFrame or in class vars... see MethodWrappers for an example.
MethodAnnotations just provides a general, nice and easy way to store stuff in compiledMethods, no need for hacks anymore.
e.g. store:
(Object>>#halt) setProperty: #hello toValue: 5.
and read:
(Object>>#halt) valueOfProperty: #value;
Syntax for Method Annotations.
We can set annoations to methods using the syntax we already
know for primitives (which are, in a sense, just an annotation):
Object>>mumble <hello: 4>
Tweak uses these annotations to describe when a method should be activated.
How are they implemented?
Andreas' orginal implemention used a big WeakIdentityKeyDictionary in a class var of CompiledMethods to store the IdentityDictionary for each method. This turns out to have some nice properties (no space is used for non-annotated methods) and a bad one: Performance. For ByteSurgeon, after annotation all methods (40.000), it was unusably slow.
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives, the last one encodes the class in the case that there is a supersend in the method.
So if we use the last entry to store the class for each method (supered or not), we can put the annoations in the one before and don't need to test for anything. Putting the class (or Trait) in the last litereal has the nice side-effect of making a fast #who possible.
The changesets attached are a first step: We are right now adding the class binding to all methods but quickmethods (need to fix that), the second last literal is initialized with nil and will lazy initalize the property dictionary if it's accessed.
Please note that the attached changesets need to be files in in-order and the first one will recompile the whole image.
Filling the last literal with the class (or trait) for all methods will be done in an addional step after the annotation cs is in 3.9. Then we will change the implementation of compiledMethod>>who to use this information.
Any comments? Does anyone see a problem with the annotations itself or the implementation?
Marcus
---------------------------------------------------------------------------- ----
---------------------------------------------------------------------------- ----
Alejandro F. Reimondo wrote:
Hello Marcus, and all;
The properties can be implemented for all objects (e.g. Digitalk's Smalltalk saga has had implemented for +10years, and it is proved to be helpfull). If done this way, CompiledMethods will not be "special objects"... with properties :-)
Unfortunately, this also has some significant impacts on GC behavior. This is well-known and lead to the invention of Ephemerons in VisualWorks. Unless you have something like Ephemerons you can get bitten in very weird ways.
- Syntax for Method Annotations. We can set annoations to methods using the syntax we already
know for primitives (which are, in a sense, just an annotation):
Object>>mumble <hello: 4>
Tweak uses these annotations to describe when a method should be activated.
mmm... why to use a "primitive" mechanism?
mumble ^thisContext method propertyAt: #hello (or something like this using only objects and no syntax/architecture sugar)
An annotation is called an annotation because it has no sematic effect for the execution of the method. What you have in your method is not an annotation but *code* (which does have an effect). To illustrate:
Object>>yourself <returns: Object> ^self
Here, we have annotated the Method Object>>yourself with a sample annotation to indicate the type of the return value. We could retrieve this type by using:
(Object compiledMethodAt: #yourself) propertyValueAt: #returns.
But the annotation does not change the execution of the method one bit. The method is still the same (a "quick return self"), the byte codes haven't changed.
Cheers, - Andreas
Hi Andreas,
This is well-known and lead to the invention of Ephemerons in VisualWorks. Unless you have something like Ephemerons you can get bitten in very weird ways.
Yes, ephemerons are a required.
An annotation is called an annotation because it has no sematic effect for the execution of the method. What you have in your method is not an annotation but *code* (which does have an effect). To illustrate:
Object>>yourself <returns: Object> ^self
if: 1.-it is not related with the message (selector, args & comment) 2.-is is not related with method's semantics. we can consider them as text style; a cookie to be mantained by a tool, so we are not talking about methods here.
I follow an implementation where the annotation is not "inside" the method and are mantained by tools.
cheers, Ale.
----- Original Message ----- From: "Andreas Raab" andreas.raab@gmx.de To: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Sent: Monday, August 29, 2005 12:50 AM Subject: Re: Request for Comment: MethodAnnotations for 3.9alpha
Alejandro F. Reimondo wrote:
Hello Marcus, and all;
The properties can be implemented for all objects (e.g. Digitalk's Smalltalk saga has had implemented for +10years, and it is proved to be helpfull). If done this way, CompiledMethods will not be "special objects"... with properties :-)
Unfortunately, this also has some significant impacts on GC behavior. This is well-known and lead to the invention of Ephemerons in VisualWorks. Unless you have something like Ephemerons you can get bitten in very weird ways.
- Syntax for Method Annotations. We can set annoations to methods using the syntax we already
know for primitives (which are, in a sense, just an annotation):
Object>>mumble <hello: 4>
Tweak uses these annotations to describe when a method should be activated.
mmm... why to use a "primitive" mechanism?
mumble ^thisContext method propertyAt: #hello (or something like this using only objects and no syntax/architecture
sugar)
An annotation is called an annotation because it has no sematic effect for the execution of the method. What you have in your method is not an annotation but *code* (which does have an effect). To illustrate:
Object>>yourself <returns: Object> ^self
Here, we have annotated the Method Object>>yourself with a sample annotation to indicate the type of the return value. We could retrieve this type by using:
(Object compiledMethodAt: #yourself) propertyValueAt: #returns.
But the annotation does not change the execution of the method one bit. The method is still the same (a "quick return self"), the byte codes haven't changed.
Cheers,
- Andreas
Markus and all working in "Future Squeak"
Please I beg a clear "why us think ..." page somewhere.
I still fighting the Squeak underworld and now I really confused.
Why some members think inheritance is not enough ?
What's wrong of having a Class in the usual way with the internals suited to your wish ?
Sorry if I wasting your time, but as String refactoring is causing me some problems, I really scare some radical as touching CompiledMethods.
Maybe I total miss the point ?
Regards
Edgar
___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Hi Edgar, all;
[warning: large and non-spellchecked :-) ]
Markus and all working in "Future Squeak" Please I beg a clear "why us think ..." page somewhere.
[...snip...]
Sorry if I wasting your time, but as String refactoring is causing me some problems, I really scare some radical as touching CompiledMethods.
IMHO, the real problem is related with thinking one can make the other's future a better place to live :-) The plans and actions taken to define/force a future only make visionaries and is not compromised with evolution nor with the present. (use of vision put is to use only object orientation, the future and is not related with reality/present)
When we do a plan, we make a change; but it does not mean in any way evolution. It only guaranty risk and pain (generally of the others, the users of our invent/machine). So it is very important to make little/slow/invisible changes and reinforce education to evade the continuos proliferation of non-relevant/regional enhacements.
The addition of native changes [*] increase the risk of failures and bad use of the additions increasing garbage. Any explisit evaluation of risk and how the garbage will be controlled and mantained under control is a very important ingredient of a plan.
[*] specially for changes in the way we think about behavior. The adoption of a model where behavior is anObject (and e.g. many species of behaviors are drawn), must be revised and the convenience demostrated with a proper evaluation of the "side effects" in people. To fraction/split behavior in smaller parts can be helpfull in low term but will put us in the same problem faced by physicians decades ago, when they thought that all can/must be modelled by objects... reducing the world to written words.
Why some members think inheritance is not enough ?
Inheritance is a technique, has it´s limits as any technique. But there are more techniques for delegation than inheritance.
To see the other techniques as hacks, in my opinion, reveals a lack of education and show us we have to make more efforts in education. Building more primitive tools for applying the techniques si not enough to ensure good use of them. (is like making machines to recollect garbage and not to focus on the garbage generation activities)
best, Ale.
----- Original Message ----- From: "Lic. Edgar J. De Cleene" edgardec2001@yahoo.com.ar To: "squeakdev" squeak-dev@lists.squeakfoundation.org Sent: Sunday, August 28, 2005 3:15 PM Subject: Help for beginners (was Re: Request for Comment: MethodAnnotations for 3.9alpha)
Markus and all working in "Future Squeak"
Please I beg a clear "why us think ..." page somewhere.
I still fighting the Squeak underworld and now I really confused.
Why some members think inheritance is not enough ?
What's wrong of having a Class in the usual way with the internals suited
to
your wish ?
Sorry if I wasting your time, but as String refactoring is causing me some problems, I really scare some radical as touching CompiledMethods.
Maybe I total miss the point ?
Regards
Edgar
1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Am 28.08.2005 um 15:15 schrieb Lic. Edgar J. De Cleene:
Why some members think inheritance is not enough ?
In the case of CompiledMethod: Yes.
What's wrong of having a Class in the usual way with the internals suited to your wish ?
because you can not change CompiledMethod or add a subclass that adds a instvar and use it in place of CompiledMethod.
It's structure is known by the VM.
Sorry if I wasting your time, but as String refactoring is causing me some problems, I really scare some radical as touching CompiledMethods.
Why is it radical?
Marcus
Lic. Edgar J. De Cleene wrote:
Please I beg a clear "why us think ..." page somewhere. Why some members think inheritance is not enough ?
Take the example we've been discussing, ClassDescription. It is an abstract class. Why does it exist? to share behavior between Class and Metaclass. Why is this behavior not put in Behavior, which is already shared by those? because someone might want to inherit from Behavior, to create a runnable class, that does not have all this extra detail.
And what if we want a non-runnable class that has all the ClassDesc detail? that's tough, under single inheritance, we can't do that.
And why does the structure of Class, that any newbie might need to explore to understand the image he uses, have to be constrained by the structural considerations of expert wanting to subclass behavior? that's the way inheritance works. It forces the inheritance, though some other design might be more understandable.
So traits give us a different mechanism, that allows to reuse stuff from any class, without forcing things so specifically. As an addition to inheritance, they do allow some new options. According to some, they might be a good replacement for inheritance.
Anyway, for more detail, read the papers in the trait papers page.
Daniel
Lic. Edgar J. De Cleene wrote:
What's wrong of having a Class in the usual way with the internals suited to your wish ?
There is nothing wrong with it, but in the case of CompiledMethod it is not possible. That's because CompiledMethod has a "magical" format which is specifically recognized by the VM and any attempt to alter that format will crash the VM faster than you can say "ouch".
Sorry if I wasting your time, but as String refactoring is causing me some problems, I really scare some radical as touching
CompiledMethods.
I can see that but contrary to Strings which you probably use and manipulate in much of your code, how often have you had the need to access CompiledMethods? Not use them implicitly (by running some) but use them explicitly, to query for the byte code, literals, or similar.
Maybe I total miss the point ?
In a sense you are. Most people won't even notice that change - again contrary to something as widely used as String, CompiledMethod is used in extremely rare cases (mostly in the compiler and some in the debugger). Think about it like switching to a new compiler: Do you care as long as it works? Probably not.
Cheers, - Andreas
Why some members think inheritance is not enough ?
One partial answer: http://www.iam.unibe.ch/~scg/Archive/Papers/Blac02aTraitsHierarchy.pdf
Cheers, Alexandre
Alexandre Bergel puso en su mail :
Why some members think inheritance is not enough ?
One partial answer: http://www.iam.unibe.ch/~scg/Archive/Papers/Blac02aTraitsHierarchy.pdf
Cheers, Alexandre
Thanks Alexander.
Also thanks to people with many years of expertise.
Is a good reading paper.
But still I don't found other thing what saying the actual hierarchy class and class implementation is messy .
What something is bad used don't means the concept is bad.
And I don't buy the "Compiled Methods are a special thing for the VM so you don't could ....."
The answer is.
Do a different VM what let do what you wish!!
And continue refactoring the image, until no duplicate or messy code.
I like change and experiments, but confine to my own images.
And a final word, if Nature use inheritance for produce humans , maybe is not a wrong method.
Regards.
Edgar
___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
On Aug 30, 2005, at 3:47 AM, Lic. Edgar J. De Cleene wrote:
And a final word, if Nature use inheritance for produce humans , maybe is not a wrong method.
You could also view it as Nature assembling a collection of traits from each parent.
Josh
Regards.
Edgar
1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Quoting Josh Gargus schwa@fastmail.us:
On Aug 30, 2005, at 3:47 AM, Lic. Edgar J. De Cleene wrote:
And a final word, if Nature use inheritance for produce humans , maybe is not a wrong method.
You could also view it as Nature assembling a collection of traits from each parent.
Yup, and it certainly doesn't use single inheritance. :)
Julian
Julian Fitzell puso en su mail :
Yup, and it certainly doesn't use single inheritance. :)
Julian
Squeak descend of ST 80 ? Read http://www.laputan.org/pub/papers/MI-Borning-Ingalls.PDF
I repeat , I like all class of experiments, doing lots for learn.
Sometimes I take some stones in the past by warning things in alpha images.
And very appreciate the hard work and enthusiasm of people what have YEARS of doing Smalltalk.
But as the old publicity said "I think different". I want Smalltalk , not Tweak, not Croquet, not Self, not Objetive - C, etc
Edgar, Advocatus Diaboli
___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Am 31.08.2005 um 11:33 schrieb Lic. Edgar J. De Cleene:
Julian Fitzell puso en su mail :
Yup, and it certainly doesn't use single inheritance. :)
Julian
Squeak descend of ST 80 ? Read http://www.laputan.org/pub/papers/MI-Borning-Ingalls.PDF
Yes. So what? Apparently the issue of single inheritance was regarded of one of the things in need to be improved in Smalltalk even back then.
Traits are exacly this improvement. They bring all the good things of MI without many of the negative effects.
But as the old publicity said "I think different". I want Smalltalk , not Tweak, not Croquet, not Self, not Objetive - C, etc
Then maybe you should use some old version of Squeak (e.g. 1.03) and be happy?
Marcus
Marcus Denker puso en su mail :
Then maybe you should use some old version of Squeak (e.g. 1.03) and be happy?
Marcus
Not, I have my own SqueakLight, but I don't force nobody to use or like it. I don't waste more the time of all. Forget me.
When I reach the Gestalt ,several years from now, I send a note begin pardon.
Edgar
___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Lic. Edgar J. De Cleene wrote:
Marcus Denker puso en su mail :
Then maybe you should use some old version of Squeak (e.g. 1.03) and be happy?
Marcus
Not, I have my own SqueakLight, but I don't force nobody to use or like it. I don't waste more the time of all. Forget me.
When I reach the Gestalt ,several years from now, I send a note begin pardon.
Edgar
Edgar-
The whole point of Squeak was as a base for language exploration and development. As such it will evolve. There are lots of Smalltalks around, if you want Smalltalk. Of course, you have to realize that Smalltalk itself evolved incredibly -- the original Smalltalk was very different from the current one.
David
___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
On Aug 28, 2005, at 8:41 AM, Marcus Denker wrote:
Hello squeakers,
Of the long and exiting list of things that are in consideration for 3.9a, one is MethodAnnotations. This is a changeset that was done by Andreas long time ago (2002, I think) and it's used extensively in Tweak. At SCG, we have used it for ByteSurgeon and are using it for another ongoing project.
[snip]
Any comments? Does anyone see a problem with the annotations itself or the implementation?
I'd very much like to see method annotations in Squeak. However, why not use an implementation that's compatible with VW's pragmas? AFAICT, the VW syntax is a superset of the Tweak syntax, and it has a very similar implementation, with the annotations stored in the literal frame of the CompiledMethod.
Colin
Any comments? Does anyone see a problem with the annotations itself or the implementation?
I'd very much like to see method annotations in Squeak. However, why not use an implementation that's compatible with VW's pragmas? AFAICT, the VW syntax is a superset of the Tweak syntax, and it has a very similar implementation, with the annotations stored in the literal frame of the CompiledMethod.
It is similar but not identical. Tweak supports some annotations that VW doesn't support and vice versa. For example, try:
<type: Object>
in VW (it fails) vs. Tweak (it uses class Object) or
<args: #(foo bar baz) types: #(Object Integer String)>
in VW (it works) vs. Tweak (it fails). This could probably be fixed but personally, I don't care that much. Patches are of course welcome ;-)
Cheers, - Andreas
I'd very much like to see method annotations in Squeak. However, why not use an implementation that's compatible with VW's pragmas? AFAICT, the VW syntax is a superset of the Tweak syntax, and it has a very similar implementation, with the annotations stored in the literal frame of the CompiledMethod.
One problem that I see with pragmas is that a compile method cannot be annotated without recompiling it. Which would be quite hampering on....
Having setProperty:toValue: / valueOfProperty: would make things simpler. The compiler would not have to be modified.
On some point, instead of manipulating pragmas, such might be useful: Object>>forCurrentMethodSetProperty: name toValue: val thisContext method setProperty: name toValue: val
Alexandre
Hi Alexandre,
One problem that I see with pragmas is that a compile method cannot be annotated without recompiling it. Which would be quite hampering on....
I agree with you; it is like syntax annotation. As text styles put to source code; in this case no for humman consumtion but for tools consumption.
CompiledMethods are not constrained to a syntax, they are objects and are true without relation with a source "code" (or any genetic code). You can have more of one compiler in the image, or have more than one compiler working on aBehavior. To see behavior (aBehavior) as anObject only reveals one point of view, a very common vission, but only one form of "modeling" behavior. The division of behavior in more atomic units(objects) is a kind of decomposition, degradation/reduction of the virtual space in the same direction of Self. It does not guaranties a more confortable ambient.
Having setProperty:toValue: / valueOfProperty: would make things simpler. The compiler would not have to be modified.
On some point, instead of manipulating pragmas, such might be useful: Object>>forCurrentMethodSetProperty: name toValue: val thisContext method setProperty: name toValue: val
Please do not promote the "Value" concept if we do not have a Value class/species in the ambient. (it is like saying we have "variables" in Smalltalk, imho the promotion of this concepts do more difficult to novices to understand objects and naming concepts)
best, Ale.
----- Original Message ----- From: "Alexandre Bergel" bergel@iam.unibe.ch To: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Sent: Tuesday, August 30, 2005 4:32 PM Subject: Re: Request for Comment: MethodAnnotations for 3.9alpha
I'd very much like to see method annotations in Squeak. However, why not use an implementation that's compatible with VW's pragmas? AFAICT, the VW syntax is a superset of the Tweak syntax, and it has a very similar implementation, with the annotations stored in the literal frame of the CompiledMethod.
One problem that I see with pragmas is that a compile method cannot be annotated without recompiling it. Which would be quite hampering on....
Having setProperty:toValue: / valueOfProperty: would make things simpler. The compiler would not have to be modified.
On some point, instead of manipulating pragmas, such might be useful: Object>>forCurrentMethodSetProperty: name toValue: val thisContext method setProperty: name toValue: val
Alexandre
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.iam.unibe.ch/~bergel ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Hi Marcus -
What are MethodAnnotations?
MethodAnnotations can be seen from two perspectives:
- storing state in CompiledMethod objects.
This is good and I wholeheartedly agree with it.
Syntax for Method Annotations.
We can set annoations to methods using the syntax we already know
for primitives (which are, in a sense, just an annotation):
Let me caution you about this a little. If compatibility is a concern (and I believe that contrary to Tweak, for many people compatibility is a major concern here) you may not want to introduce syntax for annotations lightly. I wonder if (except from Tweak) there is any existing use for annotation that would *require* syntactical support. And there isn't you may want to be careful about when and how to introduce that support.
Tweak uses these annotations to describe when a method should be activated.
Actually no. There is more involved than that and because of it the compiler has to support it as a syntactical entity (very much like like the primitive:module: syntax which is recognized separately, too).
How are they implemented?
Andreas' orginal implemention used a big WeakIdentityKeyDictionary in a class var of CompiledMethods to store the IdentityDictionary for each method. This turns out to have some nice properties (no space is used for non-annotated methods) and a bad one: Performance.
Unfortunately, there is more than one. For example, serializing compiled methods becomes a tricky issue (the main reason why I need to switch in Tweak to the new implementation).
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives, the last one encodes the class in the case that there is a supersend in the method.
So if we use the last entry to store the class for each method (supered or not), we can put the annoations in the one before and don't need to test for anything. Putting the class (or Trait) in the last litereal has the nice side-effect of making a fast #who possible.
Plus: We can also store the selector of a method which is extremely helpful in various situations and makes #who *blindingly* fast ;-)
Plus: We can trivially remove the awkward encoding of the file pointer (this immediately gives us an unlimited size for the changes and sources file).
Plus: We can encode which package a method belongs to right in the method.
...
The changesets attached are a first step: We are right now adding the class binding to all methods but quickmethods (need to fix that), the second last literal is initialized with nil and will lazy initalize the property dictionary if it's accessed.
Sounds good so far, but can we create a new class CompiledMethodProperties (instead of using a dictionary), please? The point being that with further normalization of CompiledMethod we will almost certainly want to add some iVars and having a dictionary will require us to do more work for converting from dictionary to an explicit object etc.
Cheers, - Andreas
Andreas Raab wrote:
Plus: We can encode which package a method belongs to right in the method.
Mmmm... so pretty. ;)
Julian
Hi!
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives
I was not aware of this use of the first literal. I was wondering in which case does it happen ? Can you point me out an example ?
Cheers, Alexandre
Am 30.08.2005 um 09:44 schrieb Alexandre Bergel:
Hi!
So we hacked a version that used the literealFrame instead, after discussing this with Andreas, we now use the second-last literal Frame entry. The reasoning is the following: The first one is already used for some primitives
I was not aware of this use of the first literal. I was wondering in which case does it happen ? Can you point me out an example ?
e.g.
BalloonEngine>>#primFlushNeeded
While doing a load MC spends almost 40% of the time investigating method timestamps, which seems to be costly because they have to be looked up in sources and changes files. I speculate that peephole optimizing this by having the timestamp be a method annotation instead could work especially to the benefit of MC loading times. No?
Alex
On Sep 14, 2005, at 1:42 AM, Alexander Lazarević wrote:
While doing a load MC spends almost 40% of the time investigating method timestamps, which seems to be costly because they have to be looked up in sources and changes files. I speculate that peephole optimizing this by having the timestamp be a method annotation instead could work especially to the benefit of MC loading times. No?
Yes. I wouldn't mind having the whole method source as an annotation, in fact...
Avi
marcus is working on that if I remember correctly
Stef
On 14 sept. 05, at 10:59, Avi Bryant wrote:
On Sep 14, 2005, at 1:42 AM, Alexander Lazarević wrote:
While doing a load MC spends almost 40% of the time investigating method timestamps, which seems to be costly because they have to be looked up in sources and changes files. I speculate that peephole optimizing this by having the timestamp be a method annotation instead could work especially to the benefit of MC loading times. No?
Yes. I wouldn't mind having the whole method source as an annotation, in fact...
Avi
Am 14.09.2005 um 12:48 schrieb stéphane ducasse:
marcus is working on that if I remember correctly
Not directly... we will have annotations in 3.9a soon, but there are no plans to save the source there... We discussed to save the source-pointer in the MethodAnnotation object, thus making the current scheme more flexible.
I think that we should at some point re-assess some desgin desicions of 10 years ago... e.g. does it really make sense to store the source in external files?
With the current machines (or even those of a couple of years ago) there should be some other designs possible. But we do *not* want to loose the good side of having a .changes file as a persistant log of all changes.
Related to that, we (Phillipe and me) are experimenting with a Squeak that has only a very high level (OO) representation of method bodies. Everything else can be generated from that on demand (e.g. bytecode, eToy Tiles, text). But that of course is really experimental and not meant to be added to squeak anytime soon.
Marcus
squeak-dev@lists.squeakfoundation.org