While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:
How HHVM Uses Modern C++ for Fun and Profit (Literally)
by Drew Paroski
Summary of the talk:
HHVM is a just-in-time compiler for PHP used by Facebook to serve billions of requests each day. This talk will give a quick overview of HHVM's history and architecture, followed by a deep dive into what made C++ the language of choice for writing HHVM.
C++ hits a sweet spot between performance and control on one end, and safety, maintainability, and convenience on the other.
The topics we’ll cover will include:
how to call into generated machine code from C++;
taking advantage of C++'s power to control "unsafe" details with memory including how memory is allocated, field size and layout, unions, reinterpret_casts, bit-stealing;
integrating generated machine code with C++ exception handling and C++ profiling tools;
leveraging templates and using the X Macro technique to improve performance and maintainability;
and taking advantage of new C++11 features like unrestricted unions and move constructors.
Finally, we'll go over some obstacles we encountered such as generating machine code that calls C++ virtual methods, and how C++'s superb flexibility allowed us to work around these obstacles.