Commit Graph

18926 Commits

Author SHA1 Message Date
gingerBill
307604381a Merge pull request #7333 from corleypc/constmerge-fix
Reenables LLVMSetUnnamedAddress for global constants merging
2026-08-17 12:33:39 +02:00
Senthilnathan
f6f686392a Merge branch 'master' into fix/recursive-soa-sigbus 2026-08-17 12:53:33 +05:30
Senthilnathan
4fe5719007 Fix SIGBUS/segfault when compiling recursive #soa slice/dynamic array types 2026-08-17 12:48:41 +05:30
kalsprite
72d1829fec #any_int range check constants 2026-08-16 22:08:52 -07:00
kalsprite
55d0aecd92 add missing break on fix dyn 2026-08-16 19:51:27 -07:00
kalsprite
35061af11b fix eol diagnostic 2026-08-16 17:31:59 -07:00
Samuel Elgozi
4a08f5c48a mem: Preserve alignment when reusing Dynamic_Arena blocks 2026-08-17 00:21:50 +03:00
Mihail Moskov
e92c04eb73 Fixes the %% operator 2026-08-16 23:08:24 +03:00
Jeroen van Rijn
35779c6fa7 Merge pull request #7352 from Kelimion/fix-#7350
Fix #7350
2026-08-16 18:24:39 +02:00
Jeroen van Rijn
a9b7d3dfc6 Fix #7350 2026-08-16 18:08:17 +02:00
Jeroen van Rijn
ca8b7c16b8 Merge pull request #7351 from Kelimion/compiler-utf8-codepage
Set console codepage to utf-8 (on Windows), and restore old one on exit
2026-08-16 18:06:39 +02:00
Flāvius
b54c60b76a rexcode: the x86 test suite could fail and the build said PASS
Found by accident, and worse than the bug that found it. Five deliberately
broken decode cases came back green through `build.lua --test --isa x86`, while
running the same suite directly reported "253/258 PASSED, 5 FAILED".

Two independent holes, both open, so neither backstopped the other:

  - the x86 test binary ended at `print_summary()` and never called `os.exit`,
    so it exited 0 no matter how many cases failed;
  - `do_test` looked for the words "N failed" in the output, and the x86
    harness prints "N FAILED" — a lowercase-only Lua pattern, so the largest
    suite in the tree was exempt from its own gate.

The exit code is the check that should have been load-bearing, so the harness
sets it. The output match stays as a backstop for a suite that forgets to, and
is now case-insensitive.

How long this has been true is not knowable from here — every x86 regression
since the pattern was written would have been reported as PASS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Riok9vMpkLmo78wsVKJHhz
2026-08-16 12:05:52 -04:00
Flāvius
3e3eec090d x86: +r decoding was legacy-only, so BSWAP could not be read back
`bswap` is `0F C8+rd` — the register rides in the opcode's low three bits, like
`push`/`pop`/`xchg`/`mov`, but behind an escape byte. The decoder's retry at the
+r base opcode was gated on `esc == .NONE`, so only the register-0 forms
(`0F C8` = bswap eax, `48 0F C8` = bswap rax) landed on a table entry directly;
the other seven registers came back INVALID_OPCODE. Emission was always correct
— every `bswap` this compiler has ever produced runs — but a disassembly
containing one stopped dead, which is how it surfaced: three functions in
sigil's JIT corpus disassembled to a header with no instructions under it.

The table was never the problem. BSWAP is in `tablegen/encoding_table.odin` and
in the generated decode table, exactly where it should be.

Fixing the gate meant looking at why the retry existed twice. There is a correct
+r handler further down, carrying comments that describe two bugs already found
and fixed in it — "scan ALL entries, not just the first", "scan for the sized
register rather than assuming op0" — and the copy inside the retry had received
neither, plus a third of its own. So the retry now re-runs only the LOOKUP and
falls through to the single handler, which fixes two more instruction families
that were equally undecodable:

  - `xchg rAX, r` (90+rd): 0x90's run sorts NOP ahead of XCHG, and the copy
    tested only the first entry for a +r form, so every `xchg rAX, r` was
    rejected.
  - `push bx` / `pop bx` / `mov cx, imm` (any +r under 0x66): the copy passed
    `prefix` where the legacy row wants 0, since for legacy opcodes 0x66 is
    operand size rather than part of the opcode's identity.

Two supporting changes. The shared handler's default answer is now the first +r
entry rather than `idx.start`, so a fall-through at 0x90 cannot answer NOP for
an `xchg`. And a base-opcode retry that does not land on a +r form is now an
error rather than a fall-through: decoding 0x0E as the 0x08 entry (OR) would be
a wrong instruction reported confidently, which is worse than an unknown byte.

Verified three ways. Every opcode in every escape map was decoded before and
after: 154 combinations changed, every one of them INVALID -> valid, and nothing
that already decoded decodes differently. All 24 BSWAP encodings and all 96
legacy +r encodings were diffed against llvm-mc's disassembly and agree
operand-for-operand. Six new decode-only cases pin the three families; five of
them fail without this change.

