HHVM

{{Short description|Process virtual machine developed by Meta}}

{{Use mdy dates|date=August 2014}}

{{Infobox software

| name = HHVM

| logo = HHVM logo.svg

| logo size = x64px

| logo alt = HHVM logo, featuring white uppercase "HHVM" letters on a black background, with stylized triangular geometric shapes on the left

| logo caption =

| latest release version = {{wikidata|property|preferred|references|edit|Q18150679|P348|P548=Q2804309}}

| latest release date = {{start date and age|{{wikidata|qualifier|preferred|single|Q18150679|P348|P548=Q2804309|P577}}}}

| developer = Meta Platforms

| released = {{Start date and age|2011|12|09}}{{cite web

| url = https://www.facebook.com/notes/facebook-engineering/the-hiphop-virtual-machine/10150415177928920

| title = The HipHop Virtual Machine

| date = December 9, 2011 | access-date = August 2, 2014

| author = Jason Evans | publisher = Meta Platforms

}}

| programming language = PHP, C++,{{cite web

| url = https://github.com/facebook/hhvm/wiki/Building-and-installing-hhvm-on-CentOS-7.x

| title = Building and installing HHVM on CentOS 7.x

| date = May 26, 2015 | access-date = June 12, 2015

| publisher = Meta Platforms | website = github.com

}} OCaml{{cite web

| url = https://github.com/facebook/hhvm/wiki/Building%20the%20Hack%20Typechecker

| title = Building the Hack typechecker

| date = September 10, 2014 | access-date = June 12, 2015

| publisher = Meta | website = github.com

}}{{Efn|Only the Hack's type-checking ({{Mono|hh_server}} and {{Mono|hh_client}}) and code-formatting ({{Mono|hh_format}}) command-line utilities and daemons bundled together with the HipHop Virtual Machine are written in OCaml.}} and Rust{{cite web |title=Facebook's HHVM Begins Seeing Rust Rewrite - Phoronix |url=https://www.phoronix.com/scan.php?page=news_item&px=Facebook-Rust-HHVM |access-date=29 August 2019}}

| operating system =

| platform =

| license = PHP License and Zend License{{cite web

| url = https://github.com/facebook/hhvm#license

| title = facebook/hhvm: License

| access-date = August 2, 2014

| publisher = Facebook, Inc. | website = github.com

}}

| website = {{Official URL}}

}}

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.{{cite conference

| url = https://dl.acm.org/citation.cfm?id=3192374

| title = HHVM JIT: A Profile-Guided, Region-Based Compiler for PHP and Hack

| date = June 20, 2018

| last = Ottoni

| first = Guilherme

| book-title = Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI)

| pages = 151–165

| publisher = ACM

}}{{cite web

| url = https://github.com/facebook/hhvm

| title = facebook/hhvm

| access-date = August 2, 2014

| publisher = Meta Platforms | website = github.com

}} 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.{{cite web

| url = http://www.phpbuilder.com/articles/application-architecture/optimization/php-and-zend-engine-internals.html

| title = PHP and Zend Engine Internals

| date = April 28, 2014

| access-date = September 23, 2014

| author = Kaushik Pal

| website = phpbuilder.com

| archive-url = https://web.archive.org/web/20140915042514/http://www.phpbuilder.com/articles/application-architecture/optimization/php-and-zend-engine-internals.html

| archive-date = September 15, 2014

| url-status = dead

}}

HHVM is developed by Meta, with the project's source code hosted on GitHub;[https://github.com/facebook/hhvm HHVM source code on GitHub] 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.{{cite web

| url = https://www.facebook.com/notes/facebook-engineering/speeding-up-php-based-development-with-hiphop-vm/10151170460698920

| title = Speeding up PHP-based development with HHVM

| date = November 29, 2012 | access-date = August 2, 2014

| author = Drew Paroski | publisher = Meta Platforms

}}{{cite web

| title = Announcement on GitHub removing HPHPc support

| url = https://github.com/facebook/hiphop-php/commit/fc5b95110ff75110ad55bb97f7c93a8c4eb68e3b

| date = February 19, 2013 | access-date = May 24, 2013

| publisher = Meta Platforms | website = github.com

}} 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.{{cite web

| url = https://github.com/facebook/hhvm/blob/master/hphp/doc/bytecode.specification

| title = HipHop Bytecode v1 revision 18

| date = July 31, 2014 | access-date = May 24, 2013

| publisher = Meta Platforms | website = github.com

}} 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.{{cite web

| url = https://github.com/facebook/hiphop-php/issues/716

| title = facebook/hhvm: About upgrade to PHP 5.4 engine

| date = May 2013 | access-date = August 2, 2014

| website = github.com

}}{{cite web

| url = https://github.com/facebook/hhvm/wiki

| title = facebook/hhvm: Home

| date = May 8, 2014 | access-date = August 2, 2014

| publisher = Meta Platforms | website = github.com

}}

