Skip to content

windows: Support EMIT_X64/X86 with msvc toolchain #4699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jwang36
Copy link

@jwang36 jwang36 commented Apr 15, 2019

The patches in this PR add support of MICROPY_EMIT_X64 and MICROPY_EMIT_X86 for msvc toolchain in ports/windows. They are enabled by default if building with msvc toolchain, but not with mingw and cygwin toolchain. It includes following changes:

  • Add Windows X64 calling convention
  • Add assembly code (masm) to support nlr_push and nlr_jump because msvc doesn't support inline assembly for X64 code
  • Add alloc.c and gccollect.c (tweaked from unix/alloc.c and unix/gccollect.c) to use Windows memory management for gc

The patches pass all test cases of tests/micropython/native_,viper_ on Windows.

@@ -0,0 +1,101 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a copy of unix/alloc.c with like 3 lines changed. In such case I think it's better to modify unix/alloc.c instead to make it work with windows builds.

@stinos
Copy link
Contributor

stinos commented Apr 15, 2019

Interesting, but not all Appveyor builds pass: the native_try/viper_try tests fail for the 64bit debug build

@@ -0,0 +1,75 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as the other file: I'm not sure there even is a functional difference with unix/gccollect.c?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's windows api used. I'm not sure it's ok to put them in unix folder. So I made a copy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's only a slight change, or a function which has the same signature in POSIX but just a different name, it's ok to do this I think. Else the way this has be fixed until now is to define our own implementation of the posix function (for example like is done for realpath/gettimeofday/opendir/...).

@jwang36
Copy link
Author

jwang36 commented Apr 15, 2019

Any suggestion on the AppVeyor fails? I cannot reproduce it on my Windows 10.

@stinos
Copy link
Contributor

stinos commented Apr 15, 2019

Any suggestion on the AppVeyor fails? I cannot reproduce it on my Windows 10.

If you don't find an actual machine to reproduce it on, log in to Appveyor for your fork, adjust the settings to allow you to login with remote desktop (https://www.appveyor.com/docs/how-to/rdp-to-build-worker/) then start a build and login to the VM.

@stinos
Copy link
Contributor

stinos commented Apr 15, 2019

I was thinking it's probably better to split this in separate commits: one for the changes to nlr, one for the other changes, because those 2 are basically unrelated (as in, first one can exist without the other) and that weill be easier to see what goes on. Maybe even a seperate commit for implementing alloc.c but that's maybe a bit too much. On the other hand it would still be easier to follow, imo.

Also since nlr_jump is now available in assembly, wouldn't it be possible to use it instead of setjmp for collecting regs/stack as well (i.e. MICROPY_GCREGS_SETJMP put to 0)?

@jwang36
Copy link
Author

jwang36 commented Apr 16, 2019

Ok. I'll first fix the failed cases, and then split the commits with other changes to address review comments got so far. Thanks

@dpgeorge
Copy link
Member

Thanks for the contribution. As @stinos says, it'd be best to not duplicate alloc.c/gccollect.c if they are basically the same as in the unix port. The unix port already has some _WIN32 specific code.

And please do separate the changes to asmx64/emitnx64 into a separate commit, since they are logically separate (adding WIN64 ABI support to this emitter). If in doubt prefer more commits rather than less, since they can always be squashed together during merge if needed.

not all Appveyor builds pass: the native_try/viper_try tests fail for the 64bit debug build

I think this test also fails on the unix debug build, maybe x86 (but that's not part of Travis). I think it's related to MP_OBJ_STOP_ITERATION being different for debug vs non-debug builds. The addition of MICROPY_DEBUG_MP_OBJ_SENTINELS was supposed to fix this though.

@dpgeorge
Copy link
Member

Closing due to inactivity. It's a nice feature so feel free to reopen and address review comments.

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy