summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorsyber <syber@crazypanda.ru>2014-12-01 23:20:27 +0300
committerFather Chrysostomos <sprout@cpan.org>2014-12-02 17:56:48 -0800
commit810bd8b704e337dfba3e46eaea33244c1b0afce3 (patch)
tree1b45d1d145ccd5b7eecbb14ef57f69da2e5bdb3f /op.h
parent11f9ab1a291e36ad40cb66d0bd0aedce897c06c3 (diff)
downloadperl-810bd8b704e337dfba3e46eaea33244c1b0afce3.tar.gz
Speed up method calls like $o->Other::method() and $o->Other::SUPER::method().
It was done by adding new OP_METHOD_REDIR and OP_METHOD_REDIR_SUPER optypes. Class name to redirect is saved into METHOP as a shared hash string. Method name is changed (class name removed) an saved into op_meth_sv as a shared string hash. So there is no need now to scan for '::' and calculate class and method names at runtime (in gv_fetchmethod_*) and searching cache HV without precomputed hash. B::* modules are changed to support new op types. method_redir is now printed by Concise like (for threaded perl) $obj->AAA::meth 5 <.> method_redir[PACKAGE "AAA", PV "meth"] ->6
Diffstat (limited to 'op.h')
-rw-r--r--op.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/op.h b/op.h
index 1392fd2945..161c1a5eea 100644
--- a/op.h
+++ b/op.h
@@ -202,6 +202,11 @@ struct methop {
OP* op_first; /* optree for method name */
SV* op_meth_sv; /* static method name */
} op_u;
+#ifdef USE_ITHREADS
+ PADOFFSET op_rclass_targ; /* pad index for redirect class */
+#else
+ SV* op_rclass_sv; /* static redirect class $o->A::meth() */
+#endif
};
struct pmop {
@@ -441,6 +446,7 @@ struct loop {
? cSVOPx(v)->op_sv : PAD_SVl((v)->op_targ))
# define cSVOPx_svp(v) (cSVOPx(v)->op_sv \
? &cSVOPx(v)->op_sv : &PAD_SVl((v)->op_targ))
+# define cMETHOPx_rclass(v) PAD_SVl(cMETHOPx(v)->op_rclass_targ)
#else
# define cGVOPx_gv(o) ((GV*)cSVOPx(o)->op_sv)
# ifndef PERL_CORE
@@ -449,6 +455,7 @@ struct loop {
# endif
# define cSVOPx_sv(v) (cSVOPx(v)->op_sv)
# define cSVOPx_svp(v) (&cSVOPx(v)->op_sv)
+# define cMETHOPx_rclass(v) (cMETHOPx(v)->op_rclass_sv)
#endif
# define cMETHOPx_meth(v) cSVOPx_sv(v)