Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
Ygen
c source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502 cc65 2.17
6502 cc65 2.18
6502 cc65 2.19
6502 cc65 trunk
ARM GCC 10.2.0 (linux)
ARM GCC 10.2.1 (none)
ARM GCC 10.3.0 (linux)
ARM GCC 10.3.1 (2021.07 none)
ARM GCC 10.3.1 (2021.10 none)
ARM GCC 10.5.0
ARM GCC 11.1.0 (linux)
ARM GCC 11.2.0 (linux)
ARM GCC 11.2.1 (none)
ARM GCC 11.3.0 (linux)
ARM GCC 11.4.0
ARM GCC 12.1.0 (linux)
ARM GCC 12.2.0 (linux)
ARM GCC 12.3.0
ARM GCC 12.4.0
ARM GCC 13.1.0 (linux)
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 13.3.0 (unknown-eabi)
ARM GCC 14.1.0
ARM GCC 14.1.0 (unknown-eabi)
ARM GCC 14.2.0
ARM GCC 14.2.0 (unknown-eabi)
ARM GCC 4.5.4 (linux)
ARM GCC 4.6.4 (linux)
ARM GCC 5.4 (linux)
ARM GCC 5.4.1 (none)
ARM GCC 6.3.0 (linux)
ARM GCC 6.4.0 (linux)
ARM GCC 7.2.1 (none)
ARM GCC 7.3.0 (linux)
ARM GCC 7.5.0 (linux)
ARM GCC 8.2.0 (WinCE)
ARM GCC 8.2.0 (linux)
ARM GCC 8.3.1 (none)
ARM GCC 8.5.0 (linux)
ARM GCC 9.2.1 (none)
ARM GCC 9.3.0 (linux)
ARM GCC trunk (linux)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 GCC 10.2.0
ARM64 GCC 10.3.0
ARM64 GCC 10.4.0
ARM64 GCC 10.5.0
ARM64 GCC 11.1.0
ARM64 GCC 11.2.0
ARM64 GCC 11.3.0
ARM64 GCC 11.4.0
ARM64 GCC 12.1.0
ARM64 GCC 12.2.0
ARM64 GCC 12.3.0
ARM64 GCC 12.4.0
ARM64 GCC 13.1.0
ARM64 GCC 13.2.0
ARM64 GCC 13.3.0
ARM64 GCC 14.1.0
ARM64 GCC 14.2.0
ARM64 GCC 4.9.4
ARM64 GCC 5.4
ARM64 GCC 5.5.0
ARM64 GCC 6.3
ARM64 GCC 6.4.0
ARM64 GCC 7.3.0
ARM64 GCC 7.5.0
ARM64 GCC 8.2.0
ARM64 GCC 8.5.0
ARM64 GCC 9.3.0
ARM64 GCC 9.4.0
ARM64 GCC 9.5.0
ARM64 GCC trunk
ARM64 Morello GCC 10.1.0 Alpha 1
ARM64 Morello GCC 10.1.2 Alpha 2
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 12.4.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 14.2.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc 14.1.0
BPF gcc 14.2.0
BPF gcc trunk
Chibicc 2020-12-07
FRC 2019
FRC 2020
FRC 2023
HPPA gcc 14.2.0
K1C gcc 7.4
K1C gcc 7.5
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
KVX ACB 5.2.0 (GCC 13.2.1)
LC3 (trunk)
M68K clang (trunk)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68K gcc 14.2.0
MRISC32 gcc (trunk)
MSP430 gcc 12.1.0
MSP430 gcc 12.2.0
MSP430 gcc 12.3.0
MSP430 gcc 12.4.0
MSP430 gcc 13.1.0
MSP430 gcc 13.2.0
MSP430 gcc 13.3.0
MSP430 gcc 14.1.0
MSP430 gcc 14.2.0
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
POWER64 gcc 11.2.0
POWER64 gcc 12.1.0
POWER64 gcc 12.2.0
POWER64 gcc 12.3.0
POWER64 gcc 12.4.0
POWER64 gcc 13.1.0
POWER64 gcc 13.2.0
POWER64 gcc 13.3.0
POWER64 gcc 14.1.0
POWER64 gcc 14.2.0
POWER64 gcc trunk
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 12.4.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 14.2.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 12.4.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 14.2.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SDCC 4.0.0
SDCC 4.1.0
SDCC 4.2.0
SDCC 4.3.0
SDCC 4.4.0
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 12.4.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC LEON gcc 14.2.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 12.4.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC gcc 14.2.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 12.4.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
SPARC64 gcc 14.2.0
TCC (trunk)
TCC 0.9.27
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 12.4.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI C6x gcc 14.2.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
arm64 msvc v19.39 VS17.9
arm64 msvc v19.40 VS17.10
arm64 msvc v19.latest
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 12.0.1
armv8-a clang 13.0.0
armv8-a clang 13.0.1
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
clang 12 for DPU (rel 2023.2.0)
cproc-master
llvm-mos commander X16
llvm-mos commodore 64
llvm-mos mega65
llvm-mos nes-cnrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos osi-c1p
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 12.4.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
loongarch64 gcc 14.2.0
mips (el) gcc 12.1.0
mips (el) gcc 12.2.0
mips (el) gcc 12.3.0
mips (el) gcc 12.4.0
mips (el) gcc 13.1.0
mips (el) gcc 13.2.0
mips (el) gcc 13.3.0
mips (el) gcc 14.1.0
mips (el) gcc 14.2.0
mips (el) gcc 4.9.4
mips (el) gcc 5.4
mips (el) gcc 5.5.0
mips (el) gcc 9.5.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 12.4.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 14.2.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 12.4.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 14.2.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 12.4.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 14.2.0
mips64 gcc 4.9.4
mips64 gcc 5.4
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
movfuscator (trunk)
nanoMIPS gcc 6.3.0
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 12.4.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 14.2.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 12.4.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 14.2.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
ppci 0.5.5
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 12.4.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
s390x gcc 14.2.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 12.4.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 14.2.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x64 msvc v19.39 VS17.9
x64 msvc v19.40 VS17.10
x64 msvc v19.latest
x86 CompCert 3.10
x86 CompCert 3.11
x86 CompCert 3.12
x86 CompCert 3.9
x86 gcc 1.27
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 msvc v19.39 VS17.9
x86 msvc v19.40 VS17.10
x86 msvc v19.latest
x86 nvc 24.9
x86 tendra (trunk)
x86-64 clang (assertions trunk)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 15.0.0
x86-64 clang 16.0.0
x86-64 clang 17.0.1
x86-64 clang 18.1.0
x86-64 clang 19.1.0
x86-64 clang 3.0.0
x86-64 clang 3.1
x86-64 clang 3.2
x86-64 clang 3.3
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.7
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.1
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 12.4
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 14.2
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2024.0.0
x86_64 CompCert 3.10
x86_64 CompCert 3.11
x86_64 CompCert 3.12
x86_64 CompCert 3.9
z88dk 2.2
zig cc 0.10.0
zig cc 0.11.0
zig cc 0.12.0
zig cc 0.12.1
zig cc 0.13.0
zig cc 0.6.0
zig cc 0.7.0
zig cc 0.7.1
zig cc 0.8.0
zig cc 0.9.0
zig cc trunk
Options
Source code
#include <stdint.h> #include <stdlib.h> #include <stdio.h> /* Set this flag to debug temporary root pushes/pops. */ #define MVM_TEMP_ROOT_DEBUG 0 #define MVM_exitcode_gcroots 1 #define MVM_realloc realloc /* The number of temp roots we start out with per thread (and so can rely on * always having). */ #define MVM_TEMP_ROOT_BASE_ALLOC 16 #define NULL ((void *)0) typedef uint8_t MVMuint8; typedef uint32_t MVMuint32; typedef uint64_t MVMuint64; typedef struct MVMGCWorklist MVMGCWorklist; typedef struct MVMHeapSnapshotState MVMHeapSnapshotState; typedef struct MVMFrame MVMFrame; typedef struct { uint64_t header; void *st; } MVMCollectable; typedef struct { uint64_t random_stuff; uint32_t num_temproots; uint32_t alloc_temproots; uint64_t random_stuff2; MVMCollectable ***temproots; uint64_t random_stuff3; } MVMThreadContext; #define MVM_PUBLIC #define MVM_STATIC_INLINE static __inline__ void MVM_panic(int, char *); /* Temp root push slow-path case. */ MVM_PUBLIC void MVM_gc_root_temp_push_slow(MVMThreadContext *tc, MVMCollectable **obj_ref); /* Fast-path case of pushing a root onto the per-thread temporary roots. */ MVM_STATIC_INLINE void MVM_gc_root_temp_push(MVMThreadContext *tc, MVMCollectable **obj_ref) { /* If debugging, ensure the root is not null. */ #ifdef MVM_TEMP_ROOT_DEBUG if (obj_ref == NULL) MVM_panic(MVM_exitcode_gcroots, "Illegal attempt to add null object address as a temporary root"); #endif /* If less than the number of always-allocated roots, just add. */ if (tc->num_temproots < MVM_TEMP_ROOT_BASE_ALLOC) { tc->temproots[tc->num_temproots] = obj_ref; tc->num_temproots++; } /* Otherwise call the slow path. */ else { MVM_gc_root_temp_push_slow(tc, obj_ref); } } /* Special forms of root pushing only needed for the MVMROOT macros */ MVMuint8 __MVM_gc_root_temp_push_ensure_space_slow(MVMThreadContext *tc, MVMuint8 amount) { if (tc->num_temproots == tc->alloc_temproots) { tc->alloc_temproots *= 2; tc->temproots = MVM_realloc(tc->temproots, sizeof(MVMCollectable **) * tc->alloc_temproots); } } MVM_STATIC_INLINE MVMuint8 __MVM_gc_root_temp_push_ensure_space(MVMThreadContext *tc, MVMuint8 amount) { /* If less than the number of always-allocated roots, we are happy */ if (tc->num_temproots + amount < MVM_TEMP_ROOT_BASE_ALLOC) { return 1; } else { /* Make a call into the slow path, we don't ask for this one * to be inlined. */ __MVM_gc_root_temp_push_ensure_space_slow(tc, amount); } } /* We only use this after having manually assured that there is space. */ MVM_STATIC_INLINE MVMuint8 __MVM_gc_root_temp_push_nonvoid_noslow(MVMThreadContext *tc, MVMCollectable **obj_ref, MVMuint8 chain_in) { /* If debugging, ensure the root is not null. */ #ifdef MVM_TEMP_ROOT_DEBUG if (obj_ref == NULL) MVM_panic(MVM_exitcode_gcroots, "Illegal attempt to add null object address as a temporary root"); #endif tc->temproots[tc->num_temproots] = obj_ref; tc->num_temproots++; return 1; } /* Special version of gc_root_temp_push that returns a value so it is * allowed to be chained together without the compiler complaining. */ MVM_STATIC_INLINE MVMuint8 __MVM_gc_root_temp_push_nonvoid(MVMThreadContext *tc, MVMCollectable **obj_ref, MVMuint8 chain_in) { MVM_gc_root_temp_push(tc, obj_ref); return 1; } /* Pop top root from the per-thread temporary roots stack. */ MVM_STATIC_INLINE void MVM_gc_root_temp_pop(MVMThreadContext *tc) { #if MVM_TEMP_ROOT_DEBUG if (tc->num_temproots <= 0) MVM_panic(1, "Illegal attempt to pop empty temporary root stack"); #endif tc->num_temproots--; } /* Pop top n roots from the per-thread temporary roots stack. */ MVM_STATIC_INLINE void MVM_gc_root_temp_pop_n(MVMThreadContext *tc, MVMuint32 n) { #if MVM_TEMP_ROOT_DEBUG if (tc->num_temproots < n) MVM_panic(MVM_exitcode_gcroots, "Illegal attempt to pop insufficiently large temporary root stack"); #endif tc->num_temproots -= n; } /* Other functions related to roots. */ MVM_PUBLIC void MVM_gc_root_add_permanent(MVMThreadContext *tc, MVMCollectable **obj_ref); MVM_PUBLIC void MVM_gc_root_add_permanent_desc(MVMThreadContext *tc, MVMCollectable **obj_ref, const char *description); void MVM_gc_root_add_permanents_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMHeapSnapshotState *snapshot); void MVM_gc_root_add_instance_roots_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMHeapSnapshotState *snapshot); void MVM_gc_root_add_tc_roots_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMHeapSnapshotState *snapshot); MVMuint32 MVM_gc_root_temp_mark(MVMThreadContext *tc); void MVM_gc_root_temp_mark_reset(MVMThreadContext *tc, MVMuint32 mark); void MVM_gc_root_temp_pop_all(MVMThreadContext *tc); void MVM_gc_root_add_temps_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMHeapSnapshotState *snapshot); void MVM_gc_root_gen2_add(MVMThreadContext *tc, MVMCollectable *c); void MVM_gc_root_add_gen2s_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist); void MVM_gc_root_add_gen2s_to_snapshot(MVMThreadContext *tc, MVMHeapSnapshotState *snapshot); void MVM_gc_root_gen2_cleanup(MVMThreadContext *tc); void MVM_gc_root_add_frame_roots_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMFrame *start_frame); void MVM_gc_root_add_frame_registers_to_worklist(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMFrame *frame); /* C preprocessor macros are basically the worst thing ever. * So here's an explanation of the cool new root macro: * * We want the whole macro to expand to a "for ( ...; ...; ...)" * line, so that * 1. we can put a block afterwards as if our root macro were control flow * 2. we can put code in the initialization part of the for loop body that * pushes the temp roots * 3. we can put code in the step part of the for loop to pop the roots again * 4. we can put code in the check part that makes sure the block only * runs the first time around. * * This is achieved by chaining __MVM_gc_root_temp_push_nonvoid calls into a * single expression that we use to initialize the "loop counter" variable to * 1, which at the end of the "loop" is set to 0. */ /* The specific rules of concatenation with ## force us to put one macro in * between what we want to concat and the ## operator. */ #define __MVM__CONCAT_IMPL( x, y ) x##y #define __MVM__MACRO_CONCAT( x, y ) __MVM__CONCAT_IMPL( x, y ) // The variable that we set to 0 after the for loop runs so it terminates #define __MVMROOT_VAR_NAME __MVM__MACRO_CONCAT(__MVMROOT_runned_, __LINE__) #define __MVMROOT_PUSH(tc, obj_ref, x) __MVM_gc_root_temp_push_nonvoid_noslow(tc, (MVMCollectable **)&(obj_ref), x) #define MVMROOT(tc, obj_ref1) /* If you get "passed 3 arguments, but takes just 2" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = __MVM_gc_root_temp_push_nonvoid(tc, (MVMCollectable **)&(obj_ref1), 0); \ __MVMROOT_VAR_NAME != 0; \ MVM_gc_root_temp_pop(tc), \ __MVMROOT_VAR_NAME = 0) #define MVMROOT2(tc, obj_ref1, obj_ref2) /* If you get "passed 4 arguments, but takes just 3" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = \ __MVMROOT_PUSH(tc, obj_ref1, \ __MVMROOT_PUSH(tc, obj_ref2, \ __MVM_gc_root_temp_push_ensure_space(tc, 2))); \ __MVMROOT_VAR_NAME != 0 \ ; \ MVM_gc_root_temp_pop_n(tc, 2), __MVMROOT_VAR_NAME = 0) #define MVMROOT3(tc, obj_ref1, obj_ref2, obj_ref3) /* If you get "passed 5 arguments, but takes just 4" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = \ __MVMROOT_PUSH(tc, obj_ref1, \ __MVMROOT_PUSH(tc, obj_ref2, \ __MVMROOT_PUSH(tc, obj_ref3, \ __MVM_gc_root_temp_push_ensure_space(tc, 3)))); \ __MVMROOT_VAR_NAME != 0 \ ; \ MVM_gc_root_temp_pop_n(tc, 3), __MVMROOT_VAR_NAME = 0) #define MVMROOT4(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4) /* If you get "passed 6 arguments, but takes just 5" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = \ __MVMROOT_PUSH(tc, obj_ref1, \ __MVMROOT_PUSH(tc, obj_ref2, \ __MVMROOT_PUSH(tc, obj_ref3, \ __MVMROOT_PUSH(tc, obj_ref4, \ __MVM_gc_root_temp_push_ensure_space(tc, 4))))); \ __MVMROOT_VAR_NAME != 0 \ ; \ MVM_gc_root_temp_pop_n(tc, 4), __MVMROOT_VAR_NAME = 0) #define MVMROOT5(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4, obj_ref5) /* If you get "passed 7 arguments, but takes just 6" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = \ __MVMROOT_PUSH(tc, obj_ref1, \ __MVMROOT_PUSH(tc, obj_ref2, \ __MVMROOT_PUSH(tc, obj_ref3, \ __MVMROOT_PUSH(tc, obj_ref4, \ __MVMROOT_PUSH(tc, obj_ref5, \ __MVM_gc_root_temp_push_ensure_space(tc, 5)))))); \ __MVMROOT_VAR_NAME != 0 \ ; \ MVM_gc_root_temp_pop_n(tc, 5), __MVMROOT_VAR_NAME = 0) #define MVMROOT6(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4, obj_ref5, obj_ref6) /* If you get "passed 8 arguments, but takes just 7" error, replace it with MVMROOT_OLD or if you want to keep compatibility with older moar versions, write explicit MVM_gc_root_temp_push and _pop calls. */ \ for (MVMuint8 __MVMROOT_VAR_NAME = \ __MVMROOT_PUSH(tc, obj_ref1, \ __MVMROOT_PUSH(tc, obj_ref2, \ __MVMROOT_PUSH(tc, obj_ref3, \ __MVMROOT_PUSH(tc, obj_ref4, \ __MVMROOT_PUSH(tc, obj_ref5, \ __MVMROOT_PUSH(tc, obj_ref6, \ __MVM_gc_root_temp_push_ensure_space(tc, 6))))))); \ __MVMROOT_VAR_NAME != 0 \ ; \ MVM_gc_root_temp_pop_n(tc, 6), __MVMROOT_VAR_NAME = 0) #define MVMROOT_OLD(tc, obj_ref, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref)); \ block \ MVM_gc_root_temp_pop(tc); \ } while (0) #define MVMROOT2_OLD(tc, obj_ref1, obj_ref2, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref1)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref2)); \ block \ MVM_gc_root_temp_pop_n(tc, 2); \ } while (0) #define MVMROOT3_OLD(tc, obj_ref1, obj_ref2, obj_ref3, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref1)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref2)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref3)); \ block \ MVM_gc_root_temp_pop_n(tc, 3); \ } while (0) #define MVMROOT4_OLD(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref1)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref2)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref3)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref4)); \ block \ MVM_gc_root_temp_pop_n(tc, 4); \ } while (0) #define MVMROOT5_OLD(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4, obj_ref5, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref1)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref2)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref3)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref4)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref5)); \ block \ MVM_gc_root_temp_pop_n(tc, 5); \ } while (0) #define MVMROOT6_OLD(tc, obj_ref1, obj_ref2, obj_ref3, obj_ref4, obj_ref5, obj_ref6, block) do {\ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref1)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref2)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref3)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref4)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref5)); \ MVM_gc_root_temp_push(tc, (MVMCollectable **)&(obj_ref6)); \ block \ MVM_gc_root_temp_pop_n(tc, 6); \ } while (0) // Type your code here, or load an example. int square(int num) { MVMThreadContext *tc = calloc(sizeof(MVMThreadContext), 1); MVMCollectable *foo = malloc(sizeof(MVMCollectable)); MVMCollectable *bar = malloc(sizeof(MVMCollectable)); MVMCollectable *baz = malloc(sizeof(MVMCollectable)); MVMROOT(tc, foo) { fprintf(stderr, "rooted yay"); MVM_gc_root_add_permanent(tc, &baz); } MVMROOT(tc, bar) { fprintf(stderr, "rooted yay"); MVM_gc_root_add_permanent(tc, &baz); } MVMROOT2(tc, foo, bar) { fprintf(stderr, "rooted twice yay"); MVM_gc_root_add_permanent(tc, &baz); } } int square_old_roots(int num) { MVMThreadContext *tc = calloc(sizeof(MVMThreadContext), 1); MVMCollectable *foo = malloc(sizeof(MVMCollectable)); MVMCollectable *bar = malloc(sizeof(MVMCollectable)); MVMCollectable *baz = malloc(sizeof(MVMCollectable)); MVMROOT_OLD(tc, foo, { fprintf(stderr, "yeeted yay"); MVM_gc_root_add_permanent(tc, &baz); }); MVMROOT_OLD(tc, bar, { fprintf(stderr, "yeeted yay"); MVM_gc_root_add_permanent(tc, &baz); }); MVMROOT2_OLD(tc, foo, bar, { fprintf(stderr, "yeeted twice yay"); MVM_gc_root_add_permanent(tc, &baz); }); }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree