Coderefs in @INC are done and documented.
[p5sagit/p5-mst-13.2.git] / pod / perltodo.pod
index 1e1d452..1cff0ec 100644 (file)
@@ -34,6 +34,11 @@ TODO are completed.
 Review assertions. Review syntax to combine assertions. Assertions could take
 advantage of the lexical pragmas work. L</What hooks would assertions need?>
 
+=item *
+
+C<encoding::warnings> should be turned into a lexical pragma.
+C<encoding> should, too (probably).
+
 =back
 
 =head2 Needed for a 5.9.5 release
@@ -150,6 +155,17 @@ Ilya observed that use POSIX; eats memory like there's no tomorrow, and at
 various times worked to cut it down. There is probably still fat to cut out -
 for example POSIX passes Exporter some very memory hungry data structures.
 
+=head2 embed.pl/makedef.pl
+
+There is a script F<embed.pl> that generates several header files to prefix
+all of Perl's symbols in a consistent way, to provide some semblance of
+namespace support in C<C>. Functions are declared in F<embed.fnc>, variables
+in F<interpvar.h> and F<thrdvar.h>. Quite a few of the functions and variables
+are conditionally declared there, using C<#ifdef>. However, F<embed.pl>
+doesn't understand the C macros, so the rules about which symbols are present
+when is duplicated in F<makedef.pl>. Writing things twice is bad, m'kay.
+It would be good to teach C<embed.pl> to understand the conditional
+compilation, and hence remove the duplication, and the mistakes it has caused.
 
 
 
@@ -334,18 +350,6 @@ such that it's trivial for the Pumpking to flag "this is an official release"
 when making a tarball, yet leave the default source saying "I'm not the
 official release".
 
-=head2 Tidy up global variables
-
-There's a note in F<intrpvar.h>
-
-  /* These two variables are needed to preserve 5.8.x bincompat because
-     we can't change function prototypes of two exported functions.
-     Probably should be taken out of blead soon, and relevant prototypes
-     changed.  */
-
-So doing this, and removing any of the unused variables still present would
-be good.
-
 =head2 Ordering of "global" variables.
 
 F<thrdvar.h> and F<intrpvarh> define the "global" variables that need to be
@@ -361,6 +365,22 @@ typically requiring 4 byte alignment, and then an odd C<bool> later on.
 to review the ordering of the variables, to see how much alignment padding can
 be removed.
 
+It's also worth checking that all variables are actually used. Perl 5.8.0
+shipped with C<PL_nrs> still defined in F<thrdvar.h>, despite it being unused
+since a change over a year earlier. Had this been spotted before release, it
+could have been removed, but now it has to remain in the 5.8.x releases to
+keep the structure the same size, to retain binary compatibility.
+
+It's probably worth checking if all need to be the types they are. For example
+
+    PERLVAR(Ierror_count, I32) /* how many errors so far, max 10 */
+
+might work as well if stored in a signed (or unsigned) 8 bit value, if the
+comment is accurate. C<PL_multi_open> and C<PL_multi_close> can probably
+become C<char>s. Finding variables to downsize coupled with rearrangement
+could shrink the interpreter structure; a size saving which is multiplied by
+the number of threads running.
+
 =head2 am I hot or not?
 
 The idea of F<pp_hot.c> is that it contains the I<hot> ops, the ops that are
@@ -373,49 +393,30 @@ anyone feeling like exercising their skill with coverage and profiling tools
 might want to determine what ops I<really> are the most commonly used. And in
 turn suggest evictions and promotions to achieve a better F<pp_hot.c>.
 
-=head2 emulate the per-thread memory pool on Unix
-
-For Windows, ithreads allocates memory for each thread from a separate pool,
-which it discards at thread exit. It also checks that memory is free()d to
-the correct pool. Neither check is done on Unix, so code developed there won't
-be subject to such strictures, so can harbour bugs that only show up when the
-code reaches Windows.
+=head2 Shrink struct context
 
-It would be good to be able to optionally emulate the Window pool system on
-Unix, to let developers who only have access to Unix, or want to use
-Unix-specific debugging tools, check for these problems. To do this would
-involve figuring out how the C<PerlMem_*> macros wrap C<malloc()> access, and
-providing a layer that records/checks the identity of the thread making the
-call, and recording all the memory allocated by each thread via this API so
-that it can be summarily free()d at thread exit. One implementation idea
-would be to increase the size of allocation, and store the C<my_perl> pointer
-(to identify the thread) at the start, along with pointers to make a linked
-list of blocks for this thread. To avoid alignment problems it would be
-necessary to do something like
+In F<cop.h>, we have
 
