• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pfalcon / micropython / 1143
98%

Build:
DEFAULT BRANCH: master
Ran 26 Dec 2017 06:13PM UTC
Jobs 1
Files 226
Run time 11s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
1143

push

travis-ci

pfalcon
<a href="https://github.com/pfalcon/micropython/commit/<a class=hub.com/pfalcon/micropython/commit/096e967aad6df760c16de4878b8b2eea02330011">096e967aa<a href="https://github.com/pfalcon/micropython/commit/096e967aad6df760c16de4878b8b2eea02330011">&quot;&gt;Revert &amp;quot;py/nlr: Factor out common NLR code to generic functions.&quot;

This reverts commit </a><a class="double-link" href="https://github.com/pfalcon/micropython/commit/<a class="double-link" href="https://github.com/pfalcon/micropython/commit/6a3a742a6c9caaa2be0fd0aac7a5df4ac816081c">6a3a742a6</a>">6a3a742a6</a><a href="https://github.com/pfalcon/micropython/commit/096e967aad6df760c16de4878b8b2eea02330011">.

The above commit has number of faults starting from the motivation down
to the actual implementation.

1. Faulty implementation.

The original code contained functions like:

NORETURN void nlr_jump(void *val) {
    nlr_buf_t **top_ptr = &amp;MP_STATE_THREAD(nlr_top);
    nlr_buf_t *top = *top_ptr;
...
     __asm volatile (
    &quot;mov    %0, %%edx           \n&quot; // %edx points to nlr_buf
    &quot;mov    28(%%edx), %%esi    \n&quot; // load saved %esi
    &quot;mov    24(%%edx), %%edi    \n&quot; // load saved %edi
    &quot;mov    20(%%edx), %%ebx    \n&quot; // load saved %ebx
    &quot;mov    16(%%edx), %%esp    \n&quot; // load saved %esp
    &quot;mov    12(%%edx), %%ebp    \n&quot; // load saved %ebp
    &quot;mov    8(%%edx), %%eax     \n&quot; // load saved %eip
    &quot;mov    %%eax, (%%esp)      \n&quot; // store saved %eip to stack
    &quot;xor    %%eax, %%eax        \n&quot; // clear return register
    &quot;inc    %%al                \n&quot; // increase to make 1, non-local return
     &quot;ret                        \n&quot; // return
    :                               // output operands
    : &quot;r&quot;(top)                      // input operands
    :                               // clobbered registers
     );
}

Which clearly stated that C-level variable should be a parameter of the
assembly, whcih then moved it into correct register.

Whereas now it&#39;s:

NORETURN void nlr_jump_tail(nlr_buf_t *top) {
    (void)top;

    __asm volatile (
    &quot;mov    28(%edx), %esi      \n&quot; // load saved %esi
    &quot;mov    24(%edx), %edi      \n&quot; // load saved %edi
    &quot;mov    20(%edx), %ebx      \n&quot; // load saved %ebx
    &quot;mov    16(%edx), %esp      \n&quot; // load saved %esp
    &quot;mov    12(%edx), %ebp      \n&quot; // load saved %ebp
    &quot;mov    8(%edx), %eax       \n&quot; // load saved %eip
    &quot;mov    %eax, (%esp)        \n&quot; // store saved %eip to stack
    &quot;xor    %eax, %eax          \n&quot; // clear return register
    &quot;inc    %al                 \n&quot; // increase to make 1, non-local return
    &quot;ret                        \n&quot; // return
    );

    for (;;); // needed to silence compiler warning
}

Which just tries to perform operations on a completely random register (edx
in this case). The outcome is the expected: saving the pure random luck of
the compiler putting the right value in the random register above, there&#39;s
a crash.

2. Non-critical assessment.

The original commit message says &quot;There is a small overhead introduced
(typically 1 machine instruction)&quot;. That machine instruction is a call
if a compiler doesn&#39;t perform tail optimization (happens regularly), and
it&#39;s 1 instruction only with the broken code shown above, fixing it
requires adding more. With inefficiencies already presented in the NLR
code, the overhead becomes &quot;considerable&quot; (several times more than 1%),
not &quot;small&quot;.

The commit message also says &quot;This eliminates duplicated code.&quot;. An
obvious way to eliminate duplication would be to factor out common code
to macros, not introduce overhead and breakage like above.

3. Faulty motivation.

All this started with a report of warnings/errors happening for a niche
compiler. It could have been solved in one the direct ways: a) fixing it
just for affected compiler(s); b) rewriting it in proper assembly (like
it was before BTW); c) by not doing anything at all, MICROPY_NLR_SETJMP
exists exactly to address minor-impact cases like thar (where a) or b) are
not applicable). Instead, a backwards &quot;solution&quot; was put forward, leading
to all the issues above.

The best action thus appears to be revert and rework, not trying to work
around what went haywire in the first place.

17529 of 17836 relevant lines covered (98.28%)

319148.36 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1143.1 26 Dec 2017 06:13PM UTC 0
98.28
Travis Job 1143.1
Source Files on build 1143
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1143
  • 096e967a on github
  • Prev Build on master (#1142)
  • Next Build on master (#1144)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc