Skip to content

cpp.Function fields don't compile with HXCPP_GC_GENERATIONAL #167

Closed

Description

@dimensionscape

With HXCPP_GC_GENERATIONAL, Haxe treats a cpp.Function field as an object and writes a barrier on _hx_v.mPtr in its setter:

inline ::cpp::Function< int (int) > _hx_set_callback(::hx::StackContext *_hx_ctx,::cpp::Function< int (int) > _hx_v) { HX_OBJ_WB(this,_hx_v.mPtr) return callback=_hx_v; }

cpp::Function (include/cpp/Pointer.h) has no mPtr, so any class with a cpp.Function field fails to compile in a generational build:

error: 'class cpp::Function<int(int)>' has no member named 'mPtr'

The generator is at fault (HaxeFoundation/haxe#13001), and HaxeFoundation/haxe#13002 fixes it, but that fix is still open and only helps future compilers. HaxeFoundation/hxcpp#1425 works around it in the runtime: under HXCPP_GC_GENERATIONAL, cpp::Function gets a static null mPtr, so the barrier current compilers emit compiles and does nothing. That's correct, since a function pointer isn't a GC object, and HX_OBJ_WB already skips a null value.

libhxcpp has the same cpp::Function. The plan is to take HaxeFoundation/hxcpp#1425 with its test: a cpp.Function field in test/haxe/TestTypes.hx, which already builds with HXCPP_GC_GENERATIONAL.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions