bytecode.pl 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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 !~ /pad|xcv_name_hek|unop_aux/)) {
  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 = $fundtype =~ /^U/ ? '%u' : '%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 ($old, $max_insn) = (-1);
  585. enum:
  586. for (sort {$a->[0] <=> $b->[0] } @insndata) {
  587. ($i, $unsupp, $insn) = @$_;
  588. #
  589. # Add ENUMS to the header
  590. #
  591. $add_enum_value = 1 if $i != $old + 1;
  592. if (!$unsupp) {
  593. $insn = uc($insn);
  594. $max_insn = $i;
  595. if ($add_enum_value) {
  596. my $tabs = "\t" x (4-((9+length($insn)))/8);
  597. printf BYTERUN_H " INSN_$insn = %3d,$tabs/* $i */\n", $i;
  598. $add_enum_value = 0;
  599. } else {
  600. my $tabs = "\t" x (4-((3+length($insn))/8));
  601. print BYTERUN_H " INSN_$insn,$tabs/* $i */\n";
  602. }
  603. } else {
  604. $add_enum_value = 1;
  605. }
  606. $old = $i;
  607. }
  608. print BYTERUN_H " MAX_INSN = $max_insn\n};\n";
  609. print BYTERUN_H "\nenum {\n";
  610. for ($i = 0; $i < @optype - 1; $i++) {
  611. printf BYTERUN_H " OPt_%s,\t\t/* %d */\n", $optype[$i], $i;
  612. }
  613. printf BYTERUN_H " OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
  614. print BYTERUN_H "/* ex: set ro: */\n";
  615. #
  616. # Finish off insn_data and create array initialisers in Asmdata.pm
  617. #
  618. print ASMDATA_PM <<'EOT';
  619. my ($insn_name, $insn_data);
  620. while (($insn_name, $insn_data) = each %insn_data) {
  621. $insn_name[$insn_data->[0]] = $insn_name;
  622. }
  623. # Fill in any gaps
  624. @insn_name = map($_ || "unused", @insn_name);
  625. 1;
  626. __END__
  627. =head1 NAME
  628. B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode
  629. =head1 SYNOPSIS
  630. use B::Asmdata qw(%insn_data @insn_name @optype @specialsv_name);
  631. =head1 DESCRIPTION
  632. Provides information about Perl ops in order to generate bytecode via
  633. a bunch of exported variables. Its mostly used by B::Assembler and
  634. B::Disassembler.
  635. =over 4
  636. =item %insn_data
  637. my($bytecode_num, $put_sub, $get_meth) = @$insn_data{$op_name};
  638. For a given $op_name (for example, 'cop_label', 'sv_flags', etc...)
  639. you get an array ref containing the bytecode number of the op, a
  640. reference to the subroutine used to 'PUT' the op argument to the bytecode stream,
  641. and the name of the method used to 'GET' op argument from the bytecode stream.
  642. Most ops require one arg, in fact all ops without the PUT/GET_none methods,
  643. and the GET and PUT methods are used to en-/decode the arg to binary bytecode.
  644. The names are constructed from the GET/PUT prefix and the argument type,
  645. such as U8, U16, U32, svindex, opindex, pvindex, ...
  646. The PUT method is used in the L<B::Bytecode> compiler within L<B::Assembler>,
  647. the GET method just for the L<B::Disassembler>.
  648. The GET method is not used by the binary L<ByteLoader> module.
  649. A full C<insn> table with version, opcode, name, lvalue, argtype and flags
  650. is located as DATA in F<bytecode.pl>.
  651. An empty PUT method, the number 0, denotes an unsupported bytecode for this perl.
  652. It is there to support disassembling older perl bytecode. This was added with 1.02_02.
  653. =item @insn_name
  654. my $op_name = $insn_name[$bytecode_num];
  655. A simple mapping of the bytecode number to the name of the op.
  656. Suitable for using with %insn_data like so:
  657. my $op_info = $insn_data{$insn_name[$bytecode_num]};
  658. =item @optype
  659. my $op_type = $optype[$op_type_num];
  660. A simple mapping of the op type number to its type (like 'COP' or 'BINOP').
  661. Since Perl version 5.10 defined in L<B>.
  662. =item @specialsv_name
  663. my $sv_name = $specialsv_name[$sv_index];
  664. Certain SV types are considered 'special'. They're represented by
  665. B::SPECIAL and are referred to by a number from the specialsv_list.
  666. This array maps that number back to the name of the SV (like 'Nullsv'
  667. or '&PL_sv_undef').
  668. Since Perl version 5.10 defined in L<B>.
  669. =back
  670. =head1 PORTABILITY
  671. All bytecode values are already portable.
  672. Cross-platform portability is implemented, cross-version not yet.
  673. Cross-version portability will be very limited, cross-platform only
  674. for the same threading model.
  675. =head2 CROSS-PLATFORM PORTABILITY
  676. For different endian-ness there are ByteLoader converters in effect.
  677. Header entry: byteorder.
  678. 64int - 64all - 32int is portable. Header entry: ivsize
  679. ITHREADS are unportable; header entry: archflag - bitflag 1.
  680. MULTIPLICITY is also unportable; header entry: archflag - bitflag 2
  681. TODO For cross-version portability we will try to translate older
  682. bytecode ops to the current perl op via L<ByteLoader::Translate>.
  683. Asmdata already contains the old ops, all with the PUT method 0.
  684. Header entry: perlversion
  685. =head2 CROSS-VERSION PORTABILITY (TODO - HARD)
  686. Bytecode ops:
  687. We can only reliably load bytecode from previous versions and promise
  688. that from 5.10.0 on future versions will only add new op numbers at
  689. the end, but will never replace old opcodes with incompatible arguments.
  690. Unsupported insn's are supported by disassemble, and if C<force> in the
  691. ByteLoader is set, it is tried to load/set them also, with probably fatal
  692. consequences.
  693. On the first unknown bytecode op from a future version - added to the end
  694. - we will die.
  695. L<ByteLoader::BcVersions> contains logic to translate previous errors
  696. from this bytecode policy. E.g. 5.8 violated the 5.6 bytecode order policy
  697. and began to juggle it around (similar to parrot), in detail removed
  698. various bytecodes, like ldspecsvx:7, xpv_cur, xpv_len, xiv64:26.
  699. So in theory it would have been possible to load 5.6 into 5.8 bytecode
  700. as the underlying perl pp_code ops didn't change that much, but it is risky.
  701. We have unused tables of all bytecode ops for all version-specific changes
  702. to the bytecode table. This only changed with
  703. the ByteLoader version, ithreads and major Perl versions.
  704. Also special replacements in the byteloader for all the unsupported
  705. ops, like xiv64, cop_arybase.
  706. =head1 AUTHOR
  707. Malcolm Beattie C<MICB at cpan.org> I<(retired)>,
  708. Reini Urban added the version logic, support >= 5.10, portability.
  709. =cut
  710. # ex: set ro:
  711. EOT
  712. close ASMDATA_PM or die "Error closing $targets[0]: $!";
  713. close BYTERUN_C or die "Error closing $targets[1]: $!";
  714. close BYTERUN_H or die "Error closing $targets[2]: $!";
  715. chmod 0444, @targets;
  716. # TODO 5.10:
  717. # stpv (?)
  718. # pv_free: free the bs_pv and the SvPVX? (?)
  719. __END__
  720. # First set instruction ord("#") to read comment to end-of-line (sneaky)
  721. 35 0 comment arg comment_t
  722. # Then make ord("\n") into a no-op
  723. 10 0 nop none none
  724. # Now for the rest of the ordinary ones, beginning with \0 which is
  725. # ret so that \0-terminated strings can be read properly as bytecode.
  726. #
  727. # The argtype is either a single type or "rightvaluecast/argtype".
  728. # The version is either "i" or "!i" for ITHREADS or not,
  729. # "m" or "!m" for MULTI or not,
  730. # or num, num-num, >num or <num.
  731. # "0" is for all, "<10" requires PERL_VERSION<10, "10" requires
  732. # PERL_VERSION>=10, ">10" requires PERL_VERSION>10, "10-10"
  733. # requires PERL_VERSION>==10 only.
  734. # lvalue is the (statemachine) value to read or write.
  735. # argtype specifies the reader or writer method.
  736. # flags x specifies a special writer method BSET_$insn in bytecode.h
  737. # flags s store instructions to bytecode_obj_list[arg]. "lvalue" field is rvalue.
  738. # flags \d+ specifies the maximal length.
  739. #
  740. # bc numbering policy: <=5.6: leave out, >=5.8 leave holes
  741. # Note: ver 8 is really 8.001. 5.008000 had the same bytecodes as 5.006002.
  742. #idx version opcode lvalue argtype flags
  743. #
  744. 0 0 ret none none x
  745. 1 0 ldsv bstate->bs_sv svindex
  746. 2 0 ldop PL_op opindex
  747. 3 0 stsv bstate->bs_sv U32 s
  748. 4 0 stop PL_op U32 s
  749. 5 6.001 stpv bstate->bs_pv.pv U32 x
  750. 6 0 ldspecsv bstate->bs_sv U8 x
  751. 7 8 ldspecsvx bstate->bs_sv U8 x
  752. 8 0 newsv bstate->bs_sv U8 x
  753. 9 8 newsvx bstate->bs_sv U32 x
  754. #10 0 nop none none
  755. 11 0 newop PL_op U8 x
  756. 12 8 newopx PL_op U16 x
  757. 13 0 newopn PL_op U8 x
  758. 14 0 newpv none U32/PV
  759. 15 0 pv_cur bstate->bs_pv.cur STRLEN
  760. 16 0 pv_free bstate->bs_pv none x
  761. 17 0 sv_upgrade bstate->bs_sv U8 x
  762. 18 0 sv_refcnt SvREFCNT(bstate->bs_sv) U32
  763. 19 0 sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x
  764. 20 0 sv_flags SvFLAGS(bstate->bs_sv) U32
  765. 21 0 xrv bstate->bs_sv svindex x
  766. 22 0 xpv bstate->bs_sv none x
  767. 23 8 xpv_cur bstate->bs_sv STRLEN x
  768. 24 8 xpv_len bstate->bs_sv STRLEN x
  769. 25 8 xiv bstate->bs_sv IV x
  770. 25 <8 xiv32 SvIVX(bstate->bs_sv) I32
  771. 0 <8 xiv64 SvIVX(bstate->bs_sv) IV64
  772. 26 0 xnv bstate->bs_sv NV x
  773. 27 0 xlv_targoff LvTARGOFF(bstate->bs_sv) STRLEN
  774. 28 0 xlv_targlen LvTARGLEN(bstate->bs_sv) STRLEN
  775. 29 0 xlv_targ LvTARG(bstate->bs_sv) svindex
  776. 30 0 xlv_type LvTYPE(bstate->bs_sv) char
  777. 31 0 xbm_useful BmUSEFUL(bstate->bs_sv) I32
  778. 32 <19 xbm_previous BmPREVIOUS(bstate->bs_sv) U16
  779. 33 <19 xbm_rare BmRARE(bstate->bs_sv) U8
  780. 34 0 xfm_lines FmLINES(bstate->bs_sv) IV
  781. #35 0 comment arg comment_t
  782. 36 0 xio_lines IoLINES(bstate->bs_sv) IV
  783. 37 0 xio_page IoPAGE(bstate->bs_sv) IV
  784. 38 0 xio_page_len IoPAGE_LEN(bstate->bs_sv) IV
  785. 39 0 xio_lines_left IoLINES_LEFT(bstate->bs_sv) IV
  786. 40 0 xio_top_name IoTOP_NAME(bstate->bs_sv) pvindex
  787. 41 0 xio_top_gv *(SV**)&IoTOP_GV(bstate->bs_sv) svindex
  788. 42 0 xio_fmt_name IoFMT_NAME(bstate->bs_sv) pvindex
  789. 43 0 xio_fmt_gv *(SV**)&IoFMT_GV(bstate->bs_sv) svindex
  790. 44 0 xio_bottom_name IoBOTTOM_NAME(bstate->bs_sv) pvindex
  791. 45 0 xio_bottom_gv *(SV**)&IoBOTTOM_GV(bstate->bs_sv) svindex
  792. 46 <10 xio_subprocess IoSUBPROCESS(bstate->bs_sv) short
  793. 47 0 xio_type IoTYPE(bstate->bs_sv) char
  794. 48 0 xio_flags IoFLAGS(bstate->bs_sv) char
  795. 49 8 xcv_xsubany *(SV**)&CvXSUBANY(bstate->bs_sv).any_ptr svindex
  796. 50 <13 xcv_stash CvSTASH(bstate->bs_sv) svindex
  797. 50 13 xcv_stash bstate->bs_sv svindex x
  798. 51 0 xcv_start CvSTART(bstate->bs_sv) opindex
  799. 52 0 xcv_root CvROOT(bstate->bs_sv) opindex
  800. 53 0 xcv_gv bstate->bs_sv svindex x
  801. # <8 xcv_filegv *(SV**)&CvFILEGV(bstate->bs_sv) svindex
  802. 54 0 xcv_file CvFILE(bstate->bs_sv) pvindex
  803. 55 0 xcv_depth CvDEPTH(bstate->bs_sv) long
  804. 56 0 xcv_padlist *(SV**)&CvPADLIST(bstate->bs_sv) svindex
  805. 57 0 xcv_outside *(SV**)&CvOUTSIDE(bstate->bs_sv) svindex
  806. 58 8 xcv_outside_seq CvOUTSIDE_SEQ(bstate->bs_sv) U32
  807. 59 0 xcv_flags CvFLAGS(bstate->bs_sv) U16
  808. 60 0 av_extend bstate->bs_sv SSize_t x
  809. 61 8 av_pushx bstate->bs_sv svindex x
  810. 62 <8 av_push bstate->bs_sv svindex x
  811. 63 <8 xav_fill AvFILLp(bstate->bs_sv) SSize_t
  812. 64 <8 xav_max AvMAX(bstate->bs_sv) SSize_t
  813. 65 <10 xav_flags AvFLAGS(bstate->bs_sv) U8
  814. 65 10-12 xav_flags ((XPVAV*)(SvANY(bstate->bs_sv)))->xiv_u.xivu_i32 I32
  815. 66 <10 xhv_riter HvRITER(bstate->bs_sv) I32
  816. 67 0 xhv_name bstate->bs_sv pvindex x
  817. 68 8-9 xhv_pmroot *(OP**)&HvPMROOT(bstate->bs_sv) opindex
  818. 69 0 hv_store bstate->bs_sv svindex x
  819. 70 0 sv_magic bstate->bs_sv char x
  820. 71 0 mg_obj SvMAGIC(bstate->bs_sv)->mg_obj svindex
  821. 72 0 mg_private SvMAGIC(bstate->bs_sv)->mg_private U16
  822. 73 0 mg_flags SvMAGIC(bstate->bs_sv)->mg_flags U8
  823. # mg_name <5.8001 called mg_pv
  824. 74 0 mg_name SvMAGIC(bstate->bs_sv) pvcontents x
  825. 75 8 mg_namex SvMAGIC(bstate->bs_sv) svindex x
  826. 76 0 xmg_stash bstate->bs_sv svindex x
  827. 77 0 gv_fetchpv bstate->bs_sv strconst 128x
  828. 78 8 gv_fetchpvx bstate->bs_sv strconst 128x
  829. 79 0 gv_stashpv bstate->bs_sv strconst 128x
  830. 80 8 gv_stashpvx bstate->bs_sv strconst 128x
  831. 81 0 gp_sv bstate->bs_sv svindex x
  832. 82 0 gp_refcnt GvREFCNT(bstate->bs_sv) U32
  833. 83 0 gp_refcnt_add GvREFCNT(bstate->bs_sv) I32 x
  834. 84 0 gp_av *(SV**)&GvAV(bstate->bs_sv) svindex
  835. 85 0 gp_hv *(SV**)&GvHV(bstate->bs_sv) svindex
  836. 86 0 gp_cv *(SV**)&GvCV(bstate->bs_sv) svindex x
  837. 87 <9 gp_file GvFILE(bstate->bs_sv) pvindex
  838. 87 9 gp_file bstate->bs_sv pvindex x
  839. 88 0 gp_io *(SV**)&GvIOp(bstate->bs_sv) svindex
  840. 89 0 gp_form *(SV**)&GvFORM(bstate->bs_sv) svindex
  841. 90 0 gp_cvgen GvCVGEN(bstate->bs_sv) U32
  842. 91 0 gp_line GvLINE(bstate->bs_sv) line_t
  843. 92 0 gp_share bstate->bs_sv svindex x
  844. 93 0 xgv_flags GvFLAGS(bstate->bs_sv) U8
  845. 94 0 op_next PL_op->op_next opindex
  846. 95 0 op_sibling PL_op opindex x
  847. 96 0 op_ppaddr PL_op->op_ppaddr strconst 24x
  848. 97 0 op_targ PL_op->op_targ PADOFFSET
  849. 98 0 op_type PL_op OPCODE x
  850. 99 <9 op_seq PL_op->op_seq U16
  851. 99 9 op_opt PL_op->op_opt U8
  852. 100 0 op_flags PL_op->op_flags U8
  853. 101 0 op_private PL_op->op_private U8
  854. 102 0 op_first cUNOP->op_first opindex
  855. 103 0 op_last cBINOP->op_last opindex
  856. 104 0 op_other cLOGOP->op_other opindex
  857. # found in 5.5.5, not on 5.5.8. I found 5.5.6 and 5.5.7 nowhere
  858. 0 <5.008 op_true cCONDOP->op_true opindex
  859. 0 <5.008 op_false cCONDOP->op_false opindex
  860. 0 <6.001 op_children cLISTOP->op_children U32
  861. 105 <10 op_pmreplroot cPMOP->op_pmreplroot opindex
  862. 111 !i<10 op_pmreplrootgv *(SV**)&cPMOP->op_pmreplroot svindex
  863. 106 <10 op_pmreplstart cPMOP->op_pmreplstart opindex
  864. 105 10 op_pmreplroot (cPMOP->op_pmreplrootu).op_pmreplroot opindex
  865. 106 10 op_pmreplstart (cPMOP->op_pmstashstartu).op_pmreplstart opindex
  866. 107 <10 op_pmnext *(OP**)&cPMOP->op_pmnext opindex
  867. 108 i8 op_pmstashpv cPMOP pvindex x
  868. 109 i<10 op_pmreplrootpo cPMOP->op_pmreplroot OP*/PADOFFSET
  869. 109 i10 op_pmreplrootpo (cPMOP->op_pmreplrootu).op_pmreplroot OP*/PADOFFSET
  870. 110 !i8-10 op_pmstash *(SV**)&cPMOP->op_pmstash svindex
  871. 110 !i10 op_pmstash *(SV**)&(cPMOP->op_pmstashstartu).op_pmreplstart svindex
  872. 111 !i10 op_pmreplrootgv *(SV**)&(cPMOP->op_pmreplrootu).op_pmreplroot svindex
  873. 112 0 pregcomp PL_op pvcontents x
  874. 113 0 op_pmflags cPMOP->op_pmflags pmflags x
  875. 114 <10 op_pmpermflags cPMOP->op_pmpermflags U16
  876. 115 8-10 op_pmdynflags cPMOP->op_pmdynflags U8
  877. 116 0 op_sv cSVOP->op_sv svindex
  878. 0 <6 op_gv *(SV**)&cGVOP->op_gv svindex
  879. 117 0 op_padix cPADOP->op_padix PADOFFSET
  880. 118 0 op_pv cPVOP->op_pv pvcontents
  881. 119 0 op_pv_tr cPVOP->op_pv op_tr_array
  882. 120 0 op_redoop cLOOP->op_redoop opindex
  883. 121 0 op_nextop cLOOP->op_nextop opindex
  884. 122 0 op_lastop cLOOP->op_lastop opindex
  885. 123 0 cop_label cCOP pvindex x
  886. 124 i0 cop_stashpv cCOP pvindex x
  887. 125 i0 cop_file cCOP pvindex x
  888. 126 !i0 cop_stash cCOP svindex x
  889. 127 !i0 cop_filegv cCOP svindex x
  890. 128 0 cop_seq cCOP->cop_seq U32
  891. 129 <10 cop_arybase cCOP->cop_arybase I32
  892. 130 0 cop_line cCOP->cop_line line_t
  893. 131 8-10 cop_io cCOP->cop_io svindex
  894. 132 0 cop_warnings cCOP svindex x
  895. 133 0 main_start PL_main_start opindex
  896. 134 0 main_root PL_main_root opindex
  897. 135 8 main_cv *(SV**)&PL_main_cv svindex
  898. 136 0 curpad PL_curpad svindex x
  899. 137 0 push_begin PL_beginav svindex x
  900. 138 0 push_init PL_initav svindex x
  901. 139 0 push_end PL_endav svindex x
  902. 140 8 curstash *(SV**)&PL_curstash svindex
  903. 141 8 defstash *(SV**)&PL_defstash svindex
  904. 142 8 data none U8 x
  905. 143 8 incav *(SV**)&GvAV(PL_incgv) svindex
  906. 144 8 load_glob none svindex x
  907. 145 i8 regex_padav *(SV**)&PL_regex_padav svindex
  908. 146 8 dowarn PL_dowarn U8
  909. 147 8 comppad_name *(SV**)&PL_comppad_name svindex
  910. 148 8 xgv_stash *(SV**)&GvSTASH(bstate->bs_sv) svindex
  911. 149 8 signal bstate->bs_sv strconst 24x
  912. 150 8-17 formfeed PL_formfeed svindex
  913. 151 9-17 op_latefree PL_op->op_latefree U8
  914. 152 9-17 op_latefreed PL_op->op_latefreed U8
  915. 153 9-17 op_attached PL_op->op_attached U8
  916. # 5.10.0 misses the RX_EXTFLAGS macro
  917. 154 10-10.5 op_reflags PM_GETRE(cPMOP)->extflags U32
  918. 154 11 op_reflags RX_EXTFLAGS(PM_GETRE(cPMOP)) U32
  919. 155 10 cop_seq_low ((XPVNV*)(SvANY(bstate->bs_sv)))->xnv_u.xpad_cop_seq.xlow U32
  920. 156 10 cop_seq_high ((XPVNV*)(SvANY(bstate->bs_sv)))->xnv_u.xpad_cop_seq.xhigh U32
  921. 157 8 gv_fetchpvn_flags bstate->bs_sv U32 x
  922. # restore dup to stdio handles 0-2
  923. 158 0 xio_ifp bstate->bs_sv char x
  924. 159 10 xpvshared bstate->bs_sv none x
  925. 160 18 newpadlx bstate->bs_sv U8 x
  926. 161 18 padl_name bstate->bs_sv svindex x
  927. 162 18 padl_sym bstate->bs_sv svindex x
  928. 163 18 xcv_name_hek bstate->bs_sv pvindex x
  929. 164 18 op_slabbed PL_op->op_slabbed U8
  930. 165 18 op_savefree PL_op->op_savefree U8
  931. 166 18 op_static PL_op->op_static U8
  932. 167 19.003 op_folded PL_op->op_folded U8
  933. 168 21.002-22 op_lastsib PL_op->op_lastsib U8
  934. 168 22 op_moresib PL_op->op_moresib U8
  935. 169 18 newpadnlx bstate->bs_sv U8 x
  936. 170 22 padl_outid ((PADLIST*)bstate->bs_sv)->xpadl_outid U32
  937. 0 22 padl_id ((PADLIST*)bstate->bs_sv)->xpadl_id U32
  938. 0 22 padnl_push bstate->bs_sv svindex x
  939. 0 22 padnl_maxnamed PadnamelistMAXNAMED((PADNAMELIST*)bstate->bs_sv) U32
  940. 0 22 padnl_refcnt PadnamelistREFCNT((PADNAMELIST*)bstate->bs_sv) U32
  941. 0 22 newpadnx bstate->bs_sv strconst x
  942. 0 22 padn_stash *(SV**)PadnameOURSTASH((PADNAME*)bstate->bs_sv) svindex
  943. 0 22 padn_type *(SV**)PadnameTYPE((PADNAME*)bstate->bs_sv) svindex
  944. 0 22 padn_seq_low COP_SEQ_RANGE_LOW((PADNAME*)bstate->bs_sv) U32
  945. 0 22 padn_seq_high COP_SEQ_RANGE_HIGH((PADNAME*)bstate->bs_sv) U32
  946. 0 22 padn_refcnt PadnameREFCNT((PADNAME*)bstate->bs_sv) U32
  947. 0 22 padn_pv PadnamePV((PADNAME*)bstate->bs_sv) strconst x
  948. 0 22 padn_flags PadnameFLAGS((PADNAME*)bstate->bs_sv) U8
  949. 0 22 unop_aux cUNOP_AUX->op_aux strconst x
  950. 0 22 methop_methsv cMETHOPx(PL_op)->op_u.op_meth_sv svindex
  951. 0 !i22 methop_rclass cMETHOPx(PL_op)->op_rclass_sv svindex
  952. 0 i22 methop_rclass cMETHOPx(PL_op)->op_rclass_targ PADOFFSET