bytecode.pl 35 KB

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