caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Dmitry Bely <dmitry.bely@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Compiler bug?
Date: Mon, 06 Aug 2012 13:32:26 +0200	[thread overview]
Message-ID: <501FAB4A.107@frisch.fr> (raw)
In-Reply-To: <CAMT7qiR=7LS3211gkA2HOVwB+BQj81cs1efjy3eBESgqW03s5g@mail.gmail.com>

On 08/06/2012 01:03 PM, Dmitry Bely wrote:
> _caml_call_gc:
>      ; Record lowest stack address and return address
>          mov	eax, [esp]
>          mov     _caml_last_return_address, eax
>          lea     eax, [esp+4]
>          mov     _caml_bottom_of_stack, eax
>      ; Save all regs used by the code generator
> L105:   push    ebp
>          push    edi
>          push    esi
>          push    edx
>          push    ecx
>          push    ebx
>          push    eax
>          mov     _caml_gc_regs, esp
>      ; Call the garbage collector
>          call	_caml_garbage_collection
>      ; Restore all regs used by the code generator
> 	pop     eax
>          pop     ebx
>          pop     ecx
>          pop     edx
>          pop     esi
>          pop     edi
>          pop     ebp
>      ; Return to caller
>          ret
>
> it preserves registers and so it cannot update them

No, this code does not preserves registers.  It stores them on the 
stack, pass a pointer to them to the C code (in caml_gc_regs), and then 
restore their values from the stack.  In between, the C code has updated 
the values on the stack, so the restored values are not the saved ones.

-- Alain

  reply	other threads:[~2012-08-06 11:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 10:04 Dmitry Bely
2012-08-06 10:11 ` Alain Frisch
2012-08-06 10:20   ` Dmitry Bely
2012-08-06 10:34     ` Alain Frisch
2012-08-06 11:03       ` Dmitry Bely
2012-08-06 11:32         ` Alain Frisch [this message]
2012-08-06 12:16           ` Dmitry Bely
2012-08-07  1:35           ` Cedric Cellier
2012-08-08 16:03           ` Dmitry Bely
2012-08-08 18:03             ` Alain Frisch
2012-08-08 18:22               ` Jesper Louis Andersen
2012-08-08 18:40                 ` Dmitry Bely
2012-08-08 19:29                   ` Fabrice Le Fessant
2012-08-08 23:34                 ` Anil Madhavapeddy
2012-08-09  0:53                 ` Francois Berenger
  -- strict thread matches above, loose matches on Subject: below --
2006-05-17 23:14 compiler bug? Dan Koppel
2006-05-17 23:33 ` [Caml-list] " John Carr
2006-05-18 17:15 ` Xavier Leroy
2006-05-18 17:34   ` Jacques Carette
2006-05-18 17:46     ` Xavier Leroy
2006-05-18 19:31       ` Jacques Carette
2006-05-18 20:07         ` David Brown
2006-05-18 20:15           ` Jacques Carette
2006-05-18 20:20           ` Alain Frisch
2006-05-18 18:19     ` skaller
2006-05-18 18:53       ` Jacques Carette
2006-05-19  1:47         ` skaller
2006-05-19  2:17           ` Brian Hurt
2006-05-19  3:11             ` skaller
2006-05-19 16:48           ` Jacques Carette
2006-05-19 19:10             ` skaller

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=501FAB4A.107@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=dmitry.bely@gmail.com \
    /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).