Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
af6edc61
Commit
af6edc61
authored
Apr 2, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Enable a jump optimisation in the compiler.
parent
882b3635
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/compile.c
+13
-6
13 additions, 6 deletions
py/compile.c
with
13 additions
and
6 deletions
py/compile.c
+
13
−
6
View file @
af6edc61
...
@@ -1434,12 +1434,19 @@ void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
...
@@ -1434,12 +1434,19 @@ void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
c_if_cond
(
comp
,
pns
->
nodes
[
0
],
false
,
l_fail
);
// if condition
c_if_cond
(
comp
,
pns
->
nodes
[
0
],
false
,
l_fail
);
// if condition
compile_node
(
comp
,
pns
->
nodes
[
1
]);
// if block
compile_node
(
comp
,
pns
->
nodes
[
1
]);
// if block
//if (!(MP_PARSE_NODE_IS_NULL(pns->nodes[2]) && MP_PARSE_NODE_IS_NULL(pns->nodes[3]))) { // optimisation; doesn't align with CPython
// jump over elif/else blocks if they exist
if
(
if
(
!
EMIT
(
last_emit_was_return_value
))
{
// simple optimisation to align with CPython
#if !MICROPY_EMIT_CPYTHON
// optimisation to not jump over non-existent elif/else blocks (this optimisation is not in CPython)
!
(
MP_PARSE_NODE_IS_NULL
(
pns
->
nodes
[
2
])
&&
MP_PARSE_NODE_IS_NULL
(
pns
->
nodes
[
3
]))
&&
#endif
// optimisation to not jump if last instruction was return
!
EMIT
(
last_emit_was_return_value
)
)
{
// jump over elif/else blocks
EMIT_ARG
(
jump
,
l_end
);
EMIT_ARG
(
jump
,
l_end
);
}
}
//}
EMIT_ARG
(
label_assign
,
l_fail
);
EMIT_ARG
(
label_assign
,
l_fail
);
if
(
!
MP_PARSE_NODE_IS_NULL
(
pns
->
nodes
[
2
]))
{
if
(
!
MP_PARSE_NODE_IS_NULL
(
pns
->
nodes
[
2
]))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment