bytecode.pl 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. # -*- cperl-indent-level:4 -*-
  2. BEGIN {
  3. push @INC, '.', 'lib';
  4. require 'regen_lib.pl';
  5. }
  6. use strict;
  7. use Config;
  8. my %alias_to = (
  9. U32 => [qw(line_t)],
  10. PADOFFSET => [qw(STRLEN SSize_t)],
  11. U16 => [qw(OPCODE short)],
  12. U8 => [qw(char)],
  13. );
  14. %alias_to = (
  15. U32 => [qw(PADOFFSET STRLEN)],
  16. I32 => [qw(SSize_t long)],
  17. U16 => [qw(OPCODE line_t short)],
  18. U8 => [qw(char)],
  19. ) if $] < 5.008001;
  20. my (%alias_from, $from, $tos);
  21. while (($from, $tos) = each %alias_to) {
  22. map { $alias_from{$_} = $from } @$tos;
  23. }
  24. my (@optype, @specialsv_name);
  25. require B;
  26. # @optype was in B::Asmdata, and is since 5.10 in B
  27. if ($] < 5.009) {
  28. require B::Asmdata;
  29. @optype = @{*B::Asmdata::optype{ARRAY}};
  30. @specialsv_name = @{*B::Asmdata::specialsv_name{ARRAY}};
  31. # B::Asmdata->import qw(@optype @specialsv_name);
  32. } else {
  33. @optype = @{*B::optype{ARRAY}};
  34. @specialsv_name = @{*B::specialsv_name{ARRAY}};
  35. # B->import qw(@optype @specialsv_name);
  36. }
  37. my $perlversion = sprintf("%1.6f%s", $], ($Config{useithreads} ? '' : '-nt'));
  38. my $c_header = <<"EOT";
  39. /* -*- buffer-read-only: t -*-
  40. *
  41. * Copyright (c) 1996-1999 Malcolm Beattie
  42. * Copyright (c) 2008,2009,2010,2011,2012 Reini Urban
  43. *
  44. * You may distribute under the terms of either the GNU General Public
  45. * License or the Artistic License, as specified in the README file.
  46. *
  47. */
  48. /*
  49. * This file is autogenerated from bytecode.pl. Changes made here will be lost.
  50. * It is specific for Perl $perlversion only.
  51. */
  52. EOT
  53. my $perl_header;
  54. ($perl_header = $c_header) =~ s{[/ ]?\*/?}{#}g;
  55. my @targets = ("lib/B/Asmdata.pm", "ByteLoader/byterun.c", "ByteLoader/byterun.h");
  56. safer_unlink @targets;
  57. #
  58. # Start with boilerplate for Asmdata.pm
  59. #
  60. open(ASMDATA_PM, "> $targets[0]") or die "$targets[0]: $!";
  61. binmode ASMDATA_PM;
  62. print ASMDATA_PM $perl_header, <<'EOT';
  63. package B::Asmdata;
  64. our $VERSION = '1.03';
  65. use Exporter;
  66. @ISA = qw(Exporter);
  67. @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name);
  68. EOT
  69. if ($] > 5.009) {
  70. print ASMDATA_PM 'our(%insn_data, @insn_name);
  71. use B qw(@optype @specialsv_name);
  72. ';
  73. } elsif ($] > 5.008) {
  74. print ASMDATA_PM 'our(%insn_data, @insn_name, @optype, @specialsv_name);
  75. @optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP);
  76. @specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no pWARN_ALL pWARN_NONE);
  77. ';
  78. } else {
  79. print ASMDATA_PM 'my(%insn_data, @insn_name, @optype, @specialsv_name);
  80. @optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP);
  81. @specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no pWARN_ALL pWARN_NONE);
  82. ';
  83. }
  84. print ASMDATA_PM <<"EOT";
  85. # XXX insn_data is initialised this way because with a large
  86. # %insn_data = (foo => [...], bar => [...], ...) initialiser
  87. # I get a hard-to-track-down stack underflow and segfault.
  88. EOT
  89. #
  90. # Boilerplate for byterun.c
  91. #
  92. open(BYTERUN_C, "> $targets[1]") or die "$targets[1]: $!";
  93. binmode BYTERUN_C;
  94. print BYTERUN_C $c_header, <<'EOT';
  95. #define PERL_NO_GET_CONTEXT
  96. #include "EXTERN.h"
  97. #include "perl.h"
  98. #define NO_XSLOCKS
  99. #include "XSUB.h"
  100. #if PERL_VERSION < 8
  101. #define NEED_sv_2pv_flags
  102. #include "ppport.h"
  103. #endif
  104. /* Change 31252: move PL_tokenbuf into the PL_parser struct */
  105. #if (PERL_VERSION > 8) && (!defined(PL_tokenbuf))
  106. #define PL_tokenbuf (PL_parser->tokenbuf)
  107. #endif
  108. #if (PERL_VERSION < 8) && (!defined(DEBUG_v))
  109. #define DEBUG_v(a) DEBUG_f(a)
  110. #endif
  111. #include "byterun.h"
  112. #include "bytecode.h"
  113. struct byteloader_header bl_header;
  114. static const int optype_size[] = {
  115. EOT
  116. my $i = 0;
  117. for ($i = 0; $i < @optype - 1; $i++) {
  118. printf BYTERUN_C " sizeof(%s),\n", $optype[$i], $i;
  119. }
  120. printf BYTERUN_C " sizeof(%s)\n", $optype[$i], $i;
  121. print BYTERUN_C <<'EOT';
  122. };
  123. void *
  124. bset_obj_store(pTHX_ struct byteloader_state *bstate, void *obj, I32 ix)
  125. {
  126. if (ix > bstate->bs_obj_list_fill) {
  127. Renew(bstate->bs_obj_list, ix + 32, void*);
  128. bstate->bs_obj_list_fill = ix + 31;
  129. }
  130. bstate->bs_obj_list[ix] = obj;
  131. return obj;
  132. }
  133. int bytecode_header_check(pTHX_ struct byteloader_state *bstate, U32 *isjit) {
  134. U32 sz = 0;
  135. strconst str;
  136. BGET_U32(sz); /* Magic: 'PLBC' or 'PLJC' */
  137. if (sz != 0x43424c50) {
  138. if (sz != 0x434a4c50) {
  139. HEADER_FAIL1("bad magic (want 0x43424c50 PLBC or 0x434a4c50 PLJC, got %#x)",
  140. (int)sz);
  141. } else {
  142. *isjit = 1;
  143. }
  144. }
  145. BGET_strconst(str,80); /* archname */
  146. strcpy(bl_header.archname, str);
  147. /* just warn. relaxed strictness, only check for ithread in archflag */
  148. if (strNE(str, ARCHNAME)) {
  149. HEADER_WARN2("Different architecture %s, you have %s", str, ARCHNAME);
  150. }
  151. /* ByteLoader version strategy: Strict for 0.06_ development releases and 0.03-0.04.
  152. 0.07 should be able to load 0.5 (5.8.1 CORE) */
  153. BGET_strconst(str,16);
  154. strcpy(bl_header.version, str);
  155. if (strNE(str, VERSION)) {
  156. if ((strGT(str, "0.06") && strLT(str, "0.06_06")) /*|| strLT(str, "0.05")*/) {
  157. HEADER_FAIL2("Incompatible bytecode version %s, you have %s",
  158. str, VERSION);
  159. }
  160. }
  161. BGET_U32(sz); /* ivsize */
  162. bl_header.ivsize = sz;
  163. BGET_U32(sz); /* ptrsize */
  164. bl_header.ptrsize = sz;
  165. /* new since 0.06_03 */
  166. if (strGE(bl_header.version, "0.06_03")) {
  167. BGET_U32(sz); /* longsize */
  168. bl_header.longsize = sz;
  169. } else {
  170. bl_header.longsize = LONGSIZE;
  171. }
  172. if (strGT(bl_header.version, "0.06") || strEQ(bl_header.version, "0.04"))
  173. { /* added again with 0.06_01 */
  174. /* config.h BYTEORDER: 0x1234 of length longsize, not ivsize */
  175. char supported[16];
  176. /* Note: perl's $Config{byteorder} is wrong with 64int.
  177. Bug in Config.pm:921 my $s = $Config{ivsize}; => my $s = $Config{longsize};
  178. */
  179. sprintf(supported, "%x", BYTEORDER);
  180. BGET_strconst(str, 16); /* optional 0x prefix, 12345678 or 1234 */
  181. if (str[0] == 0x30 && str[1] == 0x78) { /* skip '0x' */
  182. str++; str++;
  183. }
  184. strcpy(bl_header.byteorder, str);
  185. if (strNE(str, supported)) {
  186. /* swab only if same length. 1234 => 4321, 12345678 => 87654321 */
  187. if (strlen(str) == strlen(supported)) {
  188. bget_swab = 1;
  189. HEADER_WARN2("EXPERIMENTAL byteorder conversion: .plc=%s, perl=%s",
  190. str, supported);
  191. } else {
  192. HEADER_FAIL2("Unsupported byteorder conversion: .plc=%s, perl=%s",
  193. str, supported);
  194. }
  195. }
  196. }
  197. /* swab byteorder */
  198. if (bget_swab) {
  199. bl_header.ivsize = _swab_32_(bl_header.ivsize);
  200. bl_header.ptrsize = _swab_32_(bl_header.ptrsize);
  201. if (bl_header.longsize != LONGSIZE) {
  202. bl_header.longsize = _swab_32_(bl_header.longsize);
  203. }
  204. }
  205. #ifdef USE_ITHREADS
  206. # define HAVE_ITHREADS_I 1
  207. #else
  208. # define HAVE_ITHREADS_I 0
  209. #endif
  210. #ifdef MULTIPLICITY
  211. # define HAVE_MULTIPLICITY_I 2
  212. #else
  213. # define HAVE_MULTIPLICITY_I 0
  214. #endif
  215. if (strGE(bl_header.version, "0.06_05")) {
  216. BGET_U16(sz); /* archflag */
  217. bl_header.archflag = sz;
  218. if ((sz & 1) != HAVE_ITHREADS_I) {
  219. HEADER_FAIL2("Wrong USE_ITHREADS. Bytecode: %s, System: %s)",
  220. bl_header.archflag & 1 ? "yes" : "no",
  221. HAVE_ITHREADS_I ? "yes" : "no");
  222. }
  223. if (strGE(bl_header.version, "0.08")) {
  224. if ((sz & 2) != HAVE_MULTIPLICITY_I) {
  225. HEADER_FAIL2("Wrong MULTIPLICITY. Bytecode: %s, System: %s)",
  226. bl_header.archflag & 2 ? "yes" : "no",
  227. HAVE_MULTIPLICITY_I ? "yes" : "no");
  228. }
  229. }
  230. }
  231. if (bl_header.ivsize != IVSIZE) {
  232. HEADER_WARN("different IVSIZE");
  233. if ((bl_header.ivsize != 4) && (bl_header.ivsize != 8))
  234. HEADER_FAIL1("unsupported IVSIZE %d", bl_header.ivsize);
  235. }
  236. if (bl_header.ptrsize != PTRSIZE) {
  237. HEADER_WARN("different PTRSIZE");
  238. if ((bl_header.ptrsize != 4) && (bl_header.ptrsize != 8))
  239. HEADER_FAIL1("unsupported PTRSIZE %d", bl_header.ptrsize);
  240. }
  241. if (strGE(bl_header.version, "0.06_03")) {
  242. if (bl_header.longsize != LONGSIZE) {
  243. HEADER_WARN("different LONGSIZE");
  244. if ((bl_header.longsize != 4) && (bl_header.longsize != 8))
  245. HEADER_FAIL1("unsupported LONGSIZE %d", bl_header.longsize);
  246. }
  247. }
  248. if (strGE(bl_header.version, "0.06_06")) {
  249. BGET_strconst(str, 16);
  250. strcpy(bl_header.perlversion, str);
  251. } else {
  252. *bl_header.perlversion = 0;
  253. }
  254. return 1;
  255. }
  256. int
  257. byterun(pTHX_ struct byteloader_state *bstate)
  258. {
  259. register int insn;
  260. U32 isjit = 0;
  261. U32 ix;
  262. EOT
  263. printf BYTERUN_C " SV *specialsv_list[%d];\n", scalar @specialsv_name;
  264. print BYTERUN_C <<'EOT';
  265. bytecode_header_check(aTHX_ bstate, &isjit); /* croak if incorrect platform,
  266. set isjit on PLJC magic header */
  267. if (isjit) {
  268. Perl_croak(aTHX_ "PLJC-magic: No JIT support yet\n");
  269. return 0; /*jitrun(aTHX_ &bstate);*/
  270. } else {
  271. New(0, bstate->bs_obj_list, 32, void*); /* set op objlist */
  272. bstate->bs_obj_list_fill = 31;
  273. bstate->bs_obj_list[0] = NULL; /* first is always Null */
  274. bstate->bs_ix = 1;
  275. CopLINE(PL_curcop) = bstate->bs_fdata->next_out;
  276. DEBUG_l( Perl_deb(aTHX_ "(bstate.bs_fdata.idx %d)\n", bstate->bs_fdata->idx));
  277. DEBUG_l( Perl_deb(aTHX_ "(bstate.bs_fdata.next_out %d)\n", bstate->bs_fdata->next_out));
  278. DEBUG_l( Perl_deb(aTHX_ "(bstate.bs_fdata.datasv %p:\"%s\")\n", bstate->bs_fdata->datasv,
  279. SvPV_nolen(bstate->bs_fdata->datasv)));
  280. EOT
  281. for my $i ( 0 .. $#specialsv_name ) {
  282. print BYTERUN_C " specialsv_list[$i] = $specialsv_name[$i];\n";
  283. }
  284. print BYTERUN_C <<'EOT';
  285. while ((insn = BGET_FGETC()) != EOF) {
  286. CopLINE(PL_curcop) = bstate->bs_fdata->next_out;
  287. switch (insn) {
  288. EOT
  289. my ($idx, @insn_name, $insn_num, $ver, $insn, $lvalue, $argtype, $flags, $fundtype, $unsupp);
  290. my $ITHREADS = $Config{useithreads} eq 'define';
  291. my $MULTI = $Config{useithreads} eq 'define';
  292. $insn_num = 0;
  293. my @data = <DATA>;
  294. my @insndata = ();
  295. for (@data) {
  296. if (/^\s*#/) {
  297. print BYTERUN_C if /^\s*#\s*(?:if|endif|el)/;
  298. next;
  299. }
  300. chop;
  301. next unless length;
  302. ($idx, $ver, $insn, $lvalue, $argtype, $flags) = split;
  303. # bc numbering policy: <=5.6: leave out (squeeze), >=5.8 leave holes
  304. if ($] > 5.007) {
  305. $insn_num = $idx ? $idx : $insn_num;
  306. $insn_num = 0 if !$idx and $insn eq 'ret';
  307. } else { # ignore the idx and count through. just fixup comment and nop
  308. $insn_num = 35 if $insn eq "comment";
  309. $insn_num = 10 if $insn eq "nop";
  310. $insn_num = 0 if $insn eq "ret"; # start from 0
  311. }
  312. my $rvalcast = '';
  313. $unsupp = 0;
  314. if ($argtype =~ m:(.+)/(.+):) {
  315. ($rvalcast, $argtype) = ("($1)", $2);
  316. }
  317. if ($ver) {
  318. if ($ver =~ /^\!?i/) {
  319. $unsupp++ if ($ver =~ /^i/ and !$ITHREADS) or ($ver =~ /\!i/ and $ITHREADS);
  320. $ver =~ s/^\!?i//;
  321. }
  322. if ($ver =~ /^\!?m/) {
  323. $unsupp++ if ($ver =~ /^m/ and !$MULTI) or ($ver =~ /\!m/ and $MULTI);
  324. $ver =~ s/^\!?m//;
  325. }
  326. # perl version 5.010000 => 10.000, 5.009003 => 9.003
  327. # Have to round the float: 5.010 - 5 = 0.00999999999999979
  328. my $pver = 0.0+(substr($],2,3).".".substr($],5));
  329. if ($ver =~ /^<?8\-?/) {
  330. $ver =~ s/8/8.001/; # as convenience for a shorter table.
  331. }
  332. # Add these misses to ASMDATA. TODO: To BYTERUN maybe with a translator, as the
  333. # perl fields to write to are gone. Reading for the disassembler should be possible.
  334. if ($ver =~ /^\>[\d\.]+$/) {
  335. $unsupp++ if $pver < substr($ver,1);# ver >10: skip if pvar lowereq 10
  336. } elsif ($ver =~ /^\<[\d\.]+$/) {
  337. $unsupp++ if $pver >= substr($ver,1); # ver <10: skip if pvar higher than 10;
  338. } elsif ($ver =~ /^([\d\.]+)-([\d\.]+)$/) {
  339. $unsupp++ if $pver >= $2 or $pver < $1; # ver 8-10 (both inclusive): skip if pvar
  340. # lower than 8 or higher than 10;
  341. } elsif ($ver =~ /^[\d\.]*$/) {
  342. $unsupp++ if $pver < $ver; # ver 10: skip if pvar lower than 10;
  343. }
  344. }
  345. # warn "unsupported $idx\t$ver\t$insn\n" if $unsupp;
  346. if (!$unsupp or ($] >= 5.007 and $insn !~ /padl|xcv_name_hek/)) {
  347. $insn_name[$insn_num] = $insn;
  348. push @insndata, [$insn_num, $unsupp, $insn, $lvalue, $rvalcast, $argtype, $flags];
  349. # Find the next unused instruction number
  350. do { $insn_num++ } while $insn_name[$insn_num];
  351. }
  352. }
  353. # calculate holes and insn_nums (number of instructions per bytecode)
  354. my %holes = ();
  355. my $insn_max = $insndata[$#insndata]->[0];
  356. # %holes = (46=>1,66=>1,68=>1,107=>1,108=>1,115=>1,126=>1,127=>1,129=>1,131=>1) if $] > 5.007;
  357. my %insn_nums;
  358. if ($] > 5.007) {
  359. my %unsupps;
  360. for (@insndata) { $insn_nums{$_->[0]}++; } # all
  361. for (@insndata) { $holes{$_->[0]}++ if $_->[1] and $insn_nums{$_->[0]} == 1; }
  362. }
  363. my $UVxf = substr($Config{uvxformat},1,-1);
  364. for (@insndata) {
  365. my ($unsupp, $rvalcast);
  366. ($insn_num, $unsupp, $insn, $lvalue, $rvalcast, $argtype, $flags) = @$_;
  367. $fundtype = $alias_from{$argtype} || $argtype;
  368. #
  369. # Add the initialiser line for %insn_data in Asmdata.pm
  370. #
  371. if ($unsupp) {
  372. print ASMDATA_PM <<"EOT" if $insn_nums{$insn_num} == 1; # singletons only
  373. \$insn_data{$insn} = [$insn_num, 0, "GET_$fundtype"];
  374. EOT
  375. } else {
  376. print ASMDATA_PM <<"EOT";
  377. \$insn_data{$insn} = [$insn_num, \\&PUT_$fundtype, "GET_$fundtype"];
  378. EOT
  379. }
  380. #
  381. # Add the case statement and code for the bytecode interpreter in byterun.c
  382. #
  383. # On unsupported codes add to BYTERUN CASE only for certain nums: holes.
  384. if (!$unsupp or $holes{$insn_num}) {
  385. printf BYTERUN_C "\t case %s:\t\t/* %d */\n\t {\n",
  386. $unsupp ? $insn_num : "INSN_".uc($insn), $insn_num;
  387. } else {
  388. next;
  389. }
  390. my $optarg = $argtype eq "none" ? "" : ", arg";
  391. my ($argfmt, $rvaldcast, $printarg);
  392. if ($fundtype =~ /(strconst|pvcontents|op_tr_array)/) {
  393. $argfmt = '\"%s\"';
  394. $rvaldcast = '(char*)';
  395. $printarg = "${rvaldcast}arg";
  396. } elsif ($argtype =~ /index$/) {
  397. $argfmt = '0x%'.$UVxf.', ix:%d';
  398. $rvaldcast = "($argtype)";
  399. $printarg = "PTR2UV(arg)";
  400. } else {
  401. $argfmt = '%d';
  402. $rvaldcast = '(int)';
  403. $printarg = "${rvaldcast}arg";
  404. }
  405. if ($optarg) {
  406. print BYTERUN_C "\t\t$argtype arg;\n";
  407. if ($rvalcast) {
  408. $argtype = $rvalcast . $argtype;
  409. }
  410. if ($unsupp and $holes{$insn_num}) {
  411. printf BYTERUN_C "\t\tPerlIO_printf(Perl_error_log, \"Unsupported bytecode instruction %%d (%s) at stream offset %%d.\\n\",
  412. insn, bstate->bs_fdata->next_out);\n", uc($insn);
  413. }
  414. print BYTERUN_C "\t\tif (force)\n\t" if $unsupp;
  415. if ($fundtype eq 'strconst') {
  416. my $maxsize = ($flags =~ /(\d+$)/) ? $1 : 0;
  417. printf BYTERUN_C "\t\tBGET_%s(arg, %d);\n", $fundtype, $maxsize;
  418. } else {
  419. printf BYTERUN_C "\t\tBGET_%s(arg);\n", $fundtype;
  420. }
  421. printf BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"(insn %%3d) $insn $argtype:%s\\n\",\n\t\t\t\tinsn, $printarg%s));\n",
  422. $argfmt, ($argtype =~ /index$/ ? ', (int)ix' : '');
  423. if ($insn eq 'newopx' or $insn eq 'newop') {
  424. print BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"\t [%s %d]\\n\", PL_op_name[arg>>7], bstate->bs_ix));\n";
  425. }
  426. if ($fundtype eq 'PV') {
  427. print BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"\t BGET_PV(arg) => \\\"%s\\\"\\n\", bstate->bs_pv.pv));\n";
  428. }
  429. } else {
  430. if ($unsupp and $holes{$insn_num}) {
  431. printf BYTERUN_C "\t\tPerlIO_printf(Perl_error_log, \"Unsupported bytecode instruction %%d (%s) at stream offset %%d.\\n\",
  432. insn, bstate->bs_fdata->next_out);\n", uc($insn);
  433. }
  434. print BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"(insn %3d) $insn\\n\", insn));\n";
  435. }
  436. if ($flags =~ /x/) {
  437. # Special setter method named after insn
  438. print BYTERUN_C "\t\tif (force)\n\t" if $unsupp;
  439. print BYTERUN_C "\t\tBSET_$insn($lvalue$optarg);\n";
  440. my $optargcast = $optarg eq ", arg" ? ",\n\t\t\t\t$printarg" : '';
  441. $optargcast .= ($insn =~ /x$/ and $optarg eq ", arg" ? ", bstate->bs_ix-1" : '');
  442. printf BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"\t BSET_$insn($lvalue%s)\\n\"$optargcast));\n",
  443. $optarg eq ", arg"
  444. ? ($fundtype =~ /(strconst|pvcontents)/
  445. ? ($insn =~ /x$/ ? ', \"%s\" ix:%d' : ', \"%s\"')
  446. : (", " .($argtype =~ /index$/ ? '0x%'.$UVxf : $argfmt)
  447. .($insn =~ /x$/ ? ' ix:%d' : ''))
  448. )
  449. : '';
  450. } elsif ($flags =~ /s/) {
  451. # Store instructions to bytecode_obj_list[arg]. "lvalue" field is rvalue.
  452. print BYTERUN_C "\t\tif (force)\n\t" if $unsupp;
  453. print BYTERUN_C "\t\tBSET_OBJ_STORE($lvalue$optarg);\n";
  454. print BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"\t BSET_OBJ_STORE($lvalue$optarg)\\n\"));\n";
  455. }
  456. elsif ($optarg && $lvalue ne "none") {
  457. print BYTERUN_C "\t\t$lvalue = ${rvalcast}arg;\n" unless $unsupp;
  458. printf BYTERUN_C "\t\tDEBUG_v(Perl_deb(aTHX_ \"\t $lvalue = ${rvalcast}%s;\\n\", $printarg%s));\n",
  459. $fundtype =~ /(strconst|pvcontents)/ ? '\"%s\"' : ($argtype =~ /index$/ ? '0x%'.$UVxf : $argfmt);
  460. }
  461. print BYTERUN_C "\t\tbreak;\n\t }\n";
  462. }
  463. #
  464. # Finish off byterun.c
  465. #
  466. print BYTERUN_C <<'EOT';
  467. default:
  468. Perl_croak(aTHX_ "Illegal bytecode instruction %d at stream offset %d.\n",
  469. insn, bstate->bs_fdata->next_out);
  470. /* NOTREACHED */
  471. }
  472. /* debop is not public in 5.10.0 on strict platforms like mingw and MSVC, cygwin is fine. */
  473. #if defined(DEBUG_t_TEST_) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(AIX)
  474. if (PL_op && DEBUG_t_TEST_)
  475. /* GV without the cGVOPo_gv initialized asserts. We need to skip newopx */
  476. if ((insn != INSN_NEWOPX) && (insn != INSN_NEWOP) && (PL_op->op_type != OP_GV)) debop(PL_op);
  477. #endif
  478. }
  479. }
  480. return 0;
  481. }
  482. /* ex: set ro: */
  483. EOT
  484. #
  485. # Write the instruction and optype enum constants into byterun.h
  486. #
  487. open(BYTERUN_H, "> $targets[2]") or die "$targets[2]: $!";
  488. binmode BYTERUN_H;
  489. print BYTERUN_H $c_header, <<'EOT';
  490. #if PERL_VERSION < 10
  491. # define PL_RSFP PL_rsfp
  492. #else
  493. # define PL_RSFP PL_parser->rsfp
  494. #endif
  495. #if (PERL_VERSION <= 8) && (PERL_SUBVERSION < 8)
  496. # define NEED_sv_2pv_flags
  497. # include "ppport.h"
  498. #endif
  499. /* macros for correct constant construction */
  500. # if INTSIZE >= 2
  501. # define U16_CONST(x) ((U16)x##U)
  502. # else
  503. # define U16_CONST(x) ((U16)x##UL)
  504. # endif
  505. # if INTSIZE >= 4
  506. # define U32_CONST(x) ((U32)x##U)
  507. # else
  508. # define U32_CONST(x) ((U32)x##UL)
  509. # endif
  510. # ifdef HAS_QUAD
  511. typedef I64TYPE I64;
  512. typedef U64TYPE U64;
  513. # if INTSIZE >= 8
  514. # define U64_CONST(x) ((U64)x##U)
  515. # elif LONGSIZE >= 8
  516. # define U64_CONST(x) ((U64)x##UL)
  517. # elif QUADKIND == QUAD_IS_LONG_LONG
  518. # define U64_CONST(x) ((U64)x##ULL)
  519. # else /* best guess we can make */
  520. # define U64_CONST(x) ((U64)x##UL)
  521. # endif
  522. # endif
  523. /* byte-swapping functions for big-/little-endian conversion */
  524. # define _swab_16_(x) ((U16)( \
  525. (((U16)(x) & U16_CONST(0x00ff)) << 8) | \
  526. (((U16)(x) & U16_CONST(0xff00)) >> 8) ))
  527. # define _swab_32_(x) ((U32)( \
  528. (((U32)(x) & U32_CONST(0x000000ff)) << 24) | \
  529. (((U32)(x) & U32_CONST(0x0000ff00)) << 8) | \
  530. (((U32)(x) & U32_CONST(0x00ff0000)) >> 8) | \
  531. (((U32)(x) & U32_CONST(0xff000000)) >> 24) ))
  532. # ifdef HAS_QUAD
  533. # define _swab_64_(x) ((U64)( \
  534. (((U64)(x) & U64_CONST(0x00000000000000ff)) << 56) | \
  535. (((U64)(x) & U64_CONST(0x000000000000ff00)) << 40) | \
  536. (((U64)(x) & U64_CONST(0x0000000000ff0000)) << 24) | \
  537. (((U64)(x) & U64_CONST(0x00000000ff000000)) << 8) | \
  538. (((U64)(x) & U64_CONST(0x000000ff00000000)) >> 8) | \
  539. (((U64)(x) & U64_CONST(0x0000ff0000000000)) >> 24) | \
  540. (((U64)(x) & U64_CONST(0x00ff000000000000)) >> 40) | \
  541. (((U64)(x) & U64_CONST(0xff00000000000000)) >> 56) ))
  542. # else
  543. # define _swab_64_(x) _swab_32_((U32)(x) & U32_CONST(0xffffffff))
  544. # endif
  545. # define _swab_iv_(x,size) ((size==4) ? _swab_32_(x) : ((size==8) ? _swab_64_(x) : _swab_16_(x)))
  546. struct byteloader_fdata {
  547. SV *datasv;
  548. int next_out;
  549. int idx;
  550. };
  551. struct byteloader_xpv {
  552. char *pv;
  553. int cur;
  554. int len;
  555. };
  556. struct byteloader_header {
  557. char archname[80];
  558. char version[16];
  559. int ivsize;
  560. int ptrsize;
  561. int longsize;
  562. char byteorder[16];
  563. int archflag;
  564. char perlversion[16];
  565. };
  566. struct byteloader_state {
  567. struct byteloader_fdata *bs_fdata;
  568. SV *bs_sv;
  569. void **bs_obj_list;
  570. int bs_obj_list_fill;
  571. int bs_ix;
  572. struct byteloader_xpv bs_pv;
  573. int bs_iv_overflows;
  574. };
  575. int bl_getc(struct byteloader_fdata *);
  576. int bl_read(struct byteloader_fdata *, char *, size_t, size_t);
  577. extern int byterun(pTHX_ register struct byteloader_state *);
  578. enum {
  579. EOT
  580. my $add_enum_value = 0;
  581. my $max_insn;
  582. enum:
  583. for (sort {$a->[0] <=> $b->[0] } @insndata) {
  584. ($i, $unsupp, $insn) = @$_;
  585. #
  586. # Add ENUMS to the header
  587. #
  588. if (!$unsupp) {
  589. $insn = uc($insn);
  590. $max_insn = $i;
  591. if ($add_enum_value) {
  592. my $tabs = "\t" x (4-((9+length($insn)))/8);
  593. printf BYTERUN_H " INSN_$insn = %3d,$tabs/* $i */\n", $i;
  594. $add_enum_value = 0;
  595. } else {
  596. my $tabs = "\t" x (4-((3+length($insn))/8));
  597. print BYTERUN_H " INSN_$insn,$tabs/* $i */\n";
  598. }
  599. } else {
  600. $add_enum_value = 1;
  601. }
  602. }
  603. print BYTERUN_H " MAX_INSN = $max_insn\n};\n";
  604. print BYTERUN_H "\nenum {\n";
  605. for ($i = 0; $i < @optype - 1; $i++) {
  606. printf BYTERUN_H " OPt_%s,\t\t/* %d */\n", $optype[$i], $i;
  607. }
  608. printf BYTERUN_H " OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
  609. print BYTERUN_H "/* ex: set ro: */\n";
  610. #
  611. # Finish off insn_data and create array initialisers in Asmdata.pm
  612. #
  613. print ASMDATA_PM <<'EOT';
  614. my ($insn_name, $insn_data);
  615. while (($insn_name, $insn_data) = each %insn_data) {
  616. $insn_name[$insn_data->[0]] = $insn_name;
  617. }
  618. # Fill in any gaps
  619. @insn_name = map($_ || "unused", @insn_name);
  620. 1;
  621. __END__
  622. =head1 NAME
  623. B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode
  624. =head1 SYNOPSIS
  625. use B::Asmdata qw(%insn_data @insn_name @optype @specialsv_name);
  626. =head1 DESCRIPTION
  627. Provides information about Perl ops in order to generate bytecode via
  628. a bunch of exported variables. Its mostly used by B::Assembler and
  629. B::Disassembler.
  630. =over 4
  631. =item %insn_data
  632. my($bytecode_num, $put_sub, $get_meth) = @$insn_data{$op_name};
  633. For a given $op_name (for example, 'cop_label', 'sv_flags', etc...)
  634. you get an array ref containing the bytecode number of the op, a
  635. reference to the subroutine used to 'PUT' the op argument to the bytecode stream,
  636. and the name of the method used to 'GET' op argument from the bytecode stream.
  637. Most ops require one arg, in fact all ops without the PUT/GET_none methods,
  638. and the GET and PUT methods are used to en-/decode the arg to binary bytecode.
  639. The names are constructed from the GET/PUT prefix and the argument type,
  640. such as U8, U16, U32, svindex, opindex, pvindex, ...
  641. The PUT method is used in the L<B::Bytecode> compiler within L<B::Assembler>,
  642. the GET method just for the L<B::Disassembler>.
  643. The GET method is not used by the binary L<ByteLoader> module.
  644. A full C<insn> table with version, opcode, name, lvalue, argtype and flags
  645. is located as DATA in F<bytecode.pl>.
  646. An empty PUT method, the number 0, denotes an unsupported bytecode for this perl.
  647. It is there to support disassembling older perl bytecode. This was added with 1.02_02.
  648. =item @insn_name
  649. my $op_name = $insn_name[$bytecode_num];
  650. A simple mapping of the bytecode number to the name of the op.
  651. Suitable for using with %insn_data like so:
  652. my $op_info = $insn_data{$insn_name[$bytecode_num]};
  653. =item @optype
  654. my $op_type = $optype[$op_type_num];
  655. A simple mapping of the op type number to its type (like 'COP' or 'BINOP').
  656. Since Perl version 5.10 defined in L<B>.
  657. =item @specialsv_name
  658. my $sv_name = $specialsv_name[$sv_index];
  659. Certain SV types are considered 'special'. They're represented by
  660. B::SPECIAL and are referred to by a number from the specialsv_list.
  661. This array maps that number back to the name of the SV (like 'Nullsv'
  662. or '&PL_sv_undef').
  663. Since Perl version 5.10 defined in L<B>.
  664. =back
  665. =head1 PORTABILITY
  666. All bytecode values are already portable.
  667. Cross-platform portability is implemented, cross-version not yet.
  668. Cross-version portability will be very limited, cross-platform only
  669. for the same threading model.
  670. =head2 CROSS-PLATFORM PORTABILITY
  671. For different endian-ness there are ByteLoader converters in effect.
  672. Header entry: byteorder.
  673. 64int - 64all - 32int is portable. Header entry: ivsize
  674. ITHREADS are unportable; header entry: archflag - bitflag 1.
  675. MULTIPLICITY is also unportable; header entry: archflag - bitflag 2
  676. TODO For cross-version portability we will try to translate older
  677. bytecode ops to the current perl op via L<ByteLoader::Translate>.
  678. Asmdata already contains the old ops, all with the PUT method 0.
  679. Header entry: perlversion
  680. =head2 CROSS-VERSION PORTABILITY (TODO - HARD)
  681. Bytecode ops:
  682. We can only reliably load bytecode from previous versions and promise
  683. that from 5.10.0 on future versions will only add new op numbers at
  684. the end, but will never replace old opcodes with incompatible arguments.
  685. Unsupported insn's are supported by disassemble, and if C<force> in the
  686. ByteLoader is set, it is tried to load/set them also, with probably fatal
  687. consequences.
  688. On the first unknown bytecode op from a future version - added to the end
  689. - we will die.
  690. L<ByteLoader::BcVersions> contains logic to translate previous errors
  691. from this bytecode policy. E.g. 5.8 violated the 5.6 bytecode order policy
  692. and began to juggle it around (similar to parrot), in detail removed
  693. various bytecodes, like ldspecsvx:7, xpv_cur, xpv_len, xiv64:26.
  694. So in theory it would have been possible to load 5.6 into 5.8 bytecode
  695. as the underlying perl pp_code ops didn't change that much, but it is risky.
  696. We have unused tables of all bytecode ops for all version-specific changes
  697. to the bytecode table. This only changed with
  698. the ByteLoader version, ithreads and major Perl versions.
  699. Also special replacements in the byteloader for all the unsupported
  700. ops, like xiv64, cop_arybase.
  701. =head1 AUTHOR
  702. Malcolm Beattie C<MICB at cpan.org> I<(retired)>,
  703. Reini Urban added the version logic, support >= 5.10, portability.
  704. =cut
  705. # ex: set ro:
  706. EOT
  707. close ASMDATA_PM or die "Error closing $targets[0]: $!";
  708. close BYTERUN_C or die "Error closing $targets[1]: $!";
  709. close BYTERUN_H or die "Error closing $targets[2]: $!";
  710. chmod 0444, @targets;
  711. # TODO 5.10:
  712. # stpv (?)
  713. # pv_free: free the bs_pv and the SvPVX? (?)
  714. __END__
  715. # First set instruction ord("#") to read comment to end-of-line (sneaky)
  716. 35 0 comment arg comment_t
  717. # Then make ord("\n") into a no-op
  718. 10 0 nop none none
  719. # Now for the rest of the ordinary ones, beginning with \0 which is
  720. # ret so that \0-terminated strings can be read properly as bytecode.
  721. #
  722. # The argtype is either a single type or "rightvaluecast/argtype".
  723. # The version is either "i" or "!i" for ITHREADS or not,
  724. # "m" or "!m" for MULTI or not,
  725. # or num, num-num, >num or <num.
  726. # "0" is for all, "<10" requires PERL_VERSION<10, "10" requires
  727. # PERL_VERSION>=10, ">10" requires PERL_VERSION>10, "10-10"
  728. # requires PERL_VERSION>==10 only.
  729. # lvalue is the (statemachine) value to read or write.
  730. # argtype specifies the reader or writer method.
  731. # flags x specifies a special writer method BSET_$insn in bytecode.h
  732. # flags s store instructions to bytecode_obj_list[arg]. "lvalue" field is rvalue.
  733. # flags \d+ specifies the maximal length.
  734. #
  735. # bc numbering policy: <=5.6: leave out, >=5.8 leave holes
  736. # Note: ver 8 is really 8.001. 5.008000 had the same bytecodes as 5.006002.
  737. #idx version opcode lvalue argtype flags
  738. #
  739. 0 0 ret none none x
  740. 1 0 ldsv bstate->bs_sv svindex
  741. 2 0 ldop PL_op opindex
  742. 3 0 stsv bstate->bs_sv U32 s
  743. 4 0 stop PL_op U32 s
  744. 5 6.001 stpv bstate->bs_pv.pv U32 x
  745. 6 0 ldspecsv bstate->bs_sv U8 x
  746. 7 8 ldspecsvx bstate->bs_sv U8 x
  747. 8 0 newsv bstate->bs_sv U8 x
  748. 9 8 newsvx bstate->bs_sv U32 x
  749. #10 0 nop none none
  750. 11 0 newop PL_op U8 x
  751. 12 8 newopx PL_op U16 x
  752. 13 0 newopn PL_op U8 x
  753. 14 0 newpv none U32/PV
  754. 15 0 pv_cur bstate->bs_pv.cur STRLEN
  755. 16 0 pv_free bstate->bs_pv none x
  756. 17 0 sv_upgrade bstate->bs_sv U8 x
  757. 18 0 sv_refcnt SvREFCNT(bstate->bs_sv) U32
  758. 19 0 sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x
  759. 20 0 sv_flags SvFLAGS(bstate->bs_sv) U32
  760. 21 0 xrv bstate->bs_sv svindex x
  761. 22 0 xpv bstate->bs_sv none x
  762. 23 8 xpv_cur bstate->bs_sv STRLEN x
  763. 24 8 xpv_len bstate->bs_sv STRLEN x
  764. 25 8 xiv bstate->bs_sv IV x
  765. 25 <8 xiv32 SvIVX(bstate->bs_sv) I32
  766. 0 <8 xiv64 SvIVX(bstate->bs_sv) IV64
  767. 26 0 xnv bstate->bs_sv NV x
  768. 27 0 xlv_targoff LvTARGOFF(bstate->bs_sv) STRLEN
  769. 28 0 xlv_targlen LvTARGLEN(bstate->bs_sv) STRLEN
  770. 29 0 xlv_targ LvTARG(bstate->bs_sv) svindex
  771. 30 0 xlv_type LvTYPE(bstate->bs_sv) char
  772. 31 0 xbm_useful BmUSEFUL(bstate->bs_sv) I32
  773. 32 <19 xbm_previous BmPREVIOUS(bstate->bs_sv) U16
  774. 33 <19 xbm_rare BmRARE(bstate->bs_sv) U8
  775. 34 0 xfm_lines FmLINES(bstate->bs_sv) IV
  776. #35 0 comment arg comment_t
  777. 36 0 xio_lines IoLINES(bstate->bs_sv) IV
  778. 37 0 xio_page IoPAGE(bstate->bs_sv) IV
  779. 38 0 xio_page_len IoPAGE_LEN(bstate->bs_sv) IV
  780. 39 0 xio_lines_left IoLINES_LEFT(bstate->bs_sv) IV
  781. 40 0 xio_top_name IoTOP_NAME(bstate->bs_sv) pvindex
  782. 41 0 xio_top_gv *(SV**)&IoTOP_GV(bstate->bs_sv) svindex
  783. 42 0 xio_fmt_name IoFMT_NAME(bstate->bs_sv) pvindex
  784. 43 0 xio_fmt_gv *(SV**)&IoFMT_GV(bstate->bs_sv) svindex
  785. 44 0 xio_bottom_name IoBOTTOM_NAME(bstate->bs_sv) pvindex
  786. 45 0 xio_bottom_gv *(SV**)&IoBOTTOM_GV(bstate->bs_sv) svindex
  787. 46 <10 xio_subprocess IoSUBPROCESS(bstate->bs_sv) short
  788. 47 0 xio_type IoTYPE(bstate->bs_sv) char
  789. 48 0 xio_flags IoFLAGS(bstate->bs_sv) char
  790. 49 8 xcv_xsubany *(SV**)&CvXSUBANY(bstate->bs_sv).any_ptr svindex
  791. 50 <13 xcv_stash CvSTASH(bstate->bs_sv) svindex
  792. 50 13 xcv_stash bstate->bs_sv svindex x
  793. 51 0 xcv_start CvSTART(bstate->bs_sv) opindex
  794. 52 0 xcv_root CvROOT(bstate->bs_sv) opindex
  795. 53 0 xcv_gv bstate->bs_sv svindex x
  796. # <8 xcv_filegv *(SV**)&CvFILEGV(bstate->bs_sv) svindex
  797. 54 0 xcv_file CvFILE(bstate->bs_sv) pvindex
  798. 55 0 xcv_depth CvDEPTH(bstate->bs_sv) long
  799. 56 0 xcv_padlist *(SV**)&CvPADLIST(bstate->bs_sv) svindex
  800. 57 0 xcv_outside *(SV**)&CvOUTSIDE(bstate->bs_sv) svindex
  801. 58 8 xcv_outside_seq CvOUTSIDE_SEQ(bstate->bs_sv) U32
  802. 59 0 xcv_flags CvFLAGS(bstate->bs_sv) U16
  803. 60 0 av_extend bstate->bs_sv SSize_t x
  804. 61 8 av_pushx bstate->bs_sv svindex x
  805. 62 <8 av_push bstate->bs_sv svindex x
  806. 63 <8 xav_fill AvFILLp(bstate->bs_sv) SSize_t
  807. 64 <8 xav_max AvMAX(bstate->bs_sv) SSize_t
  808. 65 <10 xav_flags AvFLAGS(bstate->bs_sv) U8
  809. 65 10-12 xav_flags ((XPVAV*)(SvANY(bstate->bs_sv)))->xiv_u.xivu_i32 I32
  810. 66 <10 xhv_riter HvRITER(bstate->bs_sv) I32
  811. 67 0 xhv_name bstate->bs_sv pvindex x
  812. 68 8-9 xhv_pmroot *(OP**)&HvPMROOT(bstate->bs_sv) opindex
  813. 69 0 hv_store bstate->bs_sv svindex x
  814. 70 0 sv_magic bstate->bs_sv char x
  815. 71 0 mg_obj SvMAGIC(bstate->bs_sv)->mg_obj svindex
  816. 72 0 mg_private SvMAGIC(bstate->bs_sv)->mg_private U16
  817. 73 0 mg_flags SvMAGIC(bstate->bs_sv)->mg_flags U8
  818. # mg_name <5.8001 called mg_pv
  819. 74 0 mg_name SvMAGIC(bstate->bs_sv) pvcontents x
  820. 75 8 mg_namex SvMAGIC(bstate->bs_sv) svindex x
  821. 76 0 xmg_stash bstate->bs_sv svindex x
  822. 77 0 gv_fetchpv bstate->bs_sv strconst 128x
  823. 78 8 gv_fetchpvx bstate->bs_sv strconst 128x
  824. 79 0 gv_stashpv bstate->bs_sv strconst 128x
  825. 80 8 gv_stashpvx bstate->bs_sv strconst 128x
  826. 81 0 gp_sv bstate->bs_sv svindex x
  827. 82 0 gp_refcnt GvREFCNT(bstate->bs_sv) U32
  828. 83 0 gp_refcnt_add GvREFCNT(bstate->bs_sv) I32 x
  829. 84 0 gp_av *(SV**)&GvAV(bstate->bs_sv) svindex
  830. 85 0 gp_hv *(SV**)&GvHV(bstate->bs_sv) svindex
  831. 86 0 gp_cv *(SV**)&GvCV(bstate->bs_sv) svindex x
  832. 87 <9 gp_file GvFILE(bstate->bs_sv) pvindex
  833. 87 9 gp_file bstate->bs_sv pvindex x
  834. 88 0 gp_io *(SV**)&GvIOp(bstate->bs_sv) svindex
  835. 89 0 gp_form *(SV**)&GvFORM(bstate->bs_sv) svindex
  836. 90 0 gp_cvgen GvCVGEN(bstate->bs_sv) U32
  837. 91 0 gp_line GvLINE(bstate->bs_sv) line_t
  838. 92 0 gp_share bstate->bs_sv svindex x
  839. 93 0 xgv_flags GvFLAGS(bstate->bs_sv) U8
  840. 94 0 op_next PL_op->op_next opindex
  841. 95 0 op_sibling PL_op->op_sibling opindex
  842. 96 0 op_ppaddr PL_op->op_ppaddr strconst 24x
  843. 97 0 op_targ PL_op->op_targ PADOFFSET
  844. 98 0 op_type PL_op OPCODE x
  845. 99 <9 op_seq PL_op->op_seq U16
  846. 99 9 op_opt PL_op->op_opt U8
  847. 100 0 op_flags PL_op->op_flags U8
  848. 101 0 op_private PL_op->op_private U8
  849. 102 0 op_first cUNOP->op_first opindex
  850. 103 0 op_last cBINOP->op_last opindex
  851. 104 0 op_other cLOGOP->op_other opindex
  852. # found in 5.5.5, not on 5.5.8. I found 5.5.6 and 5.5.7 nowhere
  853. 0 <5.008 op_true cCONDOP->op_true opindex
  854. 0 <5.008 op_false cCONDOP->op_false opindex
  855. 0 <6.001 op_children cLISTOP->op_children U32
  856. 105 <10 op_pmreplroot cPMOP->op_pmreplroot opindex
  857. 111 !i<10 op_pmreplrootgv *(SV**)&cPMOP->op_pmreplroot svindex
  858. 106 <10 op_pmreplstart cPMOP->op_pmreplstart opindex
  859. 105 10 op_pmreplroot (cPMOP->op_pmreplrootu).op_pmreplroot opindex
  860. 106 10 op_pmreplstart (cPMOP->op_pmstashstartu).op_pmreplstart opindex
  861. 107 <10 op_pmnext *(OP**)&cPMOP->op_pmnext opindex
  862. 108 i8 op_pmstashpv cPMOP pvindex x
  863. 109 i<10 op_pmreplrootpo cPMOP->op_pmreplroot OP*/PADOFFSET
  864. 109 i10 op_pmreplrootpo (cPMOP->op_pmreplrootu).op_pmreplroot OP*/PADOFFSET
  865. 110 !i8-10 op_pmstash *(SV**)&cPMOP->op_pmstash svindex
  866. 110 !i10 op_pmstash *(SV**)&(cPMOP->op_pmstashstartu).op_pmreplstart svindex
  867. 111 !i10 op_pmreplrootgv *(SV**)&(cPMOP->op_pmreplrootu).op_pmreplroot svindex
  868. 112 0 pregcomp PL_op pvcontents x
  869. 113 0 op_pmflags cPMOP->op_pmflags pmflags x
  870. 114 <10 op_pmpermflags cPMOP->op_pmpermflags U16
  871. 115 8-10 op_pmdynflags cPMOP->op_pmdynflags U8
  872. 116 0 op_sv cSVOP->op_sv svindex
  873. 0 <6 op_gv *(SV**)&cGVOP->op_gv svindex
  874. 117 0 op_padix cPADOP->op_padix PADOFFSET
  875. 118 0 op_pv cPVOP->op_pv pvcontents
  876. 119 0 op_pv_tr cPVOP->op_pv op_tr_array
  877. 120 0 op_redoop cLOOP->op_redoop opindex
  878. 121 0 op_nextop cLOOP->op_nextop opindex
  879. 122 0 op_lastop cLOOP->op_lastop opindex
  880. 123 0 cop_label cCOP pvindex x
  881. 124 i0 cop_stashpv cCOP pvindex x
  882. 125 i0 cop_file cCOP pvindex x
  883. 126 !i0 cop_stash cCOP svindex x
  884. 127 !i0 cop_filegv cCOP svindex x
  885. 128 0 cop_seq cCOP->cop_seq U32
  886. 129 <10 cop_arybase cCOP->cop_arybase I32
  887. 130 0 cop_line cCOP->cop_line line_t
  888. 131 8-10 cop_io cCOP->cop_io svindex
  889. 132 0 cop_warnings cCOP svindex x
  890. 133 0 main_start PL_main_start opindex
  891. 134 0 main_root PL_main_root opindex
  892. 135 8 main_cv *(SV**)&PL_main_cv svindex
  893. 136 0 curpad PL_curpad svindex x
  894. 137 0 push_begin PL_beginav svindex x
  895. 138 0 push_init PL_initav svindex x
  896. 139 0 push_end PL_endav svindex x
  897. 140 8 curstash *(SV**)&PL_curstash svindex
  898. 141 8 defstash *(SV**)&PL_defstash svindex
  899. 142 8 data none U8 x
  900. 143 8 incav *(SV**)&GvAV(PL_incgv) svindex
  901. 144 8 load_glob none svindex x
  902. 145 i8 regex_padav *(SV**)&PL_regex_padav svindex
  903. 146 8 dowarn PL_dowarn U8
  904. 147 8 comppad_name *(SV**)&PL_comppad_name svindex
  905. 148 8 xgv_stash *(SV**)&GvSTASH(bstate->bs_sv) svindex
  906. 149 8 signal bstate->bs_sv strconst 24x
  907. 150 8-17 formfeed PL_formfeed svindex
  908. 151 9-17 op_latefree PL_op->op_latefree U8
  909. 152 9-17 op_latefreed PL_op->op_latefreed U8
  910. 153 9-17 op_attached PL_op->op_attached U8
  911. # 5.10.0 misses the RX_EXTFLAGS macro
  912. 154 10-10.5 op_reflags PM_GETRE(cPMOP)->extflags U32
  913. 154 11 op_reflags RX_EXTFLAGS(PM_GETRE(cPMOP)) U32
  914. 155 10 cop_seq_low ((XPVNV*)(SvANY(bstate->bs_sv)))->xnv_u.xpad_cop_seq.xlow U32
  915. 156 10 cop_seq_high ((XPVNV*)(SvANY(bstate->bs_sv)))->xnv_u.xpad_cop_seq.xhigh U32
  916. 157 8 gv_fetchpvn_flags bstate->bs_sv U32 x
  917. # restore dup to stdio handles 0-2
  918. 158 0 xio_ifp bstate->bs_sv char x
  919. 159 10 xpvshared bstate->bs_sv none x
  920. 160 18 newpadlx bstate->bs_sv U8 x
  921. 161 18 padl_name bstate->bs_sv svindex x
  922. 162 18 padl_sym bstate->bs_sv svindex x
  923. 163 18 xcv_name_hek bstate->bs_sv pvindex x
  924. 164 18 op_slabbed PL_op->op_slabbed U8
  925. 165 18 op_savefree PL_op->op_savefree U8
  926. 166 18 op_static PL_op->op_static U8
  927. 167 19.003 op_folded PL_op->op_folded U8