|Feb 26, 2013, 12:32 AM||#1|
llvm question: big automatics
Some while ago, there was a thread here wherein the author could not figure out why a routine ran fine on the main thread but crashed on any other thread – turned out a huge array, like 2Mb, was being allocated, spilling out all over the local stack space.
So, it occurred to me, could one set the compiler back-end (llvm) to observe excessive stack consumption and convert it to temporary heap allocation? Or is this what it already does? Obviously, if it can handle ARC, this would be even easier (of course, any additional returns would have to have matching free()s), the only real difference is that the local variable would be accessed with a pointer, though the source syntax would be identical.
What I imagine is that with such an option enabled, a main thread routine allocating a big array would have a slightly greater chance of failing (due to a malloc() error), while a secondary thread might fail in an orderly fashion rather than assuredly crashing – in either case, a returned NULL pointer would result in a transparent exception throw added in to the object code.
So, my question is, assuming this is not being done, would it be a good idea? I, personally, regard stack space as sort of valuable, so I would allocate the heap block as a matter of course, but would it be wise to obscure this kind of thing from the programmer? Are the old-school, machine-aware habits just becoming passé?
Mr. Paul, sir, I thought you should be advised, there seems to be a zombie tribble clinging to your head, for it is scarfing your brain
|Thread Tools||Search this Thread|
All times are GMT -5. The time now is 04:22 AM.