feat: implements outofmemoryerror handling

This commit is contained in:
Guy C
2025-02-28 11:58:38 +00:00
parent f2a1eaf24c
commit b733d233b0
2 changed files with 24 additions and 3 deletions

View File

@@ -141,8 +141,13 @@ object asmGenerator {
chain ++= wrapBuiltinFunc(
labelGenerator.getLabel(Builtin.Malloc),
Chain(stackAlign, assemblyIR.Call(CLibFunc.Malloc))
// Out of memory check is optional
Chain(
stackAlign,
assemblyIR.Call(CLibFunc.Malloc),
// Out of memory check
Compare(RAX, ImmediateVal(0)),
Jump(LabelArg(OutOfMemoryError.errLabel), Cond.Equal)
)
)
chain ++= wrapBuiltinFunc(