Skip to content

[cpp] Avoid write barriers for cpp.Function fields - #13002

Open
Tutez64 wants to merge 1 commit into
HaxeFoundation:developmentfrom
Tutez64:fix-cpp-function-generational-barrier
Open

[cpp] Avoid write barriers for cpp.Function fields#13002
Tutez64 wants to merge 1 commit into
HaxeFoundation:developmentfrom
Tutez64:fix-cpp-function-generational-barrier

Conversation

@Tutez64

@Tutez64 Tutez64 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Do not emit generational GC write barriers for cpp.Function instance fields.

With HXCPP_GC_GENERATIONAL enabled, assigning such a field generated an HX_OBJ_WB_SET call. This macro expects an object-like value with an mPtr member, but cpp::Function is a native function-pointer wrapper and does not have one, causing the generated C++ to fail to compile.

Fix

Exclude TCppFunction from GC write-barrier generation while keeping it classified as an object element for the other code paths that rely on that classification.

Tests

Added a C++ regression test which:

  • Enables HXCPP_GC_GENERATIONAL
  • Stores a native callback in a cpp.Function instance field
  • Calls the stored callback and verifies its result

The targeted misc test passes successfully.

Closes #13001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cpp] HXCPP_GC_GENERATIONAL emits an invalid write barrier for cpp.Function fields

1 participant