memesearch

Виртуальная функция экономит код

Download Find similar pictures
Text on the meme
struct S { virtual ~S(); // defined elsewhere }; class T : public S { private: virtual void f(); }; int main() { T t; } main: push rax mov qword ptr [rsp], offset vtable for T+16 mov rdi, rsp call S::~S() [base object destructor] pop rax pop rcx ret T::~T() [deleting destructor]: push rbx mov rbx, rdi call S::~S() [base object destructor] mov rdi, rbx pop rbx ret vtable for T: .quad 0 .quad typeinfo for T .quad T::~T() [deleting destructor] typedef name for T: .asciz "T" typeinfo for T: .quad vtable for __cxxabiv1::__si_class_type_info+16 .quad typeinfo name for T .quad typeinfo for S
What it means

На экране показан редактор с кодом C++ слева и сгенерированным ассемблером справа. В ролике строка с виртуальным методом появляется и исчезает, а вместе с ней меняется объём сгенерированного кода и vtable. Шутка высмеивает малоизвестную деталь компиляции: виртуальная функция может привести к меньшему итоговому коду благодаря размещению vtable в одной единице трансляции и последующему удалению дубликатов линкером. EN: The screen shows a code editor with C++ code on the left and generated assembly on the right. In the clip, the line containing the virtual method appears and disappears, and the amount of generated code and the vtable change with it. The joke pokes fun at an obscure compiler detail: a virtual function can result in less final code because the vtable is placed in one translation unit and duplicate copies are later removed by the linker.

Objects
Tags
Source
Type
video, 0:08
Size
1280×720 · 941.6 KiB
Mood
саркастичный, абсурдный
Language
en
Added