/src/Python-3.8.3/Python/wordcode_helpers.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* This file contains code shared by the compiler and the peephole |
2 | | optimizer. |
3 | | */ |
4 | | |
5 | | #ifdef WORDS_BIGENDIAN |
6 | | # define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((opcode) << 8) | (oparg))) |
7 | | #else |
8 | 2.16k | # define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((oparg) << 8) | (opcode))) |
9 | | #endif |
10 | | |
11 | | /* Minimum number of code units necessary to encode instruction with |
12 | | EXTENDED_ARGs */ |
13 | | static int |
14 | | instrsize(unsigned int oparg) |
15 | 4.45k | { |
16 | 4.45k | return oparg <= 0xff ? 1 : |
17 | 4.45k | oparg <= 0xffff ? 2 : |
18 | 0 | oparg <= 0xffffff ? 3 : |
19 | 0 | 4; |
20 | 4.45k | } Line | Count | Source | 15 | 3.37k | { | 16 | 3.37k | return oparg <= 0xff ? 1 : | 17 | 3.37k | oparg <= 0xffff ? 2 : | 18 | 0 | oparg <= 0xffffff ? 3 : | 19 | 0 | 4; | 20 | 3.37k | } |
Line | Count | Source | 15 | 1.08k | { | 16 | 1.08k | return oparg <= 0xff ? 1 : | 17 | 1.08k | oparg <= 0xffff ? 2 : | 18 | 0 | oparg <= 0xffffff ? 3 : | 19 | 0 | 4; | 20 | 1.08k | } |
|
21 | | |
22 | | /* Spits out op/oparg pair using ilen bytes. codestr should be pointed at the |
23 | | desired location of the first EXTENDED_ARG */ |
24 | | static void |
25 | | write_op_arg(_Py_CODEUNIT *codestr, unsigned char opcode, |
26 | | unsigned int oparg, int ilen) |
27 | 2.16k | { |
28 | 2.16k | switch (ilen) { |
29 | 0 | case 4: |
30 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff); |
31 | | /* fall through */ |
32 | 0 | case 3: |
33 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff); |
34 | | /* fall through */ |
35 | 0 | case 2: |
36 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff); |
37 | | /* fall through */ |
38 | 2.16k | case 1: |
39 | 2.16k | *codestr++ = PACKOPARG(opcode, oparg & 0xff); |
40 | 2.16k | break; |
41 | 0 | default: |
42 | 0 | Py_UNREACHABLE(); |
43 | 2.16k | } |
44 | 2.16k | } Line | Count | Source | 27 | 1.08k | { | 28 | 1.08k | switch (ilen) { | 29 | 0 | case 4: | 30 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff); | 31 | | /* fall through */ | 32 | 0 | case 3: | 33 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff); | 34 | | /* fall through */ | 35 | 0 | case 2: | 36 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff); | 37 | | /* fall through */ | 38 | 1.08k | case 1: | 39 | 1.08k | *codestr++ = PACKOPARG(opcode, oparg & 0xff); | 40 | 1.08k | break; | 41 | 0 | default: | 42 | 0 | Py_UNREACHABLE(); | 43 | 1.08k | } | 44 | 1.08k | } |
Line | Count | Source | 27 | 1.08k | { | 28 | 1.08k | switch (ilen) { | 29 | 0 | case 4: | 30 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff); | 31 | | /* fall through */ | 32 | 0 | case 3: | 33 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff); | 34 | | /* fall through */ | 35 | 0 | case 2: | 36 | 0 | *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff); | 37 | | /* fall through */ | 38 | 1.08k | case 1: | 39 | 1.08k | *codestr++ = PACKOPARG(opcode, oparg & 0xff); | 40 | 1.08k | break; | 41 | 0 | default: | 42 | 0 | Py_UNREACHABLE(); | 43 | 1.08k | } | 44 | 1.08k | } |
|