Commit 3417bc2f authored by Damien George's avatar Damien George
Browse files

py: Rename byte_code to bytecode everywhere.

bytecode is the more widely used.  See issue #590.
parent 6e8085b4
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
def nodecor(x): def nodecor(x):
return x return x
byte_code = native = viper = nodecor bytecode = native = viper = nodecor
...@@ -36,10 +36,10 @@ typedef struct _mp_exc_stack { ...@@ -36,10 +36,10 @@ typedef struct _mp_exc_stack {
byte opcode; byte opcode;
} mp_exc_stack_t; } mp_exc_stack_t;
mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret); mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret);
mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc); mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc);
void mp_byte_code_print(const byte *code, int len); void mp_bytecode_print(const byte *code, int len);
void mp_byte_code_print2(const byte *code, int len); void mp_bytecode_print2(const byte *code, int len);
// Helper macros to access pointer with least significant bit holding a flag // Helper macros to access pointer with least significant bit holding a flag
#define MP_TAGPTR_PTR(x) ((void*)((machine_uint_t)(x) & ~((machine_uint_t)1))) #define MP_TAGPTR_PTR(x) ((void*)((machine_uint_t)(x) & ~((machine_uint_t)1)))
......
...@@ -1146,7 +1146,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_ ...@@ -1146,7 +1146,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
} }
qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]); qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]);
if (attr == MP_QSTR_byte_code) { if (attr == MP_QSTR_bytecode) {
*emit_options = MP_EMIT_OPT_BYTE_CODE; *emit_options = MP_EMIT_OPT_BYTE_CODE;
#if MICROPY_EMIT_NATIVE #if MICROPY_EMIT_NATIVE
} else if (attr == MP_QSTR_native) { } else if (attr == MP_QSTR_native) {
......
This diff is collapsed.
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
struct _emit_t { struct _emit_t {
int pass; int pass;
int byte_code_offset; int bytecode_offset;
int stack_size; int stack_size;
bool last_emit_was_return_value; bool last_emit_was_return_value;
...@@ -68,7 +68,7 @@ STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) { ...@@ -68,7 +68,7 @@ STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) {
STATIC void emit_cpy_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { STATIC void emit_cpy_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
emit->pass = pass; emit->pass = pass;
emit->byte_code_offset = 0; emit->bytecode_offset = 0;
emit->stack_size = 0; emit->stack_size = 0;
emit->last_emit_was_return_value = false; emit->last_emit_was_return_value = false;
emit->scope = scope; emit->scope = scope;
...@@ -108,20 +108,20 @@ STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) { ...@@ -108,20 +108,20 @@ STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) {
} }
// TODO: module-polymorphic function (read: name clash if made global) // TODO: module-polymorphic function (read: name clash if made global)
static void emit_pre(emit_t *emit, int stack_size_delta, int byte_code_size) { static void emit_pre(emit_t *emit, int stack_size_delta, int bytecode_size) {
emit->stack_size += stack_size_delta; emit->stack_size += stack_size_delta;
if (emit->stack_size > emit->scope->stack_size) { if (emit->stack_size > emit->scope->stack_size) {
emit->scope->stack_size = emit->stack_size; emit->scope->stack_size = emit->stack_size;
} }
emit->last_emit_was_return_value = false; emit->last_emit_was_return_value = false;
if (emit->pass == MP_PASS_EMIT && byte_code_size > 0) { if (emit->pass == MP_PASS_EMIT && bytecode_size > 0) {
if (emit->byte_code_offset >= 1000) { if (emit->bytecode_offset >= 1000) {
printf("%d ", emit->byte_code_offset); printf("%d ", emit->bytecode_offset);
} else { } else {
printf("% 4d ", emit->byte_code_offset); printf("% 4d ", emit->bytecode_offset);
} }
} }
emit->byte_code_offset += byte_code_size; emit->bytecode_offset += bytecode_size;
} }
STATIC void emit_cpy_label_assign(emit_t *emit, uint l) { STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
...@@ -130,11 +130,11 @@ STATIC void emit_cpy_label_assign(emit_t *emit, uint l) { ...@@ -130,11 +130,11 @@ STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
if (emit->pass < MP_PASS_EMIT) { if (emit->pass < MP_PASS_EMIT) {
// assign label offset // assign label offset
assert(emit->label_offsets[l] == -1); assert(emit->label_offsets[l] == -1);
emit->label_offsets[l] = emit->byte_code_offset; emit->label_offsets[l] = emit->bytecode_offset;
} else { } else {
// ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT // ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT
assert(emit->label_offsets[l] == emit->byte_code_offset); assert(emit->label_offsets[l] == emit->bytecode_offset);
//printf("l%d: (at %d)\n", l, emit->byte_code_offset); //printf("l%d: (at %d)\n", l, emit->bytecode_offset);
} }
} }
...@@ -421,7 +421,7 @@ STATIC void emit_cpy_jump(emit_t *emit, uint label) { ...@@ -421,7 +421,7 @@ STATIC void emit_cpy_jump(emit_t *emit, uint label) {
emit_pre(emit, 0, 3); emit_pre(emit, 0, 3);
if (emit->pass == MP_PASS_EMIT) { if (emit->pass == MP_PASS_EMIT) {
int dest = emit->label_offsets[label]; int dest = emit->label_offsets[label];
if (dest < emit->byte_code_offset) { if (dest < emit->bytecode_offset) {
printf("JUMP_ABSOLUTE %d\n", emit->label_offsets[label]); printf("JUMP_ABSOLUTE %d\n", emit->label_offsets[label]);
} else { } else {
printf("JUMP_FORWARD %d\n", emit->label_offsets[label]); printf("JUMP_FORWARD %d\n", emit->label_offsets[label]);
......
...@@ -73,7 +73,7 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) { ...@@ -73,7 +73,7 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
return rc; return rc;
} }
void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags) { void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags) {
rc->kind = MP_CODE_BYTE; rc->kind = MP_CODE_BYTE;
rc->scope_flags = scope_flags; rc->scope_flags = scope_flags;
rc->n_pos_args = n_pos_args; rc->n_pos_args = n_pos_args;
...@@ -99,7 +99,7 @@ void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint ...@@ -99,7 +99,7 @@ void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint
#endif #endif
#if MICROPY_DEBUG_PRINTERS #if MICROPY_DEBUG_PRINTERS
if (mp_verbose_flag > 0) { if (mp_verbose_flag > 0) {
mp_byte_code_print(code, len); mp_bytecode_print(code, len);
} }
#endif #endif
} }
......
...@@ -59,7 +59,7 @@ void mp_emit_glue_deinit(void); ...@@ -59,7 +59,7 @@ void mp_emit_glue_deinit(void);
mp_raw_code_t *mp_emit_glue_new_raw_code(void); mp_raw_code_t *mp_emit_glue_new_raw_code(void);
void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags); void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags);
void mp_emit_glue_assign_native_code(mp_raw_code_t *rc, void *f, uint len, int n_args); void mp_emit_glue_assign_native_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
void mp_emit_glue_assign_inline_asm_code(mp_raw_code_t *rc, void *f, uint len, int n_args); void mp_emit_glue_assign_inline_asm_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
// Whether to build functions that print debugging info: // Whether to build functions that print debugging info:
// mp_token_show // mp_token_show
// mp_byte_code_print // mp_bytecode_print
// mp_parse_node_print // mp_parse_node_print
#ifndef MICROPY_DEBUG_PRINTERS #ifndef MICROPY_DEBUG_PRINTERS
#define MICROPY_DEBUG_PRINTERS (0) #define MICROPY_DEBUG_PRINTERS (0)
......
...@@ -378,7 +378,7 @@ continue2:; ...@@ -378,7 +378,7 @@ continue2:;
DEBUG_printf("Calling: args=%p, n_args=%d, extra_args=%p, n_extra_args=%d\n", args, n_args, extra_args, n_extra_args); DEBUG_printf("Calling: args=%p, n_args=%d, extra_args=%p, n_extra_args=%d\n", args, n_args, extra_args, n_extra_args);
dump_args(args, n_args); dump_args(args, n_args);
dump_args(extra_args, n_extra_args); dump_args(extra_args, n_extra_args);
mp_vm_return_kind_t vm_return_kind = mp_execute_byte_code(self->bytecode, args, n_args, extra_args, n_extra_args, &result); mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(self->bytecode, args, n_args, extra_args, n_extra_args, &result);
mp_globals_set(old_globals); mp_globals_set(old_globals);
if (vm_return_kind == MP_VM_RETURN_NORMAL) { if (vm_return_kind == MP_VM_RETURN_NORMAL) {
......
...@@ -118,7 +118,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ ...@@ -118,7 +118,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
} }
mp_obj_dict_t *old_globals = mp_globals_get(); mp_obj_dict_t *old_globals = mp_globals_get();
mp_globals_set(self->globals); mp_globals_set(self->globals);
mp_vm_return_kind_t ret_kind = mp_execute_byte_code_2(self->code_info, &self->ip, mp_vm_return_kind_t ret_kind = mp_execute_bytecode2(self->code_info, &self->ip,
&self->state[self->n_state - 1], &self->sp, (mp_exc_stack_t*)(self->state + self->n_state), &self->state[self->n_state - 1], &self->sp, (mp_exc_stack_t*)(self->state + self->n_state),
&self->exc_sp, throw_value); &self->exc_sp, throw_value);
mp_globals_set(old_globals); mp_globals_set(old_globals);
...@@ -276,7 +276,7 @@ mp_obj_t mp_obj_new_gen_instance(mp_obj_dict_t *globals, const byte *bytecode, u ...@@ -276,7 +276,7 @@ mp_obj_t mp_obj_new_gen_instance(mp_obj_dict_t *globals, const byte *bytecode, u
o->exc_sp = (mp_exc_stack_t*)(o->state + n_state) - 1; o->exc_sp = (mp_exc_stack_t*)(o->state + n_state) - 1;
o->n_state = n_state; o->n_state = n_state;
// copy args to end of state array, in reverse (that's how mp_execute_byte_code_2 needs it) // copy args to end of state array, in reverse (that's how mp_execute_bytecode2 needs it)
for (uint i = 0; i < n_args; i++) { for (uint i = 0; i < n_args; i++) {
o->state[n_state - 1 - i] = args[i]; o->state[n_state - 1 - i] = args[i];
} }
......
...@@ -61,7 +61,7 @@ Q(__del__) ...@@ -61,7 +61,7 @@ Q(__del__)
Q(__call__) Q(__call__)
Q(micropython) Q(micropython)
Q(byte_code) Q(bytecode)
Q(native) Q(native)
Q(viper) Q(viper)
Q(const) Q(const)
......
...@@ -54,9 +54,9 @@ ...@@ -54,9 +54,9 @@
ip += sizeof(machine_uint_t); \ ip += sizeof(machine_uint_t); \
} while (0) } while (0)
void mp_byte_code_print2(const byte *ip, int len); void mp_bytecode_print2(const byte *ip, int len);
void mp_byte_code_print(const byte *ip, int len) { void mp_bytecode_print(const byte *ip, int len) {
const byte *ip_start = ip; const byte *ip_start = ip;
// get code info size // get code info size
...@@ -99,10 +99,10 @@ void mp_byte_code_print(const byte *ip, int len) { ...@@ -99,10 +99,10 @@ void mp_byte_code_print(const byte *ip, int len) {
printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
} }
} }
mp_byte_code_print2(ip, len - 0); mp_bytecode_print2(ip, len - 0);
} }
void mp_byte_code_print2(const byte *ip, int len) { void mp_bytecode_print2(const byte *ip, int len) {
const byte *ip_start = ip; const byte *ip_start = ip;
machine_uint_t unum; machine_uint_t unum;
qstr qstr; qstr qstr;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#define DETECT_VM_STACK_OVERFLOW (0) #define DETECT_VM_STACK_OVERFLOW (0)
#if 0 #if 0
#define TRACE(ip) mp_byte_code_print2(ip, 1); #define TRACE(ip) mp_bytecode_print2(ip, 1);
#else #else
#define TRACE(ip) #define TRACE(ip)
#endif #endif
...@@ -104,7 +104,7 @@ typedef enum { ...@@ -104,7 +104,7 @@ typedef enum {
currently_in_except_block = MP_TAGPTR_TAG(exc_sp->val_sp); /* restore previous state */ \ currently_in_except_block = MP_TAGPTR_TAG(exc_sp->val_sp); /* restore previous state */ \
exc_sp--; /* pop back to previous exception handler */ exc_sp--; /* pop back to previous exception handler */
mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret) { mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret) {
const byte *ip = code; const byte *ip = code;
// get code info size, and skip line number table // get code info size, and skip line number table
...@@ -155,7 +155,7 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, ...@@ -155,7 +155,7 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args,
} }
// execute the byte code // execute the byte code
mp_vm_return_kind_t vm_return_kind = mp_execute_byte_code_2(code, &ip, &state[n_state - 1], &sp, exc_stack, &exc_sp, MP_OBJ_NULL); mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode2(code, &ip, &state[n_state - 1], &sp, exc_stack, &exc_sp, MP_OBJ_NULL);
#if DETECT_VM_STACK_OVERFLOW #if DETECT_VM_STACK_OVERFLOW
// We can't check the case when an exception is returned in state[n_state - 1] // We can't check the case when an exception is returned in state[n_state - 1]
...@@ -217,7 +217,7 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, ...@@ -217,7 +217,7 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args,
// MP_VM_RETURN_NORMAL, sp valid, return value in *sp // MP_VM_RETURN_NORMAL, sp valid, return value in *sp
// MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp // MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp
// MP_VM_RETURN_EXCEPTION, exception in fastn[0] // MP_VM_RETURN_EXCEPTION, exception in fastn[0]
mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_in_out,
mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out,
mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out,
volatile mp_obj_t inject_exc) { volatile mp_obj_t inject_exc) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment