Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Mar 1, 2017

This PR converts all the py/nlrXXX.S assembler files to py/nlrXXX.c C files with inline assembler. The benefits of this are:

  • the core now only has .c files
  • you can #include headers in .c files to get access to config variables (before, with .S files, this was a bit of a hack)
  • no need for special treatment for linux vs mac vs windows (well, not as much as with .S files)
  • much cleaner code because now half of it is written in C
  • easily supports both threading and non-threading builds without magic numbers and difficult assembly

Drawbacks:

  • slightly less efficient due to some C overhead (a few extra instructions here and there but nothing major)

@stinos I have a feeling that this won't work properly on all windows machines / with all supported windows compilers. Can you please check and advise? Thanks.

@stinos
Copy link
Contributor

stinos commented Mar 1, 2017

The msvc implementation uses setjmp so that is ok. With mingw the code doesn't build currently due to an undefined reference to nlr_push_tail Reason for that, as well as the solution: http://stackoverflow.com/questions/1034852/adding-leading-underscores-to-assembly-symbols-with-gcc-on-win32.
Indeed after adding this this to nlrx86.c before the definition of nlr_push

#if NLR_OS_WINDOWS
unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail");
#endif

everything builds and runs. No idea why nlrx64.c doesn't seem to need this modification though.

@dpgeorge
Copy link
Member Author

dpgeorge commented Mar 2, 2017

@stinos thanks for testing. I've now updated this PR to add that line in nlrx86.c and it seems that all tests are now passing.

@pfalcon
Copy link
Contributor

pfalcon commented Mar 4, 2017

ack

@dpgeorge dpgeorge merged commit 914648c into micropython:master Mar 6, 2017
@dpgeorge
Copy link
Member Author

dpgeorge commented Mar 6, 2017

Ok, this is now merged.

@pfalcon
Copy link
Contributor

pfalcon commented Mar 7, 2017

So, workaround for workaround for this is pushed as fd49ff9.

@dpgeorge
Copy link
Member Author

dpgeorge commented Mar 8, 2017

So, this refactor, and this particular change broke Zephyr/x86

Sorry about that! I didn't expect going from .S to .c with inline asm to be a simple change, but I still think it's worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants