https://github.com/abertschi/graalphp
An efficient PHP implementation built on GraalVM
https://github.com/abertschi/graalphp
graalvm php truffle
Last synced: about 2 months ago
JSON representation
An efficient PHP implementation built on GraalVM
- Host: GitHub
- URL: https://github.com/abertschi/graalphp
- Owner: abertschi
- License: apache-2.0
- Created: 2020-02-26T14:51:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T11:30:31.000Z (over 2 years ago)
- Last Synced: 2025-04-02T07:41:47.608Z (about 2 months ago)
- Topics: graalvm, php, truffle
- Language: Java
- Homepage: https://abertschi.ch/blog/2020/building-graalphp/
- Size: 22.5 MB
- Stars: 292
- Watchers: 19
- Forks: 11
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/abertschi/graalphp)
[](https://codebeat.co/projects/github-com-abertschi-graalphp-master)
[](https://www.codefactor.io/repository/github/abertschi/graalphp)
[](https://www.codacy.com/manual/abertschi/graalphp?utm_source=github.com&utm_medium=referral&utm_content=abertschi/graalphp&utm_campaign=Badge_Grade)# A PHP implementation built on GraalVM
> Graalphp is an experimental just-in-time (JIT) compiler and runtime
for PHP 7.4+ hosted on GraalVM.### Abstract
PHP is a popular, weakly typed, general purpose programming
language. Originally designed for building dynamic web pages, the
language has since gained wide adoption in server-side web
development. In this work, we describe the design and
implementation of graalphp, an experimental compiler and
runtime for PHP hosted on Truffle and GraalVM. GraalVM is a virtual
machine that supports execution of multiple languages, which are
implemented as Abstract Syntax Tree (AST) interpreters based on
Truffle. GraalVM uses Graal as its JIT compiler to compile
frequently executed code fragments to machine code. We implement a
subset of the PHP language to run synthetic benchmarks by
The Computer Language Benchmarks Game. We compare peak
performance of our implementation against PHP 7 as well as
alternative implementations such as HHVM, JPHP and an early alpha
version of PHP 8. Experimental results indicate that our runtime
reaches competitive results with performance gains of up to 859%
compared to PHP 7. These preliminary results
suggest that a Truffle-hosted PHP implementation might be
significantly faster than existing language implementations.
![]()
- Benchmarks: [./results.md/](./results.md/)
- [Download Report](https://abertschi.ch/default_public/ethz/graalphp/download.php)
- Presentation: https://www.youtube.com/watch?v=Dzahabn8ojoThis project was launched as an undergraduate thesis at ETHZ.
### Build and Run
For a container image with development and benchmark dependencies see
[./docker/](./docker/).```shell
# Build Dependencies: Linux environment, maven, ant, GraalVM
# download GraalVM from https://github.com/graalvm/graalvm-ce-builds/releases
$ export JAVA_HOME=/path/to/graalvm
$ mvn package
$ ./graalphp
``````sh
# build native image:
$ export JAVA_HOME=/path/to/graalvm
$ $JAVA_HOME/bin/gu install native-image
$ export GRAALPHP_BUILD_NATIVE="true"
$ mvn package
```### Feature Set
High Level Overview of implemented features, current runtime code
base. ca. 4000 LOC. Implemented features are chosen to support execution of the Computer Language Benchmark Game.
https://github.com/abertschi/graalphp/tree/master/benchmarks/evaluation
Non exhaustive list of features:
+ Datatypes: int, float, boolean, arrays (sequences) of these types
+ Unconditionally defined functions
+ Variables in function scope, global scope
+ Binary, unary, operations
+ while, do while, for, if### More Resources
- Graal Github Issue for PHP support :: https://github.com/oracle/graal/issues/361
- GraalVM :: https://graalvm.org