relocate WIP
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1444 c26eb9a1-5813-0410-bd6c-c2e55f420ca7master
parent
b5f6974ff9
commit
41b20da882
@ -1,25 +1,25 @@
|
||||
$(XCACHE_INCLUDES_I) includes.lo $(builddir)/includes.lo: $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
mod_assembler/xc_assembler.lo $(builddir)/mod_assembler/xc_assembler.lo:
|
||||
mod_cacher/xc_cacher.lo $(builddir)/mod_cacher/xc_cacher.lo: $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(XCACHE_PROC_H)
|
||||
mod_coverager/xc_coverager.lo $(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
mod_cacher/xc_cacher.lo $(builddir)/mod_cacher/xc_cacher.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
mod_coverager/xc_coverager.lo $(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
mod_decoder/xc_decoder.lo $(builddir)/mod_decoder/xc_decoder.lo:
|
||||
mod_disassembler/xc_disassembler.lo $(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(XCACHE_PROC_H)
|
||||
mod_disassembler/xc_disassembler.lo $(builddir)/mod_disassembler/xc_disassembler.lo: $(XCACHE_PROC_H) $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
mod_encoder/xc_encoder.lo $(builddir)/mod_encoder/xc_encoder.lo:
|
||||
mod_optimizer/xc_optimizer.lo $(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(XCACHE_PROC_H)
|
||||
mod_optimizer/xc_optimizer.lo $(builddir)/mod_optimizer/xc_optimizer.lo: $(XCACHE_PROC_H) $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
util/xc_stack.lo $(builddir)/util/xc_stack.lo: $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h
|
||||
util/xc_trace.lo $(builddir)/util/xc_trace.lo: $(srcdir)/util/xc_trace.h
|
||||
xcache.lo $(builddir)/xcache.lo: $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(XCACHE_PROC_H)
|
||||
xcache.lo $(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
xcache/xc_allocator.lo $(builddir)/xcache/xc_allocator.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_allocator_bestfit.lo $(builddir)/xcache/xc_allocator_bestfit.lo: $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_allocator.lo $(builddir)/xcache/xc_allocator.lo: $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_compatibility.lo $(builddir)/xcache/xc_compatibility.lo: $(srcdir)/xcache/xc_compatibility.h
|
||||
xcache/xc_const_string.lo $(builddir)/xcache/xc_const_string.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_const_string_opcodes_php4.x.h $(srcdir)/xcache/xc_const_string_opcodes_php5.0.h $(srcdir)/xcache/xc_const_string_opcodes_php5.1.h $(srcdir)/xcache/xc_const_string_opcodes_php5.2.h $(srcdir)/xcache/xc_const_string_opcodes_php5.3.h $(srcdir)/xcache/xc_const_string_opcodes_php5.4.h $(srcdir)/xcache/xc_const_string_opcodes_php5.5.h $(srcdir)/xcache/xc_const_string_opcodes_php6.x.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_extension.lo $(builddir)/xcache/xc_extension.lo: $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_ini.lo $(builddir)/xcache/xc_ini.lo: $(srcdir)/xcache/xc_ini.h
|
||||
xcache/xc_malloc.lo $(builddir)/xcache/xc_malloc.lo: $(srcdir)/util/xc_align.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_mutex.lo $(builddir)/xcache/xc_mutex.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_opcode_spec.lo $(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec_def.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_opcode_spec.lo $(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_opcode_spec_def.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C)
|
||||
xcache/xc_sandbox.lo $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/util/xc_stack.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
xcache/xc_shm.lo $(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_sandbox.lo $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/util/xc_stack.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
xcache/xc_shm.lo $(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
|
||||
xcache/xc_shm_mmap.lo $(builddir)/xcache/xc_shm_mmap.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
xcache/xc_utils.lo $(builddir)/xcache/xc_utils.lo: $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
|
||||
xcache/xc_utils.lo $(builddir)/xcache/xc_utils.lo: $(srcdir)/util/xc_stack.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
|
||||
|
@ -0,0 +1,159 @@
|
||||
define(`DEFINE_STORE_API', `
|
||||
EXPORTED_FUNCTION(`$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
$1 *dst;
|
||||
xc_processor_t processor;
|
||||
|
||||
memset(&processor, 0, sizeof(processor));
|
||||
processor.reference = 1;
|
||||
processor.shm = shm;
|
||||
processor.allocator = allocator;
|
||||
|
||||
IFAUTOCHECK(`xc_stack_init(&processor.allocsizes);')
|
||||
|
||||
/* calc size */ {
|
||||
zend_hash_init(&processor.strings, 0, NULL, NULL, 0);
|
||||
if (processor.reference) {
|
||||
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
processor.size = 0;
|
||||
/* allocate */
|
||||
processor.size = ALIGN(processor.size + sizeof(src[0]));
|
||||
|
||||
xc_calc_$1(&processor, src TSRMLS_CC);
|
||||
if (processor.reference) {
|
||||
zend_hash_destroy(&processor.zvalptrs);
|
||||
}
|
||||
zend_hash_destroy(&processor.strings);
|
||||
}
|
||||
ifelse(
|
||||
`$1', `xc_entry_data_php_t', `SRC(`size')',
|
||||
`', `', SRC(`entry.size')) = processor.size;
|
||||
ifelse(
|
||||
`$1', `xc_entry_var_t', `SRC(`have_references') = processor.have_references;',
|
||||
`$1', `xc_entry_data_php_t', `SRC(`have_references') = processor.have_references;'
|
||||
)
|
||||
|
||||
IFAUTOCHECK(`xc_stack_reverse(&processor.allocsizes);')
|
||||
/* store {{{ */
|
||||
{
|
||||
IFAUTOCHECK(`char *oldp;')
|
||||
zend_hash_init(&processor.strings, 0, NULL, NULL, 0);
|
||||
if (processor.reference) {
|
||||
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
/* allocator :) */
|
||||
processor.p = (char *) processor.allocator->vtable->malloc(processor.allocator, processor.size);
|
||||
if (processor.p == NULL) {
|
||||
dst = NULL;
|
||||
goto err_alloc;
|
||||
}
|
||||
IFAUTOCHECK(`oldp = processor.p;')
|
||||
assert(processor.p == (char *) ALIGN(processor.p));
|
||||
|
||||
/* allocate */
|
||||
dst = ($1 *) processor.p;
|
||||
processor.p = (char *) ALIGN(processor.p + sizeof(dst[0]));
|
||||
|
||||
xc_store_$1(&processor, dst, src TSRMLS_CC);
|
||||
IFAUTOCHECK(` {
|
||||
size_t unexpected = processor.p - oldp;
|
||||
size_t expected = processor.size;
|
||||
if (unexpected != processor.size) {
|
||||
fprintf(stderr, "unexpected:%lu - expected:%lu = %ld != 0\n", (unsigned long) unexpected, (unsigned long) expected, (long) unexpected - expected);
|
||||
abort();
|
||||
}
|
||||
}')
|
||||
err_alloc:
|
||||
if (processor.reference) {
|
||||
zend_hash_destroy(&processor.zvalptrs);
|
||||
}
|
||||
zend_hash_destroy(&processor.strings);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
IFAUTOCHECK(`xc_stack_destroy(&processor.allocsizes);')
|
||||
|
||||
return dst;
|
||||
}
|
||||
dnl }}}
|
||||
')
|
||||
DEFINE_STORE_API(`xc_entry_var_t')
|
||||
DEFINE_STORE_API(`xc_entry_php_t')
|
||||
DEFINE_STORE_API(`xc_entry_data_php_t')
|
||||
EXPORTED_FUNCTION(`xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
xc_processor_t processor;
|
||||
|
||||
memset(&processor, 0, sizeof(processor));
|
||||
xc_restore_xc_entry_php_t(&processor, dst, src TSRMLS_CC);
|
||||
|
||||
return dst;
|
||||
}
|
||||
dnl }}}
|
||||
EXPORTED_FUNCTION(`xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *entry_php, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
xc_processor_t processor;
|
||||
|
||||
memset(&processor, 0, sizeof(processor));
|
||||
processor.readonly_protection = readonly_protection;
|
||||
/* this function is used for php data only */
|
||||
if (SRC(`have_references')) {
|
||||
processor.reference = 1;
|
||||
}
|
||||
processor.entry_php_src = entry_php;
|
||||
|
||||
if (processor.reference) {
|
||||
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
|
||||
}
|
||||
xc_restore_xc_entry_data_php_t(&processor, dst, src TSRMLS_CC);
|
||||
if (processor.reference) {
|
||||
zend_hash_destroy(&processor.zvalptrs);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
dnl }}}
|
||||
EXPORTED_FUNCTION(`zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
xc_processor_t processor;
|
||||
|
||||
memset(&processor, 0, sizeof(processor));
|
||||
processor.reference = have_references;
|
||||
|
||||
if (processor.reference) {
|
||||
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
|
||||
dnl fprintf(stderr, "mark[%p] = %p\n", src, dst);
|
||||
zend_hash_add(&processor.zvalptrs, (char *)src, sizeof(src), (void*)&dst, sizeof(dst), NULL);
|
||||
}
|
||||
xc_restore_zval(&processor, dst, src TSRMLS_CC);
|
||||
if (processor.reference) {
|
||||
zend_hash_destroy(&processor.zvalptrs);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
dnl }}}
|
||||
define(`DEFINE_RELOCATE_API', `
|
||||
EXPORTED_FUNCTION(`void xc_processor_relocate_$1($1 *dst, char *old_start, char *new_start TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
xc_relocate_t relocate;
|
||||
relocate.dst = dst;
|
||||
relocate.old_start = old_start;
|
||||
relocate.new_start = new_start;
|
||||
xc_relocate_$1(&relocate, dst TSRMLS_CC);
|
||||
}
|
||||
dnl }}}
|
||||
')
|
||||
DEFINE_RELOCATE_API(`xc_entry_var_t')
|
||||
DEFINE_RELOCATE_API(`xc_entry_php_t')
|
||||
DEFINE_RELOCATE_API(`xc_entry_data_php_t')
|
||||
EXPORTED(`#ifdef HAVE_XCACHE_DPRINT')
|
||||
EXPORTED_FUNCTION(`void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC)') dnl {{{
|
||||
{
|
||||
IFDPRINT(`INDENT()`'fprintf(stderr, "xc_entry_php_t:src");')
|
||||
xc_dprint_xc_entry_php_t(src, indent TSRMLS_CC);
|
||||
}
|
||||
dnl }}}
|
||||
EXPORTED(`#endif')
|
Loading…
Reference in New Issue