From: Christopher S. <cs...@dt...> - 2018-06-24 03:32:16
|
Measuring / timing or relying on the delay of code is naturally an implementation dependent thing, and it's also something that is useful and that programs are known to do. We have the OPTIMIZE declarations, which are ignorable and allow implementation dependent qualities; sometimes documented (which programmers are tempted to view as guarantees). I don't think this hoisting feature should necessarily respect the SPEED quality either way: you shouldn't have to make a declaration to get ordinary optimizations like this, especially ones that don't argue against SAFETY in whatever strategy calculus is in the mind of the implementor. Note that there are no negative values allowed for optimize qualities. When someone writes timing code like this, it is for a special purpose, so they should have to make a more specific declaration of their weird intent. The most conservative approach, and coincidentally perhaps the easiest to implement, would be a very specific "negative quality" called NO-HOIST that given any value other than 0 means not to do this particular optimization. This would also flag the source code for humans; for third-party tools, it would be flagged as an unknown optimization (which is about as meaningful as it can really be at that level, anyway). |