[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: Missing ResourceMark in TraceStream::print_val()
From:       "=?GBK?B?w7fCt41pKNTGtO8p?=" <yunda.mly () taobao ! com>
Date:       2014-04-15 15:01:50
Message-ID: CF736A56.10FAE%yunda.mly () taobao ! com
[Download RAW message or body]

> 此邮件使用 MIME 格式。由于邮件阅读程序不能识别
此格式,因此,可能无法识别该邮件的分部或部分内容。


Hi Staffan,

Thanks for pointing this out. How can I be so blind鈥


Regards,
Yunda

鍙戜欢浜:  Staffan Larsen <staffan.larsen@oracle.com>
鏃ユ湡:  2014骞4鏈15鏃 鏄熸湡浜 涓嬪崍6:57
鑷:  Luyao Mei <yunda.mly@taobao.com>
鎶勯:  "serviceability-dev@openjdk.java.net"
<serviceability-dev@openjdk.java.net>
涓婚:  Re: Missing ResourceMark in TraceStream::print_val()

The comment in code to says that the necessary ResourceMark is in the
generated code:

  // Caller is machine generated code located in traceEventClasses.hpp
  // Event<TraceId>::writeEvent() (pseudocode) contains the
  // necessary ResourceMark for the resource allocations below.
  // See traceEventClasses.xsl for details.
  void print_val(const char* label, const Klass* const val) {


/Staffan

On 15 apr 2014, at 11:54, 姊呰矾宄(浜戣揪) <yunda.mly@taobao.com> wrote:

> Hi all,
> 
> In TraceStream::print_val(const char* label, const Klass* const val) and
> TraceStream::print_val(const char* label, const Method* const val),
> Symbol::as_C_string() and Method::name_and_sig_as_C_string() are called in
> line 93 and 106 of traceStream.hpp
> <http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/4dedef5e51ed/src/share/vm/t
> race/traceStream.hpp> , respectively. Since they both use NEW_RESOURCE_ARRAY
> to allocate memory, I think ResourceMark should be used. Please see the patch
> below:
> 
> diff -r 4dedef5e51ed src/share/vm/trace/traceStream.hpp
> --- a/src/share/vm/trace/traceStream.hpp Fri Apr 11 11:23:30 2014 -0700
> +++ b/src/share/vm/trace/traceStream.hpp Tue Apr 15 15:50:31 2014 +0800
> @@ -86,6 +86,7 @@
>    // necessary ResourceMark for the resource allocations below.
>    // See traceEventClasses.xsl for details.
>    void print_val(const char* label, const Klass* const val) {
> +    ResourceMark rm;
>      const char* description = "NULL";
>      if (val != NULL) {
>        Symbol* name = val->name();
> @@ -101,6 +102,7 @@
>    // necessary ResourceMark for the resource allocations below.
>    // See traceEventClasses.xsl for details.
>    void print_val(const char* label, const Method* const val) {
> +    ResourceMark rm;
>      const char* description = "NULL";
>      if (val != NULL) {
>        description = val->name_and_sig_as_C_string();
> 
> 
> 
> Regards,
> Yunda




[Attachment #3 (text/html)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; \
font-family: 瀹嬩綋, sans-serif;"><div>Hi Staffan,</div><div><br></div><div>Thanks \
for pointing this out. How can I be so \
blind&#8230;</div><div><br></div><div><br></div><div>Regards,</div><div>Yunda</div><div><br></div><span \
id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; \
text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; \
PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt \
solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span \
style="font-weight:bold">鍙戜欢浜: </span> Staffan Larsen &lt;<a \
href="mailto:staffan.larsen@oracle.com">staffan.larsen@oracle.com</a>&gt;<br><span \
style="font-weight:bold">鏃ユ湡: </span> 2014骞4鏈15鏃 鏄熸湡浜 \
涓嬪崍6:57<br><span style="font-weight:bold">鑷: </span> Luyao Mei &lt;<a \
href="mailto:yunda.mly@taobao.com">yunda.mly@taobao.com</a>&gt;<br><span \
style="font-weight:bold">鎶勯: </span> "<a \
href="mailto:serviceability-dev@openjdk.java.net">serviceability-dev@openjdk.java.net</a>" \
&lt;<a href="mailto:serviceability-dev@openjdk.java.net">serviceability-dev@openjdk.java.net</a>&gt;<br><span \
style="font-weight:bold">涓婚: </span> Re: Missing ResourceMark in \
TraceStream::print_val()<br></div><div><br></div><div><meta http-equiv="Content-Type" \
content="text/html charset=gb18030"><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">The comment in code \
to says that the necessary ResourceMark is in the generated \
code:<div><br></div><div>&nbsp;&nbsp;// Caller is machine generated code located in \
traceEventClasses.hpp<br>&nbsp;&nbsp;// Event&lt;TraceId&gt;::writeEvent() \
(pseudocode) contains the<br>&nbsp;&nbsp;// necessary ResourceMark for the resource \
allocations below.<br>&nbsp;&nbsp;// See traceEventClasses.xsl for \
details.<br>&nbsp;&nbsp;void&nbsp;print_val(const&nbsp;char* \
label,&nbsp;const&nbsp;Klass*&nbsp;const&nbsp;val) \
{</div><div><br></div><div><br></div><div>/Staffan<br><div><br><div><div>On 15 apr \
2014, at 11:54, 姊呰矾宄(浜戣揪) &lt;<a \
href="mailto:yunda.mly@taobao.com">yunda.mly@taobao.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: \
break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; \
font-size: 14px; font-family: 瀹嬩綋, sans-serif;"><div>Hi \
all,</div><div><br></div><div>In TraceStream::print_val(const char* label, const \
Klass* const val) and TraceStream::print_val(const char* label, const Method* const \
val),&nbsp;Symbol::as_C_string() and Method::name_and_sig_as_C_string() are called in \
line 93 and 106 of&nbsp;<a \
href="http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/4dedef5e51ed/src/share/vm/trace/traceStream.hpp">traceStream.hpp</a>, \
respectively. Since they both use&nbsp;NEW_RESOURCE_ARRAY to allocate memory, I think \
ResourceMark should be used. Please see the patch below:</div><div><br></div><div \
style="font-family: 瀹嬩綋; font-size: 16px;"><div><font \
face="瀹嬩綋,sans-serif">diff -r 4dedef5e51ed \
src/share/vm/trace/traceStream.hpp</font></div><div><font \
face="瀹嬩綋,sans-serif">--- a/src/share/vm/trace/traceStream.hpp<span \
class="Apple-tab-span" style="white-space: pre;">	</span>Fri Apr 11 11:23:30 2014 \
-0700</font></div><div><font face="瀹嬩綋,sans-serif">+++ \
b/src/share/vm/trace/traceStream.hpp<span class="Apple-tab-span" style="white-space: \
pre;">	</span>Tue Apr 15 15:50:31 2014 +0800</font></div><div><font \
face="瀹嬩綋,sans-serif">@@ -86,6 +86,7 @@</font></div><div><font \
face="瀹嬩綋,sans-serif">&nbsp; &nbsp;// necessary ResourceMark for the resource \
allocations below.</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp;// \
See traceEventClasses.xsl for details.</font></div><div><font \
face="瀹嬩綋,sans-serif">&nbsp; &nbsp;void print_val(const char* label, const Klass* \
const val) {</font></div><div><font face="瀹嬩綋,sans-serif">+ &nbsp; \
&nbsp;ResourceMark rm;</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp; \
&nbsp;const char* description = "NULL";</font></div><div><font \
face="瀹嬩綋,sans-serif">&nbsp; &nbsp; &nbsp;if (val != NULL) \
{</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;Symbol* \
name = val-&gt;name();</font></div><div><font face="瀹嬩綋,sans-serif">@@ -101,6 \
+102,7 @@</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp;// necessary \
ResourceMark for the resource allocations below.</font></div><div><font \
face="瀹嬩綋,sans-serif">&nbsp; &nbsp;// See traceEventClasses.xsl for \
details.</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp;void \
print_val(const char* label, const Method* const val) {</font></div><div><font \
face="瀹嬩綋,sans-serif">+ &nbsp; &nbsp;ResourceMark rm;</font></div><div><font \
face="瀹嬩綋,sans-serif">&nbsp; &nbsp; &nbsp;const char* description = \
"NULL";</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp; &nbsp;if (val \
!= NULL) {</font></div><div><font face="瀹嬩綋,sans-serif">&nbsp; &nbsp; &nbsp; \
&nbsp;description = val-&gt;name_and_sig_as_C_string();</font></div></div><div><br></d \
iv><div><br></div><div><br></div><div>Regards,</div><div>Yunda</div></div></blockquote></div><br></div></div></div></div></span></body></html>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic