Skip to content

Conversation

@steveklabnik
Copy link
Owner

Summary

  • Add a thread-safe bump allocator with arena-based allocation for the rue runtime
  • Uses mmap syscalls for memory allocation (64KB arenas)
  • Atomic pointer operations for thread safety
  • Implements alloc_init, arena_alloc, arena_free intrinsics
  • Includes memory intrinsics (memcpy, memmove, memset, memcmp)

Linker Fixes

  • Handle GOT relocations with GOT relaxation for static linking
  • Skip R_*_NONE and null symbol relocations
  • Skip relocations to unhandled sections (.bss, .data, etc.)

Build Fixes

  • Disable LSE atomics on aarch64 to avoid __aarch64_have_lse_atomics symbol dependency
  • Use static relocation model to avoid GOT-relative relocations

Test plan

  • Local macOS aarch64 tests pass
  • CI Linux x86-64 tests pass
  • CI Linux aarch64 tests pass

🤖 Generated with Claude Code

steveklabnik and others added 11 commits December 25, 2025 05:39
The parser had identical select! blocks for parsing primitive type keywords
(i8, i16, i32, i64, u8, u16, u32, u64, bool) in two places: type_parser()
and the intrinsic argument parser. Extract this into a shared
primitive_type_parser() function that both can reuse.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Introduces a TempLinkDir struct that encapsulates temporary directory
management for external linker invocations. This uses RAII (Drop trait)
to ensure cleanup happens in all code paths, fixing potential resource
leaks in error cases where manual cleanup could be missed.

Fixes rue-a38t

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add tests verifying that try_get returns None for invalid Symbols,
and that get panics as documented. This ensures the interner's
Option-returning API is properly tested.

Fixes rue-627f
Add 8 tests covering move semantics for struct return values,
which was specified (3.8:7) but lacked test coverage:
- Basic return from function
- Chained returns through multiple functions
- Returning function parameters
- Use-after-move errors for returned values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Replace the panic in register allocation (when a virtual register
is not allocated) with a proper InternalCodegenError that propagates
through the compilation pipeline. This allows the error to be
reported to users rather than crashing the compiler.

Changes both x86_64 and aarch64 backends to return CompileResult
from allocate(), allocate_with_spills(), and related functions.

Fixes rue-8osd

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Design document for destructor support in Rue. Destructors are needed
for heap-allocated types like mutable strings where free() must be called
when values go out of scope.

Key decisions:
- Drop runs when value's owning binding goes out of scope (not moved)
- Drop order is reverse declaration order (LIFO)
- Trivially droppable types (primitives, @copy) have no destructor
- Provisional `drop fn TypeName(self)` syntax for user-defined destructors
- Copy types cannot have destructors (would cause double-free)

Implementation phases follow spec-first, test-driven development:
1. Spec and infrastructure (rue-wjha.7)
2. Drop elaboration (rue-wjha.8)
3. Codegen (rue-wjha.9)
4. User-defined destructors (rue-wjha.10)
5. Integration with built-in types (rue-wjha.11) - deferred

Also adds `destructors` preview feature flag.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Design document for implementing a custom bump allocator in the Rue
runtime. Uses mmap/munmap syscalls directly (no libc dependency) to
provide __rue_alloc, __rue_realloc, and __rue_free functions.

This enables heap-allocated types like String, Vec, and Box.

Epic: rue-n50n

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement Phase 1 of ADR-0009 (struct methods):
- Add `impl` and `self` keywords to lexer
- Parse `impl Type { fn... }` blocks with Method AST nodes
- Parse method calls (`.method()`) as distinct from field access
- Add ImplDecl and MethodCall to RIR with placeholder sema handling
- Add preview tests (gated on `methods` feature flag)

Methods currently return Unit type as placeholders - actual type checking
and code generation are in Phase 3 and Phase 4 respectively.

Related to rue-qs3z

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Adds RIR instructions and generation for method calls and associated
function calls:

- Add AssocFnCall RIR instruction for Type::fn() syntax
- Parse associated function calls in the parser
- Generate RIR for method calls and associated function calls
- Add placeholder handling in sema and inference for Phase 3

Phase 3 (type checking) will implement method resolution and self
parameter binding.

Closes rue-qs3z.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implements Phase 1 (rue-wjha.7) of the destructors epic:

Specification:
- Add destructor chapter to specification (section 3.9)
- Define drop semantics (scope exit, not moved)
- Define drop order (reverse declaration order)
- Define trivially droppable types (primitives, enums, @copy structs)
- Define types with destructors (structs with non-trivial fields)

Tests:
- Add spec tests with preview = "destructors" flag
- Cover drop semantics, drop order, trivially droppable types
- Placeholder tests for types with destructors (skipped until String lands)
- Achieve 100% normative coverage in traceability report

Infrastructure:
- Add Drop instruction to AIR (rue-air)
- Add Drop instruction to CFG (rue-cfg)
- Add type_needs_drop() method to CfgBuilder (requires struct/array definitions)
- Add Drop handling to CFG builder (no-op for trivially droppable)
- Add Drop handling to x86_64 and aarch64 codegen backends

Most destructor tests pass (trivially droppable types work correctly).
Three placeholder tests are skipped pending mutable String implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add a thread-safe bump allocator with arena-based allocation:
- Uses mmap syscalls for memory allocation (64KB arenas)
- Atomic pointer operations for thread safety
- Implements alloc_init, arena_alloc, arena_free intrinsics
- Includes memory intrinsics (memcpy, memmove, memset, memcmp)

Fixes linker issues:
- Handle GOT relocations (GOT relaxation for static linking)
- Skip R_*_NONE and null symbol relocations
- Skip relocations to unhandled sections

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants