Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 43591 invoked from network); 26 Jan 2007 15:11:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jan 2007 15:11:33 -0000 Received: (qmail 28726 invoked by uid 500); 26 Jan 2007 15:11:36 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 28696 invoked by uid 500); 26 Jan 2007 15:11:35 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 28687 invoked by uid 99); 26 Jan 2007 15:11:35 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jan 2007 07:11:35 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mike.fursov@gmail.com designates 209.85.132.246 as permitted sender) Received: from [209.85.132.246] (HELO an-out-0708.google.com) (209.85.132.246) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jan 2007 07:11:26 -0800 Received: by an-out-0708.google.com with SMTP id b2so361206ana for ; Fri, 26 Jan 2007 07:11:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=uYW2BA3sll0OIr918kSzoMSIxjZB7hi2r0Z9m/uNpzH6sWU7fn0XQNUzGJ/jdjBCeVMDZkefAjHEuV2uvLUNxvRZJ2l4RHi+hVbd6WF0j/rccoMb3YoDBX3Vz5ATqLtfpHlSER7Yu//aP7wF8SYcqLqu2oB43Ho9+naE2wXVz9M= Received: by 10.115.47.1 with SMTP id z1mr116860waj.1169824265486; Fri, 26 Jan 2007 07:11:05 -0800 (PST) Received: by 10.114.130.4 with HTTP; Fri, 26 Jan 2007 07:11:05 -0800 (PST) Message-ID: Date: Fri, 26 Jan 2007 21:11:05 +0600 From: "Mikhail Fursov" To: dev@harmony.apache.org Subject: Re: [drlvm][magic] New Magic features proposal. In-Reply-To: <783bf8b0701250237u2a83b847wbd3a6476b87d4147@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10336_18779942.1169824265338" References: <783bf8b0701220250n4cd3b553kd97a07e72a1ecfa6@mail.gmail.com> <783bf8b0701220403n70faf048l560500712d274a3f@mail.gmail.com> <59713.210.9.143.64.1169473196.squirrel@sqmail.anu.edu.au> <45478.152.91.9.201.1169517639.squirrel@sqmail.anu.edu.au> <9623c9a50701230721i9237008mc370d0d941d71d4f@mail.gmail.com> <9623c9a50701231916v6a9f3521taf2423587ed5b883@mail.gmail.com> <783bf8b0701250237u2a83b847wbd3a6476b87d4147@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_10336_18779942.1169824265338 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/25/07, Pavel Afremov wrote: > > > The other possible way use annotation instead MyJNICalls > andMyNativeFastCalls > classes. Yes, I vote to have annotations for JNI methods to describe how to call JNI method. More specifically annotation must say which Java method to use as a fast path helper for a JNI call. For a method without annotation we can assume that the method has all possible side-effects and use our default helper. Here is the scenario with a solution how to pass arbitrary number of params from magic JNI helper into the native method in Java. Example 1. //JNI call without special annotation -> use default helper private static native void onTimeout(); The body of the default JNI helper: void VMHelperFastPath::callNativeDefault(Address method_handle) { //prepare all VM stuff (allocate M2N on stack, fill all required fields...) Address m2n = ..; Address jniEnv = ..; VMHelper::doDirectJNICallDefault(m2n,jniEnv); //proccess all sideeffects. } The most interesting part here is what VMHelper::callDirect is and where are params and call result? The answer is: JIT knows the semantic (but not internals!) of the helper: it expects that JNI call will be replaced with direct call. To call JNI method directly JIT must have several additional params like JNIEnv or m2n address. All other params and return value stays the same as in original call and JIT is able to restore them from helper inlining context. Example 2. JNI call with special annotation: method has no side effects: //@use JNI helper with name="VMHelperFastPath::callNativeFast" annotation is here private static native int getTimeout(); void VMHelperFastPath::callNativeFast(Address method_handle) { //nothing to prepare Address jniEnv = ..; VMHelper::doDirectJNICallFast(jniEnv); //nothing to process here } So, finally we have 3 new feature to support in JIT 1) On-stack allocations 2) Direct JNI calls with M2N context prepared 3) A contract that magic JNI wrapper calls original JNI method - so JIT can handle it's params and return type. Are there any potential drawbacks that I missed here? -- Mikhail Fursov ------=_Part_10336_18779942.1169824265338--