Threading atomic mvp#55
Merged
Merged
Conversation
Add AST/parser support for 'atomic' types and let/stmt flags. Implement atomic storage TypeInfo, synthesize and const-eval handling in the typechecker, and HIR/MIR support for atomic loads/ops. Add LLVM lowering for atomic instructions and runtime symbols. Introduce std/task surface and C runtime using pthreads on non-Windows (platform no-op on Windows). Pass -pthread to compiler/linker on non-Windows. Add tests and repro programs for atomics and task usage.
Comment on lines
+14
to
+21
| fn run_ref<T>(entry: fn(T) -> void, arg: T) -> ^taskInner; | ||
|
|
||
| #[extern("ferret_task_wait")] | ||
| fn wait_raw(handle: ^void) -> void; | ||
|
|
||
| fn Run<T>(callback: fn(T) -> void, arg: T) -> Handle { | ||
| unsafe { | ||
| return .{ .raw = mem::Adopt(run_ref(callback, arg)) } |
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.
This pull request introduces two major improvements: (1) it adds first-class support for atomic types and atomic storage in the type checker, and (2) it fixes and extends ownership analysis for composite values (such as structs, tuples, slices, and maps), especially regarding move semantics. Additionally, it introduces a new standard library module for explicit task/thread management and enhances test coverage for ownership checks.
Atomic type support and type checker enhancements:
AtomicType) in the type checker, including type synthesis, storage validation, type inference, and type parameter collection. This ensures that variables declared as atomic are handled correctly throughout the type system, and that only permitted types can be marked as atomic. (internal/analysis/semantics/typechecker/typechecker.go,internal/analysis/semantics/typechecker/core.go,internal/analysis/semantics/typechecker/syntax_types.go,internal/analysis/semantics/typechecker/symbol_types.go,internal/analysis/semantics/typechecker/const_eval.go) [1] [2] [3] [4] [5] [6]internal/analysis/semantics/typechecker/typechecker.go,internal/analysis/semantics/typechecker/stmts.go) [1] [2]internal/analysis/semantics/typechecker/typechecker.go) [1] [2] [3]internal/analysis/semantics/typechecker/typechecker.go) [1] [2]internal/analysis/semantics/typechecker/typechecker.go)Ownership analysis improvements:
internal/analysis/semantics/ownership/ownership.go) [1] [2] [3] [4] [5] [6]internal/analysis/semantics/ownership/ownership_test.go) [1] [2]Standard library and build improvements:
std/taskmodule for explicit task/thread management, providing a safe and ergonomic interface for spawning and waiting on OS threads. (ferret_libs_dev/std/task.fer)bundler/build_tools.go)