File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -218,8 +218,12 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
218218 size_t n_state , state_size ;
219219 DECODE_CODESTATE_SIZE (self -> bytecode , n_state , state_size );
220220
221- // allocate state for locals and stack
222221 mp_code_state_t * code_state ;
222+ // If we use m_new_obj_var(), then on no memory, MemoryError will be
223+ // raised. But this is not correct exception for a function call,
224+ // RuntimeError should be raised instead. So, we use m_new_obj_var_maybe(),
225+ // return NULL, then vm.c takes the needed action (either raise
226+ // RuntimeError or fallback to stack allocation).
223227 code_state = m_new_obj_var_maybe (mp_code_state_t , byte , state_size );
224228 if (!code_state ) {
225229 return NULL ;
Original file line number Diff line number Diff line change @@ -937,6 +937,9 @@ unwind_jump:;
937937 deep_recursion_error :
938938 mp_exc_recursion_depth ();
939939 }
940+ #else
941+ // If we couldn't allocate codestate on heap, in
942+ // non non-strict case fall thru to stack allocation.
940943 #endif
941944 }
942945 #endif
@@ -974,6 +977,9 @@ unwind_jump:;
974977 else {
975978 goto deep_recursion_error ;
976979 }
980+ #else
981+ // If we couldn't allocate codestate on heap, in
982+ // non non-strict case fall thru to stack allocation.
977983 #endif
978984 }
979985 #endif
@@ -1008,6 +1014,9 @@ unwind_jump:;
10081014 else {
10091015 goto deep_recursion_error ;
10101016 }
1017+ #else
1018+ // If we couldn't allocate codestate on heap, in
1019+ // non non-strict case fall thru to stack allocation.
10111020 #endif
10121021 }
10131022 #endif
@@ -1045,6 +1054,9 @@ unwind_jump:;
10451054 else {
10461055 goto deep_recursion_error ;
10471056 }
1057+ #else
1058+ // If we couldn't allocate codestate on heap, in
1059+ // non non-strict case fall thru to stack allocation.
10481060 #endif
10491061 }
10501062 #endif
You can’t perform that action at this time.
0 commit comments