diff options
| author | Damien George | 2019-09-25 15:45:47 +1000 |
|---|---|---|
| committer | Damien George | 2019-10-01 12:26:22 +1000 |
| commit | c8c0fd4ca39fbdcf9ca5f2fc99ca4d6b81a28b65 (patch) | |
| tree | 0fcbf3a263817be928c0b7db847d94293c79cce5 /tests | |
| parent | b5ebfadbd615de42c43851f27a062bacd9147996 (diff) | |
py: Rework and compress second part of bytecode prelude.
This patch compresses the second part of the bytecode prelude which
contains the source file name, function name, source-line-number mapping
and cell closure information. This part of the prelude now begins with a
single varible length unsigned integer which encodes 2 numbers, being the
byte-size of the following 2 sections in the header: the "source info
section" and the "closure section". After decoding this variable unsigned
integer it's possible to skip over one or both of these sections very
easily.
This scheme saves about 2 bytes for most functions compared to the original
format: one in the case that there are no closure cells, and one because
padding was eliminated.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cmdline/cmd_parsetree.py.exp | 2 | ||||
| -rw-r--r-- | tests/cmdline/cmd_showbc.py.exp | 22 | ||||
| -rw-r--r-- | tests/cmdline/cmd_verbose.py.exp | 2 | ||||
| -rw-r--r-- | tests/import/mpy_native.py | 4 |
4 files changed, 15 insertions, 15 deletions
diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp index 58d419dc4..18986318a 100644 --- a/tests/cmdline/cmd_parsetree.py.exp +++ b/tests/cmdline/cmd_parsetree.py.exp @@ -36,7 +36,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: (N_STATE 5) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 bc=0 line=4 bc=9 line=5 bc=12 line=6 diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp index 839034a69..b0a9016c5 100644 --- a/tests/cmdline/cmd_showbc.py.exp +++ b/tests/cmdline/cmd_showbc.py.exp @@ -5,7 +5,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: (N_STATE 3) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 ######## bc=\\d\+ line=155 00 MAKE_FUNCTION \.\+ @@ -38,7 +38,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): (INIT_CELL 14) (INIT_CELL 15) (INIT_CELL 16) - bc=-4 line=1 + bc=0 line=1 ######## bc=\\d\+ line=126 00 LOAD_CONST_NONE @@ -318,7 +318,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): \.\+rg names: (N_STATE 22) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 ######## bc=\\d\+ line=132 00 LOAD_CONST_SMALL_INT 1 @@ -392,7 +392,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: (N_STATE 2) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 bc=0 line=143 bc=3 line=144 bc=6 line=145 @@ -416,7 +416,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: (N_STATE 1) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 ######## bc=13 line=149 00 LOAD_NAME __name__ (cache=0) @@ -432,7 +432,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: self (N_STATE 4) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 bc=0 line=156 00 LOAD_GLOBAL super (cache=0) \\d\+ LOAD_GLOBAL __class__ (cache=0) @@ -449,7 +449,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: * * * (N_STATE 9) (N_EXC_STACK 0) - bc=-\\d\+ line=1 + bc=0 line=1 bc=0 line=59 ######## 00 LOAD_NULL @@ -473,7 +473,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: * * * (N_STATE 10) (N_EXC_STACK 0) - bc=-\\d\+ line=1 + bc=0 line=1 bc=0 line=60 ######## 00 BUILD_LIST 0 @@ -494,7 +494,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: * * * (N_STATE 11) (N_EXC_STACK 0) - bc=-\\d\+ line=1 + bc=0 line=1 ######## 00 BUILD_MAP 0 02 LOAD_FAST 2 @@ -515,7 +515,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: * (N_STATE 4) (N_EXC_STACK 0) - bc=-\\d\+ line=1 + bc=0 line=1 ######## bc=\\d\+ line=113 00 LOAD_DEREF 0 @@ -534,7 +534,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: * b (N_STATE 4) (N_EXC_STACK 0) - bc=-\\d\+ line=1 + bc=0 line=1 ######## bc=\\d\+ line=139 00 LOAD_FAST 1 diff --git a/tests/cmdline/cmd_verbose.py.exp b/tests/cmdline/cmd_verbose.py.exp index 60b499c26..a2fdf1f00 100644 --- a/tests/cmdline/cmd_verbose.py.exp +++ b/tests/cmdline/cmd_verbose.py.exp @@ -6,7 +6,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): arg names: (N_STATE 2) (N_EXC_STACK 0) - bc=-1 line=1 + bc=0 line=1 bc=0 line=3 00 LOAD_NAME print (cache=0) 04 LOAD_CONST_SMALL_INT 1 diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py index 03abab349..749320dbb 100644 --- a/tests/import/mpy_native.py +++ b/tests/import/mpy_native.py @@ -56,8 +56,8 @@ user_files = { '/mod1.mpy': ( b'M\x05\x0b\x1f\x20' # header - b'\x24' # n bytes, bytecode - b'\x00\x05\x00\x00\x00\x00\xff' # prelude + b'\x20' # n bytes, bytecode + b'\x00\x08\x00\x00\x00\x00' # prelude b'\x51' # LOAD_CONST_NONE b'\x63' # RETURN_VALUE |
