Re:Exception-handling changes relevant for g++?
on
C++ In The Linux kernel
·
· Score: 2, Informative
These changes would definately be applicable to user space as well, and indeed we mention it in our paper. In kernel however they are more important as performance is normally of more concern.
Ideally you should be able to turn on these optimizations by a switch. If any g++ developer is out there I'd be more than happy to explain what we did and they are free to use it.
Some of the overhead in the g++ exception implementation arises from the fact that ease of debugging is considered important. However in kernel space that does not apply.
this of course depends on the C++ implementation but G++ compares the pointers to a Type Information object (the one that is returned with the typeid operator). The second entry in each virtual table produced by G++ happens to be a pointer to this type information object.
Just to clarify things...
The user space linker ensures that there is one copy of each RTTI object so in user space dynamic type checking is based on pointer comparison.
The problem arise in the Linux kernel. The kernel module loader (located in kernel/module.c) does not handle weak symbols to ensure that there is only one copy, so that to be sure that dynamic type checking works string comparison is needed.
It seems that the G++ developers have recognized this in the sense that a special preprocessor macro changes the dynamic type checking to string comparison if KERNEL is defined.
We modified the linux kernel module loader to ensure that only one copy of a weak symbol exists within the kernel and made sure that the type checking is performed with pointer comparison
These changes would definately be applicable to user space as well, and indeed we mention it in our paper. In kernel however they are more important as performance is normally of more concern.
Ideally you should be able to turn on these optimizations by a switch. If any g++ developer is out there I'd be more than happy to explain what we did and they are free to use it.
Some of the overhead in the g++ exception implementation arises from the fact that ease of debugging is considered important. However in kernel space that does not apply.
Just to make it absolutely clear this C++ patch is free for everybody to use.
this of course depends on the C++ implementation but G++ compares the pointers to a Type Information object (the one that is returned with the typeid operator). The second entry in each virtual table produced by G++ happens to be a pointer to this type information object.
Just to clarify things... The user space linker ensures that there is one copy of each RTTI object so in user space dynamic type checking is based on pointer comparison. The problem arise in the Linux kernel. The kernel module loader (located in kernel/module.c) does not handle weak symbols to ensure that there is only one copy, so that to be sure that dynamic type checking works string comparison is needed. It seems that the G++ developers have recognized this in the sense that a special preprocessor macro changes the dynamic type checking to string comparison if KERNEL is defined. We modified the linux kernel module loader to ensure that only one copy of a weak symbol exists within the kernel and made sure that the type checking is performed with pointer comparison