A Tango Fibers question and a functional programming anecdote.

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Oct 27 23:19:51 PDT 2007


"downs" <default_357-line at yahoo.de> wrote in message 
news:fg15ev$12uh$1 at digitalmars.com...
> Here's a question to the tango devs.
> I've been developing my own stackthreads (Fibers basically) library for
> a while now, and finally got it working a few days ago.
>
> Then we did some speed tests and discovered that it was about twice as
> slow as Tango's Fiber implementation.
>
> This prompted me to dig into the Fibers sourcecode, where I discovered
> that Fibers doesn't backup ECX/EDX on context switch, and the FP
> registers only on windows.
>
> Now I am confused.
>
> Could a knowledgeable tango dev kindly shed light on this issue? Why
> isn't it necessary to save all registers on a context switch?

I'm not knowledgeable, but you said ECX/EDX and it triggered something in my 
brain.  Sure enough, according to the D 1.0 ABI, "EAX, ECX, EDX are scratch 
registers and can be destroyed by a function."  So they don't have to be 
preserved because you're allowed to do anything with them.

As for nothing but ST(0-7) being preserved on Windows.. no clue.

>>
>> ["Load ", "Prefetch ", "Prefetch "] /zip/ ([0, 1, 2] /map/ (&info
> /rfix/ currentComic /fix/ (&subtract!(int) /fix/ currentStrip))) /map/
> &concat!(string) /zip/ [&update, &prefetch /fix/ (currentStrip-1),
> &prefetch /fix/ (currentStrip-2)] /map/ &Pool.addTask;

>>
>> ["Load ", "Prefetch ", "Prefetch "] /zip/ (
>>   [0, 1, 2] /map/ (
>>     &info /rfix/ currentComic /fix/ (
>>       &subtract!(int) /fix/ currentStrip
>>       )
>>     )
>>   )
>>   /map/ &concat!(string) /zip/ [
>>     &update,
>>     &prefetch /fix/ (currentStrip-1),
>>     &prefetch /fix/ (currentStrip-2)
>>   ] /map/ &Pool.addTask;
>>

Why/how do you write code like this?  Is it some kind of thing in your brain 
that makes you think about everything inside out?  Stop it.  Please.  For 
all our brains' sakes. 





More information about the Digitalmars-d mailing list