E
Eric
I have been researching how exceptions and dynamic_cast work to
determine if I will use either feature for a game-console application.
I have a few pre-concieved notions and questions that I was hoping
some people here could validate/answer.
PRECONCEIVED NOTION #1: Common implementations of dynamic_cast<>
(VC++, GCC) rely on the presence of type_info objects. The use of
strcmp() instead of type_info pointer-equivalence in common
implementations is used ONLY to support non-statically linked
applications (.dll's & such). Other than this requirement,
dynamic_cast<> conceptually would never need the type_info::name
strings. typeid(), on the other hand, must have type_info::name
strings to fulfill it's function regardless of whether the app is
entirely statically linked or not.
QUESTION #1: Given that I am writing a statically-linked game-console
app and I am only interested in dynamic_cast and not typeid(), it
would benefit me to not have type_info::name strings added to my app
and have dynamic_cast implemented using type_info pointer equivalence.
Can gcc do this??
PRECONCEIVED NOTION #2: Exception handling (the more attractive
feature to me) actually requires dynamic_cast<> to implement the
catch-by-type mechanism, which in turn requires strcmp() to support
non-statically linked apps, which in turn requires a full
type_info::name string for every type in my code regardless of whether
or not it is ever thrown.
QUESTION #2: Given that this amounts to unnecessary size-bloat for my
statically linked game-console app, does anyone know if gcc can
implement catch-by-type using type_info pointer equivalence and
suppress the type_info::name strings?
PRECONCEIVED NOTION #3: The best implementations of exception handling
out there use the zero-runtime-cost model (I understand that VC++ does
not, but gcc does). I understand that this model has no performance
penalties when not throwing because the stack is unwound using an
exteral table of ip-sorted elements rather than inserting code into
every function. In addition to the typename strings that are
theoretically irrelevant to statically linked apps, zero-runtime-cost
models also have to add this instruction-pointer table to the app, and
the table must cover every single function in the code regardless of
whether or not it throws.
QUESTION #3: Can anyone characterize the structure of the elements in
such a table so that I can get my head around the size implications of
it? Is there one entry per instantiation of objects with actual
destructors?
Thanks for any insight you can give on any of these issues.
-Eric
determine if I will use either feature for a game-console application.
I have a few pre-concieved notions and questions that I was hoping
some people here could validate/answer.
PRECONCEIVED NOTION #1: Common implementations of dynamic_cast<>
(VC++, GCC) rely on the presence of type_info objects. The use of
strcmp() instead of type_info pointer-equivalence in common
implementations is used ONLY to support non-statically linked
applications (.dll's & such). Other than this requirement,
dynamic_cast<> conceptually would never need the type_info::name
strings. typeid(), on the other hand, must have type_info::name
strings to fulfill it's function regardless of whether the app is
entirely statically linked or not.
QUESTION #1: Given that I am writing a statically-linked game-console
app and I am only interested in dynamic_cast and not typeid(), it
would benefit me to not have type_info::name strings added to my app
and have dynamic_cast implemented using type_info pointer equivalence.
Can gcc do this??
PRECONCEIVED NOTION #2: Exception handling (the more attractive
feature to me) actually requires dynamic_cast<> to implement the
catch-by-type mechanism, which in turn requires strcmp() to support
non-statically linked apps, which in turn requires a full
type_info::name string for every type in my code regardless of whether
or not it is ever thrown.
QUESTION #2: Given that this amounts to unnecessary size-bloat for my
statically linked game-console app, does anyone know if gcc can
implement catch-by-type using type_info pointer equivalence and
suppress the type_info::name strings?
PRECONCEIVED NOTION #3: The best implementations of exception handling
out there use the zero-runtime-cost model (I understand that VC++ does
not, but gcc does). I understand that this model has no performance
penalties when not throwing because the stack is unwound using an
exteral table of ip-sorted elements rather than inserting code into
every function. In addition to the typename strings that are
theoretically irrelevant to statically linked apps, zero-runtime-cost
models also have to add this instruction-pointer table to the app, and
the table must cover every single function in the code regardless of
whether or not it throws.
QUESTION #3: Can anyone characterize the structure of the elements in
such a table so that I can get my head around the size implications of
it? Is there one entry per instantiation of objects with actual
destructors?
Thanks for any insight you can give on any of these issues.
-Eric