Opened 17 years ago
Last modified 6 years ago
#2129 new enhancement
Optimization: Helping gcc with function attributes
Reported by: | tqh | Owned by: | bonefish |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | System/Kernel | Version: | R1/pre-alpha1 |
Keywords: | Cc: | anevilyak | |
Blocked By: | Blocking: | ||
Platform: | x86 |
Description
I wanted to experiment with gcc's attribute((fastcall)) which makes the functions two first arguments being passed in registers. I added it to kernel functions I thought would be called a lot. The resulting OS seems to be very responsive, although no measurements have been done.
My patch is just for inspiration, it is ugly and I did not really care about compability or if I break any API. Providing it here for those interested. It is used A LOT in Mozilla sources btw although hidden behind macros. It might be useful along with other function attributes in critical parts.
Function attributes are described here: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
Attachments (2)
Change History (10)
by , 17 years ago
Attachment: | ugly-fastcall.patch added |
---|
comment:1 by , 17 years ago
attribute has two underscores in front and after that went missing in the submission.
comment:2 by , 17 years ago
Cc: | added |
---|
by , 17 years ago
Attachment: | ugly-fastcall.r25229.patch added |
---|
Ugly fastcall patch against hrev25229
comment:3 by , 16 years ago
Ingo, would you mind giving an eye to this enhancement ? It might be a bad idea on public functions though.
comment:4 by , 16 years ago
Cc: | added |
---|
comment:5 by , 16 years ago
Not sure they provide much speedup. Although I still keep them around in my tree.
comment:6 by , 16 years ago
Cc: | removed |
---|---|
Owner: | changed from | to
This kind of optimization can make sense; I would wait with trying it a bit longer, though. "fastcall" saves only a few cycles by passing arguments via registers instead of via the stack, but we're still looking for optimization potential of several hundred percent for certain use cases.
At any rate I would use a macro instead of hardcoding the gcc attribute.
Assigning the ticket to myself, so it won't be forgotten...
comment:7 by , 10 years ago
Milestone: | R1 → Unscheduled |
---|
comment:8 by , 6 years ago
The x86_64 ABI has the first 8 (?) arguments passed in via registers, so this is only useful on 32-bit, right? I think ARM does the same too, so this may not be so valuable.
Ugly fastcall patch