summaryrefslogtreecommitdiff
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
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
-rw-r--r--Makefile.frag.deps10
-rw-r--r--mod_cacher/xc_cacher.c79
-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
-rw-r--r--util/xc_vector.h1
-rw-r--r--xcache/xc_utils.c15
-rw-r--r--xcache/xc_utils.h2
12 files changed, 106 insertions, 66 deletions
diff --git a/Makefile.frag.deps b/Makefile.frag.deps
index cac429a..74f2dc3 100644
--- a/Makefile.frag.deps
+++ b/Makefile.frag.deps
@@ -1,14 +1,14 @@
$(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: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.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_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_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_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_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: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.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_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: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.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
+mod_optimizer/xc_optimizer.lo $(builddir)/mod_optimizer/xc_optimizer.lo: $(XCACHE_PROC_H) $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.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_trace.lo $(builddir)/util/xc_trace.lo: $(srcdir)/util/xc_trace.h
util/xc_vector_test.lo $(builddir)/util/xc_vector_test.lo: $(srcdir)/util/xc_vector.h
-xcache.lo $(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.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.lo $(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_vector.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_compatibility.lo $(builddir)/xcache/xc_compatibility.lo: $(srcdir)/xcache/xc_compatibility.h
@@ -18,7 +18,7 @@ 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.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_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/processor/class-helper.h $(srcdir)/processor/debug.h $(srcdir)/processor/processor-t.h $(srcdir)/processor/string-helper-t.h $(srcdir)/processor/string-helper.h $(srcdir)/processor/types.h $(srcdir)/processor/var-helper-t.h $(srcdir)/processor/var-helper.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_util.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
+xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/util/xc_align.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
xcache/xc_sandbox.lo $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/util/xc_vector.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
diff --git a/mod_cacher/xc_cacher.c b/mod_cacher/xc_cacher.c
index ab1912a..40c55be 100644
--- a/mod_cacher/xc_cacher.c
+++ b/mod_cacher/xc_cacher.c
@@ -3319,6 +3319,9 @@ PHP_FUNCTION(xcache_get)
xc_cache_t *cache;
xc_entry_var_t entry_var, *stored_entry_var;
zval *name;
+ xc_vector_t index_to_ce = xc_vector_initializer(zend_class_entry *, 0);
+ xc_vector_t pending_class_names = xc_vector_initializer(xc_constant_string_t, 0);
+ zend_bool reload_class;
VAR_BUFFER_FLAGS(name);
if (!xc_var_caches) {
@@ -3338,17 +3341,73 @@ PHP_FUNCTION(xcache_get)
RETURN_NULL();
}
- ENTER_LOCK(cache) {
- stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC);
- if (stored_entry_var) {
- /* return */
- xc_processor_restore_var(return_value, stored_entry_var TSRMLS_CC);
- xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
+ do {
+ reload_class = 0;
+ if (xc_vector_size(&pending_class_names)) {
+ size_t i, end = xc_vector_size(&pending_class_names);
+ assert(end != 0);
+ for (i = 0; i < end; ++i) {
+ xc_constant_string_t *pending_class_name = &xc_vector_data(xc_constant_string_t, &pending_class_names)[i];
+ zend_class_entry *ce = xc_lookup_class(pending_class_name->str, pending_class_name->len, 1 TSRMLS_CC);
+ if (!ce) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s not found when restroing variable", pending_class_name->str);
+ break;
+ }
+ }
+ if (i != end) {
+ break;
+ }
+ xc_vector_clear(&pending_class_names);
}
- else {
- RETVAL_NULL();
+
+ ENTER_LOCK(cache) {
+ stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC);
+ if (!stored_entry_var) {
+ RETVAL_NULL();
+ break;
+ }
+
+ if (stored_entry_var->class_names_count) {
+ zend_uint i;
+ /* see if lucky to have all classes needed already loaded */
+ for (i = 0; i < stored_entry_var->class_names_count; ++i) {
+ xc_constant_string_t *class_name = &stored_entry_var->class_names[i];
+ zend_class_entry *ce = xc_lookup_class(class_name->str, class_name->len, 0 TSRMLS_CC);
+
+ /* not found, add to pending */
+ if (!ce) {
+ xc_constant_string_t pending_class_name;
+ pending_class_name.str = estrndup(class_name->str, class_name->len);
+ pending_class_name.len = class_name->len;
+ xc_vector_push_back(&pending_class_names, &pending_class_name);
+ reload_class = 1;
+ }
+ else if (!reload_class) {
+ xc_vector_push_back(&index_to_ce, &ce);
+ }
+ }
+
+ if (reload_class) {
+ /* not all loaded, load it after unload and run another pass */
+ xc_vector_clear(&index_to_ce);
+ break;
+ }
+ }
+
+ xc_processor_restore_var(return_value, stored_entry_var, xc_vector_data(zend_class_entry *, &index_to_ce) TSRMLS_CC);
+ xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
+ } LEAVE_LOCK(cache);
+ } while (reload_class);
+
+ if (xc_vector_size(&pending_class_names)) {
+ size_t i;
+ for (i = 0; i < xc_vector_size(&pending_class_names); ++i) {
+ efree(xc_vector_data(xc_constant_string_t, &pending_class_names)[i].str);
}
- } LEAVE_LOCK(cache);
+ }
+ xc_vector_destroy(&pending_class_names);
+ xc_vector_destroy(&index_to_ce);
+
VAR_BUFFER_FREE(name);
}
/* }}} */
@@ -3615,7 +3674,7 @@ static inline void xc_var_inc_dec(int inc, INTERNAL_FUNCTION_PARAMETERS) /* {{{
value = 0;
}
else {
- xc_processor_restore_var(&oldzval, stored_entry_var TSRMLS_CC);
+ xc_processor_restore_var(&oldzval, stored_entry_var, NULL TSRMLS_CC);
convert_to_long(&oldzval);
value = Z_LVAL(oldzval);
zval_dtor(&oldzval);
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')')
diff --git a/util/xc_vector.h b/util/xc_vector.h
index bba5d5f..5792eb2 100644
--- a/util/xc_vector.h
+++ b/util/xc_vector.h
@@ -48,6 +48,7 @@ static inline void xc_vector_destroy_impl(xc_vector_t *vector TSRMLS_DC)
}
#define xc_vector_destroy(vector) xc_vector_destroy_impl(vector TSRMLS_CC)
+#define xc_vector_clear(vector) do { (vector)->size = 0; } while (0)
#define xc_vector_size(vector) ((vector)->size)
#define xc_vector_initialized(vector) ((vector)->data_size != 0)
diff --git a/xcache/xc_utils.c b/xcache/xc_utils.c
index 461901a..b757b3c 100644
--- a/xcache/xc_utils.c
+++ b/xcache/xc_utils.c
@@ -638,3 +638,18 @@ void xc_copy_internal_zend_constants(HashTable *target, HashTable *source) /* {{
}
/* }}} */
#endif
+zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC) /* {{{ */
+{
+ xc_cest_t *cest;
+#ifdef ZEND_ENGINE_2
+ if (zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &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/xcache/xc_utils.h b/xcache/xc_utils.h
index eae8826..86350e6 100644
--- a/xcache/xc_utils.h
+++ b/xcache/xc_utils.h
@@ -56,3 +56,5 @@ void xc_copy_internal_zend_constants(HashTable *target, HashTable *source);
#ifndef ZEND_COMPILE_DELAYED_BINDING
int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int oplineno TSRMLS_DC);
#endif
+
+zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC);