Skip to content

[Backport release/1.16] Add __crystal_raise_cast_failed for non-interpreted code#15712

Merged
straight-shoota merged 2 commits intorelease/1.16from
backport-15708-to-release/1.16
Apr 28, 2025
Merged

[Backport release/1.16] Add __crystal_raise_cast_failed for non-interpreted code#15712
straight-shoota merged 2 commits intorelease/1.16from
backport-15708-to-release/1.16

Conversation

@crysbot
Copy link
Collaborator

@crysbot crysbot commented Apr 27, 2025

Automated backport of #15708 to release/1.16, triggered by a label.

This completely circumvents the slow `MainVisitor` invocation per compiler-generated `raise(TypeCastError.new(...))` call by reimplementing the raise using a top-level fun plus LLVM instructions. It also partially addresses the issue where the codegen phase could theoretically instantiate new types due to the use of a `MainVisitor` (the only remaining place is `#cant_pass_closure_to_c_exception_call`).

There is now an internal `~type_id_to_class_name` function that returns the type name corresponding to a given instance type ID. It works even when `Class#name` is not implemented in the standard library. This might be useful for other purposes, such as debugger tooling.

(cherry picked from commit e3c1224)
@straight-shoota
Copy link
Member

straight-shoota commented Apr 28, 2025

CI is failing all over the place 🙈

  • The macOS workflow failing to install nixpkgs also happened on master. Not sure what's going on but it seemed to be a fluke fixed by a retry.
  • The windows failures seem to require Only set up Cygwin on Windows CI if truly required #15661, which we need to backport to 1.16 as well.
  • No idea what's wrong on MinGW but it got fixed by a retry as well.

@straight-shoota straight-shoota merged commit ac360a0 into release/1.16 Apr 28, 2025
68 of 69 checks passed
@straight-shoota straight-shoota deleted the backport-15708-to-release/1.16 branch April 28, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants