bytecode.pl 37 KB

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