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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 4995D7ED5C for ; Wed, 8 Aug 2012 18:03:29 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dmitry.bely@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.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=mail4-smtp-sop.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 (mail4-smtp-sop.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=mail4-smtp-sop.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: ApAGAD+NIlDRVdy2m2dsb2JhbABFuFwCdggiAQEBAQEICRQUJ4IgAQEBBBICLAEbHgMMBgULDS4iAREBBQEcGSKHWwEDDJw1CQOMI4JxhUAKGScNV4hxAQUMiwaBb4FVgxwDiEiNAY4yPoQD X-IronPort-AV: E=Sophos;i="4.77,733,1336341600"; d="scan'208";a="152702148" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Aug 2012 18:03:20 +0200 Received: by mail-vc0-f182.google.com with SMTP id gb22so1568114vcb.27 for ; Wed, 08 Aug 2012 09:03:20 -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=cLW8DpQoViXa+WN6BLvlhl5eTkbzO1foY6T3moRSH0g=; b=k33RFu2Leul61mAo4LKCQ4gdJaCGG9l9m8suTg5QVr7HSvml0vwPqOKkp0wObiMgTe +pWbG/08IW5XpaM/ZWC2IkBlQ1GdhHCvLW42Hh6AkTK6ixPjF20Qd764Jg17THlYXqu0 5MApkjvOtp4BPg+J6TxhwF+Tl1IVp69GOSroNdVo/vIyP6ecKwO3dRQQZMTYh4SGB5u6 nv6c0l0TGzvHjlaV/2syOUW5pcsok/BuMtJBF3/TtbpPqPd6CuxCwOl66lgKNBLJHECV QVrILvM/7agHJsllZTPK39FVv2Z3tS3thy9DjH9u9O3C7MD4qzBmdy1cZwG76gj+lcjK ACjQ== MIME-Version: 1.0 Received: by 10.220.141.208 with SMTP id n16mr2286554vcu.22.1344441800267; Wed, 08 Aug 2012 09:03:20 -0700 (PDT) Received: by 10.220.117.66 with HTTP; Wed, 8 Aug 2012 09:03:19 -0700 (PDT) In-Reply-To: <501FAB4A.107@frisch.fr> References: <501F9855.6080709@frisch.fr> <501F9DB9.2050805@frisch.fr> <501FAB4A.107@frisch.fr> Date: Wed, 8 Aug 2012 20:03:19 +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 3:32 PM, Alain Frisch wrote: > 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. One more question if you don't mind. Why FPU registers are not saved before caml_garbage_collection? What guarantees that they are not destroyed inside? - Dmitry Bely