Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
711f80e
finished first ir emit pass
ncannasse Mar 15, 2026
bf5620b
call emitter instead of jit, started ir emit & dump
ncannasse Mar 15, 2026
d8306a9
finalized IR and completed dump
ncannasse Mar 15, 2026
42995f1
minor
ncannasse Mar 15, 2026
fabdc47
more work on phi emit and loop managements (ongoing)
ncannasse Mar 24, 2026
78df97e
small fixes and invalid phi detect in dump
ncannasse Mar 24, 2026
8271078
fixes emit phi
ncannasse Mar 25, 2026
f2bfaa4
new jit files split
ncannasse Mar 26, 2026
5da805f
added
ncannasse Mar 26, 2026
f1248a6
minor
ncannasse Mar 26, 2026
c8ecc31
emit block output & dump check
ncannasse Mar 27, 2026
b7b7f29
finished block emit
ncannasse Mar 28, 2026
5c739b6
change writes to be values instead of opcode indexes
ncannasse Mar 28, 2026
8f07c02
rewrote phi management using separate values
ncannasse Mar 29, 2026
e4c778a
minor fixes
ncannasse Mar 29, 2026
b3569f5
added phi optimization (still needs cleanup post emit)
ncannasse Mar 29, 2026
eb1b86a
improved phi optimize and added phi cleanup
ncannasse Mar 31, 2026
ee4f242
added new data structs for emit
ncannasse Mar 31, 2026
3efb299
upgrade vs projects (partial, temporary)
ncannasse Apr 1, 2026
60ca2b2
more usage of data structs in emit
ncannasse Apr 1, 2026
0e51b22
minor changes and force inline
ncannasse Apr 1, 2026
a7b2349
started regs alloc (wip)
ncannasse Apr 12, 2026
f748a02
more regs alloc, cleanup alloc_stack & refs handling
ncannasse Apr 13, 2026
0c69fb2
continue work on reg alloc and emit fixes
ncannasse Apr 13, 2026
0945ddf
start codegen x86_64
ncannasse Apr 17, 2026
15c1c08
cleanup flags, changed VAL_NULL to UNUSED
ncannasse Apr 18, 2026
2af1e42
insert BLOCK op, completed regs assign and phi mov inserts
ncannasse Apr 18, 2026
0720e2a
more work on code emit and reg assign
ncannasse Apr 19, 2026
2f32388
move stack handling from codegen to regs, boot ok
ncannasse Apr 19, 2026
df6c18e
added unwind tables and a few fixes
ncannasse Apr 19, 2026
248ef74
added null access trampolines (shorter code) and codegen fixes/cleanu…
ncannasse Apr 19, 2026
afe37f4
rework jump tables and emit local jumps, use parallel moves for call …
ncannasse Apr 21, 2026
fda19b7
fixes in reg alloc and codegen
ncannasse Apr 21, 2026
539d267
fixed mov impl
ncannasse Apr 22, 2026
9ea4835
clear gc allocated mem to 0xCD in GC_DEBUG
ncannasse Apr 22, 2026
da98c13
various fixes
ncannasse Apr 22, 2026
b8b51ac
fixed generation for haxe unit tests, added floats constant pool
ncannasse Apr 23, 2026
9aa690d
more fixes and optims
ncannasse Apr 24, 2026
8656551
added LOAD_FUN, CATCH and some other fixes
ncannasse Apr 25, 2026
7215193
fixed refs impl and loops liveness, added jump tables and fixes
ncannasse Apr 25, 2026
223d611
complete emit for compareFun
ncannasse Apr 25, 2026
5e9ef72
added call_c2hl trampoline
ncannasse Apr 25, 2026
76a66f2
added correct phi-from block tracking, emit cmov to prevent reg overw…
ncannasse Apr 25, 2026
e4677bb
review and fixed block construction
ncannasse Apr 26, 2026
4fbb1f0
added div and conv, fixed phis (again)
ncannasse Apr 26, 2026
e9a02f1
added debug stack, added float %
ncannasse Apr 26, 2026
697aef2
various fixes
ncannasse Apr 27, 2026
bfcf813
review and cleanup reg encoding. added R_CONST for future use
ncannasse Apr 29, 2026
9574dfe
various bug fixes
ncannasse May 1, 2026
1e78167
added hl2c wrapper
ncannasse May 1, 2026
9be0ec3
more work on conv and types sizes
ncannasse May 1, 2026
18127b2
i8/i16 -> ui8/ui16
ncannasse May 1, 2026
181562f
more fixes
ncannasse May 2, 2026
e98c86f
handle nans, split phi assigns before/after jcond & other fixes
ncannasse May 3, 2026
c6ea916
more fixes
ncannasse May 3, 2026
9b7e452
more fixes
ncannasse May 8, 2026
00c66c8
more fixes & started trap phi handling
ncannasse May 8, 2026
33abaf8
more fixes
ncannasse May 9, 2026
36158dd
minor fixes, passing haxe unit tests
ncannasse May 9, 2026
ea75b91
bump version
ncannasse May 9, 2026
1b79402
fix for windows rtl & some other fixes
ncannasse May 9, 2026
ddd0cb8
fixes stack windows
ncannasse May 9, 2026
a25c312
Merged master
ncannasse May 9, 2026
5be440b
minor fixes
ncannasse May 9, 2026
b845d5c
fix
ncannasse May 9, 2026
ecaa27f
added new files
ncannasse May 9, 2026
d27b30d
more minor fixes
ncannasse May 9, 2026
d1e36f6
minor compilation fixes
ncannasse May 9, 2026
f97f6ac
disable 32 bits builds & fix cmake version
ncannasse May 9, 2026
ecae03d
AArch64 backend for the IR-based JIT
bmdhacks May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
target: [linux, darwin, windows]
architecture: [32, 64, arm64]
architecture: [64, arm64]
build_system: [make, cmake, cmake-mingw, cmake-clang-cl, vs2019, makegcc14]

