1. Some Optimisations

Heh?
Well after seeing what the translator produces, I was pleased by the
results. However, the following is an extremely obvious optimisation and too
easy to implement to not start up Note Pad and add this feature right now.

I found the following declarations in euphoria.h;
int NewDouble(double);
void de_reference(s1_ptr);
double current_time(void);
double floor(double);
double fabs(double);
int binary_op_a(int, int, int);
int binary_op(int, int, int);
void *which_file(int, int);
int unary_op(int, int);
int NewS1(int);
int compare(int, int);
unsigned long get_pos_int(char *, int);
int memory_set(int, int, int);
int memory_copy(int, int, int);
int getc(void *);
...

These are internal routines wich are called very often.
Whenever they are called you have to deal with pushing the parameters on the
stack (mov eax, val; push eax;, etc.).
And, you have to call the routine at it's address (mov eax, address; call
eax;)
In a 5000 iteration loop these operations are executed 5000 times for every
function called.
This can all be illiminated through function inlining.
For those who do not know C, no it does not mean copying the function bodies
of every function to where it is called in the C source by hand. The C
compiler can do that for you invisibly if you rewrite those produced
function declarations to the following;

_inline int NewDouble(double);
_inline void de_reference(s1_ptr);
_inline double current_time(void);
_inline double floor(double);
_inline double fabs(double);
_inline int binary_op_a(int, int, int);
_inline int binary_op(int, int, int);
_inline void *which_file(int, int);
_inline int unary_op(int, int);
_inline int NewS1(int);
_inline int compare(int, int);
_inline unsigned long get_pos_int(char *, int);
_inline int memory_set(int, int, int);
_inline int memory_copy(int, int, int);
_inline int getc(void *);
...

and also define them as _inline's in ec.obj.
This optimisation gains a crapload of speed!
And it's rediculously easy for Robert to implement!


Think about it.


Mike The Spike
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

new topic     » topic index » view message » categorize

2. Re: Some Optimisations

Good idea. Not to sound too sarcastic here, but how would you implement
inline functions into an interpreter? Hmmm....?

Teehee :)

new topic     » goto parent     » topic index » view message » categorize

3. Re: Some Optimisations

>Good idea. Not to sound too sarcastic here, but how would you implement
>inline functions into an interpreter? Hmmm....?
>
>Teehee :)

Huh?
WTF?
Wha?
No wait........Wha?

What interpretter?
This is C (70's language based on BCPL & B by Bell Labortatories  worker
standardised by commision X3J11 of the ANSI) source code we're talking
about, intended for a C compiler (first one operated by Ada, female
programmer, implemented as a kinetic punchcard generator, based on
Assemblers, have the task to turn lexical source code into native CPU
instructions).

I don't see the sarcasm.

Do you even know what Source Code means?
Object files?
Compiler? (COM-PILE-R)
Repeat after me; "An interpretter is not a compiler."
Again; "An interpretter is not a compiler."


Mike The Spike
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: Some Optimisations

Mike, calm down, I wasn't attacking you and it's not fair to attack me back.
I am perfectly aware of what a compiler is, thank you very much. I had
misunderstood your original post as a comment to Euphoria, not 'C', since
this isn't a 'C' channel (though with the new "translator" I suppose it may
be going that way); so I appologise for any misunderstanding. That having
been said, I agree that inlining a lot of the basic functions should almost
be considered essential, even though some compilers are known to ignore the
inline directive to suit their needs. I am suprised that that is not the
case. C'est la vie.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Some Optimisations

>Mike, calm down, I wasn't attacking you and it's not fair to attack me
>back.
>I am perfectly aware of what a compiler is, thank you very much. I had
>misunderstood your original post as a comment to Euphoria, not 'C', since
>this isn't a 'C' channel (though with the new "translator" I suppose it may
>be going that way); so I appologise for any misunderstanding. That having
>been said, I agree that inlining a lot of the basic functions should almost
>be considered essential, even though some compilers are known to ignore the
>inline directive to suit their needs. I am suprised that that is not the
>case. C'est la vie.

Heh?
OK Then.
I'm sorry, I didn't know you missunderstood the topic.

And, you're right about two things.
One, some C compilers don't inline functions if they are called by address,
and two, I'm surprised it's not in there allready, it's an easy optmisation
wich gains a lot of speed on the math.

Mike The Spike
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu