summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-07-01 13:37:32 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:34 +0000
commit9513529b23cf2efc93bca3bd53c9cd7a87b71001 (patch)
treeeacd5c49e2d175f6522eddd971aa4e86293a02d6 /pp_sort.c
parente2657e180a66b618ece78ca6b9c1f9e9b361a948 (diff)
downloadperl-9513529b23cf2efc93bca3bd53c9cd7a87b71001.tar.gz
eliminate the argarray field from the CX struct
At the end of a normal sub call there are often 3 AVs of interest associated with @_; these are: cx->blk_sub.savearray the caller's @_ GvAV(PL_defgv) the current sub's current @_ cx->blk_sub.argarray the current sub's original @_ Note that those last two can differ: if for example the sub does local *_ = []; Each sub's arg array is created and stored in pad slot 0 at the time the sub is created. When a sub is called, pp_entersub() does cx->blk_sub.argarray = PL_curpad[0] The argarray field is used in two main places: * at subroutine exit, to clear/abandon the sub's original @_; * in pp_caller, to set @DB::args to the caller(n)'s args. In the first case, the last few commits have arranged things so that at that point, PL_curpad always points to the current pad of the sub being exited from. So we can just use PL_curpad[0] rather than cx->blk_sub.argarray. In the second case (which is not performance critical), we can just use cx->blk_sub.cv and cx->blk_sub.olddepth+1 to find the pad of that call frame's CV. So we can eliminate the argarray field. This saves a write during a sub call, and potentially reduces the size of the context struct. It also makes the code marginally less confusing: there are now 3 arrays pointed to from 3 places, rather than 3 arrays pointed to from 4 places. The asserts added in the previous commit confirmed that using argarray is the same as using PL_curpad[0]; They also confirmed that the current PL_curpad matches the current CV at the current depth. Those latter asserts are kept for now.
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 73f520d7d4..1e48042a9f 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1688,7 +1688,6 @@ PP(pp_sort)
cx->blk_sub.savearray = GvAV(PL_defgv);
GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
- cx->blk_sub.argarray = av;
}
}