HipHop Virtual Machine
|Initial release||December 9, 2011|
|Stable release||3.11.0 / December 9, 2015|
|Written in||C++ and OCaml[a]|
|License||PHP License and Zend License|
HipHop Virtual Machine (HHVM) is a process virtual machine based on just-in-time (JIT) compilation that serves as an execution engine for the PHP and Hack programming languages. By using the principle of JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into the x86-64 machine code, optimized, and natively executed. This contrasts to the PHP's usual interpreted execution, in which the Zend Engine transforms the PHP source code into opcodes that serve as a form of intermediate code, and executes the opcodes directly on the Zend Engine's virtual CPU.
HHVM was created as the successor of the HipHop for PHP (HPHPc) PHP execution engine, which is a PHP-to-C++ transpiler that has also been created by Facebook. Based on the gained experience and aiming to solve issues introduced by HPHPc, Facebook decided in early 2010 to create a JIT-based PHP virtual machine. Issues associated with HPHPc included its reaching of a plateau for further performance improvements, lack of full support for all features of the PHP language, and difficulties arising from specific time- and resource-consuming development and deployment processes required for PHP projects that used HPHPc. In Q1 2013, the production version of facebook.com website stopped using HPHPc and switched to HHVM.
Following the JIT compilation principle, HHVM first converts the executed PHP or Hack code into a high-level bytecode, HHBC, which is also known as an intermediate language. HHBC is a bytecode format created specifically for HHVM, in a form that is appropriate for consumption by both interpreters and just-in-time compilers. As the next steps in execution, HHVM dynamically ("just-in-time") translates the HHBC bytecode into x86-64 machine code, performs its additional optimizations through a dynamic analysis of the translated bytecode, and executes the x86-64 machine code. As a result, HHVM has certain similarities to the virtual machines used by other programming languages, including the Common Language Runtime (CLR, for the C# language) and Java virtual machine (JVM, for the Java language).
HHVM brings many benefits in comparison with HPHPc, and one of them is almost complete support for the entire PHP language as defined by the official implementation of PHP version 5.4, including the HHVM's support for
eval() constructs. Furthermore, HHVM uses the same execution engine when deployed in both production and development environments, while supporting integration between the execution engine and the HPHPd debugger in both environment types; as a result, maintaining HPHPi (HipHop interpreter) separately as a development utility is no longer needed as it was the case with HPHPc. HHVM also eliminates the lengthy builds required by HPHPc to run PHP programs, resulting in much simpler development and deployment processes than it was the case with HPHPc.
Together with HHVM, Facebook also released Hack, which is a programming language specifically tailored for HHVM and can be seen as a new version of the PHP language. Hack allows programmers to use both dynamic typing and static typing, which is a concept also known as gradual typing, and allows types to be specified for function arguments, function return values, and class properties; however, types of local variables cannot be specified. At the same time, Hack does not provide complete backward compatibility by not carrying on some of the PHP features, such as the
goto statement and dynamic variable names.
Studies of end-user behavior conclude that the lack of speed in website operation and even small delays in web server response time, lower than half of a second, can have significant negative impacts on the end-user experience and overall performance of the website. Some formerly popular websites, such as Friendster, have suffered due to prolonged speed issues.
As a process virtual machine that provides the execution environment, HHVM has the ability to use live type information to produce more efficient native code, leading to a higher web server throughput and lower latency. In Q4 2012, the execution of facebook.com's source code on HHVM achieved performance parity with HPHPc, and in December 2013 HPHPc was even surpassed by around 15%.
- Jason Evans (December 9, 2011). "The HipHop Virtual Machine". Facebook. Retrieved August 2, 2014.
- "facebook/hhvm: Release HHVM-3.11.0". github.com. Facebook. December 9, 2015. Retrieved January 22, 2016.
- "Building and installing HHVM on CentOS 7.x". github.com. Facebook. May 26, 2015. Retrieved June 12, 2015.
- "Building the Hack typechecker". github.com. Facebook. September 10, 2014. Retrieved June 12, 2015.
- "facebook/hhvm: License". github.com. Facebook. Retrieved August 2, 2014.
- "facebook/hhvm". github.com. Facebook. Retrieved August 2, 2014.
- Kaushik Pal (April 28, 2014). "PHP and Zend Engine Internals". phpbuilder.com. Retrieved September 23, 2014.
- Drew Paroski (November 29, 2012). "Speeding up PHP-based development with HHVM". Facebook. Retrieved August 2, 2014.
- "Announcement on GitHub removing HPHPc support". github.com. Facebook. February 19, 2013. Retrieved May 24, 2013.
- Cade Metz (June 10, 2013). "How Three Guys Rebuilt the Foundation of Facebook". Wired. Retrieved September 28, 2014.
- "HipHop Bytecode v1 revision 18". github.com. Facebook. July 31, 2014. Retrieved May 24, 2013.
- "facebook/hhvm: About upgrade to PHP 5.4 engine". github.com. May 2013. Retrieved August 2, 2014.
- "facebook/hhvm: Home". github.com. Facebook. May 8, 2014. Retrieved August 2, 2014.
- Cade Metz (March 20, 2014). "Facebook Introduces 'Hack,' the Programming Language of the Future". Wired. Retrieved April 15, 2014.
- Julien Verlaguet; Alok Menghrajani (April 2014). "Hack: a new programming language for HHVM". code.facebook.com. Facebook. Retrieved March 23, 2014.
- Josh Lockhart (April 3, 2014). "Facebook's Hack, HHVM, and the future of PHP". O'Reilly Media. Retrieved August 2, 2014.
- "Hack and HHVM: Type Annotations (Hack Manual)". docs.hhvm.com. Retrieved March 25, 2014.
- "Hack and HHVM: Type Inference (Hack Manual)". docs.hhvm.com. Retrieved March 25, 2014.
- "Hack and HHVM: Unsupported PHP Features in Hack (Hack Manual)". docs.hhvm.com. Retrieved April 2, 2014.
- Brady Forrest (June 23, 2009). "Bing and Google Agree: Slow Pages Lose Users". O'Reilly Media. Retrieved September 28, 2014.
- Gary Rivlin (October 5, 2006). "Wallflower at the Web Party". The New York Times. Retrieved September 28, 2014.
- "We are the 98.5% (and the 16%)". hhvm.com. December 19, 2013. Retrieved August 2, 2014.
Find more about
HipHop Virtual Machine
at Wikipedia's sister projects
|Media from Commons|
|Documentation from MediaWiki|
- Official website and Facebook page
- HHVM source code repository on GitHub
- Internals of HHVM, a QCon conference 2012 talk by Keith Adams
- HHVM talk to Wikimedia, a March 2013 talk at the Wikimedia Foundation by Andrew Paroski
- on YouTube, a PHP UK Conference 2013 talk by Sara Goleman
- HHVM: The HipHop Virtual Machine, a PHP Conference Argentina 2013 talk by Guilherme Ottoni
- Next-generation PHP 7.0 is running well, but will it catch up to HHVM?, Phoronix, January 3, 2015, by Michael Larabel