abertschi / graalphp Goto Github PK
View Code? Open in Web Editor NEWAn efficient PHP implementation built on GraalVM
Home Page: https://abertschi.ch/blog/2020/building-graalphp/
License: Apache License 2.0
An efficient PHP implementation built on GraalVM
Home Page: https://abertschi.ch/blog/2020/building-graalphp/
License: Apache License 2.0
complete support for sequences, add support for maps, sets, stacks, queues
https://www.php.net/manual/en/language.types.array.php
Some ideas to evaluate:
Graalvm "enterprise edition" ships with even more advanced optimizations which can be significant
Is it possible to further develop graalphp?
Do we aggree that we should use simplelang as starting repo if yes you should merge me and i merge you back so we can start issuing pull requests directly.
https://github.com/direktspeed/graalphp
Can I help and add the Dockerfile and docker-compose to have an ability to UP this project in docker?
What Java configuration and dependencies are required for building this project?
When bailing out with an error, print where in source error occurred. We already set source section in ast visitor but do not print it in error cases.
Decide if early or lazy loading is better for graalphp.
It was previously mentioned here #57 (comment)
on how to use or implement PHP functions in Graal,
Integration of PHP's native libraries. I see JPHP follows an approach which re-implements many libraries.
I believe an approachwhich reuses and integrates existing libraries is more viable. This depends on how efficiently these libraries can be integrated and needs to be further evaluated.
I see @chrisseaton blogged about what they have done with truffleruby some years ago: https://chrisseaton.com/truffleruby/cext/. This sounds very interesting.
One approach is using re-implementing the PHP function in Java, I am slightly in favour of this approach as it brings some other major IO related real world performance benefits with the combination of https://openjdk.java.net/jeps/353 and http://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html. The obvious downside being the time taken to re-implement those methods. There are good transpilers available these days to do most of the heavy lifting though.
The second option is going the route that is described here https://chrisseaton.com/truffleruby/cext/ , There is no source code made available and hence difficult to see how complicated, practical or time consuming this would be when applied to a large project like PHP.
The third option which I would propose is,
How easy is all this? See the video for yourself,
https://youtu.be/zvsR90T_4ME?t=255 (it covers the first three points)
The obvious drawback would be the IO performance, if I can make an assumption that Graal/Sulong cannot inject instructions for co-operative scheduling.
Any feedback is appreciated 🙂
See discussion here #28 (comment)
This has low priority as the current implementation already generates performant code.
Hi,
is there a way to add the graalphp as gu package?
As of today, it seems that there is no package available:
Downloading: Component catalog from www.graalvm.org
ComponentId Version Component name Origin
--------------------------------------------------------------------------------
llvm-toolchain 20.2.0 LLVM.org toolchain github.com
native-image 20.2.0 Native Image github.com
python 20.2.0 Graal.Python github.com
R 20.2.0 FastR github.com
ruby 20.2.0 TruffleRuby github.com
wasm 20.2.0 GraalWasm github.com
I want to ".eval" some php today with the polyglot api, can we manually achieve this?
Thank you!
....
We currently deprecated IBinding and make it compile. It has no use anymore as it was used for Eclipse related features. Remove from graalphp-parser. See
package org.eclipse.php.core.ast.nodes.IBinding
As for now we only run mvn package without the native build on travis
i originally was not aware of truffle's builtin logging facilities and wanted to avoid issues with substrate vm to native compile.
so we added a simple logging interface which prints to stdout. Replace it with truffle's builtin functionality.
I thought implementing string would be easy, but I was so wrong,
[https://github.com/avierr/graalphp/commit/58142efd3c8e3e65ac1be93d21edea32c35c9810]
PHP supports string interpolation,
probably this needs some pre-processing to convert it into string concatenation operations?
we know Java uses strings that are utf16 encoded.
strings in PHP are also used to store binary data, I went ahead and did some research on how others handle this,
1.PeachPie
https://github.com/peachpiecompiler/peachpie/blob/master/src/Peachpie.Runtime/PhpString.cs
2.JPHP
https://github.com/jphp-group/jphp/blob/master/jphp-runtime/src/php/runtime/memory/StringMemory.java
3.HippyVM
https://github.com/hippyvm/hippyvm/blob/master/hippy/objects/strobject.py
4.Tagua-vm
https://github.com/tagua-vm/tagua-vm (not sure how this works)
other challenges:
implicit casting rules that PHP has to convert strings to numbers and vis versa.
https://php.net/manual/en/language.types.type-juggling.php
Most of this is way out of my league, so I don't have any opinions on this, let me if anyone has any thoughts on which direction to proceed in
Evaluate efficient way to call native libraries/ extensions
Extensions:
We may want to reconsider the name 'graalphp'. Other language implementations were asked to do so as well due to GraalVM trademark issues.
Suggestions:
AFAIK you are allowed to use “gr + <something>“, so “grPHP” would be ok (although probably not a good name). I think you could call it TrufflePHP but I am not sure anyone else is using it (apart from https://github.com/direktspeed/trufflephp).
Latest changes cause BailoutException in graal compiler, probably caused by recursive copying of nested arrays in #37
Run binary-trees benchmark with N = 21
22
8388607
2097152
4
65011712
524288
6
66584576
[Use -Dgraal.LogFile=<path> to redirect Graal log output to a file.]
[truffle] opt fail PhpFunctionRootNode{body=PhpReturnBodyNode@27c91bce, name='bottomUpTree'}|ASTSize 67 |Reason org.graalvm.compiler.core.common.PermanentBailoutException: Compilation exceeded 300 seconds during CFG traversal
org.graalvm.compiler.core.common.PermanentBailoutException: Compilation exceeded 300 seconds during CFG traversal
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:116)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:97)
at org.graalvm.compiler.virtual.phases.ea.EffectsPhase.runAnalysis(EffectsPhase.java:94)
at org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:82)
at org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:44)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:139)
at org.graalvm.compiler.truffle.compiler.PartialEvaluator.fastPartialEvaluation(PartialEvaluator.java:671)
at org.graalvm.compiler.truffle.compiler.PartialEvaluator.createGraph(PartialEvaluator.java:281)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.compileAST(TruffleCompilerImpl.java:467)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl$TruffleCompilationWrapper.performCompilation(TruffleCompilerImpl.java:660)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl$TruffleCompilationWrapper.performCompilation(TruffleCompilerImpl.java:598)
at org.graalvm.compiler.core.CompilationWrapper.run(CompilationWrapper.java:179)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.actuallyCompile(TruffleCompilerImpl.java:308)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.doCompile(TruffleCompilerImpl.java:259)
at org.graalvm.compiler.truffle.compiler.hotspot.libgraal.HotSpotToSVMEntryPoints.doCompile(HotSpotToSVMEntryPoints.java:269)
[truffle] opt fail PhpFunctionRootNode{body=PhpReturnBodyNode@3305bcdd, name='itemCheck'}|ASTSize 120 |Reason org.graalvm.compiler.core.common.PermanentBailoutException: Compilation exceeded 300 seconds during CFG traversal
org.graalvm.compiler.core.common.PermanentBailoutException: Compilation exceeded 300 seconds during CFG traversal
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:116)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.processLoop(ReentrantBlockIterator.java:77)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:335)
at org.graalvm.compiler.virtual.phases.ea.EffectsClosure.processLoop(EffectsClosure.java:69)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.recurseIntoLoop(ReentrantBlockIterator.java:210)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:138)
at org.graalvm.compiler.phases.graph.ReentrantBlockIterator.apply(ReentrantBlockIterator.java:97)
at org.graalvm.compiler.virtual.phases.ea.EffectsPhase.runAnalysis(EffectsPhase.java:94)
at org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:82)
at org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase.run(PartialEscapePhase.java:44)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:139)
at org.graalvm.compiler.truffle.compiler.PartialEvaluator.fastPartialEvaluation(PartialEvaluator.java:671)
at org.graalvm.compiler.truffle.compiler.PartialEvaluator.createGraph(PartialEvaluator.java:281)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.compileAST(TruffleCompilerImpl.java:467)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl$TruffleCompilationWrapper.performCompilation(TruffleCompilerImpl.java:660)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl$TruffleCompilationWrapper.performCompilation(TruffleCompilerImpl.java:598)
at org.graalvm.compiler.core.CompilationWrapper.run(CompilationWrapper.java:179)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.actuallyCompile(TruffleCompilerImpl.java:308)
at org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.doCompile(TruffleCompilerImpl.java:259)
at org.graalvm.compiler.truffle.compiler.hotspot.libgraal.HotSpotToSVMEntryPoints.doCompile(HotSpotToSVMEntryPoints.java:269)
131072
8
66977792
32768
10
67076096
8192
12
67100672
2048
14
67106816
512
16
67108352
128
18
67108736
32
20
67108832
21
4194303
"binary-trees N/iters/iter/val";21;30;0;1437810.077891;
We compare two approaches to parse PHP source code. Adaption of the parser
implemented in JPHP and use of an existing grammer for ANTRL to generate a new Parser.
JPHP
(- is contra, + is pro)
+ PHP 7.1+ compliant
+ Apache License 2.0
- Tokenizer and Parser written from scratch
- a lot of boilerplate code
- tokenizer and syntax analyser code: > 10k LOC
+ Parser creates instances of Token for all language constructs
- Token instances do not provide visitor pattern for tree transformations
- dependency to org.ow2.asm (reflections)
- Poorly documented code
+ Active community, 1.6k stars on github
- 100k LOC in total (core: 38k, runtime 51k, extensions, package, debugger...)
+ implements PHP standard library
How parsing is implemented:
In a next step, SyntaxAnalyser is used in Compiler Classes. Compiler
classes create Entity classes;
What to adapt if JPHP parser is used
ANTLR
(- is contra, + is pro)
+ BSD 3-clause license
+ grammar for PHP 7.4 available
+ Generates Visitor or listener classes for tree traversal
- no provided semantic analysis. needs to be implemented where needed
- no PHP specific error messages, needs to be implemented where needed
+ vertical development allows expeditious progress, we don't need to implement the whole AST visitor
How parsing is implemented
The ANTRL approach seems more straightforward and introduces less code to maintain.
The token parsing code is generated and the use of the visitor pattern allows for elegant
translation to a graal AST tree. ANTRL is used in other graal projects, too.
mvn package
works beautifully but we can't be doing it over and over again, as it is very slow.
My knowledge on mvn is limited as I mostly use gradle,
is there some mvn equivalent to mvn run GraalPhpMain /path/file.php
so that we can iterate faster.
and probably how to run the tests as well
would be nice to have this added to the Readme
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.