Andrew Haley <andr...@littlepinkcloud.invalid> writes:
>Anton Ertl <
an...@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andr...@littlepinkcloud.invalid> writes:
>>>Anton Ertl <
an...@mips.complang.tuwien.ac.at> wrote:
>>>> This assuption is not based on a particular style of Forth compiler,
>>>> but on pretty fundamental issues:
>>>>
>>>> In typical Forth code it is relatively easy to map stack items to
>>>> registers (there are exceptions, but they are rare and do not occur in
>>>> the case in point).
>>>
>>>I take your point. However, that is assuming a particular style of
>>>Forth implementation.
>>
>> No, it's a statement about what is possible in an implementation.
>
>Eh? Of course not. Hoisting memory references is far from
>impossible.
Eliminating memory accesses is possible in some cases, but there are
other cases where it is impossible; and whether a compiler actually
does eliminate the memory access in a case where it is possible is
hard to predict; also, I would not expect a Forth compiler to do it
because of the costs in complexity and compilation time (and AFAIK no
Forth compiler does it).
So, in my performance model for general use, a memory access on the
programming language level costs a memory access on the machine level;
if you are doing supercomputer-type programming, you may use a more
complex performance model, but that's too complex for most uses.
>>> It certainly doesn't apply to traditional
>>>threaded code or even to simple native code Forths;
>>
>> These don't make use of that property, then. Does it matter?
>
>Yes, of course. We're talking about contorting perfectly reasonable
>Forth code (using PICKs) because doing it some other way that's easier
>to write and understand (field accesses) is slower.
You are talking about that, but the OP actually has code that uses
PICKs and no code that uses memory, so he obviously has not contorted
memory-using code.
For the rectangle example, I had the memory and locals variants from
the paper
<
http://www.complang.tuwien.ac.at/anton/euroforth/ef11/papers/ertl.pdf>
and derived the stack variant from the locals variant, not the memory
variant. You might consider the PICKing variant more contorted than
the locals variant, but the locals-haters may disagree.
BTW, I would expect picking and locals to be equally fast. Both can
be mapped to registers.
>> Just because there are other perverts does not make it any less
>> perverted.
>
>Um, yes it does, by definition.
The definition of "pervert" is not "singleton".
>I am certainly not convinced that caring for performace involves
>always squeezing the last microsecond out of every operation. That
>way leads to the enormous complexity of today's compilers for other
>languages. I don't think that's appropriate for Forth. Forth gets
>its performance from clarity and simplicity, by eschewing much of that
>complexity.
We seem to be on the same page here. And certainly, when doing the
the Bezier thing for real, one would note that the LINE word uses so
much time that the time for dealing with the coordinates probably does
not matter (whether stack, locals, or memory).
But there are other cases where performance does matter, and there one
needs a performance model. Having that, we can consider if the
cleaner solution is expected to be faster (good), equally fast (good),
or slower, and in the latter case, which concern is more important.
And on a different level, if we find that there are many cases where
speed conflicts with clarity and simplicity, maybe there could be a
new language feature that allows us to reconcile both.
>>>Stephen's posting suggests very strongly that it's not universally a
>>>problem with native code generators.
>>
>> What is not universally a problem?
>
>The performance problem that causes PICK to be faster than field
>accesses.
His posting does not suggest that very much. He compared two
unspecified pieces of code, and for all we know (and as you
suggested), there might be a lot of differences other than just
between PICKs and field accesses.
>>>Dreaming for a moment: there may, I suppose, be some mileage in a hint
>>>to a compiler that some memory references really don't alias to
>>>anything else.
>>
>> Hey, Andrew Haley suggests a language feature!
>
>Eh? This discussion is becoming surreal.
Hmm? Ok, we started discussing your dreams, but it's a somewhat
realistic dream.