(Two remaining differences from llvm-mc are deliberate and documented here:
implicit accumulators are left unmaterialized so a short form re-encodes to the
short form, and `48 90` reads as `xchg rax` rather than `nop`.)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Riok9vMpkLmo78wsVKJHhz
2026-08-16 12:05:42 -04:00
Jeroen van Rijn
c63561b700 Also restore codepage on trap. 2026-08-16 17:50:49 +02:00
Jeroen van Rijn
7f532cad14 Add -define:ODIN_CODEPAGE_MAGIC=false opt-out to the runtime 2026-08-16 17:01:41 +02:00
Jeroen van Rijn
0b7b8ba4a2 Set console codepage to utf-8 (on Windows), and restore old one on exit
Avoid mojibake.
2026-08-16 16:16:35 +02:00
Jeroen van Rijn
cc7d6764d3 Merge pull request #7349 from TheRadischen/merge_sort
improved stable sort | from insertion_sort to merge_rotate
2026-08-16 16:03:57 +02:00
TheRadischen
7d9367e3b4 morestyle improvements mybe this is it? 2026-08-16 15:24:55 +02:00
TheRadischen
0b0778f981 morestyle improvements mybe this is it? 2026-08-16 15:24:19 +02:00
TheRadischen
f6b8eafdfd imporved_style 2026-08-16 15:10:01 +02:00
TheRadischen
1a70315797 style_corrections 2026-08-16 15:09:12 +02:00
TheRadischen
9757fed9f9 changed_to_tabs 2026-08-16 14:28:38 +02:00
TheRadischen
d8177f7716 adjusted_smallsort_threshhold 2026-08-16 13:33:32 +02:00
TheRadischen
4c945c995a added_back_where 2026-08-16 12:58:23 +02:00
KBS
e62ed261c5 base/runtime: do not free the original block on a failed heap resize
`base/runtime`: do not free the original block on a failed heap resize

The default heap allocator freed old_ptr when the underlying allocation
failed (allocated_mem == nil). On the realloc path (heap_resize) the original
block is left intact on failure, and on the copy/fresh path old_ptr has not
been copied or freed yet, so freeing it left the caller holding a dangling
pointer. A [dynamic] array whose resize failed therefore double-freed its
data on the next delete (reported as free(): invalid pointer / use-after-free).

Return .Out_Of_Memory without freeing anything; the caller retains ownership
of the original block.

Fixes #7262
2026-08-16 12:54:16 +02:00
Jeroen van Rijn
889ad95c7e Merge pull request #7342 from kalsprite/alpha
quat/cmplx nan cmp & accessors
2026-08-16 12:31:55 +02:00
Jeroen van Rijn
7aa805e22a Merge pull request #7343 from kalsprite/rune_unsigned_mapping
intrinsics.type_integer_to_unsigned(rune) returns f16
2026-08-16 12:28:59 +02:00
TheRadischen
3f851d2b02 smarter_test 2026-08-16 12:27:30 +02:00
TheRadischen
df54692a9b addedtest 2026-08-16 12:22:25 +02:00
Jeroen van Rijn
3eeda58634 Merge pull request #7344 from kalsprite/simd_builtin_diagnostics
simd: enforce the `#simd` construction rules and stop two crashes
2026-08-16 12:17:39 +02:00
TheRadischen
267c745ac7 rotate_merge 2026-08-16 12:07:09 +02:00
Jeroen van Rijn
36695f9715 Merge pull request #7345 from kalsprite/and_not_constant_folding
big_int: fix three faults in `&~` constant folding
2026-08-16 11:37:35 +02:00
Jeroen van Rijn
e2ae9c7447 Disable Wycheproof on Windows CI 2026-08-16 11:26:14 +02:00
Jeroen van Rijn
94528dde45 Merge branch 'master' into pr/7345 2026-08-16 11:19:48 +02:00
Jeroen van Rijn
78b9c31a10 Merge pull request #7346 from kalsprite/bit_set_subset_folding
fix `bit_set` subset/superset constant folding
2026-08-16 11:05:30 +02:00
Jeroen van Rijn
ea77c4aeb9 Merge pull request #7347 from mocompute/hex-decode-into-buffer
Add non-allocating hex.decode_into_buffer
2026-08-16 11:03:16 +02:00
Jeroen van Rijn
f758c2edf9 Merge pull request #7338 from harold-b/hb.linux-build-explicit-llvm-components
Explicitly specify all required LLVM components on linux build
2026-08-16 10:57:14 +02:00
mo
4e0a71c24c Add non-allocating hex.decode_into_buffer
Also minor fixes to documentation of hex.decode().

Adds tests of the new procedure with buffers the correct size, larger,
and too small.
2026-08-16 19:48:19 +12:00
kalsprite
f7b734c82b deinterleave -> shuffle 2026-08-16 00:24:09 -07:00
kalsprite
95c4004239 switch to shuffle intrinsic since #simd is pow2 2026-08-16 00:16:21 -07:00
kalsprite
d52aff5c4b impl riffle for llvm<=20 fallback on interleave 2026-08-15 23:53:54 -07:00
kalsprite
a7029ef7b6 bitset subset 2026-08-15 23:25:13 -07:00
kalsprite
885e12d21d and-not fold 2026-08-15 23:06:35 -07:00
kalsprite
5f0251fec2 5791,6748 2026-08-15 22:44:52 -07:00
kalsprite
e53fc6a879 simd [?] type fix; count recovery 2026-08-15 22:23:15 -07:00
kalsprite
69fb453e51 redecl type; pairwise guard 2026-08-15 22:02:06 -07:00
kalsprite
0243398b19 swizzle arg guard 2026-08-15 21:52:07 -07:00
kalsprite
4ceba928c7 fix swizzle and shuffle max size bypass 2026-08-15 21:28:43 -07:00
kalsprite
b2f2b653c5 add pow2 guard on interleave 2026-08-15 21:18:36 -07:00
kalsprite
e699d2185e simd diagnostics 2026-08-15 21:07:17 -07:00