rtti: self-contained annotation info in debug info (AnnotationInfo/AnnotationArgumentInfo)#3101
Merged
Merged
Conversation
…notationArgumentInfo) Debug info no longer aliases the AST: struct/field/global/function/enum annotations are deep-copied into the context DebugInfoAllocator as POD AnnotationInfo / AnnotationArgumentInfo, so a Context can reflect them after its Program is released. 'options rtti' is no longer required for annotation reflection (or json field annotations); its only remaining effect is keeping context.thisProgram for compile-time introspection. - VarInfo.annotation_arguments: void* -> AnnotationArgumentInfo* + count - StructInfo.annotation_list: void* -> AnnotationInfo* + count - FuncInfo/EnumInfo/globals gain annotation reflection (new) - TypeInfo.annotation_or_name -> annotation_info; the ~-padded tagged pointer dies; Module::resolveAnnotation resolves name+module against the bound environment with a cached 'resolved' pointer - DebugInfoHelper::rtti deleted; init values + builtin cppName un-gated - new das API: each_annotation / each_annotation_argument / get_annotation / get_annotation_argument / resolve_annotation / get_annotation_argument_value(AnnotationArgumentInfo); old structure_for_each_annotation kept as a [deprecated] shim that reconstructs the AST-shaped pair per invoke - AOT emits pure static annotation data; the init-time field-annotation fixup and DAS_MAKE_ANNOTATION are gone - JIT: varinfo-annotation ctor/dtor shims and the wasm tagged-pointer handle_typeinfo ctor deleted (all static now); JIT gains struct/enum annotation lists; LLVM_JIT_CODEGEN_VERSION 0x25 -> 0x26 - tests: tests/language/annotation_info.das (no options rtti), tests-cpp/small/test_annotation_lifetime (reflect after ProgramPtr release); docs + handmade RST regenerated Design doc: ANNOTATION_INFO_REWORK.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The das-side DebugInfoHelper.rtti field is gone; the leftover positional doc line leaked into generated RST as stray text and failed sphinx -W. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks runtime debug-info annotation storage so it is self-contained (no longer aliases AST memory), enabling safe annotation reflection from a live Context even after its Program is released and without requiring options rtti.
Changes:
- Introduces POD
AnnotationInfo/AnnotationArgumentInfoindebug_info.hand updatesVarInfo/StructInfo/FuncInfo/EnumInfo/TypeInfolayouts to store deep-copied annotation data plus counts. - Updates interpreter/JIT/AOT paths (including LLVM JIT data layouts and AOT emitters) to generate/consume static or debug-heap annotation data without runtime ctor/dtor shims.
- Adds new rtti APIs (
each_annotation,each_annotation_argument,get_annotation*,resolve_annotation) and test coverage validating lifetime safety and reflection behavior.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/daslang-live/main.cpp | Updates lifetime comment now that annotations no longer alias AST memory. |
| tutorials/integration/cpp/06_interop.cpp | Updates TypeInfo union documentation comment to annotation_info. |
| tests/language/annotation_info.das | Adds language-level tests for new annotation reflection APIs without options rtti. |
| tests-cpp/small/test_annotation_lifetime.das | Adds fixture validating annotation reflection after Program release. |
| tests-cpp/small/test_annotation_lifetime.cpp | Adds C++ doctest ensuring annotation data survives ProgramPtr reset. |
| src/simulate/json_scan.cpp | Migrates JSON field rename handling to new AnnotationArgumentInfo array representation. |
| src/simulate/json_print.cpp | Migrates JSON print options (rename, optional, etc.) to new annotation arg representation. |
| src/builtin/module_jit.cpp | Removes obsolete JIT varinfo-annotation init/free shims and exports. |
| src/builtin/module_builtin_rtti.h | Registers new external type factories for AnnotationInfo and AnnotationArgumentInfo. |
| src/builtin/module_builtin_rtti.cpp | Adds managed bindings + new rtti externs (get_annotation*, resolve_annotation, new value overload). |
| src/ast/ast_simulate.cpp | Removes DebugInfoHelper::rtti gating; debug capture becomes unconditional. |
| src/ast/ast_module.cpp | Replaces tagged-pointer annotation_or_name resolution with AnnotationInfo-based resolution + caching. |
| src/ast/ast_debug_info_helper.cpp | Implements deep-copy of annotation lists/args into DebugInfoAllocator and populates new debug-info fields. |
| skills/cpp_integration.md | Updates documentation for TypeInfo union member rename and new semantics. |
| modules/dasLLVM/daslib/llvm_jit.das | Updates LLVM JIT struct layouts and emits static annotation globals (removes ctor/dtor shims). |
| modules/dasLLVM/daslib/llvm_jit_run.das | Bumps LLVM_JIT_CODEGEN_VERSION to invalidate caches after ABI/layout changes. |
| include/daScript/simulate/debug_info.h | Adds AnnotationInfo/AnnotationArgumentInfo, updates debug-info struct layouts and constructors. |
| include/daScript/simulate/aot.h | Removes DAS_MAKE_ANNOTATION macro no longer needed with name-based AnnotationInfo. |
| include/daScript/simulate/aot_builtin_rtti.h | Declares new rtti AOT builtins for annotation access and value decoding. |
| include/daScript/ast/ast.h | Removes DebugInfoHelper::rtti and adds Module::resolveAnnotation(const AnnotationInfo*). |
| include/daScript/ast/ast_visitor.h | Removes now-obsolete helper.rtti = true in visitor init. |
| doc/source/stdlib/handmade/structure_annotation-rtti-StructInfo.rst | Documents new annotation_count field. |
| doc/source/stdlib/handmade/structure_annotation-rtti-FuncInfo.rst | Documents new annotation_count field. |
| doc/source/stdlib/handmade/structure_annotation-rtti-EnumInfo.rst | Documents new annotation_count field. |
| doc/source/stdlib/handmade/structure_annotation-rtti-DebugInfoHelper.rst | Removes obsolete rtti field documentation. |
| doc/source/stdlib/handmade/structure_annotation-rtti-AnnotationInfo.rst | Adds docs for new AnnotationInfo structure. |
| doc/source/stdlib/handmade/structure_annotation-rtti-AnnotationArgumentInfo.rst | Adds docs for new AnnotationArgumentInfo structure. |
| doc/source/stdlib/handmade/function-rtti-resolve_annotation-0xdf30cb3959a59b9e.rst | Documents new resolve_annotation function. |
| doc/source/stdlib/handmade/function-rtti-get_annotation-0xdbc45dc33bc67300.rst | Documents new get_annotation function. |
| doc/source/stdlib/handmade/function-rtti-get_annotation_argument-0xcf249595f05c3934.rst | Documents new get_annotation_argument function. |
| doc/source/reference/tutorials/integration_cpp_06_interop.rst | Updates tutorial docs for TypeInfo union and handled-type annotation resolution. |
| doc/source/reference/embedding/cpp_api.rst | Updates embedding docs for TypeInfo union member rename. |
| doc/reflections/das2rst.das | Extends rtti doc grouping to include the new annotation APIs. |
| daslib/rtti.das | Adds each_annotation* iterators, get_annotation* accessors, and deprecates old shim API. |
| daslib/aot_standalone.das | Removes obsolete rtti gating in AOT standalone generator and tidies unused-arg handling. |
| daslib/aot_cpp.das | Updates AOT debug-info emission to generate static AnnotationInfo/AnnotationArgumentInfo and handled-type statics. |
| ANNOTATION_INFO_REWORK.md | Adds design doc explaining motivation, design, tier impacts, and known limitations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ionArgumentInfo) Copilot review: use the (const char*, length) allocateString overload instead of constructing a temporary string per call. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e string passes Copilot review round 2: - aot_cpp writeAnnotationArgInit: sValue now goes through escape() (an annotation string with quotes/backslashes generated invalid C++ - same latent bug existed in the old options-rtti field emission), and floats emit via to_cpp_float for the FLT_DECIMAL_DIG=9 roundtrip guarantee - llvm_jit: pass AnnotationInfo/AnnotationArgumentInfo string fields via interpolation - llvm_jit.das is AOT-compiled for jit.exe, and the const char*-backed fields fail that C++ compile when passed directly (the string() wraps removed for PERF020 were load-bearing) - annotation_info.das: v_esc argument pins the escape roundtrip; also documents that annotation string_constant unescapes only \" - backslashes pass through literally Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment on lines
+45
to
+48
| | struct | before | after | | ||
| |---|---|---| | ||
| | `VarInfo` | `void * annotation_arguments` | `AnnotationArgumentInfo * annotation_arguments; uint32_t annotation_count` | | ||
| | `StructInfo` | `void * annotation_list` | `AnnotationInfo * annotations; uint32_t annotation_count` | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Debug info no longer aliases the AST. Struct / field / global / function / enum annotations are deep-copied into the context
DebugInfoAllocatoras PODAnnotationInfo/AnnotationArgumentInfo, so aContextcan reflect them after itsProgramis released.options rttiis no longer required for annotation reflection (or for json field annotations like@rename/enum_as_int); its only remaining effect is keepingcontext.thisProgramfor compile-time introspection (this_program(),ast_typedecl).Design doc:
ANNOTATION_INFO_REWORK.md(in this PR).Core
VarInfo.annotation_arguments:void*into the AST → flatAnnotationArgumentInfo*+annotation_argument_countStructInfo.annotation_list:void*→AnnotationInfo*+annotation_countFuncInfo/EnumInfo/ globals gain annotation reflection (new coverage)TypeInfo.annotation_or_name→AnnotationInfo* annotation_info; the~-padded tagged-pointer hack dies.Module::resolveAnnotationresolves name+module against the bound environment, caching successful lookups inAnnotationInfo::resolved(write gated byg_resolve_annotations, as before)DebugInfoHelper::rttideleted; field init-value capture and builtincppNameare unconditional nowdas API (rtti)
New:
each_annotation(StructInfo|FuncInfo|EnumInfo),each_annotation_argument(AnnotationInfo|VarInfo),get_annotation,get_annotation_argument,resolve_annotation(AnnotationInfo) : Annotation?, plus aget_annotation_argument_value(AnnotationArgumentInfo)overload.Deprecated (kept working):
structure_for_each_annotationis now a[deprecated]/setDeprecatedshim that env-resolves theAnnotation*and reconstructs an AST-shapedAnnotationArgumentListper invoke — it works withoutoptions rttinow.AOT / JIT
AnnotationInfostatics for handled types, per-fieldAnnotationArgumentInfoarrays, struct/func/enum lists). The init-time field-annotation fixup andDAS_MAKE_ANNOTATIONare gone — nostd::stringconstruction at loadjit_initialize/free_varinfo_annotationsshims and the wasm tagged-pointerhandle_typeinfo_constructordeleted (everything is plain static data); JIT gains struct/enum annotation lists (previously always null);LLVM_JIT_CODEGEN_VERSION0x25 → 0x26Tests
tests/language/annotation_info.das— struct/field/function/enum annotations, all four argument value types,resolve_annotation, deprecated-shim parity; deliberately nooptions rttitests-cpp/small/test_annotation_lifetime— reflects annotations from a liveContextafter theProgramPtris released (thisProgram == null) — the actual bug being fixedValidation
test_aot -use-aot … --use-aot)tests/jit_tests+tests/json, full link via clang-cl)-L small-W)Notes:
utils/mcp/test_tools.das: 372/402 locally; the 30 failures are missing local externals (das-fmt.exe, ast-grep custom-language lib) in the fresh worktree, not this change — CI's linux lane has themconst char*-bound das string field (e.g.VarInfo.name, now alsoAnnotationInfo.name) directly as a function argument fails AOT C++ compilation; convention is"{x}"interpolationVarInfostatics setflag_hasInitValuebut never emit the value payloaddebug_info.hstruct layouts — external modules' C++ that reads these structs needs a rebuild (daspkg sweep planned post-merge, FIXED_ARRAY drill)🤖 Generated with Claude Code