-  union memory_header_padded {
-    struct memory_header {
-      void *thread_id;   /* For my_perl */
-      void *next;        /* Pointer to next block for this thread */
-    } data;
-    long double padding; /* whatever type has maximal alignment constraint */
-  };
+    struct context {
+        U32            cx_type;        /* what kind of context this is */
+        union {
+       struct block    cx_blk;
+       struct subst    cx_subst;
+        } cx_u;
+    };
 
+There are less than 256 values for C<cx_type>, and the constituent parts
+C<struct block> and C<struct subst> both contain some C<U8> and C<U16> fields,
+so it should be possible to move them to the first word, and share space with
+a C<U8> C<cx_type>, saving 1 word.
 
-although C<long double> might not be the only type to add to the padding
-union.
+=head2 Allocate OPs from arenas
 
-=head2 reduce duplication in sv_setsv_flags
-
-C<Perl_sv_setsv_flags> has a comment
-C</* There's a lot of redundancy below but we're going for speed here */>
-
-Whilst this was true 10 years ago, the growing disparity between RAM and CPU
-speeds mean that the trade offs have changed. In addition, the duplicate code
-adds to the maintenance burden. It would be good to see how much of the
-redundancy can be pruned, particular in the less common paths. (Profiling
-tools at the ready...). For example, why does the test for
-"Can't redefine active sort subroutine" need to occur in two places?
+Currently all new OP structures are individually malloc()ed and free()d.
+All C<malloc> implementations have space overheads, and are now as fast as
+custom allocates so it would both use less memory and less CPU to allocate
+the various OP structures from arenas. The SV arena code can probably be
+re-used for this.
 
 
 
@@ -426,30 +427,14 @@ These tasks would need C knowledge, and roughly the level of knowledge of
 the perl API that comes from writing modules that use XS to interface to
 C.
 
-=head2 IPv6
-
-Clean this up. Check everything in core works
-
-=head2 shrink C<GV>s, C<CV>s
-
-By removing unused elements and careful re-ordering, the structures for C<AV>s
-and C<HV>s have recently been shrunk considerably. It's probable that the same
-approach would find savings in C<GV>s and C<CV>s, if not all the other
-larger-than-C<PVMG> types.
-
-=head2 merge Perl_sv_2[inpu]v
+=head2 shrink C<PVBM>s
 
-There's a lot of code shared between C<Perl_sv_2iv_flags>,
-C<Perl_sv_2uv_flags>, C<Perl_sv_2nv>, and C<Perl_sv_2pv_flags>. It would be
-interesting to see if some of it can be merged into common shared static
-functions. In particular, C<Perl_sv_2uv_flags> started out as a cut&paste
-from C<Perl_sv_2iv_flags> around 5.005_50 time, and it may be possible to
-replace both with a single function that returns a value or union which is
-split out by the macros in F<sv.h>
-
-=head2 UTF8 caching code
-
-The string position/offset cache is not optional. It should be.
+By removing unused elements and careful re-ordering, the structures for C<AV>s,
+C<HV>s, C<CV>s and C<GV>s have recently been shrunk considerably. C<PVIO>s
+probably aren't worth it, as typical programs don't use more than 8, and
+(at least) C<Filter::Util::Call> uses C<SvPVX>/C<SvCUR>/C<SvLEN> on a C<PVIO>,
+so it would mean code changes to modules on CPAN. C<PVBM>s might have some
+savings to win.
 
 =head2 Implicit Latin 1 => Unicode translation
 
@@ -541,13 +526,6 @@ program if you pass the process ID. It would be good to do this with the Perl
 debugger on a running Perl program, although I'm not sure how it would be
 done." ssh and screen do this with named pipes in /tmp. Maybe we can too.
 
-=head2 Constant folding
-
-The peephole optimiser should trap errors during constant folding, and give
-up on the folding, rather than bailing out at compile time.  It is quite
-possible that the unfoldable constant is in unreachable code, eg something
-akin to C<$a = 0/0 if 0;>
-
 =head2 LVALUE functions for lists
 
 The old perltodo notes that lvalue functions don't work for list or hash
@@ -568,11 +546,6 @@ Study the possibility of adding a new prototype character, C<_>, meaning
 C<my $foo if 0;> is deprecated, and should be replaced with
 C<state $x = "initial value\n";> the syntax from Perl 6.
 
-=head2 @INC source filter to Filter::Simple
-
-The second return value from a sub in @INC can be a source filter. This isn't
-documented. It should be changed to use Filter::Simple, tested and documented.
-
 =head2 regexp optimiser optional
 
 The regexp optimiser is not optional. It should configurable to be, to allow