From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 0DA677ED5C for ; Mon, 6 Aug 2012 13:03:03 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of dmitry.bely@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of dmitry.bely@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhYCAPp4H1DRVdy2m2dsb2JhbABFuTYIIgEBAQEBCAkLCRQngiABAQEEEgIsARseAwwGBQsNLiIBEQEFARwZIodbAQMMnH8JA4wjgnGETgoZJw1XiHEBBQyLPoNogxwDiEeNAo4vPoQD X-IronPort-AV: E=Sophos;i="4.77,717,1336341600"; d="scan'208";a="169181571" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Aug 2012 13:03:02 +0200 Received: by vcbgb22 with SMTP id gb22so4267090vcb.27 for ; Mon, 06 Aug 2012 04:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=5gB4fX+CDO7+bpnlCXsGdckB/Xr5NS02ZY+bYmC1Au8=; b=zWByVSRw0ouFiPSfqB4EVdBpUrujKeXBpuqwMKGES1NnZMQaTvWRme9tiW50ogBD3M IaDvfKWdTGdvzmXonbr3iSNRvaCQ4fiY095oAFUWGnO2EkF/CpskuRBQlabexJHY8aOr mXkzjWMBiyJVoPs48feSwkLODx6oVGozVA7F4hZ7wgspZXk/TOj1gg4+7ymP9vfSTt6C x0NEaPY7lHSdJf6FHAcyhuBTZPZn+VxqBqlUwupAAmCKl3Rn9hqQ4kaEZtIAyD13AvHK BAalikYMxKJgXlnJyVlUf9A+ga99bqzfNelT3epoPbbxk96b45QWqMgdaLhcHBetAlAS gtLw== MIME-Version: 1.0 Received: by 10.52.21.174 with SMTP id w14mr6687806vde.24.1344250981574; Mon, 06 Aug 2012 04:03:01 -0700 (PDT) Received: by 10.220.117.66 with HTTP; Mon, 6 Aug 2012 04:03:01 -0700 (PDT) In-Reply-To: <501F9DB9.2050805@frisch.fr> References: <501F9855.6080709@frisch.fr> <501F9DB9.2050805@frisch.fr> Date: Mon, 6 Aug 2012 15:03:01 +0400 Message-ID: From: Dmitry Bely To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Compiler bug? On Mon, Aug 6, 2012 at 2:34 PM, Alain Frisch wrote: > On 08/06/2012 12:20 PM, Dmitry Bely wrote: >> >> I always thought that local roots are memory-based. How GC knows that >> in this case [ebx] should be updated? (remember, the parameter was >> passed in [eax]) Could you point me to the relevant part of Ocaml >> compiler sources? > > > The compiler generates 'frame descriptors', which associate to each possible > GC call site the set of registers and stack slots which hold values. > > Look for caml_frame_descriptors. The logic to scan frame descriptors is in > asmrun/roots.c. The implementation of caml_call_gc (e.g. in amd64.S) > saves/restored machine registers to/from caml_gc_regs. Aha. _caml_call_gc is _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, like it does with memory-based local roots. The initial question if [ebx] contents is invalidated by GC remains open, at least for me. - Dmitry Bely