-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Varargs for externals, shared lib globals and other fixes #71
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
Conversation
Skipping tests that use i64 vars when USE_TYPED_ARRAYS != 0; Fixed incorrectly declared printf() in tests/cases/trunc.ll.
src/jsifier.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an explanation regarding why they should not be declared.
src/library.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please combine all three of these lines into one line.
Style fixes in response to code review.
|
I am concerned about the getc/putc change. They will now allocate 1 character in each call to getc/putc. If you read 10,000 characters using getc, you will be growing the stack by 10,000 and this also adds some CPU overhead. (This happens since the stack is unwinded only in a compiled function - not in getc/putc which are handwritten - for speed reasons). Creating a fixed statically-allocated buffer is preferable I think. If you have a better place to do the allocation than in FS.init then that is fine of course. (Alternatively we can unwind the stack in getc/putc, but that would be slow I think.) |
|
Fixed all. Also, mind-reading. |
|
Looks great. Can you just verify that say llvm_gcc_0_0 tests pass, to make sure the last changes don't break anything)? |
|
Verified |
Varargs for externals, shared lib globals and other fixes
…429.1 (emscripten-core#71) [dotnet/main] Update dependencies from dotnet/arcade
This is a rather varied pull request. There is 1 significant fix and a lot of little ones.
The main change is that I've updated varargs handling to use the same approach on both internal and external or library functions. The main reason for this is that previously when a shared library called a varargs function defined in its parent, it passed its arguments in JS style, while the actual function received them in C style. This broke many Python extension modules to some degree. This is a rather extensive change as it required me to update every usage of varargs in the library. However, the end result was actually less code. I've added a few new tests to check that all this didn't break anything. Note also that the change uncovered a couple of problems in the tests, which I took the liberty of fixing:
test_bigintandtest_printfpassed around large 64-bit values, which get truncated to 32 bits when usingUSE_TYPED_ARRAYS. Printing them worked just because they were passed directly toprintf()rather than stored in memory. Now that varargs are stored on the stack, they get truncated in typed arrays. For this reason, I've added a check to skip these two tests in builds that use typed arrays.trunccase intest_caseshad an incorrecly declaredprintf()because it was compiled without the right headers.Then there are the generic fixes:
makeGetValue()for use in the varargs-drivenprintf()/_formatString()implementation.test_math_hyperbolicafter the varargs changes, since previously NaNs were passed directly rather than stored in memory.$FSand back into__setErrNo, with a static postset.getc()/putc()buffers back togetc()/putc()and switched them to be allocated on the stack. I'm assuming you moved them out into a static allocation inside$FS` because normal allocations caused autodebugger problems. I'm also assuming that stack allocations are Ok since you turned some normal allocations to stack ones in the same commit. If either of this is not the case, let me know.Tested successfully with
llvm_gcc_0_0,llvm_gcc_1_1,clang_0_0andclang_1_1.