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

List:       openjdk-serviceability-dev
Subject:    Re: RFR (M) 8210700: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti/unit tests
From:       JC Beyler <jcbeyler () google ! com>
Date:       2018-09-18 2:51:35
Message-ID: CAF9BGByG7LE47EDKZ45R5zmRb-RKeeDqFwzMJOLwnRMhmAFaUw () mail ! gmail ! com
[Download RAW message or body]

Hi all,

Thanks David, I pushed the webrev after re-testing the unit subtests.

Have all a great evening,
Jc

On Mon, Sep 17, 2018 at 3:47 PM David Holmes <david.holmes@oracle.com>
wrote:

> I'm fine with the code the way it is.
>
> Thanks,
> David
>
> On 18/09/2018 4:08 AM, Alex Menkov wrote:
> > I raised the point because I remember I saw similar issue.
> > Finally I found the issue it and it was about JNIEnv.
> > So there is no problem here (as tests creates only a single jvmtiEnv).
> > Anyway I think it would be better to use jvmtiEnv passed to callbacks
> > (then it remains correct even is other jvmtiEnv is created).
> >
> > --alex
> >
> > On 09/17/2018 09:14, JC Beyler wrote:
> >> Hi David,
> >>
> >> I think it is fine to leave the caching in the most tests I looked
> >> because they want to do JVMTI calls where there is jvmtiEnv* passed
> >> in. Would you rather I revert the rawmonitor changes to where it is
> >> still using the cached one instead of the one passed in by the call?
> >>
> >> Let me know,
> >> Jc
> >>
> >> On Sun, Sep 16, 2018 at 9:15 PM David Holmes <david.holmes@oracle.com
> >> <mailto:david.holmes@oracle.com>> wrote:
> >>
> >>     I took a look at it all and it seems okay, though the use of the
> >> cached
> >>     jvmtiEnv pointer did not really need to be changed. As per the spec:
> >>
> >>     "JVM TI environments work across threads"
> >>
> >>     The caching and its use is somewhat hard to understand without
> seeing
> >>     where all the call paths are for the functions that still used the
> >>     cached version.
> >>
> >>     It would have been simpler to address the caching issue (if it
> >> needs to
> >>     be addressed) separately.
> >>
> >>     Cheers,
> >>     David
> >>
> >>     On 15/09/2018 7:30 AM, Alex Menkov wrote:
> >>      > Hi Jc,
> >>      >
> >>      > I looked only at rawmonitor.cpp (I suppose nothing other has been
> >>     changed).
> >>      > Looks good.
> >>      >
> >>      > --alex
> >>      >
> >>      > On 09/14/2018 13:50, JC Beyler wrote:
> >>      >> Hi Alex,
> >>      >>
> >>      >> Ok I understand now what you mean. I just did a double check on
> >>     files
> >>      >> that had global definitions of jvmtiEnv across the tests (not
> >>     complete
> >>      >> but I looked at any file that has a grep for "^jvmtiEnv") and
> >> those
> >>      >> were the only case where this happens.
> >>      >>
> >>      >> Here is a new version:
> >>      >> Webrev: http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.02/
> >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/>
> >>      >> <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/>
> >>      >> Bug: https://bugs.openjdk.java.net/browse/JDK-8210700
> >>      >>
> >>      >> Let me know what you think and sorry I misunderstood what you
> >> meant,
> >>      >> Jc
> >>      >>
> >>      >> On Fri, Sep 14, 2018 at 10:52 AM Alex Menkov
> >>     <alexey.menkov@oracle.com <mailto:alexey.menkov@oracle.com>
> >>      >> <mailto:alexey.menkov@oracle.com
> >>     <mailto:alexey.menkov@oracle.com>>> wrote:
> >>      >>
> >>      >>     Hi Jc,
> >>      >>
> >>      >>     On 09/13/2018 20:05, JC Beyler wrote:
> >>      >>      > Thanks Alexey for the review, I fixed all the " ," issues
> >>     that
> >>      >>     the patch
> >>      >>      > changed but there are still at least 29 files that seem
> >>     to have
> >>      >> that
> >>      >>      > issue in the vmTestbase that were not touched by this
> >>     webrev. I
> >>      >>     imagine
> >>      >>      > we can do a refactoring in another webrev (want me to
> >>     file it?)
> >>      >>     or we
> >>      >>      > can try to handle them when we refactor the tests to move
> >>     them
> >>      >>     out of
> >>      >>      > vmTestbase.
> >>      >>
> >>      >>     I don't think we need to fix this minor style issues - I
> >>     asked to fix
> >>      >>     them just because your fix touches the lines.
> >>      >>
> >>      >>     Regarding jvmti/jvmti_env mix:
> >>      >>     Looks like you are right about
> >>     <...>/timers/JvmtiTest/JvmtiTest.cpp
> >>      >>     (actually if JNI_ENV_ARG didn't drop the 1st arg, the code
> >>     would just
> >>      >>     fail to compile as jvmti_env is undefined in some cases).
> >>      >>
> >>      >>     But the same issues in
> >>     <...>/functions/rawmonitor/rawmonitor.cpp
> >>      >> needs
> >>      >>     to be fixed.
> >>      >>     As I wrote before if jvmtiEnv is used in JVMTI callback, it
> >>     should
> >>      >> use
> >>      >>     jvmtiEnv passed to the callback (callback may be called on a
> >>      >> different
> >>      >>     thread and in the case jvmti if different from jvmti_env):
> >>      >>
> >>      >>     void JNICALL vmStart(jvmtiEnv *jvmti_env, JNIEnv *env) {
> >>      >>            jvmtiError res;
> >>      >>     -    res =
> >>      >>
> >> JVMTI_ENV_PTR(jvmti)->GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,
> >>      >>     &main_thread));
> >>      >>     +    res = jvmti->GetCurrentThread(&main_thread);
> >>      >>
> >>      >>     should be
> >>      >>     +    res = jvmti_env->GetCurrentThread(&main_thread);
> >>      >>
> >>      >>     the same for other callbacks in rawmonitor.cpp
> >>      >>
> >>      >>     --alex
> >>      >>
> >>      >>      >
> >>      >>      > The new webrev is here:
> >>      >>      > Webrev:
> >>     http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.01/
> >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/>
> >>      >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/>
> >>      >>      >
> >> <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/>
> >>      >>      > Bug: https://bugs.openjdk.java.net/browse/JDK-8210700
> >>      >>      >
> >>      >>      > Good catch on the change here:
> >>      >>      > -    res =
> >>      >>      >
> >>     JVMTI_ENV_PTR(jvmti)->GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,
> >>      >>      > &main_thread));
> >>      >>      > +    res = jvmti->GetCurrentThread(&main_thread);
> >>      >>      >
> >>      >>      > You are right that the change from Igor introduced this
> >> weird
> >>      >>     part where
> >>      >>      > jvmti and jvmti_env are seemingly used at the same time.
> >>     Turns
> >>      >>     out that
> >>      >>      > for C++, JVMTI_ENV_ARG/JVMTI_ENV_PTR is transformed into:
> >>      >>      >
> >>      >>      > -#define JNI_ENV_PTR(x) x
> >>      >>      > -#define JNI_ENV_ARG(x, y) y
> >>      >>      >
> >>      >>      > ..
> >>      >>      >
> >>      >>      > -#define JVMTI_ENV_PTR JNI_ENV_PTR
> >>      >>      > -#define JVMTI_ENV_ARG JNI_ENV_ARG
> >>      >>      >
> >>      >>      > So you are right that actually it is weird but it all
> >>     works out:
> >>      >>      >
> >>      >>      > -    res =
> >>      >>      >
> >>     JVMTI_ENV_PTR(jvmti)->GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,
> >>      >>      > &main_thread));
> >>      >>      >
> >>      >>      > -> The JVMTI_ENV_PTR is JNI_ENV_PTR which is identity so
> >>      >>     JVMTI_ENV_PTR(jvmti) -> jvmti
> >>      >>      >
> >>      >>      > -> The JVMT_ENV_ARG ignores the first argument so
> >>      >>     JVMTI_ENV_ARG(jvmti_env, &main_thread) -> &main_thread
> >>      >>      >
> >>      >>      > So my transformation is correct; turns out that Igor's
> >>      >>     transformation was wrong but because things were in C++,
> >>      >>      >
> >>      >>      > the undeclared jvmti_env was just ignored.
> >>      >>      >
> >>      >>      >
> >>      >>      > So apart from the case where I missed something I think
> >>     we are
> >>      >>     good. Let me know what you think,
> >>      >>      >
> >>      >>      > Jc
> >>      >>      >
> >>      >>      >
> >>      >>      >
> >>      >>      >
> >>      >>      > On Thu, Sep 13, 2018 at 5:32 PM Alex Menkov
> >>      >>     <alexey.menkov@oracle.com <mailto:alexey.menkov@oracle.com>
> >>     <mailto:alexey.menkov@oracle.com <mailto:alexey.menkov@oracle.com>>
> >>      >>      > <mailto:alexey.menkov@oracle.com
> >>     <mailto:alexey.menkov@oracle.com>
> >>      >>     <mailto:alexey.menkov@oracle.com
> >>     <mailto:alexey.menkov@oracle.com>>>> wrote:
> >>      >>      >
> >>      >>      >     Hi Jc,
> >>      >>      >
> >>      >>      >     Some notes:
> >>      >>      >     <...>/MethodBind/JvmtiTest/JvmtiTest.cpp
> >>      >>      >     and
> >>      >>      >     <...>/StackTrace/JvmtiTest/JvmtiTest.cpp
> >>      >>      >     have several places with extra space before comma
> >> like:
> >>      >>      >     -    ret =
> >>      >>     JVMTI_ENV_PTR(jvmti)->GetStackTrace(JVMTI_ENV_ARG(jvmti,
> >>      >>      >     thr), 0, max_count , stack_buffer, &count);
> >>      >>      >     +    ret = jvmti->GetStackTrace(thr, 0, max_count ,
> >>      >> stack_buffer,
> >>      >>      >     &count);
> >>      >>      >
> >>      >>      >     <...>/functions/rawmonitor/rawmonitor.cpp
> >>      >>      >     and
> >>      >>      >     <...>/timers/JvmtiTest/JvmtiTest.cpp
> >>      >>      >     have several suspicious changes when JVMTI_ENV_PTR
> and
> >>      >>     JVMTI_ENV_ARG
> >>      >>      >     have different arguments (that's certainly wrong, but
> >>     needs
> >>      >> to re
> >>      >>      >     resolved correctly):
> >>      >>      >     -    res =
> >>      >>      >
> >>      >>  JVMTI_ENV_PTR(jvmti)->GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,
> >>      >>      >     &main_thread));
> >>      >>      >     +    res = jvmti->GetCurrentThread(&main_thread);
> >>      >>      >
> >>      >>      >     JVMTI_ENV_PTR(jvmti) is an address of the function
> >> in the
> >>      >>     vtable, and
> >>      >>      >     JVMTI_ENV_ARG(jvmti_env, ...) is a C++ "this"
> pointer.
> >>      >>      >     So I'd expect that this should be
> >>      >>      >     +    res = +
> >> jvmti_env->GetCurrentThread(&main_thread);
> >>      >>      >
> >>      >>      >     Looking at timers/JvmtiTest/JvmtiTest.cpp history
> >>     looks like
> >>      >>      >
> >>  JVMTI_ENV_PTR(jvmti)-><func>(JVMTI_ENV_ARG(jvmti_env, ...
> >>      >>     changes were
> >>      >>      >     introduced recently by the fix for "8209611: use C++
> >>      >> compiler for
> >>      >>      >     hotspot tests".
> >>      >>      >
> >>      >>      >     /functions/rawmonitor/rawmonitor.cpp had such wrong
> >>      >>     statements before,
> >>      >>      >     so they should be revised carefully.
> >>      >>      >     AFAIU if JVMTI dunction is called from some callback
> >>     where
> >>      >>     jvmtiEnv is
> >>      >>      >     passed, the passed value should be used.
> >>      >>      >
> >>      >>      >     --alex
> >>      >>      >
> >>      >>      >     On 09/13/2018 13:26, JC Beyler wrote:
> >>      >>      >      > Hi all,
> >>      >>      >      >
> >>      >>      >      > We have arrived to the last webrev for removing
> >>     the JNI_ENV
> >>      >>      >     macros from
> >>      >>      >      > the vmTestbase:
> >>      >>      >      >
> >>      >>      >      > Webrev:
> >>      >> http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.00/
> >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/>
> >>      >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/>
> >>      >>      >
> >>  <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/>
> >>      >>      >      >
> >>     <http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/>
> >>      >>      >      > Bug:
> >> https://bugs.openjdk.java.net/browse/JDK-8210700
> >>      >>      >      >
> >>      >>      >      > Thanks again for the reviews,
> >>      >>      >      > Jc
> >>      >>      >
> >>      >>      >
> >>      >>      >
> >>      >>      > --
> >>      >>      >
> >>      >>      > Thanks,
> >>      >>      > Jc
> >>      >>
> >>      >>
> >>      >>
> >>      >> --
> >>      >>
> >>      >> Thanks,
> >>      >> Jc
> >>
> >>
> >>
> >> --
> >>
> >> Thanks,
> >> Jc
>


-- 

Thanks,
Jc

[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>Thanks David, I pushed the \
webrev after re-testing the unit subtests.</div><div><br></div><div>Have all a great \
evening,</div><div>Jc</div><div></div></div></div><br><div class="gmail_quote"><div \
dir="ltr">On Mon, Sep 17, 2018 at 3:47 PM David Holmes &lt;<a \
href="mailto:david.holmes@oracle.com">david.holmes@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">I&#39;m fine with the code the way \
it is.<br> <br>
Thanks,<br>
David<br>
<br>
On 18/09/2018 4:08 AM, Alex Menkov wrote:<br>
&gt; I raised the point because I remember I saw similar issue.<br>
&gt; Finally I found the issue it and it was about JNIEnv.<br>
&gt; So there is no problem here (as tests creates only a single jvmtiEnv).<br>
&gt; Anyway I think it would be better to use jvmtiEnv passed to callbacks <br>
&gt; (then it remains correct even is other jvmtiEnv is created).<br>
&gt; <br>
&gt; --alex<br>
&gt; <br>
&gt; On 09/17/2018 09:14, JC Beyler wrote:<br>
&gt;&gt; Hi David,<br>
&gt;&gt;<br>
&gt;&gt; I think it is fine to leave the caching in the most tests I looked <br>
&gt;&gt; because they want to do JVMTI calls where there is jvmtiEnv* passed <br>
&gt;&gt; in. Would you rather I revert the rawmonitor changes to where it is <br>
&gt;&gt; still using the cached one instead of the one passed in by the call?<br>
&gt;&gt;<br>
&gt;&gt; Let me know,<br>
&gt;&gt; Jc<br>
&gt;&gt;<br>
&gt;&gt; On Sun, Sep 16, 2018 at 9:15 PM David Holmes &lt;<a \
href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a> \
<br> &gt;&gt; &lt;mailto:<a href="mailto:david.holmes@oracle.com" \
target="_blank">david.holmes@oracle.com</a>&gt;&gt; wrote:<br> &gt;&gt;<br>
&gt;&gt;        I took a look at it all and it seems okay, though the use of the <br>
&gt;&gt; cached<br>
&gt;&gt;        jvmtiEnv pointer did not really need to be changed. As per the \
spec:<br> &gt;&gt;<br>
&gt;&gt;        &quot;JVM TI environments work across threads&quot;<br>
&gt;&gt;<br>
&gt;&gt;        The caching and its use is somewhat hard to understand without \
seeing<br> &gt;&gt;        where all the call paths are for the functions that still \
used the<br> &gt;&gt;        cached version.<br>
&gt;&gt;<br>
&gt;&gt;        It would have been simpler to address the caching issue (if it <br>
&gt;&gt; needs to<br>
&gt;&gt;        be addressed) separately.<br>
&gt;&gt;<br>
&gt;&gt;        Cheers,<br>
&gt;&gt;        David<br>
&gt;&gt;<br>
&gt;&gt;        On 15/09/2018 7:30 AM, Alex Menkov wrote:<br>
&gt;&gt;          &gt; Hi Jc,<br>
&gt;&gt;          &gt;<br>
&gt;&gt;          &gt; I looked only at rawmonitor.cpp (I suppose nothing other has \
been<br> &gt;&gt;        changed).<br>
&gt;&gt;          &gt; Looks good.<br>
&gt;&gt;          &gt;<br>
&gt;&gt;          &gt; --alex<br>
&gt;&gt;          &gt;<br>
&gt;&gt;          &gt; On 09/14/2018 13:50, JC Beyler wrote:<br>
&gt;&gt;          &gt;&gt; Hi Alex,<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt; Ok I understand now what you mean. I just did a double \
check on<br> &gt;&gt;        files<br>
&gt;&gt;          &gt;&gt; that had global definitions of jvmtiEnv across the tests \
(not<br> &gt;&gt;        complete<br>
&gt;&gt;          &gt;&gt; but I looked at any file that has a grep for \
&quot;^jvmtiEnv&quot;) and <br> &gt;&gt; those<br>
&gt;&gt;          &gt;&gt; were the only case where this happens.<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt; Here is a new version:<br>
&gt;&gt;          &gt;&gt; Webrev: <a \
href="http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.02/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.02/</a><br> \
&gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/</a>&gt;<br> \
&gt;&gt;          &gt;&gt; &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.02/</a>&gt;<br> \
&gt;&gt;          &gt;&gt; Bug: <a \
href="https://bugs.openjdk.java.net/browse/JDK-8210700" rel="noreferrer" \
target="_blank">https://bugs.openjdk.java.net/browse/JDK-8210700</a><br> &gt;&gt;     \
&gt;&gt;<br> &gt;&gt;          &gt;&gt; Let me know what you think and sorry I \
misunderstood what you <br> &gt;&gt; meant,<br>
&gt;&gt;          &gt;&gt; Jc<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt; On Fri, Sep 14, 2018 at 10:52 AM Alex Menkov<br>
&gt;&gt;        &lt;<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a> &lt;mailto:<a \
href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;<br> &gt;&gt;          &gt;&gt; \
&lt;mailto:<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a><br> &gt;&gt;        &lt;mailto:<a \
href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;&gt;&gt; wrote:<br> &gt;&gt;          \
&gt;&gt;<br> &gt;&gt;          &gt;&gt;        Hi Jc,<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        On 09/13/2018 20:05, JC Beyler wrote:<br>
&gt;&gt;          &gt;&gt;          &gt; Thanks Alexey for the review, I fixed all \
the &quot; ,&quot; issues<br> &gt;&gt;        that<br>
&gt;&gt;          &gt;&gt;        the patch<br>
&gt;&gt;          &gt;&gt;          &gt; changed but there are still at least 29 \
files that seem<br> &gt;&gt;        to have<br>
&gt;&gt;          &gt;&gt; that<br>
&gt;&gt;          &gt;&gt;          &gt; issue in the vmTestbase that were not \
touched by this<br> &gt;&gt;        webrev. I<br>
&gt;&gt;          &gt;&gt;        imagine<br>
&gt;&gt;          &gt;&gt;          &gt; we can do a refactoring in another webrev \
(want me to<br> &gt;&gt;        file it?)<br>
&gt;&gt;          &gt;&gt;        or we<br>
&gt;&gt;          &gt;&gt;          &gt; can try to handle them when we refactor the \
tests to move<br> &gt;&gt;        them<br>
&gt;&gt;          &gt;&gt;        out of<br>
&gt;&gt;          &gt;&gt;          &gt; vmTestbase.<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        I don&#39;t think we need to fix this minor style \
issues - I<br> &gt;&gt;        asked to fix<br>
&gt;&gt;          &gt;&gt;        them just because your fix touches the lines.<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        Regarding jvmti/jvmti_env mix:<br>
&gt;&gt;          &gt;&gt;        Looks like you are right about<br>
&gt;&gt;        &lt;...&gt;/timers/JvmtiTest/JvmtiTest.cpp<br>
&gt;&gt;          &gt;&gt;        (actually if JNI_ENV_ARG didn&#39;t drop the 1st \
arg, the code<br> &gt;&gt;        would just<br>
&gt;&gt;          &gt;&gt;        fail to compile as jvmti_env is undefined in some \
cases).<br> &gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        But the same issues in<br>
&gt;&gt;        &lt;...&gt;/functions/rawmonitor/rawmonitor.cpp<br>
&gt;&gt;          &gt;&gt; needs<br>
&gt;&gt;          &gt;&gt;        to be fixed.<br>
&gt;&gt;          &gt;&gt;        As I wrote before if jvmtiEnv is used in JVMTI \
callback, it<br> &gt;&gt;        should<br>
&gt;&gt;          &gt;&gt; use<br>
&gt;&gt;          &gt;&gt;        jvmtiEnv passed to the callback (callback may be \
called on a<br> &gt;&gt;          &gt;&gt; different<br>
&gt;&gt;          &gt;&gt;        thread and in the case jvmti if different from \
jvmti_env):<br> &gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        void JNICALL vmStart(jvmtiEnv *jvmti_env, JNIEnv \
*env) {<br> &gt;&gt;          &gt;&gt;                   jvmtiError res;<br>
&gt;&gt;          &gt;&gt;        -      res =<br>
&gt;&gt;          &gt;&gt;        <br>
&gt;&gt; JVMTI_ENV_PTR(jvmti)-&gt;GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,<br>
&gt;&gt;          &gt;&gt;        &amp;main_thread));<br>
&gt;&gt;          &gt;&gt;        +      res = \
jvmti-&gt;GetCurrentThread(&amp;main_thread);<br> &gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        should be<br>
&gt;&gt;          &gt;&gt;        +      res = \
jvmti_env-&gt;GetCurrentThread(&amp;main_thread);<br> &gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        the same for other callbacks in rawmonitor.cpp<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;        --alex<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; The new webrev is here:<br>
&gt;&gt;          &gt;&gt;          &gt; Webrev:<br>
&gt;&gt;        <a href="http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.01/" \
rel="noreferrer" target="_blank">http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.01/</a><br>
 &gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;          &gt; <br> &gt;&gt; &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.01/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;          &gt; Bug: <a \
href="https://bugs.openjdk.java.net/browse/JDK-8210700" rel="noreferrer" \
target="_blank">https://bugs.openjdk.java.net/browse/JDK-8210700</a><br> &gt;&gt;     \
&gt;&gt;          &gt;<br> &gt;&gt;          &gt;&gt;          &gt; Good catch on the \
change here:<br> &gt;&gt;          &gt;&gt;          &gt; -      res =<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;        JVMTI_ENV_PTR(jvmti)-&gt;GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,<br>
 &gt;&gt;          &gt;&gt;          &gt; &amp;main_thread));<br>
