]> gcc.gnu.org Git - gcc.git/commit
initialize fde objects lazily
authorThomas Neumann <tneumann@users.sourceforge.net>
Fri, 9 Dec 2022 17:23:44 +0000 (18:23 +0100)
committerThomas Neumann <tneumann@users.sourceforge.net>
Fri, 16 Dec 2022 23:48:25 +0000 (00:48 +0100)
commit6e56633daae79f514b0e71f4d9849bcd8d9ce71f
treeca386c29cd4093b38d5b84ac429157550b2edc50
parent1c118c9970600117700cc12284587e0238de6bbe
initialize fde objects lazily

When registering an unwind frame with __register_frame_info_bases
we currently initialize that fde object eagerly. This has the
advantage that it is immutable afterwards and we can safely
access it from multiple threads, but it has the disadvantage
that we pay the initialization cost even if the application
never throws an exception.

This commit changes the logic to initialize the objects lazily.
The objects themselves are inserted into the b-tree when
registering the frame, but the sorted fde_vector is
not constructed yet. Only on the first time that an
exception tries to pass through the registered code the
object is initialized. We notice that with a double checking,
first doing a relaxed load of the sorted bit and then re-checking
under a mutex when the object was not initialized yet.

Note that the check must implicitly be safe concering a concurrent
frame deregistration, as trying the deregister a frame that is
on the unwinding path of a concurrent exception is inherently racy.

libgcc/ChangeLog:
* unwind-dw2-fde.c: Initialize fde object lazily when
the first exception tries to pass through.
libgcc/unwind-dw2-fde.c
This page took 0.060106 seconds and 5 git commands to generate.