Skip to content
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

Fix wasm2c on windows (via MSVC) #909

Closed
wants to merge 5 commits into from
Closed

Fix wasm2c on windows (via MSVC) #909

wants to merge 5 commits into from

Conversation

binji
Copy link
Member

@binji binji commented Sep 10, 2018

No description provided.

binji and others added 5 commits February 21, 2019 00:48
* `min`/`max` are defined in windows headers, so avoid using them as
  symbol names.

* Don't write 0-sized variable definitions; MSVC doesn't like them.

* Prefix all functions with `WASM_RT_CC` to allow specifying a calling
  convention. On MSVC this is always `__vectorcall`, to prevent the
  optimizer from using the x87 stack for passing floats and doubles.

* Cast the load/store offset to `u64` before adding it to the address.

* MSVC doesn't have `__builtin_expect`, so just ignore it.

* Copy MSVC implementations of i{32,64}.{clz,ctz,popcount} from
  config.h.in

* Write 32-bit float constants with 10 digits of precision instead of 9.
  For some reason MSVC says that `3.40282347e+38f` is too big, but
  `3.402823466e+38f` is OK.

* Refactor `run-spec-wasm2c.py` a bit to pass different command-line
  flags when running as MSVC. The `--msvc` flag enables this new
  behavior.

* MSVC doesn't have `__attribute__((noreturn))` but instead has
  `__declspec(noreturn)`.
* Forward `--msvc` flag through `run-tests.py` to `run-spec-wasm2c.py`

* Wrap some long lines

* Some python2 vs python3 fixes

* Default compiler with `--msvc` flag is `cl`
* Avoid undefined behavior w/ isalpha/isalnum

* Track call stack size (not just call stack depth) when trying to
  determine call stack exhaustion
static inline unsigned long HighDword(unsigned __int64 value) {
unsigned long high;
memcpy(&high, (unsigned char*)&value + sizeof(high), sizeof(high));
return high;
Copy link

Choose a reason for hiding this comment

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

Why not return value >> 32;?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, I copied this from config.h.in, but I'm not sure why I wrote it this way. :-)

t2 result; \
memcpy(&result, &x, sizeof(result)); \
return result; \
#define DEFINE_REINTERPRET(name, t1, t2) \
Copy link

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, though I'd rather get this working and landed before optimizing. It still isn't quite there, unfortunately. It's pretty hard for me to test, since I don't normally run windows.

@keithw
Copy link
Member

keithw commented Aug 16, 2022

Done in #1843.

@keithw keithw closed this Aug 16, 2022
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