summaryrefslogtreecommitdiff
path: root/regen/opcode.pl
Commit message (Collapse)AuthorAgeFilesLines
...
* Note where B::Op_private’s pod is to be editedFather Chrysostomos2014-09-101-1/+2
|
* Wrap long lines in B::Op_private podFather Chrysostomos2014-09-101-5/+5
|
* Automate processing of op_private flagsDavid Mitchell2014-09-101-4/+740
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new config file, regen/op_private, which contains all the information about the flags and descriptions for the OP op_private field. Previously, the flags themselves were defined in op.h, accompanied by textual descriptions (sometimes inaccurate or incomplete). For display purposes, there were short labels for each flag found in Concise.pm, and another set of labels for Perl_do_op_dump() in dump.c. These two sets of labels differed from each other in spelling (e.g. REFC verses REFCOUNT), and differed in completeness and accuracy. With this commit, all the data to generate the defines and the labels is derived from a single source, and are generated automatically by 'make regen'. It also contains complete data on which bits are used for what by each op. So any attempt to add a new flag for a particular op where that bit is already in use, will raise an error in make regen. This compares to the previous practice of reading the descriptions in op.h and hoping for the best. It also makes use of data in regen/opcodes: for example, regen/op_private specifies that all ops flagged as 'T' get the OPpTARGET_MY flag. Since the set of labels used by Concise and Perl_do_op_dump() differed, I've standardised on the Concise version. Thus this commit changes the output produced by Concise only marginally, while Perl_do_op_dump() is considerably different. As well as the change in labels (and missing labels), Perl_do_op_dump() formerly had a bug whereby any unrecognised bits would not be shown if there was at least one recognised bit. So while Concise displayed (and still does) "LVINTRO,2", Perl_do_op_dump() has changed: - PRIVATE = (INTRO) + PRIVATE = (LVINTRO,0x2) Concise has mainly changed in that a few op/bit combinations weren't being shown symbolically, and now are. I've avoiding fixing the ones that would break tests; they'll be fixed up in the next few commits. A few new OPp* flags have been added: OPpARG1_MASK OPpARG2_MASK OPpARG3_MASK OPpARG4_MASK OPpHINT_M_VMSISH_STATUS OPpHINT_M_VMSISH_TIME OPpHINT_STRICT_REFS The last three are analogues for existing HINT_* flags. The former four reflect that many ops some of the lower few bits of op_private to indicate how many args the op expects. While (for now) this is still displayed as, e.g. "LVINTRO,2", the definitions in regen/op_private now fully account for which ops use which bits for the arg count. There is a new module, B::Op_private, which allows this new data to be accessed from Perl. For example, use B::Op_private; my $name = $B::Op_private::bits{aelem}{7}; # OPpLVAL_INTRO my $value = $B::Op_private::defines{$name}; # 128 my $label = $B::Op_private::labels{$name}; # LVINTRO There are several new constant PL_* tables. PL_op_private_valid[] specifies for each op number, which bits are valid for that op. In a couple of commits' time, op_free() will use this on debugging builds to assert that no ops gained any private flags which we don't know about. In fact it was by using such a temporary assert repeatedly against the test suite, that I tracked down most of the inconsistencies and errors in the current flag data. The other PL_op_private_* tables contain a compact representation of all the ops/bits/labels in a format suitable for Perl_do_op_dump() to decode Op_private. Overall, the perl binary is about 500 bytes smaller on my system.
* Add clonecv op typeFather Chrysostomos2012-09-151-1/+1
| | | | | | This will be used for cloning a ‘my’ sub on scope entry. I was going to use pp_padcv for this, but it would end up having a top-level if/else.
* Add introcv op typeFather Chrysostomos2012-09-151-1/+1
| | | | | This will be used for introducing ‘my’ subs on scope entry, by turning off the stale flag.
* Remove boolkeys opFather Chrysostomos2012-08-261-2/+1
|
* Banish boolkeysFather Chrysostomos2012-08-251-1/+2
| | | | | | | | | | | | | | Since 6ea72b3a1, rv2hv and padhv have had the ability to return boo- leans in scalar context, instead of bucket stats, if flagged the right way. sub { %hash || ... } is optimised to take advantage of this. If the || is in unknown context at compile time, the %hash is flagged as being maybe a true boolean. When flagged that way, it returns a bool- ean if block_gimme() returns G_VOID. If rv2hv and padhv can already do this, then we don’t need the boolkeys op any more. We can just flag the rv2hv to return a boolean. In all the cases where boolkeys was used, we know at compile time that it is true boolean context, so we add a new flag for that.
* Add freed ops to PL_op_(name|desc)Father Chrysostomos2012-08-081-0/+2
| | | | This is useful for debugging, especially with -DT.
* Add OP_FREED op typeFather Chrysostomos2012-06-291-0/+3
| | | | | | | | This is a dummy op type that should never be seen by any code except op allocation code (to come). So it is not in the usual list of opcodes, but is #defined outside the range valid of opcodes.
* Merge postinc and postdecFather Chrysostomos2011-09-161-2/+1
| | | | They were nearly identical.
* Merge preinc and postincFather Chrysostomos2011-09-161-2/+1
| | | | | They are almost identical. This gives the compiler less code to digest.
* regen/opcode.pl: generate OP_IS_DIRHOP, use in gv.cJim Cromie2011-09-091-3/+11
| | | | | | | Generate OP_IS_DIRHOP like other OP_IS_* macros, use in gv.c:Perl_gv_add_by_type(). Modifies 'F' operand type to 'DF'. This yields a micro-optimization.
* implement OP_IS_NUMCOMPARE like other OP_IS macrosJim Cromie2011-09-091-7/+12
| | | | | | | other macros are written by regen/opcode.pl into opnames.h Generate OP_IS_NUMCOMPARE the same way, and get a micro-optimization. Adds a new 'S<' operand type for the numeric comparison ops. Needs make regen.
* Split OP_AELEMFAST_LEX out from OP_AELEMFAST.Nicholas Clark2011-06-121-0/+1
| | | | | | | | | | | | | 6a077020aea1c5f0 extended the OP_AELEMFAST optimisation to lexical arrays. Previously OP_AELEMFAST was only used as an optimisation for OP_GV, which is a PADOP/SVOP. However, by reusing the same opcode, and signalling (pad) lexical vs package, it introduced a myriad of special cases, because OP_PADAV is a BASEOP (not a PADOP), whilst OP_AELEMFAST is a PADOP/SVOP (which is larger). Using two OP numbers allows each variant to have the correct OP flags in PL_opargs. Both can continue to share the same C code.
* Add an optional third argument to open_new(), to invoke read_only_top() with.Nicholas Clark2011-05-191-13/+12
| | | | Merge together many calls to open_new() and read_only_top().
* Rename safer_open() to open_new(), and eliminate the first parameter.Nicholas Clark2011-05-191-3/+3
| | | | Update the SHA256s where necessary in the generated files.
* In regen scripts, print to explicit file handles instead of using select.Nicholas Clark2011-01-231-40/+28
| | | | | Also put explicit quotes on heredoc declarations to show whether they should interpolate, merge some heredocs, and remove & from calls to &tab(...)
* Move the duplicated subroutine tab() into regen_lib.plNicholas Clark2011-01-231-8/+0
|
* Change close_and_rename() to read_only_bottom_close_and_rename()Nicholas Clark2011-01-231-13/+6
| | | | | | | | | | All users of close_and_rename() were printing out the appropriate "ex: set ro:" string to the file handle immediately before closing it. So move that into the common function and rename it to reflect what it now does. [Except overload.pl, which should have been, given that it calls read_only_top()] Print a newline above the "ex: set ro:" line. This removes many newlines from the regen scripts, but does add newlines to a couple of generated files.
* In regen/*.pl, refactor the repeated code for close and rename if different.Nicholas Clark2011-01-231-14/+5
| | | | | | | Pass the final file name as an optional second argument of safer_open() and store it with the file handle. Add a function close_and_rename() which closes the file handle, then retrieves the final name, and renames the temporary file if the two differ.
* opcode.pl hasn't generated files named *-old since 2008, so don't delete them.Nicholas Clark2011-01-231-6/+0
| | | | | | Commit b6b9a09997c80269 removed the last vestiges of the code that generated any files named *-old, but the code to clean them up remained. It serves no purpose.
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-46/+9
| | | | | | | | | Previously all the scripts in regen/ had code to generate header comments (buffer-read-only, "do not edit this file", and optionally regeneration script, regeneration data, copyright years and filename). This change results in some minor reformatting of header blocks, and standardises the copyright line as "Larry Wall and others".
* "Don't repeat yourself" in regen/opcode.plNicholas Clark2011-01-221-5/+4
|
* Merge the implementations of {end,set}{gr,pw}ent with endhostent.Nicholas Clark2011-01-101-1/+2
| | | | | Unlike set{host,net,proto,serv}ent, set{gr,pw}ent don't have stayopen parameter, hence their "signature" is the same as the ent*ent functions.
* Merge the implementations of pp_s{host,net,proto,serv}ent.Nicholas Clark2011-01-101-0/+1
|
* Merge the implementations of pp_e{host,net,proto,serv}ent.Nicholas Clark2011-01-101-0/+1
| | | | | | | PL_op_desc[] rather than PL_op_name(), as the OPs are internally named e*ent, but implement the ent*ent functions, and when unimplemented report themselves using the function name. No need for OP_DESC(), as the switch statement means that we can't encounter OP_CUSTOM.
* Generate "Unsupported socket function" stubs using PL_ppaddr.Nicholas Clark2011-01-091-16/+60
| | | | | | | | | | | | | | | Instead of having each socket op conditionally compile as either the implementation or a DIE() depending on #HAS_SOCKET 1: remove the conditional code from the ops themselves 2: only compile the ops if HAS_SOCKET is defined 3: general conditional code for the intialisation of PL_ppaddr - as appropriate either the ops, or Perl_unimplemented_op 4: Amend Perl_unimplemented_op to generate the appropriate DIE() for socket ops (ie not the "panic"... message) Whilst this complicates the support code in regen/opcode.pl, it's already a net saving of 5 lines in the C code.
* Rename pp_send to pp_syswrite, making send an alias for syswrite.Nicholas Clark2011-01-091-1/+1
| | | | | Previously syswrite was an alias for send. However, syswrite is always available, whereas send is not implemented if HAS_SOCKET is not defined.
* In opcode.h, use the alias macros in PL_ppaddr[]Nicholas Clark2011-01-091-1/+1
| | | | | | | | For OPs that share implementations, use #define aliases for the "original" names in PL_ppaddr[], instead of having regen/opcode.pl replace them with the name of the implementing OP body. Whilst this initially adds another layer of indirection, it will give more flexibility where conditional compilation of OPs is determined by the feature macros in config.h
* Remove commented-out code from regen/opcode.plNicholas Clark2011-01-091-13/+0
|
* regen/opcode.pl should only generate prototypes for pp_* functions that exist.Nicholas Clark2011-01-091-10/+7
| | | | | | | It now generates prototypes for all functions that implement OPs. Hence Perl_unimplemented_op no longer needs a special-case prototype. As it is now generating a prototype for Perl_do_kv, no need for regen/embed.pl to duplicate this. Convert the last two users of the macro do_kv() to Perl_do_kv(aTHX).
* Generate pp_* prototypes in pp_proto.h, and remove pp.symNicholas Clark2011-01-091-17/+16
| | | | | | | | | | | Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13 locations that relied on them. regen/opcode.pl now generates prototypes for the PP functions directly, into pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads this, removing the only ordering dependency in the regen scripts. opcode.pl is now responsible for prototypes for pp_* functions. (embed.pl remains responsible for ck_* functions, reading from regen/opcodes)
* embed.pl can read the names of ck_* functions direct from regen/opcodesNicholas Clark2011-01-091-5/+0
| | | | Previously regen/opcode.pl wrote them to pp.sym for regen/embed.pl to read.
* Extract the opcode data from regen/opcode.pl into regen/opcodesNicholas Clark2011-01-091-552/+5
| | | | | Whilst it is possible to open regen/opcode.pl and parse it to find the __END__ token, it's not the cleanest approach.
* Replace OP stubs in mathoms.c with #define aliases in opcode.hNicholas Clark2011-01-091-7/+14
| | | | | | | External code that references OPs by name will still link (and work). Unlike the other compatibility functions in mathoms.c, the OP stubs were simply making calls onwards to their replacements, so simply taking up space without adding anything.
* Merge the opcode bodies for pp_bind and pp_connect.Nicholas Clark2010-12-301-0/+1
|
* Remove OP_phoney_{IN,OUT}PUT_ONLY, as they are no longer used or supported.Nicholas Clark2010-12-281-2/+0
|
* Merge the opcode bodies for chop/chomp and schop/schomp.Nicholas Clark2010-12-271-0/+2
|
* Make entertry a LOGOP, not BASEOP/UNOPReini Urban2010-12-121-1/+1
| | | | | | | The initial parse-time UNOP is upgraded at ck_eval to an LOGOP - op_other holding the ptr to leavetry - which causes problems at run-time B optype inspection. The opclass info was always wrong, the Bytecode compiler broke with 5.12.
* Improve custom OP support.Ben Morrow2010-11-141-5/+0
| | | | | | | | | | | | | | | | | Change the custom op registrations from two separate hashes to one hash holding structure pointers, and add API functions to register ops and look them up. This will make it easier to add new properties of custom ops in the future. Copy entries across from the old hashes where necessary, to preserve compatibility. Add two new properties, in addition to the already-existing 'name' and 'description': 'class' and 'peep'. 'class' is one of the OA_*OP constants, and allows B and other introspection mechanisms to work with custom ops that aren't BASEOPs. 'peep' is a pointer to a function that will be called for ops of this type from Perl_rpeep. Adjust B.xs to take account of the new properties, and also to give custom ops their registered name rather than simply 'custom'.
* Add transr op typeFather Chrysostomos2010-11-021-1/+7
| | | | | for the upcoming y///r feature. There are not enough flag bits, hence the extra type.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* opcode.pl -> regen/opcode.plFather Chrysostomos2010-10-131-6/+6
|
* Move regen scripts to regen/Steffen Mueller2010-10-101-0/+1101
Moves the various scripts that are called by regen.pl to a subdirectory to reduce clutter.