From 204dee162d014ee82d3bb00b4c66f8e90c04ba54 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 18:31:43 +0100 Subject: [PATCH 1/8] remove xxhash core:mem dependency --- core/hash/xxhash/streaming.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/hash/xxhash/streaming.odin b/core/hash/xxhash/streaming.odin index d34206fdb..22d99be1d 100644 --- a/core/hash/xxhash/streaming.odin +++ b/core/hash/xxhash/streaming.odin @@ -10,7 +10,7 @@ package xxhash Jeroen van Rijn: Initial implementation. */ -import "core:mem" +import "base:runtime" import "base:intrinsics" /* @@ -121,7 +121,7 @@ XXH3_init_state :: proc(state: ^XXH3_state) { } XXH3_create_state :: proc(allocator := context.allocator) -> (res: ^XXH3_state, err: Error) { - state, mem_error := mem.new_aligned(XXH3_state, 64, allocator) + state, mem_error := runtime.new_aligned(XXH3_state, 64, allocator) err = nil if mem_error == nil else .Error XXH3_init_state(state) From 53cb56cc2196cc435567a0293a639f59ffc2bc1c Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 18:48:22 +0100 Subject: [PATCH 2/8] remove core:mem dependency from core:bytes --- core/bytes/bytes.odin | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin index 79de89d2f..911c62d5d 100644 --- a/core/bytes/bytes.odin +++ b/core/bytes/bytes.odin @@ -1,8 +1,8 @@ // Procedures for manipulation of `[]byte` slices. package bytes +import "base:runtime" import "base:intrinsics" -import "core:mem" import "core:simd" import "core:unicode" import "core:unicode/utf8" @@ -40,7 +40,7 @@ clone :: proc(s: []byte, allocator := context.allocator, loc := #caller_location return c[:len(s)] } -clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: mem.Allocator_Error) { +clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: runtime.Allocator_Error) { c := make([]byte, len(s), allocator, loc) or_return copy(c, s) return c[:len(s)], nil @@ -48,7 +48,7 @@ clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_loc ptr_from_slice :: ptr_from_bytes ptr_from_bytes :: proc(str: []byte) -> ^byte { - d := transmute(mem.Raw_String)str + d := transmute(runtime.Raw_String)str return d.data } @@ -70,7 +70,13 @@ truncate_to_rune :: proc(str: []byte, r: rune) -> []byte { // Compares two strings, returning a value representing which one comes first lexiographically. // -1 for `a`; 1 for `b`, or 0 if they are equal. compare :: proc(lhs, rhs: []byte) -> int { - return mem.compare(lhs, rhs) + res := runtime.memory_compare(raw_data(lhs), raw_data(rhs), min(len(lhs), len(rhs))) + if res == 0 && len(lhs) != len(rhs) { + return len(lhs) <= len(rhs) ? -1 : +1 + } else if len(lhs) == 0 && len(rhs) == 0 { + return 0 + } + return res } contains_rune :: proc(s: []byte, r: rune) -> int { @@ -176,7 +182,7 @@ join :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> []byte return b } -join_safe :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> (data: []byte, err: mem.Allocator_Error) { +join_safe :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> (data: []byte, err: runtime.Allocator_Error) { if len(a) == 0 { return nil, nil } @@ -212,7 +218,7 @@ concatenate :: proc(a: [][]byte, allocator := context.allocator) -> []byte { return b } -concatenate_safe :: proc(a: [][]byte, allocator := context.allocator) -> (data: []byte, err: mem.Allocator_Error) { +concatenate_safe :: proc(a: [][]byte, allocator := context.allocator) -> (data: []byte, err: runtime.Allocator_Error) { if len(a) == 0 { return nil, nil } From 874ffa0385046efdab5b03f2bfc04bb735968400 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:19:30 +0100 Subject: [PATCH 3/8] remove core:fmt dependency from core:debug/trace --- core/debug/trace/trace.odin | 30 +++++++++++++++++++++++++++++ core/debug/trace/trace_cpp.odin | 2 +- core/debug/trace/trace_windows.odin | 4 ++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/core/debug/trace/trace.odin b/core/debug/trace/trace.odin index 134609b05..79c10b67f 100644 --- a/core/debug/trace/trace.odin +++ b/core/debug/trace/trace.odin @@ -44,4 +44,34 @@ resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (r @(require_results) in_resolve :: proc "contextless" (ctx: ^Context) -> bool { return intrinsics.atomic_load(&ctx.in_resolve) +} + +_format_hex :: proc(buf: []byte, val: uintptr, allocator: runtime.Allocator) -> int { + _digits := "0123456789abcdef" + + shift := (size_of(uintptr) * 8) - 4 + offs := 0 + + for shift >= 0 { + d := (val >> uint(shift)) & 0xf + buf[offs] = _digits[d] + shift -= 4 + offs += 1 + } + + return offs +} + +_format_missing_proc :: proc(addr: uintptr, allocator: runtime.Allocator) -> string { + PREFIX :: "proc:0x" + buf, buf_err := make([]byte, len(PREFIX) + 16, allocator) + copy(buf, PREFIX) + + if buf_err != nil { + return "OUT_OF_MEMORY" + } + + offs := len(PREFIX) + offs += _format_hex(buf[offs:], uintptr(addr), allocator) + return string(buf[:offs]) } \ No newline at end of file diff --git a/core/debug/trace/trace_cpp.odin b/core/debug/trace/trace_cpp.odin index 8ef377cef..49a5a9055 100644 --- a/core/debug/trace/trace_cpp.odin +++ b/core/debug/trace/trace_cpp.odin @@ -164,7 +164,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> F } else if info: Dl_info; dladdr(rawptr(address), &info) != 0 && info.dli_sname != "" { frame.procedure = strings.clone_from_cstring(info.dli_sname, btc.allocator) } else { - frame.procedure = fmt.aprintf("(procedure: 0x%x)", allocator=btc.allocator) + fl.procedure = _format_missing_proc(address, allocator) } frame.line = i32(line) return 0 diff --git a/core/debug/trace/trace_windows.odin b/core/debug/trace/trace_windows.odin index 04e92f125..d4f5d08cc 100644 --- a/core/debug/trace/trace_windows.odin +++ b/core/debug/trace/trace_windows.odin @@ -6,7 +6,7 @@ import "base:intrinsics" import "base:runtime" import win32 "core:sys/windows" -import "core:fmt" +import "core:strconv" _Context :: struct { hProcess: win32.HANDLE, @@ -56,7 +56,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> ( if win32.SymFromAddrW(ctx.impl.hProcess, win32.DWORD64(frame), &{}, symbol) { fl.procedure, _ = win32.wstring_to_utf8(cstring16(&symbol.Name[0]), -1, allocator) } else { - fl.procedure = fmt.aprintf("(procedure: 0x%x)", frame, allocator=allocator) + fl.procedure = _format_missing_proc(uintptr(frame), allocator) } line: win32.IMAGEHLP_LINE64 From 0e2f5b7d7007df27f4a9f4a7eaa4b1166dd45f3a Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:45:18 +0100 Subject: [PATCH 4/8] remove strconv --- core/debug/trace/trace_windows.odin | 1 - 1 file changed, 1 deletion(-) diff --git a/core/debug/trace/trace_windows.odin b/core/debug/trace/trace_windows.odin index d4f5d08cc..b27b0ee29 100644 --- a/core/debug/trace/trace_windows.odin +++ b/core/debug/trace/trace_windows.odin @@ -6,7 +6,6 @@ import "base:intrinsics" import "base:runtime" import win32 "core:sys/windows" -import "core:strconv" _Context :: struct { hProcess: win32.HANDLE, From 77be6a1f1837253c66eaaec2e5009ec9e52a23e3 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:46:51 +0100 Subject: [PATCH 5/8] fix tabs --- core/debug/trace/trace.odin | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/debug/trace/trace.odin b/core/debug/trace/trace.odin index 79c10b67f..8561d72c2 100644 --- a/core/debug/trace/trace.odin +++ b/core/debug/trace/trace.odin @@ -49,15 +49,15 @@ in_resolve :: proc "contextless" (ctx: ^Context) -> bool { _format_hex :: proc(buf: []byte, val: uintptr, allocator: runtime.Allocator) -> int { _digits := "0123456789abcdef" - shift := (size_of(uintptr) * 8) - 4 + shift := (size_of(uintptr) * 8) - 4 offs := 0 - for shift >= 0 { - d := (val >> uint(shift)) & 0xf + for shift >= 0 { + d := (val >> uint(shift)) & 0xf buf[offs] = _digits[d] - shift -= 4 + shift -= 4 offs += 1 - } + } return offs } From edd960905a043ad08bb6bc3cfcc6234f9c9baa3c Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:48:12 +0100 Subject: [PATCH 6/8] fix typo in the trace cpp backend --- core/debug/trace/trace.odin | 2 +- core/debug/trace/trace_cpp.odin | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/debug/trace/trace.odin b/core/debug/trace/trace.odin index 8561d72c2..6a9ba9dab 100644 --- a/core/debug/trace/trace.odin +++ b/core/debug/trace/trace.odin @@ -74,4 +74,4 @@ _format_missing_proc :: proc(addr: uintptr, allocator: runtime.Allocator) -> str offs := len(PREFIX) offs += _format_hex(buf[offs:], uintptr(addr), allocator) return string(buf[:offs]) -} \ No newline at end of file +} diff --git a/core/debug/trace/trace_cpp.odin b/core/debug/trace/trace_cpp.odin index 49a5a9055..5c2c381d2 100644 --- a/core/debug/trace/trace_cpp.odin +++ b/core/debug/trace/trace_cpp.odin @@ -164,7 +164,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> F } else if info: Dl_info; dladdr(rawptr(address), &info) != 0 && info.dli_sname != "" { frame.procedure = strings.clone_from_cstring(info.dli_sname, btc.allocator) } else { - fl.procedure = _format_missing_proc(address, allocator) + frame.procedure = _format_missing_proc(address, allocator) } frame.line = i32(line) return 0 From 26e4af28adbdfef1d751bae22c847568b602ebb3 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:55:50 +0100 Subject: [PATCH 7/8] remove the actual fmt import from trace_cpp --- core/debug/trace/trace_cpp.odin | 1 - 1 file changed, 1 deletion(-) diff --git a/core/debug/trace/trace_cpp.odin b/core/debug/trace/trace_cpp.odin index 5c2c381d2..afa065474 100644 --- a/core/debug/trace/trace_cpp.odin +++ b/core/debug/trace/trace_cpp.odin @@ -5,7 +5,6 @@ package debug_trace import "base:intrinsics" import "base:runtime" import "core:strings" -import "core:fmt" import "core:c" // NOTE: Relies on C++23 which adds and becomes ABI and that can be used From 83489c07f1123e1994e40a08a32206d8d78414a9 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:56:49 +0100 Subject: [PATCH 8/8] fix allocator error --- core/debug/trace/trace_cpp.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/debug/trace/trace_cpp.odin b/core/debug/trace/trace_cpp.odin index afa065474..1a96ee112 100644 --- a/core/debug/trace/trace_cpp.odin +++ b/core/debug/trace/trace_cpp.odin @@ -163,7 +163,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> F } else if info: Dl_info; dladdr(rawptr(address), &info) != 0 && info.dli_sname != "" { frame.procedure = strings.clone_from_cstring(info.dli_sname, btc.allocator) } else { - frame.procedure = _format_missing_proc(address, allocator) + frame.procedure = _format_missing_proc(address, btc.allocator) } frame.line = i32(line) return 0