Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
300b27c
Fix #681; Fix class_dist
inumanag Dec 1, 2025
200860c
Add method decorator support
inumanag Dec 2, 2025
cbba7ae
Refactor __internal__ module; Make RTTI types references (wip); Add t…
inumanag Dec 7, 2025
972208d
Initial async/await support in Codon IR
arshajii Dec 9, 2025
b16471a
Move TypeInfo to ByRef Type
inumanag Dec 10, 2025
f44dfa3
Move TypeInfo to ByRef Type
inumanag Dec 10, 2025
4521e55
Move TypeInfo to ByRef Type
inumanag Dec 10, 2025
bf49fa8
Move TypeInfo to ByRef Type
inumanag Dec 10, 2025
3b02038
Fix polymorphic class codegen
arshajii Dec 10, 2025
66b7732
Add TypeInfo.mro; Plug async to IR
inumanag Dec 10, 2025
afff4a3
Fix async flag
inumanag Dec 12, 2025
c961a16
Fix async types
inumanag Dec 13, 2025
aea20c5
Fix paths
inumanag Dec 14, 2025
b72623c
Refactor GPU kernel
inumanag Dec 14, 2025
c51d33d
Fix Coroutine IR mappings and NoneType handling
inumanag Dec 16, 2025
71e9d59
Update async
arshajii Dec 17, 2025
061c606
Add Task
arshajii Dec 17, 2025
c5439cb
Add await typechecking; Fix await IR node creation
inumanag Dec 17, 2025
95b2be6
Fix class variable typechecking order; Add static.vars(Cls) iteration…
inumanag Dec 19, 2025
c57fc40
Remove exception checks
inumanag Dec 19, 2025
1886a75
Add Cache helpers for RTTI types
inumanag Dec 19, 2025
b3711e6
Disable BaseException requirement
inumanag Dec 20, 2025
89e7c6b
Support polymorphic exceptions in runtime
arshajii Dec 21, 2025
47658c5
Update exception handling logic
arshajii Dec 22, 2025
12b53da
Fix static.range issue
inumanag Dec 23, 2025
6586a38
Merge branch 'poly-fixes' of github.com:exaloop/codon into poly-fixes
inumanag Dec 23, 2025
b84ad62
Update exception header
arshajii Dec 23, 2025
46db867
Update docs
arshajii Dec 23, 2025
f800145
Update asyncio module
arshajii Dec 24, 2025
9eba25c
Update await lowering
arshajii Dec 26, 2025
f3fd990
Update await lowering
arshajii Dec 27, 2025
ae8254d
Update asyncio module
arshajii Dec 27, 2025
ab182e8
Update work queue
arshajii Dec 28, 2025
bbc826c
Fix bugs with try/throw and scoping; Add polymorphic isinstance (just…
inumanag Dec 29, 2025
825ff6a
Update asyncio module
arshajii Dec 29, 2025
f984692
Update await lowering
arshajii Dec 29, 2025
afb91ce
Fix tests
inumanag Dec 30, 2025
681cc65
Update exception handling in asyncio
arshajii Dec 30, 2025
49f4d7d
Add asyncio.sleep()
arshajii Dec 30, 2025
62b2012
Make await expression
inumanag Dec 31, 2025
2c855a0
Make isinstance RTTI-aware
inumanag Dec 31, 2025
c2346b7
Add ThreadLocal handling
inumanag Dec 31, 2025
28ba45d
Update sleep() to match Python's asyncio
arshajii Dec 31, 2025
0ff7e17
Add codegen support for thread-local vars
arshajii Dec 31, 2025
6f302c0
Make event loops thread-local
arshajii Dec 31, 2025
93994d6
Fix exception handling
arshajii Dec 31, 2025
e9fbb1f
Add asyncio.gather()
arshajii Jan 1, 2026
9bd90a4
Add cancellation logic
arshajii Jan 1, 2026
012dd7e
Update await lowering
arshajii Jan 2, 2026
0554bcc
Update asyncio module
arshajii Jan 2, 2026
b2f1b03
Support callback cancellation
arshajii Jan 2, 2026
2434421
Fix Static[] base initialization; fix ThreadLocal handling; Add 'awai…
inumanag Jan 2, 2026
850fcbf
Merge branch 'poly-fixes' of github.com:exaloop/codon into poly-fixes
inumanag Jan 2, 2026
2d71775
Add cancellation checkpoints to await lowering
arshajii Jan 2, 2026
e01fded
Update EventLoop fields
arshajii Jan 2, 2026
df24f78
Fix await type
inumanag Jan 3, 2026
b717ae8
Update await lowering
arshajii Jan 4, 2026
108d38d
Fix asyncio.gather()
arshajii Jan 4, 2026
a3abe41
Fix await implementation
arshajii Jan 5, 2026
b066253
Add asyncio tests
arshajii Jan 5, 2026
3e56b34
Update docs
arshajii Jan 5, 2026
042bb96
Add additional runtime checks to event loop
arshajii Jan 5, 2026
d97f9f0
Fix AsyncGenerator
inumanag Jan 8, 2026
a415f97
Remove unused CoroHandleInstr from IR
arshajii Jan 8, 2026
0fd417a
Add async-for lowering to IR
arshajii Jan 8, 2026
1b6782d
async with support; async for support; Bugfixes
inumanag Jan 10, 2026
b250904
Fix async for; Add __getitem__/__setitem__ support
inumanag Jan 11, 2026
00bb8d5
Fix ir::types::FuncType::doGetGenerics(); Fix plugin compile warnings
inumanag Jan 19, 2026
585d49e
Add int.bit_length()
arshajii Jan 19, 2026
08b97d1
Fix tests
inumanag Jan 21, 2026
d474017
Remove unused class
arshajii Jan 21, 2026
cbbf180
Fix JIT RTTI
inumanag Jan 22, 2026
825b38d
Make builtin.object RTTI by default
inumanag Jan 22, 2026
db6a06f
Fix pyext
inumanag Jan 23, 2026
9fb02db
Fix pyext exception handling
arshajii Jan 23, 2026
d1fc730
Fix Python bridge
arshajii Jan 24, 2026
72c228b
Fix pybridge
inumanag Jan 25, 2026
39e6238
Use specialized call functions in PyBridge
arshajii Jan 26, 2026
69fce9a
Support __await__
inumanag Jan 26, 2026
8fb6973
Add __await__ methods
arshajii Jan 27, 2026
ba2e54b
Add debug logs
inumanag Jan 28, 2026
0d1e7bf
Support async __await__
inumanag Jan 29, 2026
94236ab
Add generator flag to await instruction
arshajii Jan 29, 2026
80c9a37
Add AwaitExpr flag
inumanag Jan 30, 2026
cd5bd92
Fix reversed()
inumanag Jan 31, 2026
900453c
Fix await instruction in IR
arshajii Feb 1, 2026
728792a
Fix GPU codegen if no kernels present
arshajii Feb 3, 2026
0c05223
Fix and/or side effects and static short-circuit
inumanag Feb 4, 2026
cbb03eb
Fix reversed
inumanag Feb 4, 2026
1b1b52b
Fix stride checks
arshajii Feb 4, 2026
dad37fb
Add assertion to LLVM codegen
arshajii Feb 4, 2026
5942304
Fix GPU name cleaning
arshajii Feb 4, 2026
bc04c24
Add GPU target selection flags
arshajii Feb 4, 2026
31c0c72
Fix dict.get()
arshajii Feb 5, 2026
b87863f
Fix ForFlow initialization
arshajii Feb 5, 2026
acbb7cc
Fix dict test
arshajii Feb 5, 2026
dec0074
Fix docs build
arshajii Feb 5, 2026
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ jobs:
contents: write
id-token: write
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.11'

Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
Expand All @@ -109,10 +109,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install git+https://${{ secrets.GH_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
python -m pip install mkdocs \
mkdocs-autorefs \
mkdocs-macros-plugin \
mkdocs-material \
mkdocs-material-extensions \
mkdocs-redirects
sudo apt-get update
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ set(CODON_HPPFILES
codon/cir/transform/folding/const_prop.h
codon/cir/transform/folding/folding.h
codon/cir/transform/folding/rule.h
codon/cir/transform/lowering/async_for.h
codon/cir/transform/lowering/await.h
codon/cir/transform/lowering/imperative.h
codon/cir/transform/lowering/pipeline.h
codon/cir/transform/manager.h
Expand Down Expand Up @@ -347,6 +349,8 @@ set(CODON_CPPFILES
codon/cir/transform/folding/const_fold.cpp
codon/cir/transform/folding/const_prop.cpp
codon/cir/transform/folding/folding.cpp
codon/cir/transform/lowering/async_for.cpp
codon/cir/transform/lowering/await.cpp
codon/cir/transform/lowering/imperative.cpp
codon/cir/transform/lowering/pipeline.cpp
codon/cir/transform/manager.cpp
Expand Down
5 changes: 5 additions & 0 deletions codon/cir/analyze/dataflow/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ struct CaptureTracker : public util::Operator {
[&](DerivedSet &dset) { dset.result.returnCaptures = true; });
}

void handle(AwaitInstr *v) override {
forEachDSetOf(v->getValue(),
[&](DerivedSet &dset) { dset.result.returnCaptures = true; });
}

void handle(ThrowInstr *v) override {
forEachDSetOf(v->getValue(), [&](DerivedSet &dset) { dset.setExternCaptured(); });
}
Expand Down
5 changes: 5 additions & 0 deletions codon/cir/analyze/dataflow/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ void CFVisitor::visit(const YieldInstr *v) {
defaultInsert(v);
}

void CFVisitor::visit(const AwaitInstr *v) {
process(v->getValue());
defaultInsert(v);
}

void CFVisitor::visit(const ThrowInstr *v) {
if (v->getValue())
process(v->getValue());
Expand Down
1 change: 1 addition & 0 deletions codon/cir/analyze/dataflow/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ class CFVisitor : public util::ConstVisitor {
void visit(const ContinueInstr *v) override;
void visit(const ReturnInstr *v) override;
void visit(const YieldInstr *v) override;
void visit(const AwaitInstr *v) override;
void visit(const ThrowInstr *v) override;
void visit(const FlowInstr *v) override;
void visit(const dsl::CustomInstr *v) override;
Expand Down
4 changes: 4 additions & 0 deletions codon/cir/analyze/module/side_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ struct SideEfectAnalyzer : public util::ConstVisitor {
set(v, max(Status::NO_CAPTURE, process(v->getValue())));
}

void visit(const AwaitInstr *v) override {
set(v, max(Status::NO_CAPTURE, process(v->getValue())));
}

void visit(const ThrowInstr *v) override {
process(v->getValue());
set(v, Status::UNKNOWN, Status::NO_CAPTURE);
Expand Down
14 changes: 12 additions & 2 deletions codon/cir/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class ForFlow : public AcceptorExtend<ForFlow, Flow> {
Var *var;
/// parallel loop schedule, or null if none
std::unique_ptr<transform::parallel::OMPSched> schedule;
/// true if loop is async
bool async;

public:
static const char NodeId;
Expand All @@ -132,11 +134,13 @@ class ForFlow : public AcceptorExtend<ForFlow, Flow> {
/// @param iter the iterator
/// @param body the body
/// @param var the variable
/// @param schedule the parallel schedule
/// @param async true if loop is async
/// @param name the flow's name
ForFlow(Value *iter, Flow *body, Var *var,
std::unique_ptr<transform::parallel::OMPSched> schedule = {},
std::string name = "")
: AcceptorExtend(std::move(name)), iter(iter), body(body), var(var),
bool async = false, std::string name = "")
: AcceptorExtend(std::move(name)), iter(iter), body(body), var(var), async(async),
schedule(std::move(schedule)) {}

/// @return the iter
Expand Down Expand Up @@ -184,6 +188,12 @@ class ForFlow : public AcceptorExtend<ForFlow, Flow> {
schedule = std::move(s);
}

/// @return true if async
bool isAsync() const { return async; }
/// Sets async status.
/// @param a true if async
void setAsync(bool a = true) { async = a; }

protected:
std::vector<Value *> doGetUsedValues() const override;
int doReplaceUsedValue(id_t id, Value *newValue) override;
Expand Down
2 changes: 1 addition & 1 deletion codon/cir/func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Func::realize(types::Type *newType, const std::vector<std::string> &names)

auto i = 0;
for (auto *t : *funcType) {
args.push_back(getModule()->Nr<Var>(t, false, false, names[i]));
args.push_back(getModule()->Nr<Var>(t, false, false, false, names[i]));
++i;
}
}
Expand Down
12 changes: 10 additions & 2 deletions codon/cir/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Func : public AcceptorExtend<Func, Var> {
std::string unmangledName;
/// whether the function is a generator
bool generator;
/// whether the function is an async function
bool async;
/// Parent type if func is a method, or null if not
types::Type *parentType;

Expand All @@ -35,8 +37,8 @@ class Func : public AcceptorExtend<Func, Var> {
/// Constructs an unrealized CIR function.
/// @param name the function's name
explicit Func(std::string name = "")
: AcceptorExtend(nullptr, true, false, std::move(name)), generator(false),
parentType(nullptr) {}
: AcceptorExtend(nullptr, true, false, false, std::move(name)), generator(false),
async(false), parentType(nullptr) {}

/// Re-initializes the function with a new type and names.
/// @param newType the function's new type
Expand Down Expand Up @@ -73,6 +75,12 @@ class Func : public AcceptorExtend<Func, Var> {
/// @param v the new value
void setGenerator(bool v = true) { generator = v; }

/// @return true if the function is an async function
bool isAsync() const { return async; }
/// Sets the function's async flag.
/// @param v the new value
void setAsync(bool v = true) { async = v; }

/// @return the variable corresponding to the given argument name
/// @param n the argument name
Var *getArgVar(const std::string &n);
Expand Down
18 changes: 18 additions & 0 deletions codon/cir/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ int YieldInInstr::doReplaceUsedType(const std::string &name, types::Type *newTyp
return 0;
}

const char AwaitInstr::NodeId = 0;

int AwaitInstr::doReplaceUsedValue(id_t id, Value *newValue) {
if (value->getId() == id) {
value = newValue;
return 1;
}
return 0;
}

int AwaitInstr::doReplaceUsedType(const std::string &name, types::Type *newType) {
if (type->getName() == name) {
type = newType;
return 1;
}
return 0;
}

const char TernaryInstr::NodeId = 0;

int TernaryInstr::doReplaceUsedValue(id_t id, Value *newValue) {
Expand Down
47 changes: 46 additions & 1 deletion codon/cir/instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class YieldInInstr : public AcceptorExtend<YieldInInstr, Instr> {
/// @param v the new value
void setSuspending(bool v = true) { suspend = v; }

/// Sets the type being inspected
/// Sets the type.
/// @param t the new type
void setType(types::Type *t) { type = t; }

Expand Down Expand Up @@ -477,6 +477,7 @@ class ReturnInstr : public AcceptorExtend<ReturnInstr, ControlFlowInstr> {
int doReplaceUsedValue(id_t id, Value *newValue) override;
};

/// Instr representing a yield statement.
class YieldInstr : public AcceptorExtend<YieldInstr, Instr> {
private:
/// the value
Expand Down Expand Up @@ -509,6 +510,50 @@ class YieldInstr : public AcceptorExtend<YieldInstr, Instr> {
int doReplaceUsedValue(id_t id, Value *newValue) override;
};

/// Instr representing an await statement.
class AwaitInstr : public AcceptorExtend<AwaitInstr, Instr> {
private:
/// the value
Value *value;
/// the type of the result
types::Type *type;
/// true if argument is a generator (e.g. custom __await__)
bool generator;

public:
static const char NodeId;

explicit AwaitInstr(Value *value, types::Type *type, bool generator = false,
std::string name = "")
: AcceptorExtend(std::move(name)), value(value), type(type),
generator(generator) {}

/// @return the value
Value *getValue() { return value; }
/// @return the value
const Value *getValue() const { return value; }
/// Sets the value.
/// @param v the new value
void setValue(Value *v) { value = v; }

/// Sets the type.
/// @param t the new type
void setType(types::Type *t) { type = t; }

/// @return whether argument is a generator
bool isGenerator() const { return generator; }
/// Sets generator status
/// @param g the new value
void setGenerator(bool g = true) { generator = g; }

protected:
types::Type *doGetType() const override { return type; }
std::vector<Value *> doGetUsedValues() const override { return {value}; }
std::vector<types::Type *> doGetUsedTypes() const override { return {type}; }
int doReplaceUsedValue(id_t id, Value *newValue) override;
int doReplaceUsedType(const std::string &name, types::Type *newType) override;
};

class ThrowInstr : public AcceptorExtend<ThrowInstr, Instr> {
private:
/// the value
Expand Down
Loading
Loading