caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dmitry Bely <dbely@mail.ru>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Timing Ocaml
Date: Tue, 11 Jun 2002 12:28:33 +0400	[thread overview]
Message-ID: <zny2qkwe.fsf@mail.ru> (raw)
In-Reply-To: <000001c2109e$d1052e10$5ccdfea9@fourquauu8eg3x> ("Lionel Fourquaux"'s message of "Mon, 10 Jun 2002 18:49:39 +0200")

"Lionel Fourquaux" <lionel.fourquaux@wanadoo.fr> 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


  reply	other threads:[~2002-06-11  8:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-10  5:35 Blair Zajac
2002-06-10  6:24 ` Chris Hecker
2002-06-10 12:02   ` Dmitry Bely
2002-06-10 12:50     ` Remi VANICAT
2002-06-10 14:19       ` Lionel Fourquaux
2002-06-10 15:01 ` Xavier Leroy
2002-06-10 16:29   ` Dmitry Bely
2002-06-10 16:49     ` Lionel Fourquaux
2002-06-11  8:28       ` Dmitry Bely [this message]
2002-06-11  9:08         ` Xavier Leroy
2002-06-11 12:52         ` Mattias Waldau
2002-06-10 18:19   ` Blair Zajac
2002-06-11  9:23     ` Florian Hars

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=zny2qkwe.fsf@mail.ru \
    --to=dbely@mail.ru \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).