Closed
Description
In https://dart-review.googlesource.com/c/sdk/+/402860 I have a getter I am trying to call from the native code.
In Dart code, the getter is called like this:
int _tickCount = 0;
@pragma('vm:entry-point')
int get ticks => _tickCount;
And in native code, I am trying to call it like this:
Dart_GetField(Dart_RootLibrary(), Dart_NewStringFromCString("ticks"))
When I change pragma to @pragma('vm:entry-point', 'call')
, I get the following error (both in AOT and Kernel mode):
ERROR: To retrieve the value of 'file:///usr/local/google/home/iinozemtsev/work/dart-sdk/sdk/samples/embedder/timer.dart::ticks (kind GetterFunction)' from native code, it must be annotated.
ERROR: See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
When I change pragma to @pragma('vm:entry-point', 'get')
, then it works fine in Kernel mode, but in AOT mode it fails with the following error:
../../runtime/vm/dart_entry.cc: 145: error: expected: function.HasCode()
version=3.7.0-edge.193a852639ed45c9314d9e6f72f763338fba86e3 (main) (Thu Jan 16 13:45:19 2025 +0100) on "linux_x64"
pid=1218004, thread=1218004, isolate_group=file://out/DebugX64/timer_aot.snapshot(0x55597b637410), isolate=file://out/DebugX64/timer_aot.snapshot(0x55597b63ebe0)
os=linux, arch=x64, comp=no, sim=no
isolate_instructions=7f85cdb36f40, vm_instructions=7f85cdb2f000
fp=7ffe8fdb0b40, sp=7ffe8fdb0a10, pc=7f85cf1749ac
pc 0x00007f85cf1749ac fp 0x00007ffe8fdb0b40 /usr/local/google/home/iinozemtsev/work/dart-sdk/sdk/out/DebugX64/libeasy_embedder_aot_shared.so+0x5749ac
pc 0x00007f85cef920a4 fp 0x00007ffe8fdb0c20 /usr/local/google/home/iinozemtsev/work/dart-sdk/sdk/out/DebugX64/libeasy_embedder_aot_shared.so+0x3920a4
pc 0x00007f85cf025122 fp 0x00007ffe8fdb0c90 /usr/local/google/home/iinozemtsev/work/dart-sdk/sdk/out/DebugX64/libeasy_embedder_aot_shared.so+0x425122
pc 0x00007f85cf6f3285 fp 0x00007ffe8fdb0d70 Dart_GetField+0x475
pc 0x000055594517db9a fp 0x00007ffe8fdb0e00 out/DebugX64/run_timer_aot+0x39b9a
-- End of DumpStackTrace