Re:C++ Class Objects in an OS
Posted: Thu Nov 21, 2002 6:02 pm
OK, whyme_t,
I have tried inline functions, and when I disassemble my binary I see that it is still making a call to the function, rather than putting the functions code directly into the member function. So does anyone know how to force g++ to insert the inline functions code, rather than just calling the function. ???
Also, it is possible to access the data members of the class because when the actual member function is called the 'this' pointer is passed to it, then when the inline code is called (this would be different if the inline functions code was put there instead of a call), the new return address is pushed onto the stack, so the 'this' pointer is behind it, all you have to do is skip the return code and get a copy of the 'this' pointer from behind it. Then you use this as a pointer to the data member list. Of course you must know the order of the data member list, so that you dont change the wrong values, but g++ seems to alway's create this list in the order in which they are defined in the class header, obviously out of caution you should disassemble your binary just to make sure.
I really do not want to have to use inline asm, and I would rather do (3) in Tim's list, rather than a combination of (1) and (2), because g++ makes some very poor choices in code output, I know that I can write smaller and faster code than it has output, and I am willing to do extra work to do it, however I thought that putting inline in fornt of a function would force it to be put in the place where it is called, rather than just a normal call.
I know some people think that the slight overhead of calling a function is very little, and it probably is, but I want the best, and if I have to work harder then so be it.
Anyway, hopefully someone might know how to force true inline functions, if not the I guess I will be looking at the sources for g++ (the sources are freely available aren't they?) and working out what needs to be done directly in asm, even though I will be restricted to using only this version of g++ when compiling my C++ code.
Unless I check every compilers way of name mangling and edit my sources each time. :'(
Thanks.
I have tried inline functions, and when I disassemble my binary I see that it is still making a call to the function, rather than putting the functions code directly into the member function. So does anyone know how to force g++ to insert the inline functions code, rather than just calling the function. ???
Also, it is possible to access the data members of the class because when the actual member function is called the 'this' pointer is passed to it, then when the inline code is called (this would be different if the inline functions code was put there instead of a call), the new return address is pushed onto the stack, so the 'this' pointer is behind it, all you have to do is skip the return code and get a copy of the 'this' pointer from behind it. Then you use this as a pointer to the data member list. Of course you must know the order of the data member list, so that you dont change the wrong values, but g++ seems to alway's create this list in the order in which they are defined in the class header, obviously out of caution you should disassemble your binary just to make sure.
I really do not want to have to use inline asm, and I would rather do (3) in Tim's list, rather than a combination of (1) and (2), because g++ makes some very poor choices in code output, I know that I can write smaller and faster code than it has output, and I am willing to do extra work to do it, however I thought that putting inline in fornt of a function would force it to be put in the place where it is called, rather than just a normal call.
I know some people think that the slight overhead of calling a function is very little, and it probably is, but I want the best, and if I have to work harder then so be it.
Anyway, hopefully someone might know how to force true inline functions, if not the I guess I will be looking at the sources for g++ (the sources are freely available aren't they?) and working out what needs to be done directly in asm, even though I will be restricted to using only this version of g++ when compiling my C++ code.
Unless I check every compilers way of name mangling and edit my sources each time. :'(
Thanks.