Skip to content

Commit aead6c7

Browse files
committed
document ModuleInfo
1 parent 6c72655 commit aead6c7

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

spec/abi.dd

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -957,32 +957,70 @@ $(H2 $(LNAME2 garbage_collection, Garbage Collection))
957957

958958
$(P The interface to this is found in Druntime's $(DRUNTIMESRC core/gc/gcinterface.d).)
959959

960-
$(H2 $(LNAME2 runtime_helper_functions, Runtime Helper Functions))
960+
$(H2 $(LNAME2 ModuleInfo, ModuleInfo Instance))
961961

962-
$(P These are found in Druntime's $(DRUNTIMESRC rt/).)
962+
$(P An instance of $(LINK2 https://dlang.org/phobos/object.html#.ModuleInfo, `ModuleInfo`)
963+
is generated by the compiler and inserted into the object file for every module.
964+
`ModuleInfo` contains information about the module that is useful to the D runtime library:
965+
)
966+
967+
$(UL
968+
$(LI If the module has a static constructor, static destructor, shared static constructor, or shared static destructor.)
969+
$(LI A reference to any unit tests defined by the module.)
970+
$(LI An array of references to any imported modules that have one or more of:
971+
$(OL
972+
$(LI static constructors)
973+
$(LI static destructors)
974+
$(LI shared static constructors)
975+
$(LI shared static destructors)
976+
$(LI unit tests)
977+
$(LI transitive imports of any module that contains one or more of 1..5)
978+
$(LI order independent constructors (currently needed for implementing
979+
$(DDSUBLINK dmd, switch-cov, $(TT -cov))))
980+
)
981+
This enables the runtime to run the unit tests,
982+
the module constructors in a depth-first order,
983+
and the module destructors in the reverse order.
984+
)
985+
986+
$(LI An array of references to `ClassInfo` for each class defined in the module.
987+
$(NOTE this feature may be removed.))
988+
)
989+
990+
$(P `ModuleInfo` is defined in Druntime's $(DRUNTIMESRC object.d).)
991+
992+
$(P Modules compiled with $(DDSUBLINK dmd, switch-betterC, $(TT -betterC))
993+
do not have a `ModuleInfo` instance generated, because such modules must work
994+
without the D runtime library.
995+
Similarly, $(DDLINK spec/importc, ImportC, ImportC) modules do not generate a `ModuleInfo`.
996+
)
963997

964-
$(H2 $(LNAME2 module_init_and_fina, Module Initialization and Termination))
998+
$(H3 $(LNAME2 module_init_and_fina, Module Initialization and Termination))
965999

9661000
$(P All the static constructors for a module are aggregated into a
9671001
single function, and a pointer to that function is inserted
968-
into the ctor member of the ModuleInfo instance for that
1002+
into the ctor member of the `ModuleInfo` instance for that
9691003
module.
9701004
)
9711005

9721006
$(P All the static destructors for a module are aggregated into a
9731007
single function, and a pointer to that function is inserted
974-
into the dtor member of the ModuleInfo instance for that
1008+
into the dtor member of the `ModuleInfo` instance for that
9751009
module.
9761010
)
9771011

978-
$(H2 $(LNAME2 unit_testing, Unit Testing))
1012+
$(H3 $(LNAME2 unit_testing, Unit Testing))
9791013

9801014
$(P All the unit tests for a module are aggregated into a
9811015
single function, and a pointer to that function is inserted
982-
into the unitTest member of the ModuleInfo instance for that
1016+
into the unitTest member of the `ModuleInfo` instance for that
9831017
module.
9841018
)
9851019

1020+
$(H2 $(LNAME2 runtime_helper_functions, Runtime Helper Functions))
1021+
1022+
$(P These are found in Druntime's $(DRUNTIMESRC rt/).)
1023+
9861024
$(H2 $(LNAME2 symbolic_debugging, Symbolic Debugging))
9871025

9881026
$(P D has types that are not represented in existing C or C++ debuggers.

spec/betterc.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ $(H2 $(LNAME2 consequences, Unavailable Features))
122122

123123
$(OL
124124
$(LI Garbage Collection)
125-
$(LI TypeInfo and ModuleInfo)
125+
$(LI TypeInfo and (DDSUBLINK abi, ModuleInfo, $(TT ModuleInfo)))
126126
$(LI Classes)
127127
$(LI Built-in threading (e.g. $(MREF core, thread)))
128128
$(LI Dynamic arrays (though slices of static arrays work) and associative arrays)

spec/ddoc.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ $(P
905905
$(LI Postblits)
906906
$(LI Destructors)
907907
$(LI Static constructors and static destructors)
908-
$(LI Class info, type info, and module info)
908+
$(LI Class info, type info, and $(DDSUBLINK abi, ModuleInfo, module info))
909909
)
910910

911911
$(H2 $(LNAME2 macros, Macros))

spec/version.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ $(H3 $(LEGACY_LNAME2 PredefinedVersions, predefined-versions, Predefined Version
321321
(command line switch $(DDSUBLINK dmd, switch-betterC, $(TT -betterC))) is being generated))
322322
$(TROW $(ARGS $(D D_Exceptions)) , $(ARGS Exception handling is supported. Evaluates to `false` when compiling with
323323
command line switch $(DDSUBLINK dmd, switch-betterC, $(TT -betterC))))
324-
$(TROW $(ARGS $(D D_ModuleInfo)) , $(ARGS `ModuleInfo` is supported. Evaluates to `false` when compiling with
324+
$(TROW $(ARGS $(D D_ModuleInfo)) , $(ARGS $(DDSUBLINK abi, ModuleInfo, $(TT ModuleInfo)) is supported. Evaluates to `false` when compiling with
325325
command line switch $(DDSUBLINK dmd, switch-betterC, $(TT -betterC))))
326326
$(TROW $(ARGS $(D D_TypeInfo)) , $(ARGS Runtime type information (a.k.a `TypeInfo`) is supported. Evaluates to `false` when compiling with
327327
command line switch $(DDSUBLINK dmd, switch-betterC, $(TT -betterC))))

0 commit comments

Comments
 (0)