summaryrefslogtreecommitdiff
path: root/processor
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-12 07:03:46 +0000
committerXuefer <xuefer@gmail.com>2014-11-12 07:03:46 +0000
commit15ad8700a85f66cd53cb24d6f1f0aaf8cb9c1c79 (patch)
treeaba45e9c2ac2d491b6e1f7a2b1e5c6809ec03e41 /processor
parentef3a8f0221f51896ad8faf9000888d9e56cfe1b4 (diff)
downloadxcache-15ad8700a85f66cd53cb24d6f1f0aaf8cb9c1c79.tar.gz
xcache-15ad8700a85f66cd53cb24d6f1f0aaf8cb9c1c79.zip
support for reference value
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1572 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'processor')
-rw-r--r--processor/foot.m423
-rw-r--r--processor/processor.m424
2 files changed, 34 insertions, 13 deletions
diff --git a/processor/foot.m4 b/processor/foot.m4
index 65d066f..0bfe239 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -86,17 +86,15 @@ dnl }}}
DEFINE_STORE_API(`xc_entry_php_t')
DEFINE_STORE_API(`xc_entry_data_php_t')
DEFINE_STORE_API(`xc_entry_var_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 {{{
+EXPORTED_FUNCTION(`void 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 {{{
+EXPORTED_FUNCTION(`void 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;
@@ -115,10 +113,9 @@ EXPORTED_FUNCTION(`xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t
if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
- return dst;
}
dnl }}}
-EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_t *src, zend_class_entry **index_to_ce TSRMLS_DC)') dnl {{{
+EXPORTED_FUNCTION(`void xc_processor_restore_var(zval *dst, zval **dst_ptr, const xc_entry_var_t *src, zend_class_entry **index_to_ce TSRMLS_DC)') dnl {{{
{
xc_processor_t processor;
@@ -127,8 +124,9 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
if (processor.handle_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->value, sizeof(src->value), (void *) &dst, sizeof(dst), NULL);
+ if (dst_ptr) {
+ zval_ptr_dtor(dst_ptr);
+ }
}
processor.index_to_ce = index_to_ce;
@@ -146,7 +144,12 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
}
}
#endif
- xc_restore_zval(&processor, dst, src->value TSRMLS_CC);
+ if (dst_ptr) {
+ xc_restore_zval_ptr(&processor, dst_ptr, &src->value TSRMLS_CC);
+ }
+ else {
+ xc_restore_zval(&processor, dst, src->value TSRMLS_CC);
+ }
if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
}
@@ -160,8 +163,6 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
efree(processor.object_handles);
}
#endif
-
- return dst;
}
dnl }}}
define(`DEFINE_RELOCATE_API', `
diff --git a/processor/processor.m4 b/processor/processor.m4
index d2e0ca5..b202bda 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -283,8 +283,9 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
if (zend_hash_find(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void **) &ppzv) == SUCCESS) {
IFCOPY(`
DST()[0] = *ppzv;
+ IFSTORE(`Z_ADDREF(**DST());')
/* *DST() is updated */
- dnl fprintf(stderr, "*DST() is set to %p, PROCESSOR_TYPE is_shm %d\n", DST()[0], xc_is_shm(DST()[0]));
+ dnl fprintf(stderr, "*DST() is set to %p, PROCESSOR_TYPE is_shm %d\n", (void *) DST()[0], xc_is_shm(DST()[0]));
')
IFCALCSTORE(`processor->have_references = 1;')
IFSTORE(`assert(xc_is_shm(DST()[0]));')
@@ -305,7 +306,8 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
RELOCATE_EX(zval, pzv)
')
if (zend_hash_add(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { /* first add, go on */
- dnl fprintf(stderr, "mark[%p] = %p\n", SRC()[0], pzv);
+ IFSTORE(`Z_SET_REFCOUNT(**DST(), 1);')
+ dnl IFSTORE(`fprintf(stderr, "mark[%p] = %p\n", (void *) SRC()[0], (void *) pzv);')
}
else {
assert(0);
@@ -1416,6 +1418,24 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
+#if 0
+ IFSTORE(`
+ {
+ HashTable *ht;
+ zval **zv;
+
+ assert(Z_TYPE_P(SRC(`value')) == IS_ARRAY);
+ ht = Z_ARRVAL_P(SRC(`value'));
+ assert(ht->nNumOfElements == 1);
+ fprintf(stderr, "key %s\n", ht->pListHead->arKey);
+
+ zv = (zval **) ht->pListHead->pData;
+ fprintf(stderr, "%d\n", Z_TYPE_PP(zv));
+ assert(Z_TYPE_PP(zv) == IS_ARRAY);
+ assert(Z_ARRVAL_PP(zv) == ht);
+ }
+ ')
+#endif
#ifdef ZEND_ENGINE_2
IFCALC(`