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 PAA07345; Mon, 3 May 2004 15:02:30 +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 PAA07120 for ; Mon, 3 May 2004 15:02:29 +0200 (MET DST) Received: from qrnik.knm.org.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i43D2SSH006965 for ; Mon, 3 May 2004 15:02:28 +0200 Received: from qrnik ([192.168.0.1] ident=qrczak) by qrnik.knm.org.pl with esmtp (Exim 3.36 #1) id 1BKd5Y-0001LV-00 for caml-list@inria.fr; Mon, 03 May 2004 15:02:28 +0200 Subject: Re: [Caml-list] Re: Tail-calls in C code (was: [ANN] The Missing Library) From: "Marcin 'Qrczak' Kowalczyk" To: caml-list@inria.fr In-Reply-To: <82AD726A-9CF5-11D8-823C-0003937628DA@uni-muenster.de> References: <82AD726A-9CF5-11D8-823C-0003937628DA@uni-muenster.de> Content-Type: text/plain; charset=ISO-8859-2 Message-Id: <1083589347.1643.169.camel@qrnik> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.5.7 Date: Mon, 03 May 2004 15:02:28 +0200 Content-Transfer-Encoding: quoted-printable X-Miltered: at concorde with ID 409642E4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 marcin:01 'qrczak':01 kowalczyk:01 qrczak:01 gcc:01 -fpic:01 -fpic:01 gcc:01 unexpected:01 marcin:01 kowalczyk:01 qrczak:01 computed:01 assembler:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk W li=B6cie z pon, 03-05-2004, godz. 13:32 +0200, Wolfgang Lux napisa=B3: > Compiling logic programs to {C} using {GNU C} as a portable assembler, > as long as you do not want to compile position independent code. So it's not that portable :-) Well, I'm worried about violating GCC rules so badly, when jumping to a label from a different function. What if the functions have different stack frame sizes? Are you sure it works e.g. when one function uses a variable length array, and thus uses %ebp even though -fomit-frame-pointer is in effect and other functions don't use %ebp? Who is responsible for adjusting %esp along the jumps? What if one function has put callee-saved registers on the stack and happily uses them for local variables, where the other doesn't, and jumping from the second function to the first and back clobbers %ebx which is not properly restored later? Anyway, my scheme in theory works with -fPIC but it generates horrible code, on x86 at least. The pointer to global variables is computed in each function separately, and since virtual registers are in global variables... Normal C functions don't use so many globals so -fPIC doesn't hurt them that much. I guess that normal C code doesn't have to recompute the pointer to globals in all cases when jumping between static functions. But gcc doesn't know that the address of the function being taken will not be really returned but will be the target of a jump, so it must prepare the code to be called from unexpected places. --=20 __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ ------------------- 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