summaryrefslogtreecommitdiff
path: root/py/profile.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-01-19 23:30:59 +1100
committerDamien George <damien@micropython.org>2025-02-11 16:42:14 +1100
commit62e821ccb82fd8362a8198ad59ccb51b8a5c441e (patch)
tree36202713393c8bc4842171bc1cca13a4300b928b /py/profile.h
parent372ecfef02eccc4e52a5d0abef068c7d25fc4315 (diff)
py/objcode: Factor code object out into its own file.
The `mp_obj_code_t` and `mp_type_code` code object was defined internally in both `py/builtinevex.c` and `py/profile.c`, with completely different implementations (the former very minimal, the latter quite complete). This commit factors these implementations into a new, separate source file, and allows the code object to have four different modes, selected at compile-time: - MICROPY_PY_BUILTINS_CODE_NONE: code object not included in the build. - MICROPY_PY_BUILTINS_CODE_MINIMUM: very simple code object that just holds a reference to the function that it represents. This level is used when MICROPY_PY_BUILTINS_COMPILE is enabled. - MICROPY_PY_BUILTINS_CODE_BASIC: simple code object that holds a reference to the proto-function and its constants. - MICROPY_PY_BUILTINS_CODE_FULL: almost complete implementation of the code object. This level is used when MICROPY_PY_SYS_SETTRACE is enabled. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/profile.h')
-rw-r--r--py/profile.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/py/profile.h b/py/profile.h
index 7f3f91403..db72b9f07 100644
--- a/py/profile.h
+++ b/py/profile.h
@@ -28,20 +28,12 @@
#define MICROPY_INCLUDED_PY_PROFILING_H
#include "py/emitglue.h"
+#include "py/objcode.h"
#if MICROPY_PY_SYS_SETTRACE
#define mp_prof_is_executing MP_STATE_THREAD(prof_callback_is_executing)
-typedef struct _mp_obj_code_t {
- // TODO this was 4 words
- mp_obj_base_t base;
- const mp_module_context_t *context;
- const mp_raw_code_t *rc;
- mp_obj_dict_t *dict_locals;
- mp_obj_t lnotab;
-} mp_obj_code_t;
-
typedef struct _mp_obj_frame_t {
mp_obj_base_t base;
const mp_code_state_t *code_state;
@@ -53,9 +45,9 @@ typedef struct _mp_obj_frame_t {
bool trace_opcodes;
} mp_obj_frame_t;
+uint mp_prof_bytecode_lineno(const mp_raw_code_t *rc, size_t bc);
void mp_prof_extract_prelude(const byte *bytecode, mp_bytecode_prelude_t *prelude);
-mp_obj_t mp_obj_new_code(const mp_module_context_t *mc, const mp_raw_code_t *rc);
mp_obj_t mp_obj_new_frame(const mp_code_state_t *code_state);
// This is the implementation for the sys.settrace