Skip to content

Commit 0e4add4

Browse files
authored
Merge pull request #11489 from Ivorforce/trivially-relocatable
Add some information about relocation safety.
2 parents 0380fe5 + d03fcc8 commit 0e4add4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

engine_details/architecture/core_types.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,21 @@ scripting API.
150150
.. |typed_dictionary| replace:: `TypedDictionary <https://github.com/godotengine/godot/blob/master/core/variant/typed_dictionary.h>`__
151151
.. |pair| replace:: `Pair <https://github.com/godotengine/godot/blob/master/core/templates/pair.h>`__
152152

153+
Relocation safety
154+
^^^^^^^^^^^^^^^^^
155+
156+
Godot's containers assume their elements are `trivially relocatable <https://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1144r5.html>`__.
157+
158+
This means that, if you store data types in it that have pointers to themselves, or are otherwise
159+
`not trivially relocatable <https://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1144r5.html#non-trivial-samples>`__,
160+
Godot might crash. Note that storing **pointers to** objects that are not trivially relocatable, such as some Object
161+
subclasses, is unproblematic and supported.
162+
163+
The reason to assume trivial relocatability is that it allows us to make use of important optimization techniques, such
164+
as relocation by ``memcpy`` or ``realloc``.
165+
166+
`GH-100509 <https://github.com/godotengine/godot/issues/100509>`__ tracks this decision.
167+
153168
.. _doc_core_concurrency_types:
154169

155170
Multithreading / Concurrency

0 commit comments

Comments
 (0)