220 40319 <4489f889-977c-45f2-8a2f-186ee3b06bff@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Runtime code generation and self modifying code
Date: Thu, 4 Oct 2018 17:35:50 -0700 (PDT)
Lines: 66
Approved: news@gmane.org
Message-ID: <4489f889-977c-45f2-8a2f-186ee3b06bff@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_530_1020567351.1538699750987"
X-Trace: blaine.gmane.org 1538699627 8165 195.159.176.226 (5 Oct 2018 00:33:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 5 Oct 2018 00:33:47 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDELF54RTIGRB2HD3LOQKGQENRIJFEI@isocpp.org Fri Oct 05 02:33:43 2018
Return-path: <std-proposals+bncBDELF54RTIGRB2HD3LOQKGQENRIJFEI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb1-f198.google.com ([209.85.219.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDELF54RTIGRB2HD3LOQKGQENRIJFEI@isocpp.org>)
	id 1g8E3r-000230-7O
	for gclcip-std-proposals@m.gmane.org; Fri, 05 Oct 2018 02:33:43 +0200
Original-Received: by mail-yb1-f198.google.com with SMTP id o2-v6sf5937504ybq.18
        for <gclcip-std-proposals@m.gmane.org>; Thu, 04 Oct 2018 17:35:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=5bC+B7Xz24a8BaWf6nrcvYJnbbR3azeVkNMMCJnh9+M=;
        b=e4ximYX2rGLd9HcIcJrMGeSWbP/ggonwarg7Y3wIkK8hT2S/pRMyAa6qy/HRkqRyDS
         CO2sTJ3mfrIITfAzNPVy9wkGSDRFOi6tS7VUo3ut3K3SvE2eoosEXU29Xl86bSR4s2Lt
         PujRL9sxr3nlWoOlXneKd6ugjOMdfxuicV4jiBAW6wVbh2JNBlP/YiiLEUs8GBSvMo66
         oEYynBxJ63DRO91wgWkbbWwfBZLLXuur4LsLGoyEgbw2UhwLGBsmCQQARBSPgOvNeAIz
         O2HjY2DS8uV2A5HiBc+xYr9xH0DQ0Nydclyzsr4+ltCJPY/K9sej0vAcprSvPaPYc/qz
         VWyg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=5bC+B7Xz24a8BaWf6nrcvYJnbbR3azeVkNMMCJnh9+M=;
        b=nRpjvmi2rPS1qnOJXEkJ4P8+Z3nVE9vb64H55fl+w03CUEfFOtsJwYlvq+X/dCbV3u
         XSYSOxQ+lYl1xKv3N0blk+dF6fUbyp8sBPNARPS3DvrW0AgTjJD3ZtcG3MtyNolCC5v+
         nzONAczYzpno9SujVr+dMfkFKHcHcAxcfHJdMdcgqnqAu5ZWp7HDGtCXgrJuigH9W54G
         f33sXrr8Vga8PX01B8nOQa3T/5J+K4CY+D8UaQWz0XioWktSSGiSsMC01PDXptISkfv0
         HrzRMctyMM7gfcbYBgn0RY5MlJ4yxs/qT2KR7l1wGFH7w4a2pyRzncKsWps+oVGB2wlF
         4avQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=5bC+B7Xz24a8BaWf6nrcvYJnbbR3azeVkNMMCJnh9+M=;
        b=Ooi/TuYiUmO8xpK9nlGTlNE93tUOnj4b/SnhDKhXOLfUvcN4RXGmD2VTPovs5Wwj9l
         J0pUMTZ0NT+kmYn3yWyWg2TjGEUqzH48LDWQIMvI5HDsPtsjKCmxMrDOUwnduPNshEPe
         gX9boQ8vdS5DRE0t/FPVeJzNyS7Hje6+RS9q6jQYhcGO/5tMYjK2ieBjNwfhcp+SlVbA
         DFUCDGGDgZhJmXlnp2oSgCHwD2Env8v74hqIGTtXEt35N8N1nXCG3/5i3gaSZyhCtazG
         xnpLq+OhRQZl7yLVMBvXKyk7yJWpADkPrO85/fsaQxTNIbEtX7fUdPukiBtCPDw2u0uH
         xGMA==
X-Gm-Message-State: ABuFfojnNsN0zi+ZisV1uhfyN+ZwYefMCY7E5IZcDgaQRuJNzMwFHXnT
	/w73dByJlR7klFZ9gLWVo4RUvw==
X-Google-Smtp-Source: ACcGV60Mnxt+M9wbLnbQEp9aan7vSjmn3c+uD5EJNXchXj8H4LUdLE3hHZPJHnSEanV56ZzPwDUpSA==
X-Received: by 2002:a25:38d1:: with SMTP id f200-v6mr4461517yba.59.1538699753504;
        Thu, 04 Oct 2018 17:35:53 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:ae21:: with SMTP id m33-v6ls1042504ywh.9.gmail; Thu, 04
 Oct 2018 17:35:52 -0700 (PDT)
X-Received: by 2002:a81:78c6:: with SMTP id t189-v6mr95421ywc.7.1538699751765;
        Thu, 04 Oct 2018 17:35:51 -0700 (PDT)
X-Original-Sender: fmatthew5876@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40319
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40319>

------=_Part_530_1020567351.1538699750987
Content-Type: multipart/alternative; 
	boundary="----=_Part_531_1032808767.1538699750987"

------=_Part_531_1032808767.1538699750987
Content-Type: text/plain; charset="UTF-8"

One big area where dynamic languages are way ahead of C++ is runtime 
dynamic code generation or self modifying code.


One tiny example is singleton initialization. The only safe way in C++ to 
do non-constexpr singletons is by lazy init. 

The problem with lazy init is that you have to pay for a branch on every 
access, and that usually involves an atomic check.

What if you instead you atomically overwrote the check with NOPS. Then the 
branch is gone and accessing the object is as efficient as if it weren't 
lazy.

Has anyone considered writing proposals for improving runtime code gen with 
C++?

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4489f889-977c-45f2-8a2f-186ee3b06bff%40isocpp.org.

------=_Part_531_1032808767.1538699750987
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>One big area where dynamic languages are way ahead of=
 C++ is runtime dynamic code generation or self modifying code.<br></div><d=
iv><br></div><div><br></div><div>One tiny example is singleton initializati=
on. The only safe way in C++ to do non-constexpr singletons is by lazy init=
.. <br></div><div><br></div><div>The problem with lazy init is that you have=
 to pay for a branch on every access, and that usually involves an atomic c=
heck.</div><div><br></div><div>What if you instead you atomically overwrote=
 the check with NOPS. Then the branch is gone and accessing the object is a=
s efficient as if it weren&#39;t lazy.<br></div><div><br></div><div>Has any=
one considered writing proposals for improving runtime code gen with C++?<b=
r></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4489f889-977c-45f2-8a2f-186ee3b06bff%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4489f889-977c-45f2-8a2f-186ee3b06bff=
%40isocpp.org</a>.<br />

------=_Part_531_1032808767.1538699750987--

------=_Part_530_1020567351.1538699750987--

.
