Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython-simulator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython-simulator
Commits
459d3f38
Commit
459d3f38
authored
Aug 13, 2019
by
George Wort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't always allocate code_state on the heap.
parent
0083d049
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
source/py/objfun.c
source/py/objfun.c
+5
-3
No files found.
source/py/objfun.c
View file @
459d3f38
...
@@ -276,15 +276,17 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
...
@@ -276,15 +276,17 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
// allocate state for locals and stack
// allocate state for locals and stack
size_t
state_size
=
n_state
*
sizeof
(
mp_obj_t
)
+
n_exc_stack
*
sizeof
(
mp_exc_stack_t
);
size_t
state_size
=
n_state
*
sizeof
(
mp_obj_t
)
+
n_exc_stack
*
sizeof
(
mp_exc_stack_t
);
mp_code_state_t
*
code_state
=
NULL
;
mp_code_state_t
*
code_state
=
NULL
;
code_state
=
m_new_obj_var_maybe
(
mp_code_state_t
,
byte
,
state_size
);
if
(
state_size
>
VM_MAX_STATE_ON_STACK
)
{
if
(
code_state
!=
NULL
)
{
code_state
=
m_new_obj_var_maybe
(
mp_code_state_t
,
byte
,
state_size
);
m_rs_push_ptr
(
code_state
);
}
}
if
(
code_state
==
NULL
)
{
if
(
code_state
==
NULL
)
{
code_state
=
alloca
(
sizeof
(
mp_code_state_t
)
+
state_size
);
code_state
=
alloca
(
sizeof
(
mp_code_state_t
)
+
state_size
);
RETURN_ON_EXCEPTION
(
MP_OBJ_NULL
)
RETURN_ON_EXCEPTION
(
MP_OBJ_NULL
)
state_size
=
0
;
// indicate that we allocated using alloca
state_size
=
0
;
// indicate that we allocated using alloca
}
}
else
{
m_rs_push_ptr
(
code_state
);
}
code_state
->
fun_bc
=
self
;
code_state
->
fun_bc
=
self
;
code_state
->
ip
=
0
;
code_state
->
ip
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment