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 KAA04352; Tue, 11 Jun 2002 10:35:47 +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 KAA04356 for ; Tue, 11 Jun 2002 10:35:46 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g5B8ZjH26420 for ; Tue, 11 Jun 2002 10:35:45 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g5B8Zaa21652 for caml-list@inria.fr; Tue, 11 Jun 2002 12:35:36 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from bely.stormoff (BELY) [192.168.0.10] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 17Hh0w-0008OZ-00; Tue, 11 Jun 2002 12:28:30 +0400 X-Comment-To: "Lionel Fourquaux" To: caml-list@inria.fr Subject: Re: [Caml-list] Timing Ocaml References: <000001c2109e$d1052e10$5ccdfea9@fourquauu8eg3x> From: Dmitry Bely Date: Tue, 11 Jun 2002 12:28:33 +0400 In-Reply-To: <000001c2109e$d1052e10$5ccdfea9@fourquauu8eg3x> ("Lionel Fourquaux"'s message of "Mon, 10 Jun 2002 18:49:39 +0200") Message-ID: User-Agent: Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Economic Science (Windows [1]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "Lionel Fourquaux" writes: >> Thank a lot for the explanation. But why then not to use inline asm > for >> MSVC, something like that: > > Because any fragment of inline asm disable a lot of > optimisations in MSVC, and you end up with a much slower interpreter. I see... But there is another solution: use C switch() operator in interp main loop that is translated to jump table by MSVC optimizer (don't know if gcc is capable to do this). A small example: int f( int i ) { int j = 0; switch( i ){ case 1: j = 2; break; case 2: j = 4; break; case 3: j = 8; break; case 4: j = 16; break; } return j; } cl -c -Ox -Fatest.lst test.c TITLE test.c .386P include listing.inc if @Version gt 510 .model FLAT else _TEXT SEGMENT PARA USE32 PUBLIC 'CODE' _TEXT ENDS _DATA SEGMENT DWORD USE32 PUBLIC 'DATA' _DATA ENDS CONST SEGMENT DWORD USE32 PUBLIC 'CONST' CONST ENDS _BSS SEGMENT DWORD USE32 PUBLIC 'BSS' _BSS ENDS _TLS SEGMENT DWORD USE32 PUBLIC 'TLS' _TLS ENDS FLAT GROUP _DATA, CONST, _BSS ASSUME CS: FLAT, DS: FLAT, SS: FLAT endif PUBLIC _f _TEXT SEGMENT _i$ = 8 _f PROC NEAR ; File test.c ; Line 4 mov ecx, DWORD PTR _i$[esp-4] xor eax, eax dec ecx cmp ecx, 3 ja SHORT $L526 jmp DWORD PTR $L536[ecx*4] $L529: ; Line 5 mov eax, 2 ; Line 11 ret 0 $L530: ; Line 6 mov eax, 4 ; Line 11 ret 0 $L531: ; Line 7 mov eax, 8 ; Line 11 ret 0 $L532: ; Line 8 mov eax, 16 ; 00000010H $L526: ; Line 11 ret 0 npad 1 $L536: DD $L529 DD $L530 DD $L531 DD $L532 _f ENDP _TEXT ENDS END Hope to hear from you soon, Dmitry ------------------- 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