Some Optimisations

new topic     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu