Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
rurban opened this Issue · 1 comment

1 participant

@rurban
Collaborator

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 ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 bdf1590
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 c5853a2
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 de44490
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 6779592
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 ecf5070
@rurban rurban referenced this issue from a commit
@ZYROz ZYROz [pmc2c] compile-time expand pcc params and set the return result #1080
optimize pmc2c to emit static fill_params from compile-time known
params into the _call_object args array, ditto for the return values.
875aea7
@rurban rurban referenced this issue from a commit
@rurban rurban [pmc2c] add method arity check - GH #1080
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
54edbee
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] WIP for Issue #1080 f01c5e3
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz [Pmc2c] Handling 'o' sig - WIP for Issue #1080 4980e57
@ZYROz ZYROz referenced this issue from a commit in ZYROz/parrot
@ZYROz ZYROz Handling 'o' sig - WIP for Issue #1080 7026a73
@rurban rurban referenced this issue from a commit
@ZYROz ZYROz [pmc2c] compile-time expand pcc params and set the return result #1080
optimize pmc2c to emit static fill_params from compile-time known
params into the _call_object args array, ditto for the return values.
497307e
@rurban rurban referenced this issue from a commit
@rurban rurban [pmc2c] add method arity check - GH #1080
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
2cc3346
@rurban rurban referenced this issue from a commit
@rurban rurban [pmc2c] fix optional arg handling for methods GH #1080
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)
65f5def
@rurban
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.