Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Verify vendor libraries
run: |
fail=0
for lib in vendor/bdwgc/libgc.a vendor/yyjson/libyyjson.a vendor/libuv/build/libuv.a vendor/picohttpparser/picohttpparser.o c_bridges/lws-bridge.o c_bridges/multipart-bridge.o c_bridges/regex-bridge.o c_bridges/child-process-bridge.o c_bridges/child-process-spawn.o c_bridges/os-bridge.o c_bridges/strlen-cache.o c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o c_bridges/dotenv-bridge.o c_bridges/watch-bridge.o; do
for lib in vendor/bdwgc/libgc.a vendor/yyjson/libyyjson.a vendor/libuv/build/libuv.a vendor/picohttpparser/picohttpparser.o c_bridges/lws-bridge.o c_bridges/multipart-bridge.o c_bridges/regex-bridge.o c_bridges/child-process-bridge.o c_bridges/child-process-spawn.o c_bridges/os-bridge.o c_bridges/strlen-cache.o c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o c_bridges/dotenv-bridge.o c_bridges/watch-bridge.o c_bridges/arena-bridge.o; do
if [ ! -f "$lib" ]; then
echo "MISSING: $lib"
fail=1
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
cp c_bridges/os-bridge.o c_bridges/strlen-cache.o release/lib/
cp c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o release/lib/
cp c_bridges/dotenv-bridge.o release/lib/
cp c_bridges/watch-bridge.o release/lib/
cp c_bridges/watch-bridge.o c_bridges/arena-bridge.o release/lib/
tar -czf chadscript-linux-x64.tar.gz -C release chad lib

- name: Upload artifact
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
- name: Verify vendor libraries
run: |
fail=0
for lib in vendor/bdwgc/libgc.a vendor/yyjson/libyyjson.a vendor/libuv/build/libuv.a vendor/picohttpparser/picohttpparser.o c_bridges/lws-bridge.o c_bridges/multipart-bridge.o c_bridges/regex-bridge.o c_bridges/child-process-bridge.o c_bridges/child-process-spawn.o c_bridges/os-bridge.o c_bridges/strlen-cache.o c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o c_bridges/dotenv-bridge.o c_bridges/watch-bridge.o; do
for lib in vendor/bdwgc/libgc.a vendor/yyjson/libyyjson.a vendor/libuv/build/libuv.a vendor/picohttpparser/picohttpparser.o c_bridges/lws-bridge.o c_bridges/multipart-bridge.o c_bridges/regex-bridge.o c_bridges/child-process-bridge.o c_bridges/child-process-spawn.o c_bridges/os-bridge.o c_bridges/strlen-cache.o c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o c_bridges/dotenv-bridge.o c_bridges/watch-bridge.o c_bridges/arena-bridge.o; do
if [ ! -f "$lib" ]; then
echo "MISSING: $lib"
fail=1
Expand Down Expand Up @@ -256,7 +256,7 @@ jobs:
cp c_bridges/os-bridge.o c_bridges/strlen-cache.o release/lib/
cp c_bridges/time-bridge.o c_bridges/base64-bridge.o c_bridges/url-bridge.o c_bridges/uri-bridge.o release/lib/
cp c_bridges/dotenv-bridge.o release/lib/
cp c_bridges/watch-bridge.o release/lib/
cp c_bridges/watch-bridge.o c_bridges/arena-bridge.o release/lib/
tar -czf chadscript-macos-arm64.tar.gz -C release chad lib

- name: Upload artifact
Expand Down Expand Up @@ -334,6 +334,7 @@ jobs:
time-bridge.o \
dotenv-bridge.o \
watch-bridge.o \
arena-bridge.o \
tree-sitter-typescript-parser.o \
tree-sitter-typescript-scanner.o \
treesitter-bridge.o; do
Expand Down
45 changes: 45 additions & 0 deletions c_bridges/arena-bridge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <string.h>
#include <stdint.h>

extern void* GC_malloc(size_t);
extern void* GC_malloc_atomic(size_t);

#define ARENA_BLOCK_SIZE (1024 * 1024)