&gt;&gt;          &gt;&gt;          &gt; +      res = \
jvmti-&gt;GetCurrentThread(&amp;main_thread);<br> &gt;&gt;          &gt;&gt;          \
&gt;<br> &gt;&gt;          &gt;&gt;          &gt; You are right that the change from \
Igor introduced this <br> &gt;&gt; weird<br>
&gt;&gt;          &gt;&gt;        part where<br>
&gt;&gt;          &gt;&gt;          &gt; jvmti and jvmti_env are seemingly used at \
the same time.<br> &gt;&gt;        Turns<br>
&gt;&gt;          &gt;&gt;        out that<br>
&gt;&gt;          &gt;&gt;          &gt; for C++, JVMTI_ENV_ARG/JVMTI_ENV_PTR is \
transformed into:<br> &gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; -#define JNI_ENV_PTR(x) x<br>
&gt;&gt;          &gt;&gt;          &gt; -#define JNI_ENV_ARG(x, y) y<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; ..<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; -#define JVMTI_ENV_PTR JNI_ENV_PTR<br>
&gt;&gt;          &gt;&gt;          &gt; -#define JVMTI_ENV_ARG JNI_ENV_ARG<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; So you are right that actually it is weird \
but it all<br> &gt;&gt;        works out:<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; -      res =<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;        JVMTI_ENV_PTR(jvmti)-&gt;GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,<br>
 &gt;&gt;          &gt;&gt;          &gt; &amp;main_thread));<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; -&gt; The JVMTI_ENV_PTR is JNI_ENV_PTR which \
