# Zend Extension - zend_compile_file - interoperability?

- Thread: https://externals.io/message/49156
- Original archive: https://news-web.php.net/php.internals/49156
- Started by Jonathan Bond-Caron on 2010-07-29T00:54:40+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #49156 — Jonathan Bond-Caron — 2010-07-29T00:54:40+00:00

URL: https://externals.io/message/49156#49156

I've starting playing around with the zend engine, 

is there any hope / plans  for better interoperability with how
zend_compile_file() should be extended? 

The goal being to reduce the amount of  "X is not compatible with Y". 

 

It would be possible to separate extensions in two categories and provide
hooks (without breaking BC):

 

# Bytecode loaders / optimizers / dumpers (zend optimizer, ioncube loader,
vld, etc.)

HOOKS: zend_compile_file, zend_compile_string, zend_execute

 

# Bytecode cache (apc, xcache, etc.)

HOOKS: zend_opc_get, zend_opc_put

 

Internally (Zend/zend.c, ext/phar/phar.c, ext/spl/php_spl.c, etc..)  use
zend_opc_compile_file() ~

 

zend_op_array * opc _compile_file(zend_file_handle *file_handle, int
lifetime, int type TSRMLS_DC)

{

                zend_op_array *retval=NULL;

 

                if( zend_opc_get(file_handle->filename, retval) )

                                return retval;

 

                retval = zend_compile_file(file_handle, type);

 

               zend_opc_put(file_handle->filename, lifetime, retval);

 

                return retval;

}

 

zend_opc_get() and zend_opc_put() would just be stub functions that do
nothing, op code caches would change these methods

 

If there's positive feedback, I can turn this into a RFC and put more work
into it

---

## #49157 — Stas Malyshev — 2010-07-29T01:18:50+00:00

URL: https://externals.io/message/49156#49157 · In reply to: #49156

Hi!

> I've starting playing around with the zend engine,
>
> is there any hope / plans  for better interoperability with how
> zend_compile_file() should be extended?
>
> The goal being to reduce the amount of  "X is not compatible with Y".

In most cases, overriding zend_compile_file() and calling previous 
handler should be enough. If it doesn't work of soe special 
modifications then additional handlers might not help either. 
Compatibility problems can arise from something like extension X (e.g. 
bytecode cache) expects certain structures to reside in shared memory 
for performance reasons while extension Y modifying them since it 
doesn't know anything about extension X.

> # Bytecode loaders / optimizers / dumpers (zend optimizer, ioncube loader,
> vld, etc.)

Those should use other handlers, such as op array ctor/dtor/handler.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
