Branch: Tag:

2014-12-04

2014-12-04 19:23:39 by Per Hedbor <ph@opera.com>

[performance] Slightly smaller low_mega_apply.

There is now only one instance of the inclusion of apply_low.h (does
anyone else feel a need for less lowness around here?) which actually
made it faster (previously there were two cases, one for scoped
functions calles and one for calls without scope).

Also created a new version of mega_apply (named lower_mega_apply) that
can only do APPLY_LOW, and only the most common cases.

It falls back to using the old low_mega_apply when needed.

Added a lot of lowness to places to utilize the optimization.

This actually saves surprising amounts of CPU in code calling a lot of
small functions, lower_mega_apply() is about 2x faster than
low_mega_apply(APPLY_LOW,...) when it does not hit one of the cases it
does not support (trampolines, calling non function constants,
variables or arrays).

There is unfortunately now even more code duplication around, but
since the code is slightly different that is rather hard to avoid.

534:    Pike_sp=s_; \   }while(0)    +    #define free_pike_frame(F) do{ struct pike_frame *f_=(F); if(!sub_ref(f_)) really_free_pike_frame(f_); }while(0)      /* A scope is any frame which may have malloced locals */
791:    int arg2);   struct pike_frame *alloc_pike_frame(void);   void really_free_pike_scope(struct pike_frame *scope); + int lower_mega_apply( INT32 args, struct object *o, ptrdiff_t fun );   int low_mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2);   void low_return(void);   void low_return_pop(void);
799:      PMOD_EXPORT struct Pike_interpreter_struct * pike_get_interpreter_pointer();   PMOD_EXPORT void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2); + PMOD_EXPORT void mega_apply_low(INT32 args, void *arg1, ptrdiff_t arg2);   PMOD_EXPORT void f_call_function(INT32 args);   PMOD_EXPORT void call_handle_error(void);   PMOD_EXPORT int safe_apply_low(struct object *o,int fun,int args);
840: Inside #if defined(__ECL)
  #ifdef __ECL   static INLINE void apply_low(struct object *o, ptrdiff_t fun, INT32 args)   { -  mega_apply(APPLY_LOW, args, (void*)o, (void*)fun); +  mega_apply_low(args, (void*)o, fun);   }      static INLINE void strict_apply_svalue(struct svalue *sval, INT32 args)
849:   }   #else /* !__ECL */   #define apply_low(O,FUN,ARGS) \ -  mega_apply(APPLY_LOW, (ARGS), (void*)(O),(void*)(ptrdiff_t)(FUN)) +  mega_apply_low((ARGS), (void*)(O),(FUN))      #define strict_apply_svalue(SVAL,ARGS) \    mega_apply(APPLY_SVALUE, (ARGS), (void*)(SVAL),0)