summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.h
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-04-22 21:46:13 +0300
committerDmitry Stogov <dmitry@zend.com>2015-04-22 21:46:13 +0300
commit15a5f61cf4ac1961c20b61ba58e19c64a653064c (patch)
treecb4159c8130e12c3e9d4ef736ca49ad3464c215f /Zend/zend_compile.h
parentaf33279a6cf1e251a8454d567726df4bbe6be1e4 (diff)
downloadphp-git-15a5f61cf4ac1961c20b61ba58e19c64a653064c.tar.gz
Use fast method to check if first arguments should be passed by reference (not tested onbig endian).
Diffstat (limited to 'Zend/zend_compile.h')
-rw-r--r--Zend/zend_compile.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 4b3d0a25b2..6ae1cd5f45 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -334,6 +334,7 @@ typedef struct _zend_internal_function_info {
struct _zend_op_array {
/* Common elements */
zend_uchar type;
+ zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string *function_name;
zend_class_entry *scope;
@@ -384,6 +385,7 @@ struct _zend_op_array {
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
+ zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string* function_name;
zend_class_entry *scope;
@@ -404,6 +406,7 @@ union _zend_function {
struct {
zend_uchar type; /* never used */
+ zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */
uint32_t fn_flags;
zend_string *function_name;
zend_class_entry *scope;
@@ -776,6 +779,7 @@ ZEND_API void zend_activate_auto_globals(void);
ZEND_API zend_bool zend_is_auto_global(zend_string *name);
ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len);
ZEND_API size_t zend_dirname(char *path, size_t len);
+ZEND_API int zend_set_function_arg_flags(zend_function *func);
int zendlex(zend_parser_stack_elem *elem);
@@ -910,6 +914,32 @@ static zend_always_inline int zend_check_arg_send_type(const zend_function *zf,
#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
zend_check_arg_send_type(zf, arg_num, ZEND_SEND_PREFER_REF)
+/* Quick API to check firat 12 arguments */
+#define MAX_ARG_FLAG_NUM 12
+
+#ifdef WORDS_BIGENDIAN
+# define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
+ *(uint32_t*)&(zf)->type |= ((mask) << ((arg_num) - 1) * 2); \
+ } while (0)
+# define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
+ (((*((uint32_t*)&((zf)->type))) >> (((arg_num) - 1) * 2)) & (mask))
+#else
+# define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
+ *(uint32_t*)&(zf)->type |= (((mask) << 6) << (arg_num) * 2); \
+ } while (0)
+# define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
+ (((*(uint32_t*)&(zf)->type) >> (((arg_num) + 3) * 2)) & (mask))
+#endif
+
+#define QUICK_ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
+ ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF)
+
+#define QUICK_ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
+ ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
+
+#define QUICK_ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
+ ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_PREFER_REF)
+
#define ZEND_RETURN_VAL 0
#define ZEND_RETURN_REF 1