Browse thread
Instruction selection in the OCaml compiler: Modules or classes?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: [Caml-list] Instruction selection in the OCaml compiler: Modules or classes? |
> 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