You cannot remove them completely, they are used to initialize global variables as specified by the C language.
If the problem is in the use of cpblk, we can add a flag that avoids its generation (it is an optimization of the code after all).
But the initialization of a constant array or struct will take a lot of instructions, the init functions can be really big.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure I am following. I was referring to local variables, not global. That is: the '.locals init' at the top of a function. Am I missing your point?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for that, I missunderstood the problem
I was referring to the init functions we create for the global variables and not to the init attribute to the .local directive.
We have to check with Gabriele, I recall that we added the init to avoid a bug in Mono 2.4
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The init attribute was added because Mono 2.4's register allocator was confused by the presence of non-initialized locals. The problem descends from the fact that in C you can access uninitialized variables even though the behavior is undefined. We did use the init attribute because we didn't have enough time to roll a clean-up phase that would look for non-initialized locals and emitted 0 initializations for them. Theoretically speaking it would be better to have such pass because init may impose a burden on the JIT and force it to emit unnecessary code at the function entry point.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then, we can probably remove the 'init', which is not required by the C language.
We can also add a flag to control whether it is emitted or not, in case somebody uses an older version of Mono.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You cannot remove them completely, they are used to initialize global variables as specified by the C language.
If the problem is in the use of cpblk, we can add a flag that avoids its generation (it is an optimization of the code after all).
But the initialization of a constant array or struct will take a lot of instructions, the init functions can be really big.
Not sure I am following. I was referring to local variables, not global. That is: the '.locals init' at the top of a function. Am I missing your point?
Sorry for that, I missunderstood the problem
I was referring to the init functions we create for the global variables and not to the init attribute to the .local directive.
We have to check with Gabriele, I recall that we added the init to avoid a bug in Mono 2.4
The init attribute was added because Mono 2.4's register allocator was confused by the presence of non-initialized locals. The problem descends from the fact that in C you can access uninitialized variables even though the behavior is undefined. We did use the init attribute because we didn't have enough time to roll a clean-up phase that would look for non-initialized locals and emitted 0 initializations for them. Theoretically speaking it would be better to have such pass because init may impose a burden on the JIT and force it to emit unnecessary code at the function entry point.
Related bug report resolved on mono https://bugzilla.novell.com/show_bug.cgi?id=497220
Then, we can probably remove the 'init', which is not required by the C language.
We can also add a flag to control whether it is emitted or not, in case somebody uses an older version of Mono.