Skip to content
Snippets Groups Projects
Commit e9cb1f80 authored by Damien George's avatar Damien George
Browse files

py/objmodule: Move module init/deinit code into runtime functions.

They are one-line functions and having them inline in mp_init/mp_deinit
eliminates the overhead of a function call, and matches how other state
is initialised in mp_init.
parent bf51200b
Branches
No related tags found
No related merge requests found
...@@ -237,14 +237,6 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = { ...@@ -237,14 +237,6 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = {
MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table); MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table);
#endif #endif
void mp_module_init(void) {
mp_obj_dict_init(&MP_STATE_VM(mp_loaded_modules_dict), 3);
}
void mp_module_deinit(void) {
//mp_map_deinit(&MP_STATE_VM(mp_loaded_modules_map));
}
// returns MP_OBJ_NULL if not found // returns MP_OBJ_NULL if not found
mp_obj_t mp_module_get(qstr module_name) { mp_obj_t mp_module_get(qstr module_name) {
mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
extern const mp_map_t mp_builtin_module_map; extern const mp_map_t mp_builtin_module_map;
extern const mp_map_t mp_builtin_module_weak_links_map; extern const mp_map_t mp_builtin_module_weak_links_map;
void mp_module_init(void);
void mp_module_deinit(void);
mp_obj_t mp_module_get(qstr module_name); mp_obj_t mp_module_get(qstr module_name);
void mp_module_register(qstr qstr, mp_obj_t module); void mp_module_register(qstr qstr, mp_obj_t module);
......
...@@ -85,8 +85,8 @@ void mp_init(void) { ...@@ -85,8 +85,8 @@ void mp_init(void) {
// optimization disabled by default // optimization disabled by default
MP_STATE_VM(mp_optimise_value) = 0; MP_STATE_VM(mp_optimise_value) = 0;
// init global module stuff // init global module dict
mp_module_init(); mp_obj_dict_init(&MP_STATE_VM(mp_loaded_modules_dict), 3);
// initialise the __main__ module // initialise the __main__ module
mp_obj_dict_init(&MP_STATE_VM(dict_main), 1); mp_obj_dict_init(&MP_STATE_VM(dict_main), 1);
...@@ -114,7 +114,7 @@ void mp_init(void) { ...@@ -114,7 +114,7 @@ void mp_init(void) {
void mp_deinit(void) { void mp_deinit(void) {
//mp_obj_dict_free(&dict_main); //mp_obj_dict_free(&dict_main);
mp_module_deinit(); //mp_map_deinit(&MP_STATE_VM(mp_loaded_modules_map));
// call port specific deinitialization if any // call port specific deinitialization if any
#ifdef MICROPY_PORT_INIT_FUNC #ifdef MICROPY_PORT_INIT_FUNC
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment