Lab 9: Virtual Method Dispatch in C++

In this laboratory, you will investigate how GCC implements virtual method calls in C++.

Submission Due: the beginning of your next lab session.

Lab Materials

  1. Slides

  2. Source Code

Assignment

Compile main.cpp from the provided tar file into an assembly file by running g++ -m32 main.cpp -S -O3. Note, main.cpp does not contain implementations of the method and thus cannot be compiled into an executable.

Write a two-to-three paragraph report describing

  • How a non-virtual method call is implemented in make_static_call versus how virtual method calls are implemented in make_virtual_call and make_virtual_call_2.

  • How the assembly generated for make_virtual_call and make_virtual_call_2 call different virtual methods.

This report is all you will submit for this lab assignment.