<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <o:p></o:p>
    <blockquote type="cite" cite="mid:BN8PR15MB257744E083B03BAF6E21572AF501A@BN8PR15MB2577.namprd15.prod.outlook.com">
      <div class="WordSection1">
        <p>and does not call back into Java (e.g. using an upcall stub).
          <span style="font-family:Wingdings">
            ß</span>------------------------- it occurs to me that any
          kind of upcall should be disallowed in such case whether it is
          JNI or FFM, am I correct?
        </p>
      </div>
    </blockquote>
    <p>Right, JNI has not much to do with this. There's different ways
      to upcall back into Java (JNI and FFM upcall stubs).</p>
    <p>Your question is: what happens if we do call back when we are in
      trivial mode.</p>
    <p>I believe the answer is "we crash" (but not in a "nice way"), and
      I'm not too sure we can do much to prevent that. I believe Jorn
      knows more on that topic.</p>
    <p>Maurizio<br>
    </p>
    <blockquote type="cite" cite="mid:BN8PR15MB257744E083B03BAF6E21572AF501A@BN8PR15MB2577.namprd15.prod.outlook.com">
      <div class="WordSection1">
        <p><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Best Regards<o:p></o:p></p>
        <p class="MsoNormal">Cheng Jin<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div style="border:none;border-top:solid #E1E1E1
          1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal"><b><span style="mso-ligatures:none" lang="EN-US">From:</span></b><span style="mso-ligatures:none" lang="EN-US"> Maurizio
              Cimadamore <a class="moz-txt-link-rfc2396E" href="mailto:maurizio.cimadamore@oracle.com"><maurizio.cimadamore@oracle.com></a>
              <br>
              <b>Sent:</b> Wednesday, July 26, 2023 7:44 PM<br>
              <b>To:</b> Cheng Jin <a class="moz-txt-link-rfc2396E" href="mailto:jincheng@ca.ibm.com"><jincheng@ca.ibm.com></a>;
              <a class="moz-txt-link-abbreviated" href="mailto:panama-dev@openjdk.org">panama-dev@openjdk.org</a><br>
              <b>Subject:</b> [EXTERNAL] Re: Questions about the trivial
              downcall<o:p></o:p></span></p>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <p class="MsoNormal" style="mso-line-height-alt:.75pt"><span style="font-size:1.0pt;color:white">Hi, a trivial downcall
              is supposed to target a native function that (a)
              terminates quickly (so as not to block the GC for too
              long) and (b) does not upcall into Java. So, no, a trivial
              downcall cannot trigger upcalls (I don't think we detect
            </span><span style="font-size:1.0pt;color:white;mso-ligatures:none"><o:p></o:p></span></p>
        </div>
        <div>
          <p class="MsoNormal" style="mso-line-height-alt:.75pt"><span style="font-size:1.0pt;color:white">ZjQcmQRYFpfptBannerStart<o:p></o:p></span></p>
        </div>
        <table class="MsoNormalTable" style="width:100.0%;border-radius:4px" width="100%" cellspacing="0" cellpadding="0" border="0">
          <tbody>
            <tr>
              <td style="padding:12.0pt 0cm 12.0pt 0cm">
                <table class="MsoNormalTable" style="width:100.0%;background:#D0D8DC;border:none;border-top:solid
                  #90A4AE 3.0pt" width="100%" cellspacing="0" cellpadding="0" border="1">
                  <tbody>
                    <tr>
                      <td style="border:none;padding:0cm 7.5pt 3.75pt
                        4.5pt" valign="top">
                        <table class="MsoNormalTable" cellspacing="0" cellpadding="0" border="0" align="left">
                          <tbody>
                            <tr>
                              <td style="padding:3.0pt 6.0pt 3.0pt
                                6.0pt">
                                <p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black">This
                                      Message Is From an External Sender
                                      <o:p></o:p></span></b></p>
                              </td>
                            </tr>
                            <tr>
                              <td style="padding:3.0pt 6.0pt 3.0pt
                                6.0pt">
                                <p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:black">This
                                    message came from outside your
                                    organization.
                                    <o:p></o:p></span></p>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                        <table class="MsoNormalTable" cellspacing="0" cellpadding="0" border="0" align="right">
                          <tbody>
                            <tr>
                              <td style="padding:3.0pt 0cm 3.0pt 0cm">
                                <p class="MsoNormal">  <a href="https://us-phishalarm-ewt.proofpoint.com/EWT/v1/PjiDSg!2c-r455VanMQ2qYReaGl7Z4QRx46ATMxAjK9nbXsj13QlLeimn0PtcIAb-U80cJ-A34Q8dYfoQ6JN5nMYOpBz-Hn3cuAGTZLJQ$" target="_blank" moz-do-not-send="true"><strong><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black;border:solid
                                        #666666
                                        1.0pt;padding:6.0pt;font-weight:normal;text-decoration:none">  Report Suspicious  </span></strong></a>  ‌
                                  <o:p></o:p></p>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </td>
            </tr>
          </tbody>
        </table>
        <div>
          <p class="MsoNormal" style="mso-line-height-alt:.75pt"><span style="font-size:1.0pt;color:white">ZjQcmQRYFpfptBannerEnd<o:p></o:p></span></p>
        </div>
        <p>Hi,<br>
          a trivial downcall is supposed to target a native function
          that (a) terminates quickly (so as not to block the GC for too
          long) and (b) does not upcall into Java.<o:p></o:p></p>
        <p>So, no, a trivial downcall cannot trigger upcalls (I don't
          think we detect this, I believe the JVM just crashes if you
          do).<o:p></o:p></p>
        <p>Also I notice that you speak of "JNI" upcall. Is that what
          you really mean - e.g. a trivial FFM downcall making an upcall
          using JNI? In general, I think it's a bit hard for downcalls
          to do anything that has to do with JNI because the invoked
          native function is not passed a JNIEnv - FFM really just
          bridges the Java code with the native library function you
          want to call, nothing more. (I suppose that function could get
          its hands on the VM using the JNI attach API, but I feel
          that's a different question from what you were asking?).<o:p></o:p></p>
        <p>Maurizio<o:p></o:p></p>
        <div>
          <p class="MsoNormal">On 26/07/2023 22:23, Cheng Jin wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">Hi there,<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">I’ve got a couple of questions about the
            behavior of a trivial downcall (with
            <b>isTrivial</b> specified).<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Is a FFI downcall able to trigger a JNI
            upcall ?<o:p></o:p></p>
          <p class="MsoNormal">If so, should a JNI upcall should be
            captured in this trivial downcall?<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Best Regards<o:p></o:p></p>
          <p class="MsoNormal">Cheng Jin<o:p></o:p></p>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>