Bytecode
From perl6.cz
Ukázka bytekódu virtuálního stroje Parrot.
See
- Format of the Parrot bytecode
- PackFile Manipulation Functions
- Inside Virtual Machines
- src/ops/ in Parrot repository
cat lgp01.pasm
<syntax lang=pasm>
.pcc_sub _sub1: set I1, 10 print "in sub1\n" add I0, 5 add I1, 10 returncc
</syntax>
parrot -o lgp01.pbc lgp01.pasm && pdump -d lgp01.pbc
HEADER => [
wordsize = 4 (interpreter's wordsize = 4)
int_size = 4 (interpreter's INTVAL size = 4)
byteorder = 0 (interpreter's byteorder = 0)
floattype = 0 (interpreter's NUMVAL_SIZE = 8)
no endianize, no opcode, no numval transform
dirformat = 1
]
DIRECTORY => [ # offs 0x20(32) = op_count 188, itype 0, id 0, size 0, ...
# 5 segments
type 4 BYTECODE_lgp01.pasm offs 0x38(0xe0) op_count 16
type 2 FIXUP_lgp01.pasm offs 0x48(0x120) op_count 12
type 3 CONSTANT_lgp01.pasm offs 0x54(0x150) op_count 84
type 1 PIC_idx_lgp01.pasm offs 0xa8(0x2a0) op_count 12
type 5 BYTECODE_lgp01.pasm_DB offs 0xb4(0x2d0) op_count 16
]
BYTECODE_lgp01.pasm => [ # 12 ops at offs 0x3c
0000: 00000320 00000001 0000000a set_i_ic
0003: 0000019d 00000001 print_sc
0005: 00000206 00000000 00000005 add_i_ic
0008: 00000206 00000001 0000000a add_i_ic
000b: 00000022 returncc
]
FIXUP_lgp01.pasm => [
#0
type => 2 offs => 3 name => '_sub1',
],
CONSTANT_lgp01.pasm => [
# 0:
[ 'PFC_PMC', {
unknown PMC
} ],
# 1:
[ 'PFC_STRING', {
FLAGS => 0x21100,
CHARSET => 5777888,
SIZE => 8,
DATA => 'in sub1
'
} ],
# 2:
[ 'PFC_STRING', {
FLAGS => 0x21100,
CHARSET => 5777888,
SIZE => 10,
DATA => 'lgp01.pasm'
} ],
# 3:
[ 'PFC_PMC', {
class => Sub,
start_offs => 0,
end_offs => 12,
name => '_sub1',
namespace => '(keyed)'
} ],
# 4:
[ 'PFC_STRING', {
FLAGS => 0x21100,
CHARSET => 5777888,
SIZE => 5,
DATA => '_sub1'
} ],
],
PIC_idx_lgp01.pasm => [ # offs 0xa8(168) = op_count 12, itype 0, id 0, size 6, ...
0000: 00000000 5f786469 3070676c 61702e31 00006d73 00000000
]
BYTECODE_lgp01.pasm_DB => [ # offs 0xb4(180) = op_count 16, itype 0, id 0, size 6, ...mappings => [
#0
[
OFFSET => 0,
MAPPINGTYPE => FILENAME,
FILENAME => lgp01.pasm
],
]
0000: 00000002 00000003 00000004 00000005 00000006 00004244
]
pdump is created by make parrot_utils