HHVM explained

HHVM
Logo Size:x64px
Logo Alt:HHVM logo, featuring white uppercase "HHVM" letters on a black background, with stylized triangular geometric shapes on the left
Developer:Meta Platforms
Released:[1]
Programming Language:PHP, C++,[2] OCaml[3] and Rust[4]
License:PHP License and Zend License[5]

HipHop Virtual Machine (HHVM) is an open-source virtual machine based on just-in-time (JIT) compilation that serves as an execution engine for the Hack programming language. By using the principle of JIT compilation, Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into x86-64 machine code, optimized, and natively executed.[6] [7] This contrasts with PHP's usual interpreted execution, in which the Zend Engine transforms PHP source code into opcodes that serve as a form of bytecode, and executes the opcodes directly on the Zend Engine's virtual CPU.[8]

HHVM is developed by Meta, with the project's source code hosted on GitHub;[9] it is licensed under the terms of the PHP License and Zend License.

Overview

HHVM was created as the successor to the HipHop for PHP (HPHPc) PHP execution engine, which is a PHP-to-C++ transpiler also created by Facebook.[10] [11] Based on the gained experience and aiming to solve issues introduced by HPHPc, Meta decided in early 2010 to create a JIT-based PHP virtual machine. Issues associated with HPHPc included reaching a plateau for further performance improvements, a fundamental inability to support all features of the PHP language, and difficulties arising from specific time- and resource-consuming development and deployment processes. In Q1 2013, the production version of the facebook.com website stopped using HPHPc and switched to HHVM.

Following the JIT compilation principle, HHVM first converts the executed code into an intermediate language, the high-level bytecode HHBC. HHBC is a bytecode format created specifically for HHVM, appropriate for consumption by both interpreters and just-in-time compilers. Next, HHVM dynamically ("just-in-time") translates the HHBC into x86-64 machine code, optimized through dynamic analysis of the translated bytecode. Finally, it executes the x86-64 machine code.[12] 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. 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 programs, resulting in much simpler development and deployment processes than it was the case with HPHPc. Finally, versions of HHVM before 4.0 have almost complete support for the entire PHP language (as defined by the official implementation of PHP version 5.4), including the support for the create_function and eval constructs, which was impossible with HPHPc.[13] [14]

Together with HHVM 3.0,[15] Meta also released Hack, a derivative of PHP[16] [17] that allows programmers to use both dynamic typing and static typing (a concept also known as gradual typing), and allows types to be specified for function arguments, function return values, and class properties. However, Hack does not provide complete backward compatibility since it removes several PHP features, such as the [[goto]] statement and dynamic variable names.[18] [19] [20] [21]

In September 2017, it was announced that version 3.30 would be the last version of HHVM to officially support PHP, and that HHVM will only support Hack going forward.[22] This was due to differences and incompatibilities in PHP 7.[23] HHVM 4.0, released in February 2019, was the first version without support for PHP.[24]

Performance

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%.[25]

See also

Notes and References

  1. Web site: The HipHop Virtual Machine . December 9, 2011 . August 2, 2014 . Jason Evans . Meta Platforms.
  2. Web site: Building and installing HHVM on CentOS 7.x . May 26, 2015 . June 12, 2015 . . github.com.
  3. Web site: Building the Hack typechecker . September 10, 2014 . June 12, 2015 . Meta . github.com.
  4. Web site: Facebook's HHVM Begins Seeing Rust Rewrite - Phoronix . 29 August 2019.
  5. Web site: facebook/hhvm: License . August 2, 2014 . . github.com.
  6. HHVM JIT: A Profile-Guided, Region-Based Compiler for PHP and Hack . June 20, 2018 . Ottoni . Guilherme . Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI) . 151–165 . ACM.
  7. Web site: facebook/hhvm . August 2, 2014 . Meta Platforms . github.com.
  8. Web site: PHP and Zend Engine Internals . April 28, 2014 . September 23, 2014 . Kaushik Pal . phpbuilder.com . https://web.archive.org/web/20140915042514/http://www.phpbuilder.com/articles/application-architecture/optimization/php-and-zend-engine-internals.html . September 15, 2014 . dead .
  9. https://github.com/facebook/hhvm HHVM source code on GitHub
  10. Web site: Speeding up PHP-based development with HHVM . November 29, 2012 . August 2, 2014 . Drew Paroski . Meta Platforms.
  11. Web site: Announcement on GitHub removing HPHPc support . February 19, 2013 . May 24, 2013 . . github.com.
  12. Web site: HipHop Bytecode v1 revision 18 . July 31, 2014 . May 24, 2013 . . github.com.
  13. Web site: facebook/hhvm: About upgrade to PHP 5.4 engine . May 2013 . August 2, 2014 . github.com.
  14. Web site: facebook/hhvm: Home . May 8, 2014 . August 2, 2014 . . github.com.
  15. Web site: HHVM 3.0.0 . March 28, 2014 . December 26, 2022 . Paul Tarjan . Facebook.
  16. Facebook Introduces 'Hack,' the Programming Language of the Future . March 20, 2014 . April 15, 2014 . Cade Metz . Wired.
  17. Web site: Hack: a new programming language for HHVM . April 2014 . March 23, 2014 . Julien Verlaguet . Alok Menghrajani . . code.facebook.com.
  18. Web site: Facebook's Hack, HHVM, and the future of PHP . April 3, 2014 . August 2, 2014 . Josh Lockhart . O'Reilly Media.
  19. Web site: Hack and HHVM: Type Annotations (Hack Manual) . March 25, 2014 . docs.hhvm.com.
  20. Web site: Hack and HHVM: Type Inference (Hack Manual) . March 25, 2014 . docs.hhvm.com . https://web.archive.org/web/20140326062812/http://docs.hhvm.com//manual/en/hack.otherrulesandfeatures.typeinference.php . March 26, 2014 . dead .
  21. Web site: Hack and HHVM: Unsupported PHP Features in Hack (Hack Manual) . April 2, 2014 . https://web.archive.org/web/20151104213753/http://docs.hhvm.com/manual/en/hack.unsupported.php . 2015-11-04 . docs.hhvm.com.
  22. Web site: Ending PHP Support, and The Future Of Hack . September 12, 2018 . December 26, 2022 . Fred Emmott.
  23. Web site: Forget PHP! Facebook's HHVM engine switches to Hack instead. Krill. Paul. 2017-09-20. InfoWorld. en. 2019-02-06.
  24. Web site: HHVM 4.0.0 . February 11, 2019 . December 26, 2022 . Fred Emmott.
  25. Web site: We are the 98.5% (and the 16%) . December 19, 2013 . August 2, 2014 . hhvm.com.