Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • The compiler might not be able to unbox the array or the array elements, though, since they're getting passed to sort(), which is an external function and has to get the arguments it's expecting. That should not matter to a relatively good compiler. Passing metadata (in the pointer - 64bits offer a lot of levee) about the actual data and branching it in the called function. Commented Jun 10, 2014 at 6:31
  • 3
    What exactly makes -Ofast "totally unsafe"? Assuming you know how to test your code and rule out overflows. Commented Jun 10, 2014 at 7:54
  • @sjeohp: That's actually assuming a lot :-) Checking the code and ruling out overflows is hard to do. From my experience (I do compiler work and have checked some big codebases), and what I've heard from people who do compiler work on huge companies, getting overflows and other undefined behavior right is hard. Even Apple's advice (just an example) on fixing UB is wrong, sometimes (randomascii.wordpress.com/2014/04/17/… ). -Ofast also changes language semantics, but I can't fund any docs for it. How can you be confident you know what it's doing? Commented Jun 10, 2014 at 15:42
  • @bestsss: It's possible, but it might not be useful. It adds checks on every access to an Int[]. It depends if arrays of Int and a few other primitive types (you have, at most, 3 bits) are used a lot (especially when you can lower to C if you need to). It also uses up some bits that they might want to use if, eventually, they want to add non-ARC GC. It doesn't scale to generics with more than one argument, either. Since they have all the types, it would be much easier to specialize all code that touched Int[] (but not Int?[]) to use inlined Int. But then you have Obj-C interop to worry about. Commented Jun 10, 2014 at 15:57
  • @filcab, non-ARC (i.e. real) GC would be actually useful but they need something that's not C compatible if they want a truly concurrent, non-STW GC. I'd not worry about 'every access to Int[]' since that depends on the level the compiler can inline and it should be able to inline the tight loops with/after some guidance. Commented Jun 10, 2014 at 19:24