eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingWywołanie wirtualne kontra wskaźnik do funkcji - optymalizacjaRe: Wywołanie wirtualne kontra wskaźnik do funkcji - optymalizacja
  • Data: 2009-08-06 09:52:49
    Temat: Re: Wywołanie wirtualne kontra wskaźnik do funkcji - optymalizacja
    Od: Jakub Debski <d...@w...pl> szukaj wiadomości tego autora
    [ pokaż wszystkie 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: