From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id BB7C3BC57 for ; Thu, 18 Nov 2010 19:19:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8BAOP85EzRVdY0kGdsb2JhbACUU415CBUBAQEBCQkMBxEDH6UGi3oBBY4nAQSFSw X-IronPort-AV: E=Sophos;i="4.59,218,1288566000"; d="scan'208";a="80050694" Received: from mail-bw0-f52.google.com ([209.85.214.52]) by mail2-smtp-roc.national.inria.fr with ESMTP; 18 Nov 2010 19:19:30 +0100 Received: by bwz4 with SMTP id 4so3045606bwz.39 for ; Thu, 18 Nov 2010 10:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=W5P7o2ZsCqqG3LgWXujfKfMKTlGYStkMy6MIZiID2is=; b=lA1ca60QQ4At+2ulBhtXp434gzHcMcCaZaOQUi/cPX9PprHI962H1XwoR8yYWjM3Ba Ix/UwsNpNOnRpB9ccB6c0RdSzQTKUQf7wfvKRi2VeAIIR6qBir6XPbf2/iGcudhGSUk4 FFgh0L1S0N59bgvu5fINgWW5PHw3nbX7nhOSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=U7J2A8QeOlAAfpA8+4dHiUkvXeKvxY9XweJkMHozRM8dakZIRsOIDrRWTgqSH7H1JH spccdxy0Qr76iYQoeQg9B9nfNe8Z86IqYx/lIwJXuSMS6hmriXrNoDPMk2YqAQWGSx1C lsGtBBmU7Y6iiEqlaqUcbyU5ad/sfBFcOpeHg= Received: by 10.204.51.132 with SMTP id d4mr926655bkg.89.1290104369989; Thu, 18 Nov 2010 10:19:29 -0800 (PST) Received: from bespin.kosmos.all (ip-95-223-170-32.unitymediagroup.de [95.223.170.32]) by mx.google.com with ESMTPS id d27sm385377bkw.14.2010.11.18.10.19.26 (version=SSLv3 cipher=RC4-MD5); Thu, 18 Nov 2010 10:19:27 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: Native toplevel? (was: OCamlJit 2.0) From: Benedikt Meurer In-Reply-To: <4CE395D4.4000105@frisch.fr> Date: Thu, 18 Nov 2010 19:19:25 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <41279EC0-AE2A-44CD-8028-29BD08DAEBCA@googlemail.com> References: <4CE395D4.4000105@frisch.fr> To: caml-list@yquem.inria.fr X-Mailer: Apple Mail (2.1081) X-Spam: no; 0.00; toplevel:01 frisch:01 dynlink:01 toplevel:01 compiler:01 mlp:01 mlp:01 lexifi:01 compiler:01 ocamlopt:01 byte-code:01 2.0:98 wrote:01 dynamically:01 emit:01 On Nov 17, 2010, at 09:44 , Alain Frisch wrote: > There is actually already a native top-level in the distribution, even = though it is undocumented and unmaintained. You can build it with the = "make ocamlnat" target. The implementation is based on the same = approach as native dynlink. The toplevel embeds the native compiler; = for each phrase, the toplevel produces assembly code, calls the = assembler and the linker to produce a dynamic/shared library, and then = dynamically load and execute the resulting code. This gives some = latency, but it's not so bad in practice, and you get the full speed of = native code. >=20 > A further step to improve this native toplevel is to avoid the call to = the external assembler and linker. To do that, one basically needs to = replace the assembly code emitters (emit.mlp/emit_nt.mlp) with native = code emitters and do the relocation/dynamic loading by hand, which is = quite easy. >=20 > As it turns out, LexiFi uses on a daily basis such direct binary code = emitters for x86/amd64 on Windows, and that would be easy to port to = other x86/amd64 platforms. The x86 version was developed internally, = and the amd64 version was done by Fabrice Le Fessant. There is also = some code to wrap the binary code into COFF objects (and flexdll has a = stand-alone mode to produce .cmxs files without an external linker), but = that would be useless for a native toplevel. The goal was to have a = compiler which can be more easily embedded in our applications and = deployed to our customers, without depending on any external tool. >=20 > If you Benedikt, or someone else, is willing to work on a native = top-level without the need to call an external assembler/linker, we are = ready to extract the binary code emitters from our code base and share = them with the community (with an open-source license to be determined). = This requires some packaging work on our side, so we're going to do it = only if there is interest in the project. This is indeed very interesting. I haven't thought of the native = top-level. I haven't done any measurements yet, but from my experience = with ocamlopt, I know that the optimizing native compiler is somewhat = slower than the byte-code compiler. I doubt that this is related solely = to the external as/ld invocations, so there's certainly more work to do = than just replacing the calls to as/ld with an in-process = assembler/linker. > -- Alain Benedikt=