Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSOC#2 compile-time expand pcc params and set the return result #1080

Closed
rurban opened this issue Jun 16, 2014 · 1 comment
Closed

GSOC#2 compile-time expand pcc params and set the return result #1080

rurban opened this issue Jun 16, 2014 · 1 comment

Comments

@rurban
Copy link
Member

rurban commented Jun 16, 2014

PCCMETHODs can be optimized to omit the run-time call to Parrot_pcc_fill_params_from_c_args(interp, _call_object, sig, &_self, args...);
and create the necessary C code to fill the params directly in pmc2c.
E.g. for "Pi" _self = VTABLE_get_pmc_keyed_int(interp, _call_object, 0); with _self being the first arg and 0 being the index for the first argument.

Same for assigning the RETURN result:
Parrot_pcc_set_call_from_c_args(interp, _call_object, rettype, result);
which only sets one argument, so a call set_call_from_varargs is not needed, just the type-specific part from set_call_from_varargs.
E.g. VTABLE_set_integer_keyed_int(interp, _call_object, 0, retvar);

Unfortunately we have to check the number of provided arguments at run-time: VTABLE_get_integer(interp, _call_object); and throw EXCEPTION_INVALID_OPERATION if too less or too many.
:optional and :opt_flag handling can be left to the old slow method or also expanded. (see rurban/pcc-opt-gh1080)
The flags flatten, lookahead, name and slurpy and multiple return values are rarely used and should be left to the old method. :constant should be expanded, but is not used yet.

This saves two unneccessary nested function calls, and one intermediate PMC creation just for holding the sig array and will lead to about 2-4% faster code with method calls. The arity check for the number of provided vs expected args is now the bottleneck.

ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 20, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 22, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 22, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 27, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 27, 2014
rurban pushed a commit that referenced this issue Jun 29, 2014
optimize pmc2c to emit static fill_params from compile-time known
params into the _call_object args array, ditto for the return values.
rurban pushed a commit that referenced this issue Jun 29, 2014
on method calls without optional args do one
arity check, with the new exception message:
  "wrong number of arguments: %d passed, %d expected"
Matching the old exception message too many/few would require
two run-time checks, which costs ~2% in parrot-bench.

fixes t/pmc/class.t
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 29, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 29, 2014
ZYROz added a commit to ZYROz/parrot that referenced this issue Jun 29, 2014
rurban pushed a commit that referenced this issue Jun 29, 2014
optimize pmc2c to emit static fill_params from compile-time known
params into the _call_object args array, ditto for the return values.
rurban pushed a commit that referenced this issue Jun 29, 2014
on method calls without optional args do one
arity check, with the new exception message:
  "wrong number of arguments: %d passed, %d expected"
Matching the old exception message too many/few would require
two run-time checks, which costs ~2% in parrot-bench.

fixes t/pmc/class.t
rurban pushed a commit that referenced this issue Jun 29, 2014
handle now also :optional and :opt_flag at compile-time,
not at run-time. (o and p arg adverbs)
Unprovided args get initialized with empty defaults.
With optional args, fall back to the two-fold old too many
and too few arguments checks, for backward compat. (about 2% slower)
rurban pushed a commit that referenced this issue Jul 1, 2014
@rurban
Copy link
Member Author

rurban commented Jul 1, 2014

Merged with commit 000a132
Merge: 9e15179 65f5def
Author: Reini Urban rurban@cpanel.net
Date: Tue Jul 1 15:30:26 2014 -0500

Merge branch 'rurban/pcc-opt-gh1080'

Second part of GSOC, but surprisingly with only minimal performance
impact on normal code (~0.5%). About 4-10% faster per method call.

@rurban rurban closed this as completed Jul 1, 2014
rurban pushed a commit that referenced this issue Jul 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant