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

List:       openjdk-serviceability-dev
Subject:    Re: RFR (M) 8213003: Remove more assignments in ifs for vmTestbase/[a-s]
From:       JC Beyler <jcbeyler () google ! com>
Date:       2018-10-31 20:54:55
Message-ID: CAF9BGByaZGyjCCw6nZxW8eOo-6x6aw28HY033K29nSHTaXEKxg () mail ! gmail ! com
[Download RAW message or body]

@Claes: you are right, I did not do a grep such as "if.* =$"; by adding the
space instead of the $, I missed a few :)

I've been meaning to ask if we could deprecate these anyway. Are these
really being used? And if so, are we saying everything here is useful:
   - Line/File + JNI call?

I ask because I'd like to deprecate the NSK_VERIFY macros but the LINE/FILE
is a bit annoying to deprecate.

I'd rather be able to remove them entirely but we could do an alternative
and migrate the NSK_VERIFY to:

   testedFieldID = jni->GetStaticFieldID(testedClass, FIELD_NAME,
FIELD_SIGNATURE);
    if (!testedFieldID) {

where the print out of the jni method and argument values can still be done
in the JNI wrapper I added (ExceptionCheckingJniEnv.cpp) so we'd have the
printout of the calls but not the line and filename from where the call was
done.

If lines and filenames are really important, then we could do something
like:
    testedFieldID = NSK_TRACE(jni->GetStaticFieldID(testedClass,
FIELD_NAME, FIELD_SIGNATURE));
    if (!testedFieldID) {

Which would add a line for which line/file is doing the JNI call. The
verify part can go into the wrapper I was talking about
(ExceptionCheckingJniEnv.cpp).

Thanks,
Jc


On Wed, Oct 31, 2018 at 11:52 AM Chris Plummer <chris.plummer@oracle.com>
wrote:

> On 10/31/18 11:30 AM, serguei.spitsyn@oracle.com wrote:
> > It prints the FILE/LINE which is enough to identify the error point.
> Yes, but it also prints the JNI calls.
> > But I agree that doing the assignments within the NSK_JNI_VERIFY was
> > intentional as it gives more context.
> > From the other hand it make the code ugly and less readable.
> > Not sure, what direction is better to go.
> Agreed. Somewhat of a tossup now as to whether or not this change should
> be done. I'm fine either way.
> 
> Chris
> > 
> > Thanks,
> > Serguei
> > 
> > 
> > On 10/31/18 11:21, Chris Plummer wrote:
> > > Hi Claes,
> > > 
> > > It's good that you brought this up. NSK_JNI_VERIFY is always "on",
> > > but moving the assignment outside of it does slightly change the
> > > behavior of the macro (although the code still executes "correctly"):
> > > 
> > > /**
> > > * Execute action with JNI call, check result for true and
> > > * pending exception and complain error if required.
> > > * Also trace action execution if tracing mode enabled.
> > > */
> > > #define NSK_JNI_VERIFY(jni, action)  \
> > > (nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \
> > > nsk_jni_lverify(NSK_TRUE,jni,action,__FILE__,__LINE__,"%s\n",#action))
> > > 
> > > So you will no longer see the JNI call in the trace or error output.
> > > You will just see the comparison to the JNI result, which gives no
> > > context as to the source of the result. So I'm now starting to think
> > > that doing the assignments within the NSK_JNI_VERIFY was intentional
> > > so we would see the JNI call in the trace output.
> > > 
> > > Chris
> > > 
> > > On 10/31/18 3:16 AM, Claes Redestad wrote:
> > > > Hi,
> > > > 
> > > > here's a case that your script seems to miss:
> > > > 
> > > > 
> http://cr.openjdk.java.net/%7Ejcbeyler/8213003/webrev.00/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp.udiff.html
> 
> > > > 
> > > > 
> > > > if (!NSK_JNI_VERIFY(jni, (testedFieldID =
> > > > jni->GetStaticFieldID(testedClass, FIELD_NAME,
> > > > FIELD_SIGNATURE)) != NULL))
> > > > 
> > > > I'd note that with some of your changes here you're unconditionally
> > > > executing logic outside of NSK_JNI_VERIFY macros. Does care need be
> > > > taken to wrap the code blocks in equivalent macros/ifdefs? Or are
> > > > the NSK_JNI_VERIFY macros always-on in these tests (and essentially
> > > > pointless)?
> > > > 
> > > > /Claes
> > > > 
> > > > On 2018-10-31 05:42, JC Beyler wrote:
> > > > > Hi all,
> > > > > 
> > > > > I worked on updating my script and handling more assignments so I
> > > > > redid a second pass on the same files to get all the cases. Now, on
> > > > > those files the regex "if.* = " no longer shows any cases we would
> > > > > want to fix.
> > > > > 
> > > > > Could I get a review for this webrev:
> > > > > Webrev: http://cr.openjdk.java.net/~jcbeyler/8213003/webrev.00/
> > > > > Bug: https://bugs.openjdk.java.net/browse/JDK-8213003
> > > > > 
> > > > > I tested this on my dev machine by passing all the tests that were
> > > > > modified.
> > > > > 
> > > > > Thanks!
> > > > > Jc
> > > > 
> > > 
> > > 
> > 
> 
> 
> 

-- 

Thanks,
Jc


[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr">@Claes: you are right, I did not do a grep such as \
&quot;if.* =$&quot;; by adding the space instead of the $, I missed a few \
:)</div><div dir="ltr"><br></div><div dir="ltr">I&#39;ve been meaning to ask if we \
could deprecate these anyway. Are these really being used? And if so, are we saying \
everything here is useful:<div>     - Line/File  + JNI \
call?<br><div><br></div><div><div>I ask because I&#39;d like to deprecate the \
NSK_VERIFY macros but the LINE/FILE is a bit annoying to \
deprecate.</div><div><br></div><div>I&#39;d rather be able to remove them entirely \
but we could do an alternative and migrate the NSK_VERIFY \
to:</div><div><br></div><div>     testedFieldID =  \
jni-&gt;GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE);</div><div>      \
if (!testedFieldID) {<br></div><div><br></div><div>where the print out of the jni \
method and argument values can still be done in the JNI wrapper I added \
(ExceptionCheckingJniEnv.cpp) so we&#39;d have the printout of the calls but not the \
line and filename from where the call was done.</div><div><br></div><div>If lines and \
filenames are really important, then we could do something like:</div><div><div>      \
testedFieldID = NSK_TRACE(jni-&gt;GetStaticFieldID(testedClass, FIELD_NAME, \
FIELD_SIGNATURE));</div><div>      if (!testedFieldID) {<br></div><br \
class="gmail-Apple-interchange-newline"></div><div>Which would add a line for which \
line/file is doing the JNI call. The verify part can go into the wrapper I was \
talking about (ExceptionCheckingJniEnv.cpp).  \
</div><div><br></div><div><div>Thanks,<br></div></div><div>Jc</div><div><br></div></div></div></div></div><br><div \
class="gmail_quote"><div dir="ltr">On Wed, Oct 31, 2018 at 11:52 AM Chris Plummer \
&lt;<a href="mailto:chris.plummer@oracle.com">chris.plummer@oracle.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/31/18 11:30 AM, <a \
href="mailto:serguei.spitsyn@oracle.com" \
target="_blank">serguei.spitsyn@oracle.com</a> wrote:<br> &gt; It prints the \
FILE/LINE which is enough to identify the error point.<br> Yes, but it also prints \
the JNI calls.<br> &gt; But I agree that doing the assignments within the \
NSK_JNI_VERIFY was <br> &gt; intentional as it gives more context.<br>
&gt; From the other hand it make the code ugly and less readable.<br>
&gt; Not sure, what direction is better to go.<br>
Agreed. Somewhat of a tossup now as to whether or not this change should <br>
be done. I&#39;m fine either way.<br>
<br>
Chris<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Serguei<br>
&gt;<br>
&gt;<br>
&gt; On 10/31/18 11:21, Chris Plummer wrote:<br>
&gt;&gt; Hi Claes,<br>
&gt;&gt;<br>
&gt;&gt; It&#39;s good that you brought this up. NSK_JNI_VERIFY is always \
&quot;on&quot;, <br> &gt;&gt; but moving the assignment outside of it does slightly \
change the <br> &gt;&gt; behavior of the macro (although the code still executes \
&quot;correctly&quot;):<br> &gt;&gt;<br>
&gt;&gt; /**<br>
&gt;&gt;   * Execute action with JNI call, check result for true and<br>
&gt;&gt;   * pending exception and complain error if required.<br>
&gt;&gt;   * Also trace action execution if tracing mode enabled.<br>
&gt;&gt;   */<br>
&gt;&gt; #define NSK_JNI_VERIFY(jni, action)   \<br>
&gt;&gt; (nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,&quot;%s\n&quot;,#action), \
\<br> &gt;&gt; nsk_jni_lverify(NSK_TRUE,jni,action,__FILE__,__LINE__,&quot;%s\n&quot;,#action))<br>
 &gt;&gt;<br>
&gt;&gt; So you will no longer see the JNI call in the trace or error output. <br>
&gt;&gt; You will just see the comparison to the JNI result, which gives no <br>
&gt;&gt; context as to the source of the result. So I&#39;m now starting to think \
<br> &gt;&gt; that doing the assignments within the NSK_JNI_VERIFY was intentional \
<br> &gt;&gt; so we would see the JNI call in the trace output.<br>
&gt;&gt;<br>
&gt;&gt; Chris<br>
&gt;&gt;<br>
&gt;&gt; On 10/31/18 3:16 AM, Claes Redestad wrote:<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; here&#39;s a case that your script seems to miss:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; <a href="http://cr.openjdk.java.net/%7Ejcbeyler/8213003/webrev.00/test/ho \
tspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp.udiff.html" \
rel="noreferrer" target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8213003/webrev \
.00/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp.udiff.html</a> \
<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;          if (!NSK_JNI_VERIFY(jni, (testedFieldID =<br>
&gt;&gt;&gt;                          jni-&gt;GetStaticFieldID(testedClass, \
FIELD_NAME, <br> &gt;&gt;&gt; FIELD_SIGNATURE)) != NULL))<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;d note that with some of your changes here you&#39;re \
unconditionally <br> &gt;&gt;&gt; executing logic outside of NSK_JNI_VERIFY macros. \
Does care need be <br> &gt;&gt;&gt; taken to wrap the code blocks in equivalent \
macros/ifdefs? Or are <br> &gt;&gt;&gt; the NSK_JNI_VERIFY macros always-on in these \
tests (and essentially <br> &gt;&gt;&gt; pointless)?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; /Claes<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 2018-10-31 05:42, JC Beyler wrote:<br>
&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I worked on updating my script and handling more assignments so I \
<br> &gt;&gt;&gt;&gt; redid a second pass on the same files to get all the cases. \
Now, on <br> &gt;&gt;&gt;&gt; those files the regex &quot;if.* = &quot; no longer \
shows any cases we would <br> &gt;&gt;&gt;&gt; want to fix.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Could I get a review for this webrev:<br>
&gt;&gt;&gt;&gt; Webrev: <a \
href="http://cr.openjdk.java.net/~jcbeyler/8213003/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/~jcbeyler/8213003/webrev.00/</a><br> \
&gt;&gt;&gt;&gt; Bug: <a href="https://bugs.openjdk.java.net/browse/JDK-8213003" \
rel="noreferrer" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8213003</a><br>
 &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I tested this on my dev machine by passing all the tests that were \
<br> &gt;&gt;&gt;&gt; modified.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks!<br>
&gt;&gt;&gt;&gt; Jc<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" \
class="gmail_signature" data-smartmail="gmail_signature"><div \
dir="ltr"><div><br></div>Thanks,<div>Jc</div></div></div>



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

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