Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1 participants
- 144619 messages
[Pharo-project] GUIs with Pharo / how to learn smalltalk
by Daniel Lyons
Hi,
I have two questions, a technical one and a more general one.
In broad strokes, what are people doing for GUIs? My guess would be using Morphic, but googling around you find more abuse than use, it looks like, and very little live links to up-to-date documentation. It makes me wonder: is there something other than Morphic which is being used? Or is everyone doing web apps? Or is there some other GUI toolkit I haven't found yet, and that's where all the action is? Whenever I see a neat Morphic window or something, I feel a bit like there's a party going on somewhere and I didn't get an invitation. Like the first rule of Morphic club is you don't talk about Morphic club.
The general question I have is basically, am I the problem? Is it that the documentation isn't where I expect to find it, or in the form I'm used to seeing, or that it isn't relevant somehow in the Smalltalk universe? Or is it all really intuitive except for me? :) I could accept that, I suppose, but how did you Smalltalk wizards become wizards? Did you just dive in and start reading the code in your own image? Was there some master Smalltalk wizard that you knew who showed you how to do these things? I'm currently reading Smalltalk Best Practice Patterns and it's one of the best programming books I've ever read. I see that there is a great deal of mastery of programming going around in Smalltalk circles, but I don't see the books that take you past beginner towards master, other than SBPP. So what's the trick going on here? How did you guys become excellent?
I hope none of this comes across as negative; I think surely it's that I'm missing something.
Thanks,
â
Daniel Lyons
March 25, 2011
Re: [Pharo-project] "Does Committing Code to an Open Source Project Mean Committing Career Suicide?"
by DougEdmunds
"Does Committing Code to an Open Source Project Mean Committing Career
Suicide?"
No.
--
View this message in context: http://forum.world.st/Does-Committing-Code-to-an-Open-Source-Project-Mean-C…
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
March 25, 2011
[Pharo-project] A step toward reducing complexity
by DougEdmunds
Reduce the complexity of user interface themes
In general, user interface themes should inherit directly from UITheme, not
from a chain of themes. When you have a chain of themes, you are stuck with
the intermediate themes, whether you need/use them or not. Consider
GLMUITheme. Currently it is under UIThemeWatery2, which is under
UIThemeWatery, which is under UITheme.
Some characteristics inherited from the chain are missing, but in principal,
GLMUITheme can be moved directly under UITheme with just 3 changes.
1. Add an instanceVariable 'windowActiveDropShadowStyle'
UITheme subclass: #GLMUITheme
instanceVariableNames: 'windowActiveDropShadowStyle'
classVariableNames: ''
poolDictionaries: ''
category: 'Glamour-Morphic-Theme'
2. Add a class method
isAbstract
"Answer whether the receiver is considered to be abstract."
^false
3. Add an instance method
windowActiveDropShadowStyle: anObject
"Set the value of windowActiveDropShadowStyle"
windowActiveDropShadowStyle := anObject
Because GLMOrangeUITheme inherits these changes, it does not need
modification.
--
View this message in context: http://forum.world.st/A-step-toward-reducing-complexity-tp3404504p3404504.h…
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
March 25, 2011
Re: [Pharo-project] pharo closures
by Igor Stasenko
On 25 March 2011 02:51, Toon Verwaest <toon.verwaest(a)gmail.com> wrote:
> Ok, I will do so. (read the f-ing paper) I only read the blogpost until now.
>
> I just realized that I actually made a mistake in my mental model of your
> model. See! It's complex!
> So I realized that getting to the remotes is exactly as fast as going to the
> parent or outer context.
>
> This makes it as fast as having a method context with maximally 2 nested
> contexts (3 blocks nested), and faster than deeper nestings. How often does
> it occur that you have deeper nesting in Pharo? Is it worthwhile to make the
> remote arrays just for those cases?
>
> Is the copying really worthwhile to make those cases faster?
>
> My biggest problem until now is... why wouldn't you be able to do everything
> you do with the remote arrays, directly with the context frames? Why limit
> it to only the part that is being closed over? The naive implementation that
> just extends squeak with proper closure-links will obviously be slow. I
> agree that you need a stack. Now I'd just like to read why you choose to
> just take a part of the frame (the remote array) rather than the whole
> frame. This would avoid the copyTemps thing...
>
Perhaps because you don't need to copy unnecessary stuff, which
closure not accessing anyways.
This could save some cycles.
> But then. I guess I should go off and read the f-ing paper. I hope that
> particular thing is described there, since it's basically the piece I'm
> missing.
>
> Also I don't exactly know what Peter Deutsch did, but if it was the
> straightforward implementation then it seems obvious you get such a speedup.
> Implementing it is less obvious, naturally ;)
> These responses are exactly why I posed the question here... I'd like to
> understand why. No offense.
>
> cheers,
> Toon
>
>
> On 03/25/2011 02:22 AM, Eliot Miranda wrote:
>
> Toon,
> Â Â Â what you describe is how Peter Deutsch designed closures for ObjectWorks
> 2.4 & ObjectWorks 2.5, whose virtual machine and bytecode set served all the
> way through VisualWorks 3.0. Â If you read the context management paper
> you'll understand why this is a really slow design for a JIT. Â When I
> replaced that scheme by one essentially isomorphic to the Squeak one the VM
> became substantially faster; for example factors of two and three in
> exception delivery performance. Â The description of the problem and the
> performance numbers are all in the paper. Â There are two main optimizations
> I performed on the VisualWorkas VM, one is the closures scheme and the other
> is PICs. Â Those together sped-up what was the fastest commercial Smalltalk
> implementation by a factor of two on most platforms and a factor of three on
> Windows.
> I'm sorry it's complex, but if one wants good performance it's a price
> well-worth paying. Â After all I was able to implement the compiler and
> decompiler within a month, and Jorge proved at INRIA-Lille that I'm far form
> the only person on the planet who understands it. Â Lispers have understood
> the scheme for a long time now.
> best,
> Eliot
>
> On Thu, Mar 24, 2011 at 6:01 PM, Toon Verwaest <toon.verwaest(a)gmail.com>
> wrote:
>>
>>> I can't say that i clearly understood your concept. But if it will
>>> simplify implementation
>>> without seemingly speed loss, i am all ears :)
>>>
>>
>> test
>> Â Â |b|
>> Â Â [ |a|
>> Â Â Â a + b ]
>>
>> Suppose you can't compile anything away, then you get
>>
>> |==============
>> |MethodContext
>> |
>> |a := ...
>> |==============
>> Â Â ^
>> Â Â |
>> |==============
>> |BlockContext
>> |
>> |b := ...
>> |==============
>>
>> And you just look up starting at the current context and go up. Except if
>> the var is from the homeContext, then you directly follow the home-context
>> pointer.
>> Since all contexts link to the home-context, this makes it 1 pointer
>> indirection to get to the method's context. 1 for the parent context. So
>> that makes only 2 indirections starting from the 3 nested block (so when you
>> have [ ... [ ... [ ... ] ... ] ... ]; where all of them are required for
>> storing captured data. ifTrue:ifFalse: etc blocks obviously don't count. And
>> blocks without shared locals could be left out (although we might not do
>> that, for debugging reasons).
>>
>> Hope that helps.
>>
>> cheers,
>> Toon
>>
>
>
>
--
Best regards,
Igor Stasenko AKA sig.
March 25, 2011
Re: [Pharo-project] pharo closures
by Toon Verwaest
Ok, I will do so. (read the f-ing paper) I only read the blogpost until now.
I just realized that I actually made a mistake in my mental model of
your model. See! It's complex!
So I realized that getting to the remotes is exactly as fast as going to
the parent or outer context.
This makes it as fast as having a method context with maximally 2 nested
contexts (3 blocks nested), and faster than deeper nestings. How often
does it occur that you have deeper nesting in Pharo? Is it worthwhile to
make the remote arrays just for those cases?
Is the copying really worthwhile to make those cases faster?
My biggest problem until now is... why wouldn't you be able to do
everything you do with the remote arrays, directly with the context
frames? Why limit it to only the part that is being closed over? The
naive implementation that just extends squeak with proper closure-links
will obviously be slow. I agree that you need a stack. Now I'd just like
to read why you choose to just take a part of the frame (the remote
array) rather than the whole frame. This would avoid the copyTemps thing...
But then. I guess I should go off and read the f-ing paper. I hope that
particular thing is described there, since it's basically the piece I'm
missing.
Also I don't exactly know what Peter Deutsch did, but if it was the
straightforward implementation then it seems obvious you get such a
speedup. Implementing it is less obvious, naturally ;)
These responses are exactly why I posed the question here... I'd like to
understand why. No offense.
cheers,
Toon
On 03/25/2011 02:22 AM, Eliot Miranda wrote:
> Toon,
>
> what you describe is how Peter Deutsch designed closures for
> ObjectWorks 2.4 & ObjectWorks 2.5, whose virtual machine and bytecode
> set served all the way through VisualWorks 3.0. If you read the
> context management paper you'll understand why this is a really slow
> design for a JIT. When I replaced that scheme by one essentially
> isomorphic to the Squeak one the VM became substantially faster; for
> example factors of two and three in exception delivery performance.
> The description of the problem and the performance numbers are all in
> the paper. There are two main optimizations I performed on the
> VisualWorkas VM, one is the closures scheme and the other is PICs.
> Those together sped-up what was the fastest commercial Smalltalk
> implementation by a factor of two on most platforms and a factor of
> three on Windows.
>
> I'm sorry it's complex, but if one wants good performance it's a price
> well-worth paying. After all I was able to implement the compiler and
> decompiler within a month, and Jorge proved at INRIA-Lille that I'm
> far form the only person on the planet who understands it. Lispers
> have understood the scheme for a long time now.
>
> best,
> Eliot
>
> On Thu, Mar 24, 2011 at 6:01 PM, Toon Verwaest
> <toon.verwaest(a)gmail.com <mailto:toon.verwaest@gmail.com>> wrote:
>
>
> I can't say that i clearly understood your concept. But if it will
> simplify implementation
> without seemingly speed loss, i am all ears :)
>
>
> test
> |b|
> [ |a|
> a + b ]
>
> Suppose you can't compile anything away, then you get
>
> |==============
> |MethodContext
> |
> |a := ...
> |==============
> ^
> |
> |==============
> |BlockContext
> |
> |b := ...
> |==============
>
> And you just look up starting at the current context and go up.
> Except if the var is from the homeContext, then you directly
> follow the home-context pointer.
> Since all contexts link to the home-context, this makes it 1
> pointer indirection to get to the method's context. 1 for the
> parent context. So that makes only 2 indirections starting from
> the 3 nested block (so when you have [ ... [ ... [ ... ] ... ] ...
> ]; where all of them are required for storing captured data.
> ifTrue:ifFalse: etc blocks obviously don't count. And blocks
> without shared locals could be left out (although we might not do
> that, for debugging reasons).
>
> Hope that helps.
>
> cheers,
> Toon
>
>
March 25, 2011
Re: [Pharo-project] [squeak-dev] positionalMesssge breaks literal array parsing
by Matthew Fulmer
On Thu, Mar 24, 2011 at 02:12:31PM -0700, Eliot Miranda wrote:
> What is this support for? Is it for those funky ffi calls in the OpenGL
> code? Can it not be hoisted out of the scanner and into the parser proper?
> [and optimistically anyone have a fix already?]
I was under the impression those were never in the compiler. I
had to add the support to the Compiler myself (the code was in
the inbox, but now has been removed to the treated inbox).
OpenGL no longer has positional methods; they were removed
--
Matthew Fulmer (a.k.a. Tapple)
March 25, 2011
Re: [Pharo-project] pharo closures
by Eliot Miranda
Toon,
what you describe is how Peter Deutsch designed closures for ObjectWorks
2.4 & ObjectWorks 2.5, whose virtual machine and bytecode set served all the
way through VisualWorks 3.0. If you read the context management paper
you'll understand why this is a really slow design for a JIT. When I
replaced that scheme by one essentially isomorphic to the Squeak one the VM
became substantially faster; for example factors of two and three in
exception delivery performance. The description of the problem and the
performance numbers are all in the paper. There are two main optimizations
I performed on the VisualWorkas VM, one is the closures scheme and the other
is PICs. Those together sped-up what was the fastest commercial Smalltalk
implementation by a factor of two on most platforms and a factor of three on
Windows.
I'm sorry it's complex, but if one wants good performance it's a price
well-worth paying. After all I was able to implement the compiler and
decompiler within a month, and Jorge proved at INRIA-Lille that I'm far form
the only person on the planet who understands it. Lispers have understood
the scheme for a long time now.
best,
Eliot
On Thu, Mar 24, 2011 at 6:01 PM, Toon Verwaest <toon.verwaest(a)gmail.com>wrote:
>
> I can't say that i clearly understood your concept. But if it will
>> simplify implementation
>> without seemingly speed loss, i am all ears :)
>>
>>
> test
> |b|
> [ |a|
> a + b ]
>
> Suppose you can't compile anything away, then you get
>
> |==============
> |MethodContext
> |
> |a := ...
> |==============
> ^
> |
> |==============
> |BlockContext
> |
> |b := ...
> |==============
>
> And you just look up starting at the current context and go up. Except if
> the var is from the homeContext, then you directly follow the home-context
> pointer.
> Since all contexts link to the home-context, this makes it 1 pointer
> indirection to get to the method's context. 1 for the parent context. So
> that makes only 2 indirections starting from the 3 nested block (so when you
> have [ ... [ ... [ ... ] ... ] ... ]; where all of them are required for
> storing captured data. ifTrue:ifFalse: etc blocks obviously don't count. And
> blocks without shared locals could be left out (although we might not do
> that, for debugging reasons).
>
> Hope that helps.
>
> cheers,
> Toon
>
>
March 25, 2011
Re: [Pharo-project] pharo closures
by Eliot Miranda
On Thu, Mar 24, 2011 at 5:44 PM, Toon Verwaest <toon.verwaest(a)gmail.com>wrote:
>
> No I can't. Since I did it, I naturally think it's a good idea.
> Perhaps, instead of denigrating it without substantiating your claims you
> could propose (and then implement, and then get adopted) a better idea?
>
> Sure. My own VM will take a lot longer to get done! ;) I don't want to
> blemish any of your credit for building a cool VM. I was rather just
> wondering why you decided to go for this particular implementation which
> seems unobvious to me. Hence the question. I guess I should've formulated it
> slightly differently :) More info below.
>
> I can see why it would pay off for Lisp programmers to have closures
>> that run like the Pharo closures, since it has O(1) access performance.
>> However, this performance boost only starts paying off once you have at
>> least more than 4 levels of nested closures, something which, unlike in
>> LISP, almost never happens in Pharo. Or at least shouldn't happen (if it
>> does, it's probably ok to punish the people by giving them slower
>> performance).
>>
>
> Slower performance than what? BTW, I think you have things backwards. I
> modelled the pharo closure implementation on lisp closures, not the other
> way around.
>
> This is exactly what I meant. The closures seem like a very good idea for
> languages with very deeply nested closures. Lisp is such a language with all
> the macros ... I don't really see this being so in Pharo.
>
The issue is nothing to do with nesting and everything to do with executing
closures on a stack. Since closures are non-LIFO (can outlive their
dynamic extent) any non-locval state they have should /not/ be held on the
stack. Hence copying and indirection vectors.
This implementation is pretty hard to understand, and it makes
>> decompilation semi-impossible unless you make very strong assumptions about
>> how the bytecodes are used. This then again reduces the reusability of the
>> new bytecodes and probably of the decompiler once people start actually
>> using the pushNewArray: bytecodes.
>>
>
> Um, the decompiler works, and in fact works better now than it did a
> couple of years ago. So how does your claim stand up?
>
> For example when I just use the InstructionClient I get in pushNewArray:
> and then later popIntoTemp. This combination is supposed to make clear that
> you are storing a remote array. This is not what the bytecode says however.
> And this bytecode can easily be reused for something else; what if I use the
> bytecode to make my own arrays? What if this array is created in a different
> way? I can think of a lot of ways the temparray could come to be using lots
> of variations of bytecodes, from which I would never (...) be able to figure
> out that it's actually making the tempvector. Somehow I just feel there's a
> bigger disconnect between the bytecodes and the Smalltalk code and I'm
> unsure if this isn't harmful.
>
I think you're setting up a straw-man here. Until you find an example which
is ambiguous you haven't really got a case. First of all pushNewArray:
consNewArray is /not/ used to implement Array new: N, quite rightly. It is
currently only used for tuples and indirection vectors. It is clearly
unnecessary (and for the decompiler extremely confusing) to use it for Array
new: N. What other uses do you have in mind?
And how, other than vague stirrings, is this actually harmful? Be sure :)
>
> But ok, I am working on the Opal decompiler of course. Are you building an
> IR out with your decompiler? If so I'd like to have a look since I'm
> spending the whole day already trying to get the Opal compiler to somehow do
> what I want... getting one that works and builds a reusable IR would be
> useful. (I'm implementing your field-index-updating through bytecode
> transformation btw).
>
I just modified the base Squeak decompiler. The IR there-in is a stack of
stacks of parse nodes. It's a bit hairy but works well enough.
You might save a teeny tiny bit of memory by having stuff garbage
>> collected when it's not needed anymore ... but I doubt that the whole design
>> is based on that? Especially since it just penalizes the performance in
>> almost all possible ways for standard methods. And it even wastes memory in
>> general cases. I don't get it.
>>
>
> What has garbage collection got to do with anything? What precisely are
> you talking about? Indirection vectors? To understand the rationale for
> indirection vectors you have to understand the rationale for implementing
> closures on a conventional machine stack. For lisp that's clear; compile to
> a conventional stack as that's an easy model, in which case one has to store
> values that outlive LIFO discipline on the heap, hence indirection vectors.
> Why you might want to do that in a Smalltalk implementation when you could
> just access the outer context directly has a lot to do with VM internals.
> Basically its the same argument. If one can map Smalltalk execution to a
> conventional stack organization then the JIT can produce a more efficient
> execution engine. Not doing this causes significant problems in context
> management.
>
> With the garbage collection I meant the fact that you can already collect
> part of the stack frames and leave other parts (the remote temps) and only
> get them GCd later on when possible.
>
That's not the real issue one is solving. The real issue one is solving is
not having to write-back stack state to contexts. Read the f-ing paper ;)
>
> I do understand why you want to keep them on the stack as long as possible.
> The stack-frame marriage stuff for optimizations is very neat indeed. What
> I'm more worried about myself is the fact that stackframes aren't just
> linked to each other and share memory that way. This means that you only
> have 1 indirection to access the method-frame (via the homeContext), and 1
> for the outer context. You can directly access yourself. So only the 4rd
> context will have 2 indirections (what all contexts have now for remotes).
> From the 5th on it gets worse... but I can't really see this happening in
> real world situations.
>
The only place extra indirections are introduced is in the static chain for
nesting, i.e. non-local return being more expensive. Variable access is
O(1). Either you pay at variable dereference time (by walking the static
chain, a bad idea, closed over variables are read at least as many times as
they're read, so reduce the read time, not the close-over time) or at
closure-creation time (copying). Yes, creating them isn't cheap, but its
just an allocation (and that the allocator is slow isn't closures fault, and
is remediable), and an adaptive optimizer would eliminate them altogether
and to an extent make this entire conversation moot.
Then you have the problem that since you don't just link the frames and
> don't look up values via the frames, you have to copy over part of your
> frame for activation. This isn't necessarily -that- slow (although it is an
> overhead); but it's slightly clumsy and uses more memory. And that's where
> my problem lies I guess ... There's such a straightforward implementation
> possible, by just linking up stackframes (well... they are already linked up
> anyway), and traversing them. You'll have to do some rewriting whenever you
> leave a context that's still needed, but you do that anyway for the remote
> temps right?
>
Read the f-ing paper ;)
>
> The explanation is all on my blog<http://www.mirandabanda.org/cogblog/2009/01/14/under-cover-contexts-and-the…>and in my Context
> Management in VisualWorks 5i<http://www.esug.org/data/Articles/misc/oopsla99-contexts.pdf>paper.
>
> But does a bright buy like yourself find this /really/ hard to
> understand? It's not that hard a transformation, and compared to what goes
> on in the JIT (e.g. in bytecode to machine-code pc mapping) its pretty
> trivial.
>
> I guess I just like to really see what's going on by having a decent model
> around. When I look at the bytecodes; in the end I can reconstruct what it's
> doing ... as long as they are aligned in the way that the compiler currently
> generates them. But I can easily see how slight permutations would already
> throw me off completely.
>
>
>
>> But probably I'm missing something?
>>
>
> It's me who's missing something. I did the simplest thing I knew could
> possibly work re getting an efficient JIT and a Squeak with closures
> (there's huge similarity between the above scheme and the changes I made to
> VisualWorks that resulted in a VM that was 2 to 3 times faster depending on
> platform than VW 1.0). But you can see a far more efficient and simple
> scheme. What is it?
>
> Basically my scheme isn't necessarily far more efficient. It's just more
> understandable I think. I can understand scopes that point to their outer
> scope; and I can follow these scopes to see how the lookup works. And the
> fact that it does some pointer dereferencing and copying of data less is
> just something that makes me think it wouldn't be less efficient than what
> you have now. My problem is not that your implementation is slow, rather
> that it's complex. And I don't really see why this complexity is needed.
>
> Obviously playing on my ego by telling me I should be clever enough to
> understand it makes me say I do! But I feel it's not the easiest; and
> probably less people understand this than the general model of just linking
> contexts together.
>
Read the f-ing paper ;)
>
> best,
> Eliot
>
> cheers,
> Toon
>
best
Eliot
March 25, 2011
Re: [Pharo-project] pharo closures
by Toon Verwaest
> I can't say that i clearly understood your concept. But if it will
> simplify implementation
> without seemingly speed loss, i am all ears :)
>
test
|b|
[ |a|
a + b ]
Suppose you can't compile anything away, then you get
|==============
|MethodContext
|
|a := ...
|==============
^
|
|==============
|BlockContext
|
|b := ...
|==============
And you just look up starting at the current context and go up. Except
if the var is from the homeContext, then you directly follow the
home-context pointer.
Since all contexts link to the home-context, this makes it 1 pointer
indirection to get to the method's context. 1 for the parent context. So
that makes only 2 indirections starting from the 3 nested block (so when
you have [ ... [ ... [ ... ] ... ] ... ]; where all of them are required
for storing captured data. ifTrue:ifFalse: etc blocks obviously don't
count. And blocks without shared locals could be left out (although we
might not do that, for debugging reasons).
Hope that helps.
cheers,
Toon
March 25, 2011
Re: [Pharo-project] pharo closures
by Igor Stasenko
On 25 March 2011 01:44, Toon Verwaest <toon.verwaest(a)gmail.com> wrote:
>
> No I can't. Â Since I did it, I naturally think it's a good idea. Â Perhaps,
> instead of denigrating it without substantiating your claims you could
> propose (and then implement, and then get adopted) a better idea?
>
> Sure. My own VM will take a lot longer to get done! ;) I don't want to
> blemish any of your credit for building a cool VM. I was rather just
> wondering why you decided to go for this particular implementation which
> seems unobvious to me. Hence the question. I guess I should've formulated it
> slightly differently :) More info below.
>>
>> I can see why it would pay off for Lisp programmers to have closures that
>> run like the Pharo closures, since it has O(1) access performance. However,
>> this performance boost only starts paying off once you have at least more
>> than 4 levels of nested closures, something which, unlike in LISP, almost
>> never happens in Pharo. Or at least shouldn't happen (if it does, it's
>> probably ok to punish the people by giving them slower performance).
>
> Slower performance than what? Â BTW, I think you have things backwards. Â I
> modelled the pharo closure implementation on lisp closures, not the other
> way around.
>
> This is exactly what I meant. The closures seem like a very good idea for
> languages with very deeply nested closures. Lisp is such a language with all
> the macros ... I don't really see this being so in Pharo.
>>
>> This implementation is pretty hard to understand, and it makes
>> decompilation semi-impossible unless you make very strong assumptions about
>> how the bytecodes are used. This then again reduces the reusability of the
>> new bytecodes and probably of the decompiler once people start actually
>> using the pushNewArray: bytecodes.
>
> Um, the decompiler works, and in fact works better now than it did a couple
> of years ago. Â So how does your claim stand up?
>
> For example when I just use the InstructionClient I get in pushNewArray: and
> then later popIntoTemp. This combination is supposed to make clear that you
> are storing a remote array. This is not what the bytecode says however. And
> this bytecode can easily be reused for something else; what if I use the
> bytecode to make my own arrays? What if this array is created in a different
> way? I can think of a lot of ways the temparray could come to be using lots
> of variations of bytecodes, from which I would never (...) be able to figure
> out that it's actually making the tempvector. Somehow I just feel there's a
> bigger disconnect between the bytecodes and the Smalltalk code and I'm
> unsure if this isn't harmful.
>
> But ok, I am working on the Opal decompiler of course. Are you building an
> IR out with your decompiler? If so I'd like to have a look since I'm
> spending the whole day already trying to get the Opal compiler to somehow do
> what I want... getting one that works and builds a reusable IR would be
> useful. (I'm implementing your field-index-updating through bytecode
> transformation btw).
>>
>> You might save a teeny tiny bit of memory by having stuff garbage
>> collected when it's not needed anymore ... but I doubt that the whole design
>> is based on that? Especially since it just penalizes the performance in
>> almost all possible ways for standard methods. And it even wastes memory in
>> general cases. I don't get it.
>
> What has garbage collection got to do with anything? Â What precisely are you
> talking about? Â Indirection vectors? Â To understand the rationale for
> indirection vectors you have to understand the rationale for implementing
> closures on a conventional machine stack. Â For lisp that's clear; compile to
> a conventional stack as that's an easy model, in which case one has to store
> values that outlive LIFO discipline on the heap, hence indirection vectors.
> Â Why you might want to do that in a Smalltalk implementation when you could
> just access the outer context directly has a lot to do with VM internals.
> Â Basically its the same argument. Â If one can map Smalltalk execution to a
> conventional stack organization then the JIT can produce a more efficient
> execution engine. Not doing this causes significant problems in context
> management.
>
> With the garbage collection I meant the fact that you can already collect
> part of the stack frames and leave other parts (the remote temps) and only
> get them GCd later on when possible.
>
> I do understand why you want to keep them on the stack as long as possible.
> The stack-frame marriage stuff for optimizations is very neat indeed. What
> I'm more worried about myself is the fact that stackframes aren't just
> linked to each other and share memory that way. This means that you only
> have 1 indirection to access the method-frame (via the homeContext), and 1
> for the outer context. You can directly access yourself. So only the 4rd
> context will have 2 indirections (what all contexts have now for remotes).
> From the 5th on it gets worse... but I can't really see this happening in
> real world situations.
>
> Then you have the problem that since you don't just link the frames and
> don't look up values via the frames, you have to copy over part of your
> frame for activation. This isn't necessarily -that- slow (although it is
> overhead); but it's slightly clumsy and uses more memory. And that's where
> my problem lies I guess ... There's such a straightforward implementation
> possible, by just linking up stackframes (well... they are already linked up
> anyway), and traversing them. You'll have to do some rewriting whenever you
> leave a context that's still needed, but you do that anyway for the remote
> temps right?
>
> The explanation is all on my blog and in my Context Management in
> VisualWorks 5i paper.
> But does a bright buy like yourself find this /really/ hard to understand?
> Â It's not that hard a transformation, and compared to what goes on in the
> JIT (e.g. in bytecode to machine-code pc mapping) its pretty trivial.
>
> I guess I just like to really see what's going on by having a decent model
> around. When I look at the bytecodes; in the end I can reconstruct what it's
> doing ... as long as they are aligned in the way that the compiler currently
> generates them. But I can easily see how slight permutations would already
> throw me off completely.
>
>>
>> But probably I'm missing something?
>
> It's me who's missing something. Â I did the simplest thing I knew could
> possibly work re getting an efficient JIT and a Squeak with closures
> (there's huge similarity between the above scheme and the changes I made to
> VisualWorks that resulted in a VM that was 2 to 3 times faster depending on
> platform than VW 1.0). Â But you can see a far more efficient and simple
> scheme. Â What is it?
>
> Basically my scheme isn't necessarily far more efficient. It's just more
> understandable I think. I can understand scopes that point to their outer
> scope; and I can follow these scopes to see how the lookup works. And the
> fact that it does some pointer dereferencing and copying of data less is
> just something that makes me think it wouldn't be less efficient than what
> you have now. My problem is not that your implementation is slow, rather
> that it's complex. And I don't really see why this complexity is needed.
>
> Obviously playing on my ego by telling me I should be clever enough to
> understand it makes me say I do! But I feel it's not the easiest; and
> probably less people understand this than the general model of just linking
> contexts together.
>
I can't say that i clearly understood your concept. But if it will
simplify implementation
without seemingly speed loss, i am all ears :)
> best,
> Eliot
>
> cheers,
> Toon
>
--
Best regards,
Igor Stasenko AKA sig.
March 25, 2011