-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Streamline spilling around calls in the code generator #150516
Copy link
Copy link
Open
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Fields
Give feedbackNo fields configured for issues without a type.
So that the GC can see all objects on the stack, any call that escapes and could thus potentially trigger the GC, must be wrapped in code to spill values to the stack and save the stack pointer.
Prior to tailcalling, it made sense to save and reload the stack pointer as the stack pointer would have usually been spilled anyway. Now that we use the
preserve nonecalling convention, the stack pointer will not be spilled so reloading is redundant.We can drop the reload and not adjust the stack pointer, merely saving the adjusted value.
For example, instead of:
we can do this:
Which saves a few instructions on the hot path and reduces correction code on exit and error branches.