eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingWywołanie wirtualne kontra wskaźnik do funkcji - optymalizacja › Re: Wywołanie wirtualne kontra wskaźnik do funkcji - optymalizacja
  • Path: news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news-2.dfn.de!ne
    ws.dfn.de!news.uni-stuttgart.de!news.nask.pl!news.nask.org.pl!news.internetia.p
    l!not-for-mail
    From: Jakub Debski <d...@w...pl>
    Newsgroups: pl.comp.programming,pl.comp.lang.c
    Subject: Re: Wywołanie wirtualne kontra wskaźnik do funkcji - optymalizacja
    Date: Thu, 06 Aug 2009 11:52:49 +0200
    Organization: Netia S.A.
    Lines: 36
    Message-ID: <m...@w...pl>
    References: <h5d3t9$g7h$1@inews.gazeta.pl>
    NNTP-Posting-Host: 77-252-162-178.ip.netia.com.pl
    Mime-Version: 1.0
    Content-Type: text/plain; charset="iso-8859-2"; format=flowed
    Content-Transfer-Encoding: 8bit
    X-Trace: mx1.internetia.pl 1249553070 5805 77.252.162.178 (6 Aug 2009 10:04:30 GMT)
    X-Complaints-To: a...@i...pl
    NNTP-Posting-Date: Thu, 6 Aug 2009 10:04:30 +0000 (UTC)
    X-Tech-Contact: u...@i...pl
    X-Plugin-FACETOCH: http://chasta971.free.fr/mesnews/
    X-Newsreader: MesNews/1.08.03.00-gb
    Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUEAgSPDARSEQQcFAvQBgQ0FQ
    ZwDwSxCQQnDgbrBAQMDQxoFwQWEhQkDBQXDhRJFgT6HB4IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB
    v0lEQVR4nNWSv0sjQRTHB0VZhmvWHwHLLBeLawI+dpFB7hAEWa7SYRQOZMmoK1ayEFyOqw6xsRMCIV
    1ku4dwlX+B3ZL/wkaCpIishRZxNoLuZNY/4KZ8H77f9+a9LyH/5aPlZUwRsWvWE+B9RdAAQogelhDq
    OLW9wVpquFkN+0QAPPRySZFZC1FlJATPgeZmLW1GjlPP+3S1sa3mRlwJ63xgTLzUUqC21zfAwRjwMd
    CafO1ElVAKUC30ka/8dQVqHPEWWBHM+m3bjg4Bwa3zopf1uxNHG/spQiKY8npntNHstGMOwDFJi4DA
    9sJlxjC4gfHCPtrQ6yBkXfTCWp/1ioAkox3Wpbutw8HqQPvl9NOyAt6pcAVPi4AezDHEBFwRaPMSuh
    XmF7w+D0Y6IK53oRR3rgHQ+4WojII608GXnWdET6pzMX3509VviD9s6WQTClqdx3sYhjJTV9EkW3Nn
    AYOhfJyM19RmuI8gHD4ZVstvL4qXbLhmpPi4HcvGnxEzkvr3qCkDO2OGYmZbOg07bzGZot3Y7/z8jm
    bsr1p+64ahKaHLTsaxBJAV+dgrcSLkX1jqpLwA3uqmiOL7+xS8Ai8E6F0cB40CAAAAAElFTkSuQmCC
    X-Face: =a,yA}ET[E$'Ukoo$iL|^i5vJ>Z.={}a.hUP,Y~!:yAm={Ov6$|vV63nNMe*sPb4IQ3`js-
    2dGXf?A#HXe<2Q|Pu1[k6!z:x[D\G5(Y]dnoY}}gc\3GQS{p49"FU^B3i`"1I=[e4R5v**LG7a[]z,
    @/Hf*7=#YEg`
    X-Server-Info: http://www.internetia.pl/news/
    Xref: news-archive.icm.edu.pl pl.comp.programming:183033 pl.comp.lang.c:283985
    [ ukryj nagłówki ]

    on 2009-08-06, Mariusz Marszałkowski supposed :
    > Czy w kompilatorach C++ ktoś zaimplementował jakieś optymalizacje do
    > metod wirtualnych? Chodzi mi o jakąś technikę, dzięki której kompilator
    > może wygenerować szybszy kod dla wywołań wirtualnych niż dla zwykłych
    > wskaźników do funkcji.

    Visual C++ od wersji 2005 przy użyciu Profile-Guided Optimization robi:

    Virtual Call Speculation. Virtual calls can be expensive due to the
    jumping through the vtable to invoke method. With PGO, the compiler can
    speculate at the call site of a virtual call and inline the method of
    the speculated object into the virtual call site; the data to make this
    decision is gathered with the instrumented application. In the
    optimized code, the guard around the inlined function is a check to
    ensure that the type of the speculated object matches the derived
    object.

    G++ od wersji 3.0 ma:

    If the library exports constructors to the user,
    all the user callable virtual functions of the
    class and its ancestors must be exported. Although
    virtual functions are normally called
    via the vtable (and therefore their names are
    not needed, just the index in the vtable), by exposing
    the constructor it might be possible to
    determine the dynamic type of an expression at
    compile time. Should the compiler do that, it
    may elect to replace a virtual call with a direct
    call, and hence require the name of the virtual
    function.

    pozdrawiam,
    Jakub


Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: