diff options
author | syber <syber@crazypanda.ru> | 2014-09-04 22:08:59 +0400 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-10-03 13:40:54 +0100 |
commit | b46e009d94293e069270690750f6c669c6d0ce22 (patch) | |
tree | c335154dccea12b391db6aaf7cac73db22e08f43 /op.h | |
parent | df968918245d10232f955ab0965da7f8d6297a29 (diff) | |
download | perl-b46e009d94293e069270690750f6c669c6d0ce22.tar.gz |
Make OP_METHOD* to be of new class METHOP
Introduce a new opcode class, METHOP, which will hold class/method related
info needed at runtime to improve performance of class/object method
calls, then change OP_METHOD and OP_METHOD_NAMED from being UNOP/SVOP to
being METHOP.
Note that because OP_METHOD is a UNOP with an op_first, while
OP_METHOD_NAMED is an SVOP, the first field of the METHOP structure
is a union holding either op_first or op_sv. This was seen as less messy
than having to introduce two new op classes.
The new op class's character is '.'
Nothing has changed in functionality and/or performance by this commit.
It just introduces new structure which will be extended with extra
fields and used in later commits.
Added METHOP constructors:
- newMETHOP() for method ops with dynamic method names.
The only optype for this op is OP_METHOD.
- newMETHOP_named() for method ops with constant method names.
Optypes for this op are: OP_METHOD_NAMED (currently) and (later)
OP_METHOD_SUPER, OP_METHOD_REDIR, OP_METHOD_NEXT, OP_METHOD_NEXTCAN,
OP_METHOD_MAYBENEXT
(This commit includes fixups by davem)
Diffstat (limited to 'op.h')
-rw-r--r-- | op.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -195,6 +195,17 @@ struct listop { OP * op_last; }; +struct methop { + BASEOP + union { + /* op_u.op_first *must* be aligned the same as the op_first + * field of the other op types, and op_u.op_meth_sv *must* + * be aligned with op_sv */ + OP* op_first; /* optree for method name */ + SV* op_meth_sv; /* static method name */ + } op_u; +}; + struct pmop { BASEOP OP * op_first; @@ -385,6 +396,7 @@ struct loop { #define cPVOPx(o) ((PVOP*)o) #define cCOPx(o) ((COP*)o) #define cLOOPx(o) ((LOOP*)o) +#define cMETHOPx(o) ((METHOP*)o) #define cUNOP cUNOPx(PL_op) #define cBINOP cBINOPx(PL_op) @@ -441,6 +453,8 @@ struct loop { # define cSVOPx_svp(v) (&cSVOPx(v)->op_sv) #endif +# define cMETHOPx_meth(v) cSVOPx_sv(v) + #define cGVOP_gv cGVOPx_gv(PL_op) #define cGVOPo_gv cGVOPx_gv(o) #define kGVOP_gv cGVOPx_gv(kid) @@ -481,6 +495,7 @@ struct loop { #define OA_BASEOP_OR_UNOP (11 << OCSHIFT) #define OA_FILESTATOP (12 << OCSHIFT) #define OA_LOOPEXOP (13 << OCSHIFT) +#define OA_METHOP (14 << OCSHIFT) /* Each remaining nybble of PL_opargs (i.e. bits 12..15, 16..19 etc) * encode the type for each arg */ |