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

Upstream merge #153

Merged
merged 273 commits into from
May 23, 2022
Merged

Upstream merge #153

merged 273 commits into from
May 23, 2022

Conversation

MatthewFluet
Copy link
Collaborator

Merge MLton/mlton upstream changes to master

MatthewFluet and others added 30 commits January 15, 2021 11:43
…libs

Update mlnlffigen to new SML/NJ Library PP functions
Create and update pages for 20210117 release
fix option '-pi-style pie'
mlton/Makefile writes the output to "$(MLTON_OUTPUT)-polyml", but
Makefile tries to copy it from "mlton-polyml", while MLTON_OUTPUT
is "$(MLTON)-compile" by default
'make update' failed with this message:
/bin/sh: 12: Syntax error: end of file unexpected (expecting "then")
* Correct path in `make polyml-mlton` in `./Makefile`
* Remove duplicate `if` in `./Makefile.binary`
Add support for DESTDIR in Makefile.binary
The "shortest stem" rule for choosing a pattern rule was added in GNU
Make 3.82 (https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html),
but MacOS is stuck on the (ancient) GNU Make 3.81, which uses
definition order priority.
Use static pattern rule for bootstrap compilation
Use `-{enable-disable}-pass '.*:typeCheck'` to control type-checking of ILs in
individual simplify passes, simplify pipelines, and translation passes.

The overall default behavior is the same, but rather than type checking at the
beginning and end of each IL simplify pipeline, we now type check at the end of
each translation pass and the end of each IL simplify pipeline.  (For example,
previously, we type checked at the beginning and end of `ssaSimplify`, but now
we type check at the end of `closureConvert` and the end of `ssaSimplify` (and
not at the beginning of `ssaSimplify`).)

In addition, it is possible to enable type checking for exactly one simplify
pass (e.g., `-enable-pass 'constantPropagation:typeCheck'`) without needing to
type check every pass.
MatthewFluet and others added 23 commits February 20, 2022 14:46
The `stackTop` and `stackBottom` fields are accessed infrequently by the GC
itself, so there should be little penalty to making them `volatile`.  They are
synchronized with `currentThread->stack` at GC entry and exit.
In particular, the return address stack offset is volatile when time profiling;
it is important that the return address be flushed to the stack before the
adjusted stack top is flushed to `struct GC_state`.
Currently unused, added for completeness with `Offset` and `StackOffset`
variants.
Fix bug with `-profile time` leading to a segmentation fault.
…codegens

The x86 and x86-64 calling conventions require 8- and 16-bit arguments to be
passed as 32-bit values (on the stack for x86 and in registers for x86-64).

The x86-64 SysV ABI doesn't specify the contents of the upper bits for such
argument extensions.  Both gcc and clang sign- or zero-extend according to the
declared type of the argument.  Furthermore, clang assumes such a type-directed
extension of incoming arguments (and can optimize accordingly).  See
https://stackoverflow.com/questions/36706721/is-a-sign-or-zero-extension-required-when-adding-a-32bit-offset-to-a-pointer-for/36760539#36760539.

For example, consider the function:

    unsigned int s8_to_u32(signed char x) {
        return (unsigned int)x;
    }

clang will optimize to

    movl %edi, %eax

while gcc will optimize to

    movsbl %dil, %eax

For slightly increased clang compatibility, the x86 and amd64 codegens are
modified to emit either a signed or zero extension conditional on the declared
type of the argument in the C function's prototype (rather than unconditionally
using a zero extension).
Various ABIs may require argument or return values to be sign- or zero-extended
according to the declared type of the argument.  LLVM accomodates this via the
`signext` and `zeroext` parameter attributes.
…amd64-and-llvm-codegens

Calling convention fix for amd64 and llvm codegens
Use `msys2/setup-msys2` and `shell: msys2 {0}` to share CI steps between all
platforms.
Copy link
Collaborator

@shwestrick shwestrick left a comment

Choose a reason for hiding this comment

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

Looks good to me. I did some testing and haven't noticed any problems.

Just curious, could you remind me what the runtime annotation does for _imported calls? I noticed it's been removed from various places here.

@MatthewFluet
Copy link
Collaborator Author

An _import-ed function can be annotated as pure, impure (default), reentrant, or runtime (non-public). These annotations dictate how the calls are optimized and/or how the MLton state is managed around calls.

The runtime annotation is shorthand for a particular (conservative) set of CFunction.Kind.Runtime settings (https://github.com/MLton/mlton/blob/master/mlton/atoms/c-function.fun#L55-L62). That got removed from a number of the GC functions that just inspect GC state (especially the cumulative statistics), because such functions can't ever invoke a GC and don't require that the ML execution is at a safe point (with the frontier and stack-top written back to the GC state from their local-variable caches).

@shwestrick
Copy link
Collaborator

Excellent, thanks. We've been putting runtime annotation conservatively on all the functions we've created for scheduling/heap management. So, I'm glad to hear that that should be correct 😃

Perhaps at some point I'll go through an look more carefully at where the annotation is and isn't needed.

But anyway, this pull looks ready to go. Merging now! 🚀

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.

6 participants