<div dir="ltr">Dear Jungwoo,<div><br></div><div>Why is this array not resource allocated?</div><div><br></div><div>Carsten</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 10, 2015 at 9:31 AM, Jungwoo Ha <span dir="ltr"><<a href="mailto:jwha@google.com" target="_blank">jwha@google.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">What's the conclusion? Should I fix it or discuss it separately?</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 9, 2015 at 2:43 PM, Kim Barrett <span dir="ltr"><<a href="mailto:kim.barrett@oracle.com" target="_blank">kim.barrett@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Apr 9, 2015, at 1:25 PM, Jungwoo Ha <<a href="mailto:jwha@google.com" target="_blank">jwha@google.com</a>> wrote:<br>
><br>
> Can someone sponsor this change?<br>
><br>
> <a href="https://bugs.openjdk.java.net/browse/JDK-8075288" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8075288</a><br>
> <a href="http://cr.openjdk.java.net/~jwha/8075288/webrev.00" target="_blank">http://cr.openjdk.java.net/~jwha/8075288/webrev.00</a><br>
<br>
</div></div>I think the change is correct.  Good find!<br>
<br>
However, it’s not clear to me why this is using malloc (and now free), rather than stack allocation.<br>
The size is a declared variable at the allocation point, but it’s initialized from a constant with a<br>
not big value (17) and never modified, so could be changed to be a constant.<br>
<br>
That is, instead of<br>
<br>
 592   char* saved_vtbl = (char*)os::malloc(vtbl_list_size * sizeof(void*), mtClass);<br>
 593   memmove(saved_vtbl, vtbl_list, vtbl_list_size * sizeof(void*));<br>
<br>
use<br>
<br>
  void* saved_vtbl[vtbl_list_size];<br>
  memmove(saved_vtbl, vtbl_list, ARRAY_SIZE(saved_vtbl));<br>
<br>
Maybe the worry is that vtbl_list_size might not always be a small constant?<br>
<br>
Probably this question of whether to use malloc/free here at all should be a separate CR.<br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>