typedef struct ArenaBlock {
char* data;
size_t used;
size_t capacity;
struct ArenaBlock* next;
} ArenaBlock;

static ArenaBlock* current_block = NULL;
static ArenaBlock* block_list = NULL;

static ArenaBlock* arena_new_block(size_t min_size) {
size_t cap = min_size > ARENA_BLOCK_SIZE ? min_size : ARENA_BLOCK_SIZE;
ArenaBlock* block = (ArenaBlock*)GC_malloc(sizeof(ArenaBlock));
block->data = (char*)GC_malloc_atomic(cap);
block->used = 0;
block->capacity = cap;
block->next = block_list;
block_list = block;
return block;
}

void* cs_arena_alloc(size_t size) {
size = (size + 7) & ~(size_t)7;

if (!current_block || current_block->used + size > current_block->capacity) {
current_block = arena_new_block(size);
}

void* ptr = current_block->data + current_block->used;
current_block->used += size;
return ptr;
}

void cs_arena_reset(void) {
current_block = NULL;
block_list = NULL;
}
2 changes: 1 addition & 1 deletion scripts/build-target-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fi

# Copy C bridge object files
echo " Copying bridge objects..."
for bridge in child-process-bridge.o os-bridge.o strlen-cache.o time-bridge.o base64-bridge.o url-bridge.o uri-bridge.o regex-bridge.o dotenv-bridge.o watch-bridge.o lws-bridge.o multipart-bridge.o child-process-spawn.o; do
for bridge in child-process-bridge.o os-bridge.o strlen-cache.o time-bridge.o base64-bridge.o url-bridge.o uri-bridge.o regex-bridge.o dotenv-bridge.o watch-bridge.o lws-bridge.o multipart-bridge.o child-process-spawn.o arena-bridge.o; do
if [ -f "$C_BRIDGES_DIR/$bridge" ]; then
cp "$C_BRIDGES_DIR/$bridge" "$SDK_DIR/bridges/"
fi
Expand Down
11 changes: 11 additions & 0 deletions scripts/build-vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ else
echo "==> strlen-cache already built, skipping"
fi

# --- arena-bridge (bump-pointer arena allocator for strings) ---
ARENA_BRIDGE_SRC="$C_BRIDGES_DIR/arena-bridge.c"
ARENA_BRIDGE_OBJ="$C_BRIDGES_DIR/arena-bridge.o"
if [ ! -f "$ARENA_BRIDGE_OBJ" ] || [ "$ARENA_BRIDGE_SRC" -nt "$ARENA_BRIDGE_OBJ" ]; then
echo "==> Building arena-bridge..."
cc -c -O2 -fPIC "$ARENA_BRIDGE_SRC" -o "$ARENA_BRIDGE_OBJ"
echo " -> $ARENA_BRIDGE_OBJ"
else
echo "==> arena-bridge already built, skipping"
fi

