-
Notifications
You must be signed in to change notification settings - Fork 69
C Backend and Runtime Improvements
There are many areas where we can improve the C backend to produce better code.
Currently, using apply()
results in some code that builds some buffers and has a dedicated apply_buffer
on the TEB
. This doesn't seem optimal.
- In the case where we know the number of arguments, can we make a more direct invocation of the right thing?
- Can we use a buffer on the stack instead of the
apply_buffer
on theTEB
? - Can we use
memcpy
instead of iterating over the items?
It is worth noting that the HARP backend generates fairly different code for this.
The C run-time uses int and long interchangeably in a number of areas.
- Things like
vector_size
,vector_ref
andvector_ref_setter
should be usingsize_t
. This will bring a number of additional changes to remove all associated warnings.
The C run-time doesn't do any signal handling like the HARP run-time does. This prevents code using the C back-end from correctly handling division by zero and other errors.
It may be that this should be fixed at the same time as merging the run-times or it could be done in advance of that.
With a current version of Clang (currently 3.3 or XCode 5), try enabling -Weverything
and the static analysis tools and look at what concerns are raised by Clang.
We still use the non-thread-safe versions of some functions, like localtime
. In the case of localtime
, some refactoring of the code that calls it will be required to be able to use localtime_r
.