From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA01038; Mon, 3 May 2004 13:31:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA01057 for ; Mon, 3 May 2004 13:31:52 +0200 (MET DST) Received: from ZIVLNX01.uni-muenster.de (ZIVLNX01.UNI-MUENSTER.DE [128.176.188.24]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i43BVpSH021168 for ; Mon, 3 May 2004 13:31:51 +0200 Received: from localhost (unknown [127.0.0.1]) by ZIVLNX01.uni-muenster.de (Postfix) with ESMTP id 2756C36808; Mon, 3 May 2004 13:31:50 +0200 (CEST) Received: from ZIVLNX01.uni-muenster.de ([127.0.0.1]) by localhost (ZIVLNX01 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13484-02; Mon, 3 May 2004 13:31:49 +0200 (CEST) Received: from uni-muenster.de (VPNPOOL01-0247.UNI-MUENSTER.DE [128.176.151.1]) by ZIVLNX01.uni-muenster.de (Postfix) with ESMTP id CD80536870; Mon, 3 May 2004 13:31:47 +0200 (CEST) Date: Mon, 3 May 2004 13:32:08 +0200 Subject: [Caml-list] Re: Tail-calls in C code (was: [ANN] The Missing Library) Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v553) Cc: caml-list@inria.fr To: "Marcin 'Qrczak' Kowalczyk" From: Wolfgang Lux In-Reply-To: <1083574691.1643.55.camel@qrnik> Message-Id: <82AD726A-9CF5-11D8-823C-0003937628DA@uni-muenster.de> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.553) X-Virus-Scanned: by amavisd-new at uni-muenster.de X-Miltered: at concorde with ID 40962DA7.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; wlux:01 uni-muenster:01 marcin:01 'qrczak':01 kowalczyk:01 trampoline:01 gcc:01 30%.:99 fergus:01 compiler:01 compiler:01 assembler:01 assembler:01 variant:02 compile:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Marcin 'Qrczak' Kowalczyk wrote: > The portable variant uses the well-known trampoline style, where each C > function returns a pointer to the next function to jump into. The stack > is managed explicitly. But for x86 I process the assembler output of > gcc > and convert code which returns an address (marked with a comment in > asm) > with a jump. This increased performance by about 30%. > > If the compiler is ever used on other architectures, someone who knows > other assemblers might extend the mangler to handle them. I only know > the x86 assembly. You can find a somewhat more portable way to achieve a similar effect using Gnu C in order to emit ``portable assembler'' code instead of post-processing the compiled assembler code here: Fergus Henderson and Thomas Conway and Zoltan Somogyi, Compiling logic programs to {C} using {GNU C} as a portable assembler, Proc. ILPS '95 Postconference Workshop on Sequential Implementation Technologies for Logic Programming, pp. 1-15. http://www.cs.mu.oz.au/mercury/information/papers/mercury_to_c.ps.gz I'm using that in my Curry compiler as well and it works nicely on Linux, Solaris, and other OSes as long as you do not want to compile position independent code. Unfortunately, it doesn't work on Mac OS X for exactly that reason. Wolfgang ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners