Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Optimize static methods to subs #329

Closed
rurban opened this issue Aug 26, 2017 · 3 comments
Closed

Optimize static methods to subs #329

rurban opened this issue Aug 26, 2017 · 3 comments
Assignees
Projects
Milestone

Comments

@rurban
Copy link
Member

rurban commented Aug 26, 2017

Was CM-885, part of the GH #23 inliner.

See http://blogs.perl.org/users/rurban/2011/06/how-perl-calls-subs-and-methods.html
It is better to do it with the inline peep check, and not in ck_subr. (Now changed back to ck_subr)
So if any stash already contains the method, use it. No other stash can interfer with that during run-time method-dispatch.

But we cannot use the $obj->method type info, because $obj may be a subtype
of the declared type, which may have a different method.

Add several smaller optims:

  • convert pushmark-gv(packagename)-args-method_named(GV)-entersub
    to pushmark-gv(packagename)-args-gv(GV)-entersub

  • use the faster cvref not the gv. the biggest problem was that destroying &main::BEGIN cleared the attached GV (missing refcount bump):
    Not when a static method is allowed to be redefined. perlcc -O3 may disallow this for perf. reasons.
    t/op/symbolcache.t wants to redefine a sub at run-time and this can only be caught with the GV, not the old cvref.

  • convert entersub to enterxssub for XS methods.

  • detect class subs called as methods at compile-time already.

  • using a gv ALIAS e.g. *Carp::Import{CV} pointing to &Exporter::import is forbidden. This needs to be resolved by method_named.

This should be merged earlier than the inliner, because the stable parts are needed for other branches to go on. op_clone() is needed to clone roles #311.

@rurban rurban self-assigned this Aug 26, 2017
@rurban rurban added this to the v5.27.2c milestone Aug 26, 2017
@rurban rurban modified the milestones: v5.27.2c, v5.27.3c Dec 5, 2017
@rurban
Copy link
Member Author

rurban commented Dec 13, 2017

  • cvt method sub -> xs done at run-time since v5.27.1c (596c328) in METHOD_CHECK_CACHE. this is safe even when a stash is invalidated.

rurban added a commit that referenced this issue Dec 13, 2017
Prefer the CV GvSTASH over the GvSTASH of the found name.
This was fooled the previous attempts.
See #329

Also warn the unsuccessful make_ext cmdline.
rurban added a commit that referenced this issue Dec 13, 2017
again disable static method optimization threaded
because some PAD GV (alias?) gets corrupted.
See #329.
@rurban
Copy link
Member Author

rurban commented Dec 13, 2017

  • conversion of method_named -> gv done with 4c9c0ae but only for non-threaded perls. still an unknown corruption with that gv on the pad at run-time.
    also done: skip if gv alias.

not yet done:

  • class/subclasses with typed lhs objects
  • cvref (probably not possible, see symbolcache)

@rurban
Copy link
Member Author

rurban commented Dec 14, 2017

Threaded perls fixed with a386e87
It was pad_alloc flag problem. With the GV as SVf_READONLY it will be not reused for another TARG.

@rurban rurban added this to In progress in cperl Dec 16, 2017
rurban added a commit that referenced this issue Dec 16, 2017
This reverts parts of commit a4e59bf.
Try to make static method opts work with threads.
See #329
@rurban rurban closed this as completed Dec 16, 2017
cperl automation moved this from In progress to Done Dec 16, 2017
@ghost ghost removed the in progress label Dec 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
cperl
  
Done
Development

No branches or pull requests

1 participant