all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
This commit is contained in:
86
py/profile.c
86
py/profile.c
@@ -73,18 +73,18 @@ STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
|
||||
o,
|
||||
prelude->qstr_source_file,
|
||||
rc->line_of_definition
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
STATIC mp_obj_tuple_t* code_consts(const mp_raw_code_t *rc) {
|
||||
STATIC mp_obj_tuple_t *code_consts(const mp_raw_code_t *rc) {
|
||||
const mp_bytecode_prelude_t *prelude = &rc->prelude;
|
||||
int start = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj;
|
||||
int stop = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj + rc->n_raw_code;
|
||||
int stop = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj + rc->n_raw_code;
|
||||
mp_obj_tuple_t *consts = MP_OBJ_TO_PTR(mp_obj_new_tuple(stop - start + 1, NULL));
|
||||
|
||||
size_t const_no = 0;
|
||||
for (int i = start; i < stop; ++i) {
|
||||
mp_obj_t code = mp_obj_new_code((const mp_raw_code_t*)MP_OBJ_TO_PTR(rc->const_table[i]));
|
||||
mp_obj_t code = mp_obj_new_code((const mp_raw_code_t *)MP_OBJ_TO_PTR(rc->const_table[i]));
|
||||
if (code == MP_OBJ_NULL) {
|
||||
m_malloc_fail(sizeof(mp_obj_code_t));
|
||||
}
|
||||
@@ -103,7 +103,7 @@ STATIC mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
|
||||
uint last_lineno = mp_prof_bytecode_lineno(rc, start);
|
||||
uint lasti = 0;
|
||||
|
||||
const uint buffer_chunk_size = (stop-start) >> 2; // heuristic magic
|
||||
const uint buffer_chunk_size = (stop - start) >> 2; // heuristic magic
|
||||
uint buffer_size = buffer_chunk_size;
|
||||
byte *buffer = m_new(byte, buffer_size);
|
||||
uint buffer_index = 0;
|
||||
@@ -141,12 +141,12 @@ STATIC void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
mp_obj_code_t *o = MP_OBJ_TO_PTR(self_in);
|
||||
const mp_raw_code_t *rc = o->rc;
|
||||
const mp_bytecode_prelude_t *prelude = &rc->prelude;
|
||||
switch(attr) {
|
||||
switch (attr) {
|
||||
case MP_QSTR_co_code:
|
||||
dest[0] = mp_obj_new_bytes(
|
||||
(void*)prelude->opcodes,
|
||||
rc->fun_data_len - (prelude->opcodes - (const byte*)rc->fun_data)
|
||||
);
|
||||
(void *)prelude->opcodes,
|
||||
rc->fun_data_len - (prelude->opcodes - (const byte *)rc->fun_data)
|
||||
);
|
||||
break;
|
||||
case MP_QSTR_co_consts:
|
||||
dest[0] = MP_OBJ_FROM_PTR(code_consts(rc));
|
||||
@@ -165,7 +165,7 @@ STATIC void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
break;
|
||||
case MP_QSTR_co_lnotab:
|
||||
if (!o->lnotab) {
|
||||
o->lnotab = raw_code_lnotab(rc);
|
||||
o->lnotab = raw_code_lnotab(rc);
|
||||
}
|
||||
dest[0] = o->lnotab;
|
||||
break;
|
||||
@@ -207,7 +207,7 @@ STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
|
||||
prelude->qstr_source_file,
|
||||
frame->lineno,
|
||||
prelude->qstr_block_name
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
STATIC void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
@@ -218,7 +218,7 @@ STATIC void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
|
||||
mp_obj_frame_t *o = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
switch(attr) {
|
||||
switch (attr) {
|
||||
case MP_QSTR_f_back:
|
||||
dest[0] = mp_const_none;
|
||||
if (o->code_state->prev_state) {
|
||||
@@ -282,7 +282,7 @@ mp_obj_t mp_obj_new_frame(const mp_code_state_t *code_state) {
|
||||
// Trace logic
|
||||
|
||||
typedef struct {
|
||||
struct _mp_obj_frame_t * frame;
|
||||
struct _mp_obj_frame_t *frame;
|
||||
mp_obj_t event;
|
||||
mp_obj_t arg;
|
||||
} prof_callback_args_t;
|
||||
@@ -340,7 +340,7 @@ mp_obj_t mp_prof_frame_enter(mp_code_state_t *code_state) {
|
||||
}
|
||||
|
||||
mp_obj_t top;
|
||||
prof_callback_args_t _args, *args=&_args;
|
||||
prof_callback_args_t _args, *args = &_args;
|
||||
args->frame = code_state->frame;
|
||||
|
||||
// SETTRACE event CALL
|
||||
@@ -388,7 +388,7 @@ mp_obj_t mp_prof_instr_tick(mp_code_state_t *code_state, bool is_exception) {
|
||||
mp_obj_t top = mp_const_none;
|
||||
mp_obj_t callback = code_state->frame->callback;
|
||||
|
||||
prof_callback_args_t _args, *args=&_args;
|
||||
prof_callback_args_t _args, *args = &_args;
|
||||
args->frame = code_state->frame;
|
||||
args->event = mp_const_none;
|
||||
args->arg = mp_const_none;
|
||||
@@ -444,10 +444,10 @@ mp_obj_t mp_prof_instr_tick(mp_code_state_t *code_state, bool is_exception) {
|
||||
#include "runtime0.h"
|
||||
|
||||
#define DECODE_UINT { \
|
||||
unum = 0; \
|
||||
do { \
|
||||
unum = (unum << 7) + (*ip & 0x7f); \
|
||||
} while ((*ip++ & 0x80) != 0); \
|
||||
unum = 0; \
|
||||
do { \
|
||||
unum = (unum << 7) + (*ip & 0x7f); \
|
||||
} while ((*ip++ & 0x80) != 0); \
|
||||
}
|
||||
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
|
||||
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
|
||||
@@ -457,7 +457,7 @@ mp_obj_t mp_prof_instr_tick(mp_code_state_t *code_state, bool is_exception) {
|
||||
ip += 2;
|
||||
#define DECODE_PTR \
|
||||
DECODE_UINT; \
|
||||
ptr = (const byte*)const_table[unum]
|
||||
ptr = (const byte *)const_table[unum]
|
||||
#define DECODE_OBJ \
|
||||
DECODE_UINT; \
|
||||
obj = (mp_obj_t)const_table[unum]
|
||||
@@ -471,13 +471,13 @@ typedef struct _mp_dis_instruction_t {
|
||||
|
||||
STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
|
||||
mp_uint_t unum;
|
||||
const byte* ptr;
|
||||
const byte *ptr;
|
||||
mp_obj_t obj;
|
||||
qstr qst;
|
||||
|
||||
instruction->qstr_opname = MP_QSTR_;
|
||||
instruction->arg = 0;
|
||||
instruction->argobj= mp_const_none;
|
||||
instruction->argobj = mp_const_none;
|
||||
instruction->argobjex_cache = mp_const_none;
|
||||
|
||||
switch (*ip++) {
|
||||
@@ -511,14 +511,14 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_CONST_STRING;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_LOAD_CONST_OBJ:
|
||||
DECODE_OBJ;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_CONST_OBJ;
|
||||
instruction->arg = unum;
|
||||
instruction->argobj= obj;
|
||||
instruction->argobj = obj;
|
||||
break;
|
||||
|
||||
case MP_BC_LOAD_NULL:
|
||||
@@ -541,7 +541,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_NAME;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
|
||||
}
|
||||
@@ -551,7 +551,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_GLOBAL;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
|
||||
}
|
||||
@@ -561,7 +561,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_ATTR;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
|
||||
}
|
||||
@@ -571,14 +571,14 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_METHOD;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_LOAD_SUPER_METHOD:
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_LOAD_SUPER_METHOD;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_LOAD_BUILD_CLASS:
|
||||
@@ -605,21 +605,21 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_STORE_NAME;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_STORE_GLOBAL:
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_STORE_GLOBAL;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_STORE_ATTR:
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_STORE_ATTR;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
|
||||
}
|
||||
@@ -645,14 +645,14 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_DELETE_NAME;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_DELETE_GLOBAL:
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_DELETE_GLOBAL;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_DUP_TOP:
|
||||
@@ -813,14 +813,14 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_PTR;
|
||||
instruction->qstr_opname = MP_QSTR_MAKE_FUNCTION;
|
||||
instruction->arg = unum;
|
||||
instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
break;
|
||||
|
||||
case MP_BC_MAKE_FUNCTION_DEFARGS:
|
||||
DECODE_PTR;
|
||||
instruction->qstr_opname = MP_QSTR_MAKE_FUNCTION_DEFARGS;
|
||||
instruction->arg = unum;
|
||||
instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
break;
|
||||
|
||||
case MP_BC_MAKE_CLOSURE: {
|
||||
@@ -828,7 +828,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
mp_uint_t n_closed_over = *ip++;
|
||||
instruction->qstr_opname = MP_QSTR_MAKE_CLOSURE;
|
||||
instruction->arg = unum;
|
||||
instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(n_closed_over);
|
||||
break;
|
||||
}
|
||||
@@ -838,7 +838,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
mp_uint_t n_closed_over = *ip++;
|
||||
instruction->qstr_opname = MP_QSTR_MAKE_CLOSURE_DEFARGS;
|
||||
instruction->arg = unum;
|
||||
instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
|
||||
instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(n_closed_over);
|
||||
break;
|
||||
}
|
||||
@@ -899,14 +899,14 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_IMPORT_NAME;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_IMPORT_FROM:
|
||||
DECODE_QSTR;
|
||||
instruction->qstr_opname = MP_QSTR_IMPORT_FROM;
|
||||
instruction->arg = qst;
|
||||
instruction->argobj= MP_OBJ_NEW_QSTR(qst);
|
||||
instruction->argobj = MP_OBJ_NEW_QSTR(qst);
|
||||
break;
|
||||
|
||||
case MP_BC_IMPORT_STAR:
|
||||
@@ -931,7 +931,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
instruction->qstr_opname = MP_QSTR_BINARY_OP;
|
||||
instruction->arg = op;
|
||||
} else {
|
||||
mp_printf(&mp_plat_print, "code %p, opcode 0x%02x not implemented\n", ip-1, ip[-1]);
|
||||
mp_printf(&mp_plat_print, "code %p, opcode 0x%02x not implemented\n", ip - 1, ip[-1]);
|
||||
assert(0);
|
||||
return ip;
|
||||
}
|
||||
@@ -941,7 +941,7 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_
|
||||
return ip;
|
||||
}
|
||||
|
||||
void mp_prof_print_instr(const byte* ip, mp_code_state_t *code_state) {
|
||||
void mp_prof_print_instr(const byte *ip, mp_code_state_t *code_state) {
|
||||
mp_dis_instruction_t _instruction, *instruction = &_instruction;
|
||||
mp_prof_opcode_decode(ip, code_state->fun_bc->rc->const_table, instruction);
|
||||
const mp_raw_code_t *rc = code_state->fun_bc->rc;
|
||||
@@ -958,7 +958,7 @@ void mp_prof_print_instr(const byte* ip, mp_code_state_t *code_state) {
|
||||
prelude->qstr_block_name,
|
||||
offset,
|
||||
mp_prof_bytecode_lineno(rc, offset)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/* bytecode */ if (0) {
|
||||
|
||||
Reference in New Issue
Block a user