Conversation
…iled code Adds function pointer-based parallel execution for `parallel for each` loops in compiled ARO binaries, matching the interpreter's non-deterministic concurrent behavior. ## Changes ### Runtime Bridge (RuntimeBridge.swift) - Add `RuntimeError` enum for compilation error handling - Add `aro_parallel_for_each_execute` C-callable function - Uses DispatchQueue + DispatchGroup for reliable parallelism - Implements concurrency limiting with DispatchSemaphore - Thread-safe error tracking with NSLock - Defaults to System.coreCount threads, configurable via AST ### LLVM Code Generator (LLVMCodeGenerator.swift) - Add global runtime pointer (`@global_runtime`) for parallel executor access - Extract parallel loop bodies as separate LLVM functions - Signature: `ptr function(ptr context, ptr item, i64 index)` - Proper variable binding and filter support - Isolated `%__result` variable per loop body - Replace serial parallel loop generation with function pointer approach - Add `generateLoopBodyFunction()` to emit loop body functions - Add `generatePendingLoopBodies()` to emit after feature sets - Update external declarations with parallel executor ### Example - Add `Examples/ParallelForEach/` demonstrating serial vs parallel iteration - Shows non-deterministic execution order in parallel loops ## Technical Highlights - **Function Pointers**: Loop bodies compiled as separate LLVM functions - **Concurrency Control**: Default System.coreCount, override via `with <concurrency: N>` - **Context Isolation**: Child contexts per iteration for immutability - **DispatchQueue**: Replaced Swift concurrency for compiled binary compatibility - **Zero Breaking Changes**: Serial loops unchanged, parallel loops truly parallel ## Testing Verified with ParallelForEach example: - Interpreter: Non-deterministic parallel execution ✓ - Compiled binary: Non-deterministic parallel execution ✓ - Serial loops: Deterministic ordering preserved ✓ - Concurrency limiting: Respects System.coreCount ✓ Closes: Implements true concurrent parallel execution for compiled ARO code
Replace System.coreCount with ProcessInfo.processInfo.activeProcessorCount in RuntimeBridge.swift to fix Windows build failure. System.coreCount is from the swift-system package which is Unix-only and not available on Windows. ProcessInfo.processInfo.activeProcessorCount: - Works on all platforms (macOS, Linux, Windows) - Part of Foundation (already imported) - Returns the same information (number of available processor cores) Fixes Windows CI build error: error: cannot find 'System' in scope
KrisSimon
added a commit
that referenced
this pull request
Feb 28, 2026
Introduce raw string literals that prevent escape sequence processing,
making regex patterns, file paths, and backslash-heavy content more readable.
Implementation:
- Add r-prefix syntax for raw strings: r"\d+\.\d+"
- Support both double and single quotes: r"..." and r'...'
- No escape processing except \" and \' for quotes
- scanRawString() method in Lexer
Examples:
r"\d+\.\d+\.\d+" # Regex without double escaping
r"C:\Users\Admin\config.json" # Windows path
r"\\server\share\file" # UNC path
r"\documentclass{article}" # LaTeX
Tests:
- 5 new unit tests in LexerTests.swift
- RawStrings example demonstrating various use cases
Fixes GitLab #109
KrisSimon
added a commit
that referenced
this pull request
Feb 28, 2026
Add raw string literals with r-prefix (ARO-0060) Closes #109 See merge request arolang/aro!127
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implements true concurrent parallel execution for
parallel for eachloops in compiled ARO binaries using function pointers and DispatchQueue, matching the interpreter's non-deterministic concurrent behavior.Changes
Runtime Bridge (
RuntimeBridge.swift)RuntimeErrorenum for compilation error handlingaro_parallel_for_each_executeC-callable functionSystem.coreCountthreads, configurable viawith <concurrency: N>LLVM Code Generator (
LLVMCodeGenerator.swift)@global_runtime) for parallel executor accessptr function(ptr context, ptr item, i64 index)%__resultvariable per loop bodygenerateLoopBodyFunction()to emit loop body functionsgeneratePendingLoopBodies()to emit after feature setsExample
Examples/ParallelForEach/demonstrating serial vs parallel iterationTechnical Highlights
System.coreCount, override viawith <concurrency: N>syntaxTesting
Verified with
Examples/ParallelForEach:Interpreter (
aro run):Compiled Binary (
aro build):Both show true concurrent execution with varying iteration order across runs.
Performance
Example Usage
Build & Test
Files Changed
Sources/ARORuntime/Bridge/RuntimeBridge.swift(+147 lines)Sources/AROCompiler/LLVMCodeGenerator.swift(+322 lines, -66 lines)Examples/ParallelForEach/main.aro(new)Related
Implements the full vision for parallel execution in compiled ARO code, bridging the gap between interpreter and compiler capabilities.