From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7466DBC69 for ; Thu, 22 Feb 2007 18:38:45 +0100 (CET) Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1MHcj7h013891 for ; Thu, 22 Feb 2007 18:38:45 +0100 Received: from [192.168.1.2] (che78-2-82-237-71-191.fbx.proxad.net [82.237.71.191]) by smtp6-g19.free.fr (Postfix) with ESMTP id C854758429; Thu, 22 Feb 2007 18:38:41 +0100 (CET) Message-ID: <45DDD521.8080004@inria.fr> Date: Thu, 22 Feb 2007 18:38:41 +0100 From: Xavier Leroy User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joel Reymont Cc: caml-list@inria.fr Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modules or classes? References: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com> In-Reply-To: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45DDD525.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 icfp:01 ocaml:01 compiler:01 overriding:01 reloading:01 class-based:01 markus:01 mottl:01 compilation:01 native-code:01 polluted:01 hacks:01 slides:01 > I'm reading through the icfp99 slides on classes vs modules in OCaml. > The part that I'm interested in starts on p27 where instruction > selection in the OCaml compiler is discussed. > > I'm not well-versed in the OCaml compiler code yet so I thought I would > ask the list: does the compiler use a module or class solution? It uses classes, inheritance and overriding (of generic code by processor-dependent code) for a few passes: instruction selection, reloading of spilled registers, and instruction scheduling. The other passes are either processor-independent or can be parameterized in a simpler way (e.g. register allocation, which is parameterized by the number of hardware registers in each register class). > The slides seem to favor the class-based solution but then I hear that > classes in OCaml are slow and people like Markus Mottl just plain > despise them :-). What does everyone else opine? Method dispatch is slightly slower than calls to unknown functions, but the compiler passes that use objects are not speed-critical anyway (most of the compilation time is spent elsewhere). I don't despise objects and classes: it's just that the kind of code that I usually write does not need them often. But there are some cases where they work better than other forms of parameterization available in OCaml. Ensuring that the native-code compiler is not polluted all over the place by Intel x86-specific hacks is one of them. - Xavier Leroy