Zend engine question (regarding compilation)

From: Date: Fri, 03 Nov 2000 14:53:11 +0000
Subject: Zend engine question (regarding compilation)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-36959@lists.php.net to get a copy of this message
I'm not 100% sure this is the right list for this, so please forgive me if this is off topic. I originally sent it to Zeev, but I suspect hes probably inundated with mail. I'm currently about 80% of the way through finishing a PHP4 'compiler' module, and have just one or two problems left. The primary issue is with the union in the znode structure. Basically, I'm serializing the data after the internal compilation phase before the bytecode is passed to the executor. This works fine, until I reach a znode, and have to decide which parts of the union to serialize/deserialize. The op_type seems to have only 4 potential values... IS_CONST IS_TMP_VAR IS_VAR IS_UNUSED Whilst the znode structure looks like... typedef struct _znode { int op_type; union { zval constant; zend_uint var; zend_uint opline_num; zend_uint fetch_type; zend_op_array *op_array; struct { zend_uint var; zend_uint type; } EA; } u; } znode; During the serialize phase, I serialize the opcode, and for IS_CONSTANT, I use the "zval constant" element. For TMP_VAR and VAR, I use the "zend_uint var". I had assumed IS_UNUSED was not needed, but found it seems to hold the target for conditionals, so saved opline_num in the case of UNUSED. However, I'm now running into other minor problems that I suspect rely on other elements of a znode that are not being reconstructed from the compiled bytecode file correctly. I'm pretty sure op_array is a pointer to the scope holder of the op_array that this znode was 'found' in, and I can reconstruct this correctly. EA, and fetch_type, however, elude me. So, the point of this whole email was to ask, in what situations are these elements of the union set? Being a union, I cannot serialize the entire block and still hope for an accurate reconstruction. Are they unused at the end of compile time? (which is where the my serializer is called in 'compiler' mode.), or are there other possibilities for op_type that I've overlooked? I'm hoping this is the last major obstacle to my finishing this project, as it already compiles simple to medium complexity scripts without issue (function calls, recursion, conditionals all work fine, most of the time), and then reexecutes them on another machine from the compiled bytecode. I obviously plan to release the patch (which is actually to the Zend engine, hence allowing 'compliation' of any Zend driven system) as open source when I'm happy this works correctly. Many thanks for any help anyone could offer. Adam Wright adam@elysium.ltd.uk

« previous php.dev (#36959) next »