include:
Expand Down Expand Up @@ -429,7 +429,7 @@ jobs:
fail-fast: false
matrix:
os: [darwin, linux, windows]
architecture: [x86_32, x86_64, arm64]
architecture: [x86_64, arm64]
include:
- architecture: arm64
test-flags: --skip-hl-jit # not yet supported
Expand Down
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13)

set(HL_VERSION_MAJOR 1)
set(HL_VERSION_MINOR 16)
set(HL_VERSION_MAJOR 2)
set(HL_VERSION_MINOR 0)
set(HL_VERSION_PATCH 0)
set(HL_VERSION ${HL_VERSION_MAJOR}.${HL_VERSION_MINOR}.${HL_VERSION_PATCH})

Expand All @@ -20,7 +20,8 @@ include(FindPkgConfig)
include(CTest)

set(WITH_VM_DEFAULT ON)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64" AND (NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64"))
# 32-bit ARM has no JIT backend; aarch64/arm64 uses src/jit_aarch64.c.
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm$|^armv7" AND (NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64"))
set(WITH_VM_DEFAULT OFF)
endif()

Expand Down Expand Up @@ -225,9 +226,18 @@ else()
endif()

if (WITH_VM)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
set(HL_JIT_BACKEND src/jit_aarch64.c src/jit_aarch64_emit.c)
else()
set(HL_JIT_BACKEND src/jit_x86_64.c)
endif()
add_executable(hl
src/code.c
src/jit.c
src/jit_emit.c
src/jit_regs.c
${HL_JIT_BACKEND}
src/jit_dump.c
src/main.c
src/module.c
src/debugger.c
Expand Down
21 changes: 8 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ STD = src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/da
src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o src/std/thread.o src/std/process.o \
src/std/track.o

HL_OBJ = src/code.o src/jit.o src/main.o src/module.o src/debugger.o src/profile.o
ifeq ($(ARCH),arm64)
HL_JIT_BACKEND_OBJ = src/jit_aarch64.o src/jit_aarch64_emit.o
else
HL_JIT_BACKEND_OBJ = src/jit_x86_64.o
endif

HL_OBJ = src/code.o src/jit.o src/jit_emit.o src/jit_regs.o $(HL_JIT_BACKEND_OBJ) src/jit_dump.o src/main.o src/module.o src/debugger.o src/profile.o

FMT_CPPFLAGS = -I include/mikktspace -I include/minimp3

Expand Down Expand Up @@ -240,19 +246,12 @@ LIBHL = libhl.$(LIBEXT)
HL = hl$(EXE_SUFFIX)
HLC = hlc$(EXE_SUFFIX)

all: $(LIBHL) libs
ifeq ($(ARCH),arm64)
$(warning HashLink vm is not supported on arm64, skipping)
else
all: $(HL)
endif
all: $(LIBHL) libs $(HL)

install:
$(UNAME)==Darwin && ${MAKE} uninstall
ifneq ($(ARCH),arm64)
mkdir -p $(INSTALL_BIN_DIR)
cp $(HL) $(INSTALL_BIN_DIR)
endif
mkdir -p $(INSTALL_LIB_DIR)
cp *.hdll $(INSTALL_LIB_DIR)
cp $(LIBHL) $(INSTALL_LIB_DIR)
Expand Down Expand Up @@ -365,11 +364,7 @@ release_win:
rm -rf $(PACKAGE_NAME)

release_linux release_osx:
ifeq ($(ARCH),arm64)
cp $(LIBHL) *.hdll $(PACKAGE_NAME)
else
cp $(HL) $(LIBHL) *.hdll $(PACKAGE_NAME)
endif
tar -cvzf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
rm -rf $(PACKAGE_NAME)

Expand Down
25 changes: 16 additions & 9 deletions hl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,55 +45,55 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDX12Agility|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseVS2013|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDX12Agility|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseVS2013|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -186,7 +186,7 @@
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HL_VTUNE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/wd4456 /wd4100 /wd4204 /wd4702 /wd4457 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/wd4456 /wd4100 /wd4204 /wd4702 /wd4457 /we4013 %(AdditionalOptions)</AdditionalOptions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
Expand All @@ -196,6 +196,7 @@
<AdditionalDependencies>libhl.lib;user32.lib;include/vtune/jitprofiling.lib</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>false</DataExecutionPrevention>
<StackReserveSize>4194304</StackReserveSize>
</Link>
<Manifest>
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
Expand Down Expand Up @@ -361,14 +362,20 @@
<ClCompile Include="src\code.c" />
<ClCompile Include="src\debugger.c" />
<ClCompile Include="src\jit.c" />
<ClCompile Include="src\jit_dump.c" />
<ClCompile Include="src\jit_emit.c" />
<ClCompile Include="src\jit_regs.c" />
<ClCompile Include="src\jit_x86_64.c" />
<ClCompile Include="src\main.c" />
<ClCompile Include="src\module.c" />
<ClCompile Include="src\profile.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\data_struct.h" />
<ClInclude Include="src\hl.h" />
<ClInclude Include="src\hlmodule.h" />
<ClInclude Include="src\hlsystem.h" />
<ClInclude Include="src\jit.h" />
<ClInclude Include="src\opcodes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
8 changes: 7 additions & 1 deletion hl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
<ClCompile Include="src\main.c" />
<ClCompile Include="src\code.c" />
<ClCompile Include="src\module.c" />
<ClCompile Include="src\jit.c" />
<ClCompile Include="src\debugger.c" />
<ClCompile Include="src\profile.c" />
<ClCompile Include="src\jit_dump.c" />
<ClCompile Include="src\jit_emit.c" />
<ClCompile Include="src\jit.c" />
<ClCompile Include="src\jit_regs.c" />
<ClCompile Include="src\jit_x86_64.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\hlmodule.h" />
<ClInclude Include="src\opcodes.h" />
<ClInclude Include="src\hl.h" />
<ClInclude Include="src\hlsystem.h" />
<ClInclude Include="src\jit.h" />
<ClInclude Include="src\data_struct.h" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions libhl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,40 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseVS2013|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseVS2013|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ static void *gc_alloc_fixed( int part, int kind ) {
for(i=0;i<p->block_size;i++)
if( ptr[i] != 0xDD )
hl_fatal("assert");
else
ptr[i] = 0xCD;
}
# endif
gc_free_pages[pid] = ph;
Expand Down Expand Up @@ -367,6 +369,8 @@ static void *gc_alloc_var( int part, int size, int kind ) {
for(i=0;i<size;i++)
if( ptr[i] != 0xDD )
hl_fatal("assert");
else
ptr[i] = 0xCD;
}
# endif
if( ph->bmp ) {
Expand Down
Loading
Loading