You could possibly pass sdg.ptr to the gc (allocsize?) to check if it's on the heap or not.<br><br><div class="gmail_quote">On Thu, Mar 28, 2013 at 3:32 AM, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com" target="_blank">ibuclaw@ubuntu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>There's a rather sour test in the testsuite (runnable/test42.d : test7290) that looks at the address of the object, and infers locality based on the value of the address.<br>
<br>
This is very problematic and doesn't actually reliably test the feature, as it makes big assumptions about the behaviour of what the compiler does. Such as:<br><br>a) No functions are inlined.<br>b) There isn't any optimisations in place that omit the frame pointer from the function.<br>
</div><div>c) The compiler pushes the objects on the stack in a deterministic order when building under optimisations.<br> <br></div>There needs to be a better defined test for this as the current one is extremely implementation specific and fragile.<br>
<br></div>Only thought that immediately comes to mind other than pulling the test out of the testsuite is to overload _d_allocmemory to ensure that it is never called.<br><br><br></div>eg:<br><br></div>void* _d_allocmemory (size_t sz)<br>
{<br></div> assert(false);<br><div>}<br><div><div><div><div><div><div><br></div><div>void test7290()<br>{<br></div><div> int add = 2;<br></div><div> scope sdg = (int a) => a + add; // OK, is a stack allocation.<br>
</div><div> auto hdg = (int a) => a + add; // Fails as _d_allocmemory is called to initialise closure.<br></div><div>}<br></div><div><br><br></div><div>Though this would break test54 in that same file (would need to move it out).<br>
</div><div><br></div><div>Thoughts?<br><br></div><div><br></div><div>Regards<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>-- <br>Iain Buclaw<br><br>*(p < e ? p++ : p) = (c & 0x0f) + '0';
</div></font></span></div></div></div></div></div></div></div>
<br>_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br></blockquote></div><br>