is identity so<br> &gt;&gt;          &gt;&gt;        JVMTI_ENV_PTR(jvmti) -&gt; \
jvmti<br> &gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; -&gt; The JVMT_ENV_ARG ignores the first \
argument so<br> &gt;&gt;          &gt;&gt;        JVMTI_ENV_ARG(jvmti_env, \
&amp;main_thread) -&gt; &amp;main_thread<br> &gt;&gt;          &gt;&gt;          \
&gt;<br> &gt;&gt;          &gt;&gt;          &gt; So my transformation is correct; \
turns out that Igor&#39;s<br> &gt;&gt;          &gt;&gt;        transformation was \
wrong but because things were in C++,<br> &gt;&gt;          &gt;&gt;          \
&gt;<br> &gt;&gt;          &gt;&gt;          &gt; the undeclared jvmti_env was just \
ignored.<br> &gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; So apart from the case where I missed \
something I think<br> &gt;&gt;        we are<br>
&gt;&gt;          &gt;&gt;        good. Let me know what you think,<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; Jc<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; On Thu, Sep 13, 2018 at 5:32 PM Alex \
Menkov<br> &gt;&gt;          &gt;&gt;        &lt;<a \
href="mailto:alexey.menkov@oracle.com" target="_blank">alexey.menkov@oracle.com</a> \
&lt;mailto:<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;<br> &gt;&gt;        &lt;mailto:<a \
href="mailto:alexey.menkov@oracle.com" target="_blank">alexey.menkov@oracle.com</a> \
&lt;mailto:<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;&gt;<br> &gt;&gt;          &gt;&gt;   \
&gt; &lt;mailto:<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a><br> &gt;&gt;        &lt;mailto:<a \
href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;<br> &gt;&gt;          &gt;&gt;       \
&lt;mailto:<a href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a><br> &gt;&gt;        &lt;mailto:<a \
href="mailto:alexey.menkov@oracle.com" \
target="_blank">alexey.menkov@oracle.com</a>&gt;&gt;&gt;&gt; wrote:<br> &gt;&gt;      \
&gt;&gt;          &gt;<br> &gt;&gt;          &gt;&gt;          &gt;        Hi Jc,<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        Some notes:<br>
&gt;&gt;          &gt;&gt;          &gt;        \
&lt;...&gt;/MethodBind/JvmtiTest/JvmtiTest.cpp<br> &gt;&gt;          &gt;&gt;         \
&gt;        and<br> &gt;&gt;          &gt;&gt;          &gt;        \
&lt;...&gt;/StackTrace/JvmtiTest/JvmtiTest.cpp<br> &gt;&gt;          &gt;&gt;         \
&gt;        have several places with extra space before comma <br> &gt;&gt; like:<br>
&gt;&gt;          &gt;&gt;          &gt;        -      ret =<br>
&gt;&gt;          &gt;&gt;        \
JVMTI_ENV_PTR(jvmti)-&gt;GetStackTrace(JVMTI_ENV_ARG(jvmti,<br> &gt;&gt;          \
&gt;&gt;          &gt;        thr), 0, max_count , stack_buffer, &amp;count);<br> \
&gt;&gt;          &gt;&gt;          &gt;        +      ret = \
jvmti-&gt;GetStackTrace(thr, 0, max_count ,<br> &gt;&gt;          &gt;&gt; \
stack_buffer,<br> &gt;&gt;          &gt;&gt;          &gt;        &amp;count);<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        \
&lt;...&gt;/functions/rawmonitor/rawmonitor.cpp<br> &gt;&gt;          &gt;&gt;        \
&gt;        and<br> &gt;&gt;          &gt;&gt;          &gt;        \
&lt;...&gt;/timers/JvmtiTest/JvmtiTest.cpp<br> &gt;&gt;          &gt;&gt;          \
&gt;        have several suspicious changes when JVMTI_ENV_PTR and<br> &gt;&gt;       \
&gt;&gt;        JVMTI_ENV_ARG<br> &gt;&gt;          &gt;&gt;          &gt;        \
have different arguments (that&#39;s certainly wrong, but<br> &gt;&gt;        \
needs<br> &gt;&gt;          &gt;&gt; to re<br>
&gt;&gt;          &gt;&gt;          &gt;        resolved correctly):<br>
&gt;&gt;          &gt;&gt;          &gt;        -      res =<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;   \
JVMTI_ENV_PTR(jvmti)-&gt;GetCurrentThread(JVMTI_ENV_ARG(jvmti_env,<br> &gt;&gt;       \
&gt;&gt;          &gt;        &amp;main_thread));<br> &gt;&gt;          &gt;&gt;      \
&gt;        +      res = jvmti-&gt;GetCurrentThread(&amp;main_thread);<br> &gt;&gt;   \
&gt;&gt;          &gt;<br> &gt;&gt;          &gt;&gt;          &gt;        \
JVMTI_ENV_PTR(jvmti) is an address of the function <br> &gt;&gt; in the<br>
&gt;&gt;          &gt;&gt;        vtable, and<br>
&gt;&gt;          &gt;&gt;          &gt;        JVMTI_ENV_ARG(jvmti_env, ...) is a \
C++ &quot;this&quot; pointer.<br> &gt;&gt;          &gt;&gt;          &gt;        So \
I&#39;d expect that this should be<br> &gt;&gt;          &gt;&gt;          &gt;       \
+      res = + <br> &gt;&gt; jvmti_env-&gt;GetCurrentThread(&amp;main_thread);<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        Looking at \
timers/JvmtiTest/JvmtiTest.cpp history<br> &gt;&gt;        looks like<br>
&gt;&gt;          &gt;&gt;          &gt;      <br>
&gt;&gt;   JVMTI_ENV_PTR(jvmti)-&gt;&lt;func&gt;(JVMTI_ENV_ARG(jvmti_env, ...<br>
&gt;&gt;          &gt;&gt;        changes were<br>
&gt;&gt;          &gt;&gt;          &gt;        introduced recently by the fix for \
&quot;8209611: use C++<br> &gt;&gt;          &gt;&gt; compiler for<br>
&gt;&gt;          &gt;&gt;          &gt;        hotspot tests&quot;.<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        /functions/rawmonitor/rawmonitor.cpp \
had such wrong<br> &gt;&gt;          &gt;&gt;        statements before,<br>
&gt;&gt;          &gt;&gt;          &gt;        so they should be revised \
carefully.<br> &gt;&gt;          &gt;&gt;          &gt;        AFAIU if JVMTI \
dunction is called from some callback<br> &gt;&gt;        where<br>
&gt;&gt;          &gt;&gt;        jvmtiEnv is<br>
&gt;&gt;          &gt;&gt;          &gt;        passed, the passed value should be \
used.<br> &gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        --alex<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;        On 09/13/2018 13:26, JC Beyler \
wrote:<br> &gt;&gt;          &gt;&gt;          &gt;         &gt; Hi all,<br>
&gt;&gt;          &gt;&gt;          &gt;         &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;         &gt; We have arrived to the last \
webrev for removing<br> &gt;&gt;        the JNI_ENV<br>
&gt;&gt;          &gt;&gt;          &gt;        macros from<br>
&gt;&gt;          &gt;&gt;          &gt;         &gt; the vmTestbase:<br>
&gt;&gt;          &gt;&gt;          &gt;         &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;         &gt; Webrev:<br>
&gt;&gt;          &gt;&gt; <a \
href="http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/~jcbeyler/8210700/webrev.00/</a><br> \
&gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;          &gt;         <br> &gt;&gt;   &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;          &gt;         &gt;<br> &gt;&gt;        &lt;<a \
href="http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/" rel="noreferrer" \
target="_blank">http://cr.openjdk.java.net/%7Ejcbeyler/8210700/webrev.00/</a>&gt;<br> \
&gt;&gt;          &gt;&gt;          &gt;         &gt; Bug: <br> &gt;&gt; <a \
href="https://bugs.openjdk.java.net/browse/JDK-8210700" rel="noreferrer" \
target="_blank">https://bugs.openjdk.java.net/browse/JDK-8210700</a><br> &gt;&gt;     \
&gt;&gt;          &gt;         &gt;<br> &gt;&gt;          &gt;&gt;          &gt;      \
&gt; Thanks again for the reviews,<br> &gt;&gt;          &gt;&gt;          &gt;       \
&gt; Jc<br> &gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; --<br>
&gt;&gt;          &gt;&gt;          &gt;<br>
&gt;&gt;          &gt;&gt;          &gt; Thanks,<br>
&gt;&gt;          &gt;&gt;          &gt; Jc<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt; --<br>
&gt;&gt;          &gt;&gt;<br>
&gt;&gt;          &gt;&gt; Thanks,<br>
&gt;&gt;          &gt;&gt; Jc<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -- <br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Jc<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