bytecode.pl 37 KB

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