Together with HHVM 3.0,{{cite web

| url = https://hhvm.com/blog/4349/hhvm-3-0-0

| title = HHVM 3.0.0

| date = March 28, 2014 | access-date = December 26, 2022

| author1 = Paul Tarjan

| publisher = Facebook

}} Meta also released Hack, a derivative of PHP{{cite magazine

| url = https://www.wired.com/wiredenterprise/2014/03/facebook-hack/

| title = Facebook Introduces 'Hack,' the Programming Language of the Future

| date = March 20, 2014 | access-date = April 15, 2014

| author = Cade Metz | magazine = Wired

}}{{cite web

| url = https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/

| title = Hack: a new programming language for HHVM

| date = April 2014 | access-date = March 23, 2014

| author1 = Julien Verlaguet | author2 = Alok Menghrajani

| publisher = Facebook | website = code.facebook.com

}} 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.{{cite web

| url = http://radar.oreilly.com/2014/04/facebooks-hack-hhvm-and-the-future-of-php.html

| title = Facebook's Hack, HHVM, and the future of PHP

| date = April 3, 2014 | access-date = August 2, 2014

| author = Josh Lockhart | publisher = O'Reilly Media

}}{{cite web

| url = http://docs.hhvm.com/manual/en/hack.annotations.php

| title = Hack and HHVM: Type Annotations (Hack Manual)

| access-date = March 25, 2014

| website = docs.hhvm.com

}}{{cite web

| url = http://docs.hhvm.com/manual/en/hack.otherrulesandfeatures.typeinference.php

| title = Hack and HHVM: Type Inference (Hack Manual)

| access-date = March 25, 2014

| website = docs.hhvm.com

| archive-url = https://web.archive.org/web/20140326062812/http://docs.hhvm.com//manual/en/hack.otherrulesandfeatures.typeinference.php

| archive-date = March 26, 2014

| url-status = dead

}}{{cite web

| url = http://docs.hhvm.com/manual/en/hack.unsupported.php

| title = Hack and HHVM: Unsupported PHP Features in Hack (Hack Manual)

| access-date = April 2, 2014

| archive-url = https://web.archive.org/web/20151104213753/http://docs.hhvm.com/manual/en/hack.unsupported.php

| archive-date = 2015-11-04

| website = docs.hhvm.com

}}

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.{{cite web

| url = https://hhvm.com/blog/2018/09/12/end-of-php-support-future-of-hack.html

| title = Ending PHP Support, and The Future Of Hack

| date = September 12, 2018 | access-date = December 26, 2022

| author = Fred Emmott

}} This was due to differences and incompatibilities in PHP 7.{{Cite web|url=https://www.infoworld.com/article/3226489/web-development/forget-php-facebooks-hhvm-engine-switches-to-hack-instead.html|title=Forget PHP! Facebook's HHVM engine switches to Hack instead|last=Krill|first=Paul|date=2017-09-20|website=InfoWorld|language=en|access-date=2019-02-06}} HHVM 4.0, released in February 2019, was the first version without support for PHP.{{cite web

| url = https://hhvm.com/blog/2019/02/11/hhvm-4.0.0.html

| title = HHVM 4.0.0

| date = February 11, 2019 | access-date = December 26, 2022

| author = Fred Emmott

}}

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%.{{cite web

| url = http://www.hhvm.com/blog/2813/we-are-the-98-5-and-the-16

| title = We are the 98.5% (and the 16%)

| date = December 19, 2013 | access-date = August 2, 2014

| website = hhvm.com

}}

See also

{{Portal|Computer programming}}

Notes

{{Notelist}}

References

{{Reflist|30em}}