# --- base64-bridge ---
BASE64_BRIDGE_SRC="$C_BRIDGES_DIR/base64-bridge.c"
BASE64_BRIDGE_OBJ="$C_BRIDGES_DIR/base64-bridge.o"
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/expressions/access/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class IndexAccessGenerator {
// TypeScript str[i] returns a single-character string, not a number
// Allocate 2 bytes for the character + null terminator
const strBuf = this.ctx.nextTemp();
this.ctx.emit(`${strBuf} = call i8* @GC_malloc_atomic(i64 2)`);
this.ctx.emit(`${strBuf} = call i8* @cs_arena_alloc(i64 2)`);

// Store the character at position 0
this.ctx.emit(`store i8 ${charI8}, i8* ${strBuf}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function handleStringFromCharCode(
ctx.emit(`${intVal} = fptosi double ${dblVal} to i32`);
const byteVal = ctx.nextTemp();
ctx.emit(`${byteVal} = trunc i32 ${intVal} to i8`);
const buf = ctx.emitCall("i8*", "@GC_malloc_atomic", "i64 2");
const buf = ctx.emitCall("i8*", "@cs_arena_alloc", "i64 2");
ctx.emitStore("i8", byteVal, buf);
const nullPtr = ctx.emitGep("i8", buf, "i64 1");
ctx.emitStore("i8", "0", nullPtr);
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/expressions/method-calls/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { MethodCallGeneratorContext } from "../method-calls.js";
// os.hostname() — gethostname into a GC buffer
export function handleOsHostname(ctx: MethodCallGeneratorContext): string {
const buf = ctx.nextTemp();
ctx.emit(`${buf} = call i8* @GC_malloc_atomic(i64 256)`);
ctx.emit(`${buf} = call i8* @cs_arena_alloc(i64 256)`);
const rc = ctx.nextTemp();
ctx.emit(`${rc} = call i32 @gethostname(i8* ${buf}, i64 256)`);
ctx.setVariableType(buf, "i8*");
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/expressions/method-calls/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function generateProcessCwdInline(ctx: MethodCallGeneratorContext): strin
const bufSize = ctx.nextTemp();
ctx.emit(`${bufSize} = add i64 0, 4096`);
const buf = ctx.nextTemp();
ctx.emit(`${buf} = call i8* @GC_malloc_atomic(i64 ${bufSize})`);
ctx.emit(`${buf} = call i8* @cs_arena_alloc(i64 ${bufSize})`);
const result = ctx.nextTemp();
ctx.emit(`${result} = call i8* @getcwd(i8* ${buf}, i64 4096)`);
ctx.setVariableType(result, "i8*");
Expand Down
5 changes: 4 additions & 1 deletion src/codegen/infrastructure/llvm-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export function getLLVMDeclarations(config?: DeclConfig): string {
ir += "declare i8* @GC_realloc(i8*, i64)\n";
ir += "declare void @GC_disable()\n";
ir += "declare void @GC_enable()\n";
ir += "; Arena allocator for short-lived strings\n";
ir += "declare noalias i8* @cs_arena_alloc(i64)\n";
ir += "declare void @cs_arena_reset()\n";
ir += "declare i8* @strcpy(i8*, i8*)\n";
ir += "declare i8* @strncpy(i8*, i8*, i64)\n";
ir += "declare i8* @strcat(i8*, i8*)\n";
Expand Down Expand Up @@ -444,7 +447,7 @@ export function getDoubleToStringHelper(): string {
ir += "\n";
ir += "define i8* @__double_to_string(double %val) {\n";
ir += "entry:\n";
ir += " %buffer = call i8* @GC_malloc_atomic(i64 48)\n";
ir += " %buffer = call i8* @cs_arena_alloc(i64 48)\n";
ir += " %fmt = getelementptr inbounds [6 x i8], [6 x i8]* @.double_fmt, i64 0, i64 0\n";
ir += " call i32 (i8*, i64, i8*, ...) @snprintf(i8* %buffer, i64 48, i8* %fmt, double %val)\n";
ir += " ret i8* %buffer\n";
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/statements/control-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ export class ControlFlowGenerator {
this.ctx.emitLabel(bodyLabel);
this.ctx.setCurrentLabel(bodyLabel);

const charBuf = this.ctx.emitCall("i8*", "@GC_malloc_atomic", "i64 2");
const charBuf = this.ctx.emitCall("i8*", "@cs_arena_alloc", "i64 2");
const idxI64 = this.nextTemp();
this.emit(`${idxI64} = sext i32 ${currentIndex} to i64`);
const charPtr = this.nextTemp();
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/stdlib/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class DateGenerator {
if (method === "toISOString") {
this.ctx.emitCall("%struct.tm*", "@gmtime_r", `i64* ${timePtr}, %struct.tm* ${tmAlloca}`);
const buf = this.ctx.nextTemp();
this.ctx.emit(`${buf} = call i8* @GC_malloc_atomic(i64 32)`);
this.ctx.emit(`${buf} = call i8* @cs_arena_alloc(i64 32)`);
const fmt = this.ctx.stringGen.doCreateStringConstant("%Y-%m-%dT%H:%M:%SZ");
this.ctx.emitCall(
"i64",
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/stdlib/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ export class JsonGenerator {
const strLen = this.ctx.emitCall("i64", "@strlen", `i8* ${strPtr}`);
const bufferSize = this.ctx.nextTemp();
this.ctx.emit(`${bufferSize} = add i64 ${strLen}, 3`);
const buffer = this.ctx.emitCall("i8*", "@GC_malloc_atomic", `i64 ${bufferSize}`);
const buffer = this.ctx.emitCall("i8*", "@cs_arena_alloc", `i64 ${bufferSize}`);

const formatStr = this.ctx.createStringConstant('"%s"');
// sprintf has variadic signature — keep as raw emit
Expand Down Expand Up @@ -1232,7 +1232,7 @@ export class JsonGenerator {
const numValue = this.ctx.generateExpression(arg, params);
const dblValue = this.ctx.ensureDouble(numValue);

const buffer = this.ctx.emitCall("i8*", "@GC_malloc_atomic", "i64 30");
const buffer = this.ctx.emitCall("i8*", "@cs_arena_alloc", "i64 30");

const formatStr = this.ctx.createStringConstant("%.15g");
const sprintfResult = this.ctx.nextTemp();
Expand Down
34 changes: 17 additions & 17 deletions src/codegen/stdlib/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class PathGenerator {

const bufferSize = this.ctx.nextTemp();
this.ctx.emit(`${bufferSize} = add i64 0, 4096`);
const buffer = this.ctx.emitCall("i8*", "@GC_malloc_atomic", `i64 ${bufferSize}`);
const buffer = this.ctx.emitCall("i8*", "@cs_arena_alloc", `i64 ${bufferSize}`);

const resolvedPtr = this.ctx.emitCall("i8*", "@realpath", `i8* ${pathPtr}, i8* ${buffer}`);

Expand Down Expand Up @@ -95,7 +95,7 @@ export class PathGenerator {
const pathLen = this.ctx.emitCall("i64", "@strlen", `i8* ${pathPtr}`);
const copySize = this.ctx.nextTemp();
this.ctx.emit(`${copySize} = add i64 ${pathLen}, 1`);
const pathCopy = this.ctx.emitCall("i8*", "@GC_malloc_atomic", `i64 ${copySize}`);
const pathCopy = this.ctx.emitCall("i8*", "@cs_arena_alloc", `i64 ${copySize}`);
const copyResult = this.ctx.emitCall("i8*", "@strcpy", `i8* ${pathCopy}, i8* ${pathPtr}`);

// Call dirname: dirname(pathCopy)
Expand All @@ -114,15 +114,15 @@ export class PathGenerator {
const pathLen = this.ctx.emitCall("i64", "@strlen", `i8* ${pathPtr}`);
const copySize = this.ctx.nextTemp();
this.ctx.emit(`${copySize} = add i64 ${pathLen}, 1`);
const pathCopy = this.ctx.emitCall("i8*", "@GC_malloc_atomic", `i64 ${copySize}`);
const pathCopy = this.ctx.emitCall("i8*", "@cs_arena_alloc", `i64 ${copySize}`);
const copyResult = this.ctx.emitCall("i8*", "@strcpy", `i8* ${pathCopy}, i8* ${pathPtr}`);

const basenamePtr = this.ctx.emitCall("i8*", "@basename", `i8* ${pathCopy}`);

const resultLen = this.ctx.emitCall("i64", "@strlen", `i8* ${basenamePtr}`);
const resultSize = this.ctx.nextTemp();
this.ctx.emit(`${resultSize} = add i64 ${resultLen}, 1`);
const result = this.ctx.emitCall("i8*", "@GC_malloc_atomic", `i64 ${resultSize}`);
const result = this.ctx.emitCall("i8*", "@cs_arena_alloc", `i64 ${resultSize}`);
const strdupResult = this.ctx.emitCall("i8*", "@strcpy", `i8* ${result}, i8* ${basenamePtr}`);
this.ctx.setVariableType(result, "i8*");

Expand Down Expand Up @@ -250,7 +250,7 @@ export class PathGenerator {
ir += " br i1 %is_same, label %return_dot, label %find_common\n\n";

ir += "return_dot:\n";
ir += " %dot = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %dot = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 46, i8* %dot\n";
ir += " %dot1 = getelementptr inbounds i8, i8* %dot, i64 1\n";
ir += " store i8 0, i8* %dot1\n";
Expand Down Expand Up @@ -403,7 +403,7 @@ export class PathGenerator {
ir += " br i1 %has_either, label %calc_size, label %return_dot2\n\n";

ir += "return_dot2:\n";
ir += " %dot2 = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %dot2 = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 46, i8* %dot2\n";
ir += " %dot2_end = getelementptr inbounds i8, i8* %dot2, i64 1\n";
ir += " store i8 0, i8* %dot2_end\n";
Expand All @@ -420,7 +420,7 @@ export class PathGenerator {
ir += " %total_no_null = add i64 %ups_bytes, %mid_sep\n";
ir += " %total_no_null2 = add i64 %total_no_null, %to_rest_len\n";
ir += " %total = add i64 %total_no_null2, 1\n";
ir += " %result_buf = call i8* @GC_malloc_atomic(i64 %total)\n";
ir += " %result_buf = call i8* @cs_arena_alloc(i64 %total)\n";

// Write the "../.." part
ir += " br i1 %has_ups, label %write_ups, label %write_rest_check\n\n";
Expand Down Expand Up @@ -500,15 +500,15 @@ export class PathGenerator {
ir += " br i1 %is_empty, label %return_dot, label %start\n\n";

ir += "return_dot:\n";
ir += " %dot = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %dot = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 46, i8* %dot\n";
ir += " %dot1 = getelementptr inbounds i8, i8* %dot, i64 1\n";
ir += " store i8 0, i8* %dot1\n";
ir += " ret i8* %dot\n\n";

ir += "start:\n";
ir += " %buf_size = add i64 %len, 2\n";
ir += " %buf = call i8* @GC_malloc_atomic(i64 %buf_size)\n";
ir += " %buf = call i8* @cs_arena_alloc(i64 %buf_size)\n";
ir += " %first_char = load i8, i8* %path\n";
ir += " %is_abs = icmp eq i8 %first_char, 47\n";
ir += " %init_dst = select i1 %is_abs, i64 1, i64 0\n";
Expand Down Expand Up @@ -656,7 +656,7 @@ export class PathGenerator {
ir += " br i1 %is_zero, label %return_dot2, label %null_term\n\n";

ir += "return_dot2:\n";
ir += " %dot2 = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %dot2 = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 46, i8* %dot2\n";
ir += " %dot2_1 = getelementptr inbounds i8, i8* %dot2, i64 1\n";
ir += " store i8 0, i8* %dot2_1\n";
Expand Down Expand Up @@ -687,7 +687,7 @@ export class PathGenerator {

// --- No slash: root="", dir="", base=path, name/ext from dot ---
ir += "no_slash:\n";
ir += " %empty0 = call i8* @GC_malloc_atomic(i64 1)\n";
ir += " %empty0 = call i8* @cs_arena_alloc(i64 1)\n";
ir += " store i8 0, i8* %empty0\n";
ir +=
" %root0 = getelementptr inbounds %PathParseResult, %PathParseResult* %result, i32 0, i32 0\n";
Expand All @@ -710,14 +710,14 @@ export class PathGenerator {
ir += " br i1 %is_abs, label %set_root_slash, label %set_root_empty\n\n";

ir += "set_root_slash:\n";
ir += " %root_buf = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %root_buf = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 47, i8* %root_buf\n";
ir += " %root_buf1 = getelementptr inbounds i8, i8* %root_buf, i64 1\n";
ir += " store i8 0, i8* %root_buf1\n";
ir += " br label %store_root\n\n";

ir += "set_root_empty:\n";
ir += " %root_empty = call i8* @GC_malloc_atomic(i64 1)\n";
ir += " %root_empty = call i8* @cs_arena_alloc(i64 1)\n";
ir += " store i8 0, i8* %root_empty\n";
ir += " br label %store_root\n\n";

Expand All @@ -734,7 +734,7 @@ export class PathGenerator {
ir += " br i1 %slash_is_root, label %dir_is_root, label %dir_substr\n\n";

ir += "dir_is_root:\n";
ir += " %dir_root = call i8* @GC_malloc_atomic(i64 2)\n";
ir += " %dir_root = call i8* @cs_arena_alloc(i64 2)\n";
ir += " store i8 47, i8* %dir_root\n";
ir += " %dir_root1 = getelementptr inbounds i8, i8* %dir_root, i64 1\n";
ir += " store i8 0, i8* %dir_root1\n";
Expand All @@ -745,7 +745,7 @@ export class PathGenerator {
ir += " %path_off_raw = ptrtoint i8* %path to i64\n";
ir += " %dir_len = sub i64 %slash_off_raw, %path_off_raw\n";
ir += " %dir_size = add i64 %dir_len, 1\n";
ir += " %dir_buf = call i8* @GC_malloc_atomic(i64 %dir_size)\n";
ir += " %dir_buf = call i8* @cs_arena_alloc(i64 %dir_size)\n";
ir +=
" call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dir_buf, i8* %path, i64 %dir_len, i1 false)\n";
ir += " %dir_term = getelementptr inbounds i8, i8* %dir_buf, i64 %dir_len\n";
Expand Down Expand Up @@ -789,7 +789,7 @@ export class PathGenerator {
ir += " %base_off_raw = ptrtoint i8* %base_ptr to i64\n";
ir += " %name_len = sub i64 %dot_off_raw, %base_off_raw\n";
ir += " %name_size = add i64 %name_len, 1\n";
ir += " %name_buf = call i8* @GC_malloc_atomic(i64 %name_size)\n";
ir += " %name_buf = call i8* @cs_arena_alloc(i64 %name_size)\n";
ir +=
" call void @llvm.memcpy.p0i8.p0i8.i64(i8* %name_buf, i8* %base_ptr, i64 %name_len, i1 false)\n";
ir += " %name_term = getelementptr inbounds i8, i8* %name_buf, i64 %name_len\n";
Expand All @@ -801,7 +801,7 @@ export class PathGenerator {

// --- No extension ---
ir += "no_ext:\n";
ir += " %empty_ext = call i8* @GC_malloc_atomic(i64 1)\n";
ir += " %empty_ext = call i8* @cs_arena_alloc(i64 1)\n";
ir += " store i8 0, i8* %empty_ext\n";
ir +=
" %ext_f2 = getelementptr inbounds %PathParseResult, %PathParseResult* %result, i32 0, i32 4\n";
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/types/collections/string/concatenation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function generateStringConcatDirect(
ctx.emit(`${totalLenPlus1} = add i64 ${totalLen}, 1`);

const resultPtr = ctx.nextTemp();
ctx.emit(`${resultPtr} = call i8* @GC_malloc_atomic(i64 ${totalLenPlus1})`);
ctx.emit(`${resultPtr} = call i8* @cs_arena_alloc(i64 ${totalLenPlus1})`);
ctx.setVariableType(resultPtr, "i8*");

ctx.emit(
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/types/collections/string/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function convertNumberToString(ctx: IGeneratorContext, numValue: string):
ctx.emit(`${heapSize} = add i64 ${strLen}, 1`);

const heapPtr = ctx.nextTemp();
ctx.emit(`${heapPtr} = call i8* @GC_malloc_atomic(i64 ${heapSize})`);
ctx.emit(`${heapPtr} = call i8* @cs_arena_alloc(i64 ${heapSize})`);

const copyResult = ctx.nextTemp();
ctx.emit(`${copyResult} = call i8* @strcpy(i8* ${heapPtr}, i8* ${bufferPtr})`);
Expand Down Expand Up @@ -146,7 +146,7 @@ export function convertNumberToFixed(
const heapSize = ctx.nextTemp();
ctx.emit(`${heapSize} = add i64 ${strLen}, 1`);
const heapPtr = ctx.nextTemp();
ctx.emit(`${heapPtr} = call i8* @GC_malloc_atomic(i64 ${heapSize})`);
ctx.emit(`${heapPtr} = call i8* @cs_arena_alloc(i64 ${heapSize})`);
const copyResult2 = ctx.nextTemp();
ctx.emit(`${copyResult2} = call i8* @strcpy(i8* ${heapPtr}, i8* ${bufferPtr})`);
ctx.setVariableType(heapPtr, "i8*");
Expand Down
Loading
Loading