Hello internals:
I had a look at the Zend Engine to understand some
details about its internal design with respect
to its opcodes and machine model.
Would like to ask you for some comments if the
following sounds wrong or misinterpreted to you:
So, the basic design of the Zend Engine is a
a stack-based interpreter for a fixed length
instruction set (76byte on a 32bit architecture),
where the instruction encoding
is much more complex then for instance for the
JVM, Python, or Smalltalk.
Even so, the source code is compiled to a linearized
instruction stream, the instruction itself contain not just opcode and
operands.
The version I looked at had some 136 opcodes encoded
in one byte, but the rest of the instruction has
many similarities with a AST representation.
Instructions encode:
- a line number
- a function pointer to the actual handler which is
used to execute it
- two operands, which encode constant values,
object references, jump addresses,
or pointer to other functions
- 64 bit for an extended operand value
- a field for results, which is use for some
operations return values.
However, its not a simple, single stack model,
but uses several purpose-specific stacks.
What I am not so sure about is especially the
semantics of the result field and the pointer
to the other function (op_array).
Would be grateful if someone could comment on that.
I am also not really sure with these complexity,
whether is not actually some kind of abstract syntax
tree instead of a instruction set like Java
bytecode. Thats not a technical problem, but merely
an academic question to categorize/characterize PHP.
All comments are welcome.
Many thanks
Stefan
--
Stefan Marr
Software Languages Lab
Former Programming Technology Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://prog.vub.ac.be/~smarr
Phone: +32 2 629 3956
Fax: +32 2 629 3525
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php