summaryrefslogtreecommitdiff
path: root/processor
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-10 09:07:27 +0000
committerXuefer <xuefer@gmail.com>2014-11-10 09:07:27 +0000
commit6c397c70ecd8a7a4e67dd347614ee4571c2830fd (patch)
tree4c7f236e4fbd38e9a1bd24897b53022de558c43b /processor
parentcaa8966009576da40eebb8b511344ec838411067 (diff)
downloadxcache-6c397c70ecd8a7a4e67dd347614ee4571c2830fd.tar.gz
xcache-6c397c70ecd8a7a4e67dd347614ee4571c2830fd.zip
support for autoload in xcache_get
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1560 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'processor')
-rw-r--r--processor/class-helper.h15
-rw-r--r--processor/foot.m43
-rw-r--r--processor/head.m41
-rw-r--r--processor/processor.m423
-rw-r--r--processor/var-helper-t.h1
-rw-r--r--processor/var-helper.h19
-rw-r--r--processor/var-helper.m43
7 files changed, 14 insertions, 51 deletions
diff --git a/processor/class-helper.h b/processor/class-helper.h
deleted file mode 100644
index db8a562..0000000
--- a/processor/class-helper.h
+++ /dev/null
@@ -1,15 +0,0 @@
-static zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len TSRMLS_DC) /* {{{ */
-{
- xc_cest_t *cest;
-#ifdef ZEND_ENGINE_2
- if (zend_lookup_class_ex(class_name, class_name_len, NULL, 0, &cest TSRMLS_CC) != SUCCESS) {
- return NULL;
- }
-#else
- if (zend_hash_find(EG(class_table), class_name, class_name_len, (void **) &cest) != SUCCESS) {
- return NULL;
- }
-#endif
- return CestToCePtr(*cest);
-}
-/* }}} */
diff --git a/processor/foot.m4 b/processor/foot.m4
index 727b1b4..31cd2c7 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -118,7 +118,7 @@ EXPORTED_FUNCTION(`xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t
return dst;
}
dnl }}}
-EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_t *src TSRMLS_DC)') 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 {{{
{
xc_processor_t processor;
size_t i;
@@ -132,6 +132,7 @@ EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_
zend_hash_add(&processor.zvalptrs, (char *)src->value, sizeof(src->value), (void *) &dst, sizeof(dst), NULL);
}
processor.entry_var_src = src;
+ processor.index_to_ce = index_to_ce;
#ifdef ZEND_ENGINE_2
if (src->objects_count) {
diff --git a/processor/head.m4 b/processor/head.m4
index 2e6656c..f202204 100644
--- a/processor/head.m4
+++ b/processor/head.m4
@@ -55,7 +55,6 @@ static void xc_zend_extension_op_array_ctor_handler(zend_extension *extension, z
#include "processor/string-helper.h"
include(__dir__`/string-helper.m4')
-#include "processor/class-helper.h"
include(__dir__`/class-helper.m4')
#include "processor/var-helper.h"
diff --git a/processor/processor.m4 b/processor/processor.m4
index 6be2952..696add7 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -119,33 +119,18 @@ DEF_STRUCT_P_FUNC(`zend_ast', , `dnl {{{
dnl }}}
#endif
DEF_STRUCT_P_FUNC(`zend_object', , `dnl {{{
- dnl handle ce
- dnl IFCALCSTORE(`
- dnl pushdef(`SRC', `ifelse(`$1', `ce', `src->ce->name', `')')
- dnl pushdef(`DST', `ifelse(`$1', `ce', `(*(char **)&dst->ce)', `')')
- dnl PROC_STRING(`ce')
- dnl popdef(`SRC')
- dnl popdef(`DST')
- dnl ', `IFRESTORE(`
- dnl if (!(DST(`ce') = xc_lookup_class((const char *) SRC(`ce') TSRMLS_CC))) {
- dnl DST(`ce') = zend_standard_class_def;
- dnl php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s not found when restroing variable", (const char *) SRC(`ce'));
- dnl }
- dnl DONE(`ce')
- dnl ', `
- dnl PROCESS(zend_ulong, ce)
- dnl ')')
IFCALC(`
xc_var_collect_class(processor, SRC(ce) TSRMLS_CC);
DONE(ce)
', `IFSTORE(`
- DST(ce) = (zend_class_entry *) xc_var_ce_to_index(processor, DST(ce) TSRMLS_CC);
+ DST(ce) = (zend_class_entry *) xc_var_store_ce(processor, DST(ce) TSRMLS_CC);
DONE(ce)
', `IFRESTORE(`
- DST(ce) = xc_var_index_to_ec(processor, (size_t) DST(ce) TSRMLS_CC);
+ assert(processor->index_to_ce);
+ DST(ce) = processor->index_to_ce[(size_t) DST(ce)];
DONE(ce)
', `
- PROCESS_SCALAR(ce, %lu, unsigned long)
+ PROCESS_SCALAR(ce, lu, unsigned long)
')')')
STRUCT_P(HashTable, properties, HashTable_zval_ptr)
diff --git a/processor/var-helper-t.h b/processor/var-helper-t.h
index c9663af..12c2a81 100644
--- a/processor/var-helper-t.h
+++ b/processor/var-helper-t.h
@@ -7,4 +7,5 @@ const xc_entry_var_t *entry_var_src; /* in restore */
xc_vector_t class_names; /* in calc only */
HashTable class_name_to_index; /* in calc/store only */
+zend_class_entry **index_to_ce; /* in restore only */
/* }}} */
diff --git a/processor/var-helper.h b/processor/var-helper.h
index f009166..852f891 100644
--- a/processor/var-helper.h
+++ b/processor/var-helper.h
@@ -39,13 +39,14 @@ static void xc_var_collect_class(xc_processor_t *processor, zend_class_entry *ce
size_t next_index = xc_vector_size(&processor->class_names);
if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) {
- xc_constant_string_t class_name = { ce->name, ce->name_length };
+ xc_constant_string_t class_name;
+ class_name.str = (char *) ce->name;
+ class_name.len = ce->name_length;
xc_vector_push_back(&processor->class_names, &class_name);
}
}
/* }}} */
-/* on store */
-static size_t xc_var_ce_to_index(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
+static size_t xc_var_store_ce(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
size_t *index;
@@ -58,15 +59,3 @@ static size_t xc_var_ce_to_index(xc_processor_t *processor, zend_class_entry *ce
}
/* }}} */
/* on restore */
-static zend_class_entry *xc_var_index_to_ec(xc_processor_t *processor, size_t index TSRMLS_DC) /* {{{ */
-{
- xc_constant_string_t *name = &processor->entry_var_src->class_names[index];
- zend_class_entry *ce;
-
- if (!(ce = xc_lookup_class(name->str, name->len TSRMLS_CC))) {
- ce = zend_standard_class_def;
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s not found when restroing variable", name->str);
- }
- return ce;
-}
-/* }}} */
diff --git a/processor/var-helper.m4 b/processor/var-helper.m4
index 6b48efc..263856b 100644
--- a/processor/var-helper.m4
+++ b/processor/var-helper.m4
@@ -1,3 +1,6 @@
define(`xc_collect_object', `IFCALC(``xc_collect_object'($@)',``xc_collect_object' can be use in calc only')')
define(`xc_var_store_handle', `IFSTORE(``xc_var_store_handle'($@)',``xc_var_store_handle' can be use in store only')')
define(`xc_var_restore_handle', `IFRESTORE(``xc_var_restore_handle'($@)',``xc_var_restore_handle' can be use in restore only')')
+
+define(`xc_collect_class', `IFCALC(``xc_collect_class'($@)',``xc_collect_class' can be use in calc only')')
+define(`xc_var_store_ce', `IFSTORE(``xc_var_store_ce'($@)',``xc_var_store_ce' can be use in store only')')