4 ms·
Not sure if this qualifies as intermediate representation in the LLVM sense, but PHP has opcodes already, it is not fully interpreted anymore (like it was in PH
by beberlei 8y ago
Not sure if this qualifies as intermediate representation in the LLVM sense, but PHP has opcodes already, it is not fully interpreted anymore (like it was in PHP 3).
These opcodes are used for optimizations and cached for the lifetime of the PHP process (across multiple requests).
- pas 8y agoThat's probably too low-level. Usually an AST is needed that is void of all syntactic sugar, yet can express the required data flows and dependencies so the trivial substitutions/replacements/caching and refactorings can be done at this level. Lower level bytecode lacks these higher level references (it usually has a lot of indices that index into raw lookup tables, but no real symbols that refer to results of computations and other variables).
- tyingq 8y agoThere does appear to be an internal AST in php7: https://github.com/nikic/php-ast https://github.com/nikic/php-ast
- ryanmccullagh 8y agoPHP has had an AST for years now.
- pas 8y agoOf course, but the opcode is lower level than that. And that was what the parent comment mentioned.
- jashmatthews 8y agoLuaJIT and WebKit both produce their IR from the bytecode, IIUC.
- readittwice 8y agoNot sure why you think this is the case: there are numerous JITs/VMs that optimize starting from bytecode e.g. all JVMs, WebAssembly, V8, JSC,... Can you point me to some paper/reference about this? AFAIK it doesn't matter whether you have an AST or bytecode. Optimizations are done on an IR anyways.
- WalterGR 8y agoUsually an AST is needed that is void of all syntactic sugar, That’s how I’ve always see “AST” used, but not the following: yet can express the required data flows and dependencies so the trivial substitutions/replacements/caching and refactorings can be done at this level. Is what you describe some flavor of ‘augmented’ AST? Does that have a name other than AST?