Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff -ur php-5.3.8/Zend php-5.4.0RC2/Zend
Only in php-5.3.8/Zend: acconfig.h
diff -ur php-5.3.8/Zend/zend.h php-5.4.0RC2/Zend/zend.h
--- php-5.3.8/Zend/zend.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend.h 2011-12-13 14:10:09.000000000 +0900
@@ -22,7 +22,7 @@
#ifndef ZEND_H
#define ZEND_H
-#define ZEND_VERSION "2.3.0"
+#define ZEND_VERSION "2.4.0"
#define ZEND_ENGINE_2
@@ -200,9 +200,9 @@
#endif
#if ZEND_DEBUG
-#define ZEND_FILE_LINE_D char *__zend_filename, uint __zend_lineno
+#define ZEND_FILE_LINE_D const char *__zend_filename, const uint __zend_lineno
#define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
-#define ZEND_FILE_LINE_ORIG_D char *__zend_orig_filename, uint __zend_orig_lineno
+#define ZEND_FILE_LINE_ORIG_D const char *__zend_orig_filename, const uint __zend_orig_lineno
#define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
#define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
#define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
@@ -237,6 +237,7 @@
#include "zend_alloc.h"
#include "zend_types.h"
+#include "zend_string.h"
#ifdef HAVE_LIMITS_H
# include <limits.h>
@@ -297,6 +298,7 @@
typedef struct _zend_object {
zend_class_entry *ce;
HashTable *properties;
+ zval **properties_table;
HashTable *guards; /* protects from __get/__set ... recursion */
} zend_object;
@@ -351,17 +353,21 @@
#if defined(__GNUC__)
#if __GNUC__ >= 3
#define zend_always_inline inline __attribute__((always_inline))
+#define zend_never_inline __attribute__((noinline))
#else
#define zend_always_inline inline
+#define zend_never_inline
#endif
#elif defined(_MSC_VER)
#define zend_always_inline __forceinline
+#define zend_never_inline
#else
#define zend_always_inline inline
+#define zend_never_inline
#endif
-#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
+#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
# define EXPECTED(condition) __builtin_expect(condition, 1)
# define UNEXPECTED(condition) __builtin_expect(condition, 0)
#else
@@ -415,22 +421,60 @@
typedef struct _zend_serialize_data zend_serialize_data;
typedef struct _zend_unserialize_data zend_unserialize_data;
+struct _zend_trait_method_reference {
+ const char* method_name;
+ unsigned int mname_len;
+
+ zend_class_entry *ce;
+
+ const char* class_name;
+ unsigned int cname_len;
+};
+typedef struct _zend_trait_method_reference zend_trait_method_reference;
+
+struct _zend_trait_precedence {
+ zend_trait_method_reference *trait_method;
+
+ zend_class_entry** exclude_from_classes;
+
+ union _zend_function* function;
+};
+typedef struct _zend_trait_precedence zend_trait_precedence;
+
+struct _zend_trait_alias {
+ zend_trait_method_reference *trait_method;
+
+ /**
+ * name for method to be added
+ */
+ const char* alias;
+ unsigned int alias_len;
+
+ /**
+ * modifiers to be set on trait method
+ */
+ zend_uint modifiers;
+
+ union _zend_function* function;
+};
+typedef struct _zend_trait_alias zend_trait_alias;
+
struct _zend_class_entry {
char type;
- char *name;
+ const char *name;
zend_uint name_length;
struct _zend_class_entry *parent;
int refcount;
- zend_bool constants_updated;
zend_uint ce_flags;
HashTable function_table;
- HashTable default_properties;
HashTable properties_info;
- HashTable default_static_members;
- HashTable *static_members;
+ zval **default_properties_table;
+ zval **default_static_members_table;
+ zval **static_members_table;
HashTable constants_table;
- const struct _zend_function_entry *builtin_functions;
+ int default_properties_count;
+ int default_static_members_count;
union _zend_function *constructor;
union _zend_function *destructor;
@@ -459,14 +503,25 @@
zend_class_entry **interfaces;
zend_uint num_interfaces;
-
- char *filename;
- zend_uint line_start;
- zend_uint line_end;
- char *doc_comment;
- zend_uint doc_comment_len;
-
- struct _zend_module_entry *module;
+
+ zend_class_entry **traits;
+ zend_uint num_traits;
+ zend_trait_alias **trait_aliases;
+ zend_trait_precedence **trait_precedences;
+
+ union {
+ struct {
+ const char *filename;
+ zend_uint line_start;
+ zend_uint line_end;
+ const char *doc_comment;
+ zend_uint doc_comment_len;
+ } user;
+ struct {
+ const struct _zend_function_entry *builtin_functions;
+ struct _zend_module_entry *module;
+ } internal;
+ } info;
};
#include "zend_stream.h"
@@ -475,9 +530,11 @@
int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
int (*write_function)(const char *str, uint str_length);
FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
- void (*message_handler)(long message, void *data TSRMLS_DC);
+ void (*message_handler)(long message, const void *data TSRMLS_DC);
+#ifndef ZEND_SIGNALS
void (*block_interruptions)(void);
void (*unblock_interruptions)(void);
+#endif
int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds TSRMLS_DC);
@@ -518,13 +575,15 @@
#define IS_RESOURCE 7
#define IS_CONSTANT 8
#define IS_CONSTANT_ARRAY 9
+#define IS_CALLABLE 10
/* Ugly hack to support constants as static array indices */
-#define IS_CONSTANT_TYPE_MASK 0x0f
-#define IS_CONSTANT_UNQUALIFIED 0x10
-#define IS_CONSTANT_INDEX 0x80
-#define IS_LEXICAL_VAR 0x20
-#define IS_LEXICAL_REF 0x40
+#define IS_CONSTANT_TYPE_MASK 0x00f
+#define IS_CONSTANT_UNQUALIFIED 0x010
+#define IS_CONSTANT_INDEX 0x080
+#define IS_LEXICAL_VAR 0x020
+#define IS_LEXICAL_REF 0x040
+#define IS_CONSTANT_IN_NAMESPACE 0x100
/* overloaded elements data types */
#define OE_IS_ARRAY (1<<0)
@@ -599,8 +658,8 @@
/* FIXME: Check if we can save if (ptr) too */
-#define STR_FREE(ptr) if (ptr) { efree(ptr); }
-#define STR_FREE_REL(ptr) if (ptr) { efree_rel(ptr); }
+#define STR_FREE(ptr) if (ptr && !IS_INTERNED(ptr)) { efree(ptr); }
+#define STR_FREE_REL(ptr) if (ptr && !IS_INTERNED(ptr)) { efree_rel(ptr); }
#define STR_EMPTY_ALLOC() estrndup("", sizeof("")-1)
@@ -618,11 +677,13 @@
extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
+#ifndef ZEND_SIGNALS
extern ZEND_API void (*zend_block_interruptions)(void);
extern ZEND_API void (*zend_unblock_interruptions)(void);
+#endif
extern ZEND_API void (*zend_ticks_function)(int ticks);
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
-extern void (*zend_on_timeout)(int seconds TSRMLS_DC);
+extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
@@ -642,11 +703,18 @@
#define ZEND_UV(name) (zend_uv.name)
+#ifndef ZEND_SIGNALS
#define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
#define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
+#else
+#include "zend_signal.h"
+
+#define HANDLE_BLOCK_INTERRUPTIONS() SIGG(depth)++;
+#define HANDLE_UNBLOCK_INTERRUPTIONS() if (UNEXPECTED((--SIGG(depth))==SIGG(blocked))) { zend_signal_handler_unblock(TSRMLS_C); }
+#endif
BEGIN_EXTERN_C()
-ZEND_API void zend_message_dispatcher(long message, void *data TSRMLS_DC);
+ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
END_EXTERN_C()
@@ -676,19 +744,30 @@
#define PZVAL_IS_REF(z) Z_ISREF_P(z)
-#define SEPARATE_ZVAL(ppzv) \
- { \
- zval *orig_ptr = *(ppzv); \
- \
- if (Z_REFCOUNT_P(orig_ptr) > 1) { \
- Z_DELREF_P(orig_ptr); \
- ALLOC_ZVAL(*(ppzv)); \
- **(ppzv) = *orig_ptr; \
- zval_copy_ctor(*(ppzv)); \
- Z_SET_REFCOUNT_PP(ppzv, 1); \
- Z_UNSET_ISREF_PP((ppzv)); \
- } \
- }
+#define ZVAL_COPY_VALUE(z, v) \
+ do { \
+ (z)->value = (v)->value; \
+ Z_TYPE_P(z) = Z_TYPE_P(v); \
+ } while (0)
+
+#define INIT_PZVAL_COPY(z, v) \
+ do { \
+ ZVAL_COPY_VALUE(z, v); \
+ Z_SET_REFCOUNT_P(z, 1); \
+ Z_UNSET_ISREF_P(z); \
+ } while (0)
+
+#define SEPARATE_ZVAL(ppzv) \
+ do { \
+ if (Z_REFCOUNT_PP((ppzv)) > 1) { \
+ zval *new_zv; \
+ Z_DELREF_PP(ppzv); \
+ ALLOC_ZVAL(new_zv); \
+ INIT_PZVAL_COPY(new_zv, *(ppzv)); \
+ *(ppzv) = new_zv; \
+ zval_copy_ctor(new_zv); \
+ } \
+ } while (0)
#define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
if (!PZVAL_IS_REF(*ppzv)) { \
@@ -711,10 +790,9 @@
} \
INIT_PZVAL(&(zv));
-#define MAKE_COPY_ZVAL(ppzv, pzv) \
- *(pzv) = **(ppzv); \
- zval_copy_ctor((pzv)); \
- INIT_PZVAL((pzv));
+#define MAKE_COPY_ZVAL(ppzv, pzv) \
+ INIT_PZVAL_COPY(pzv, *(ppzv)); \
+ zval_copy_ctor((pzv));
#define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
int is_ref, refcount; \
@@ -723,7 +801,7 @@
is_ref = Z_ISREF_PP(ppzv_dest); \
refcount = Z_REFCOUNT_PP(ppzv_dest); \
zval_dtor(*ppzv_dest); \
- **ppzv_dest = *pzv_src; \
+ ZVAL_COPY_VALUE(*ppzv_dest, pzv_src); \
if (copy) { \
zval_copy_ctor(*ppzv_dest); \
} \
@@ -735,10 +813,7 @@
if (PZVAL_IS_REF(varptr)) { \
zval *original_var = varptr; \
ALLOC_ZVAL(varptr); \
- varptr->value = original_var->value; \
- Z_TYPE_P(varptr) = Z_TYPE_P(original_var); \
- Z_UNSET_ISREF_P(varptr); \
- Z_SET_REFCOUNT_P(varptr, 1); \
+ INIT_PZVAL_COPY(varptr, original_var); \
zval_copy_ctor(varptr); \
} else { \
Z_ADDREF_P(varptr); \
diff -ur php-5.3.8/Zend/zend_API.h php-5.4.0RC2/Zend/zend_API.h
--- php-5.3.8/Zend/zend_API.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_API.h 2011-12-13 14:10:09.000000000 +0900
@@ -98,13 +98,14 @@
#define ZEND_FE_END { NULL, NULL, NULL, 0, 0 }
-#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
-#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
-#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, 0, allow_null, pass_by_ref, 0, 0 },
-#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, sizeof(#name)-1, NULL, 0, 1, allow_null, pass_by_ref, 0, 0 },
+#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, 0, pass_by_ref},
+#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, 0, pass_by_ref},
+#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, IS_OBJECT, allow_null, pass_by_ref},
+#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, sizeof(#name)-1, NULL, 0, IS_ARRAY, allow_null, pass_by_ref},
+#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, sizeof(#name)-1, NULL, 0, type_hint, allow_null, pass_by_ref},
#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference, required_num_args) \
static const zend_arg_info name[] = { \
- { NULL, 0, NULL, 0, 0, 0, pass_rest_by_reference, return_reference, required_num_args },
+ { NULL, 0, NULL, required_num_args, 0, return_reference, pass_rest_by_reference},
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_VALUE, -1)
#define ZEND_END_ARG_INFO() };
@@ -167,10 +168,13 @@
#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
{ \
+ const char *cl_name = class_name; \
int _len = class_name_len; \
- class_container.name = zend_strndup(class_name, _len); \
+ class_container.name = zend_new_interned_string(cl_name, _len+1, 0 TSRMLS_CC); \
+ if (class_container.name == cl_name) { \
+ class_container.name = zend_strndup(cl_name, _len); \
+ } \
class_container.name_length = _len; \
- class_container.builtin_functions = functions; \
class_container.constructor = NULL; \
class_container.destructor = NULL; \
class_container.clone = NULL; \
@@ -192,10 +196,15 @@
class_container.unserialize = NULL; \
class_container.parent = NULL; \
class_container.num_interfaces = 0; \
+ class_container.traits = NULL; \
+ class_container.num_traits = 0; \
+ class_container.trait_aliases = NULL; \
+ class_container.trait_precedences = NULL; \
class_container.interfaces = NULL; \
class_container.get_iterator = NULL; \
class_container.iterator_funcs.funcs = NULL; \
- class_container.module = NULL; \
+ class_container.info.internal.module = NULL; \
+ class_container.info.internal.builtin_functions = functions; \
}
#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
@@ -209,9 +218,9 @@
INIT_OVERLOADED_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions, handle_fcall, handle_propget, handle_propset)
#ifdef ZTS
-# define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members:CG(static_members)[(zend_intptr_t)(ce)->static_members])
+# define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members_table:CG(static_members_table)[(zend_intptr_t)(ce)->static_members_table])
#else
-# define CE_STATIC_MEMBERS(ce) ((ce)->static_members)
+# define CE_STATIC_MEMBERS(ce) ((ce)->static_members_table)
#endif
#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
@@ -237,12 +246,12 @@
/* Parameter parsing API -- andrei */
#define ZEND_PARSE_PARAMS_QUIET 1<<1
-ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);
-ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);
+ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, const char *type_spec, ...);
+ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, const char *type_spec, ...);
ZEND_API char *zend_zval_type_name(const zval *arg);
-ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
-ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...);
+ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...);
+ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...);
/* End of parameter parsing API -- andrei */
@@ -253,6 +262,8 @@
ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TSRMLS_DC);
ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC);
ZEND_API int zend_startup_modules(TSRMLS_D);
+ZEND_API void zend_collect_module_handlers(TSRMLS_D);
+ZEND_API void zend_destroy_modules(void);
ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
@@ -284,14 +295,14 @@
ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC);
ZEND_API const char *zend_get_module_version(const char *module_name);
ZEND_API int zend_get_module_started(const char *module_name);
-ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC);
-ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_double(zend_class_entry *ce, char *name, int name_length, double value, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int name_length, char *value, int value_len, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type, const char *doc_comment, int doc_comment_len TSRMLS_DC);
+ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, int value_len, int access_type TSRMLS_DC);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC);
@@ -302,28 +313,28 @@
ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value TSRMLS_DC);
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
-ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC);
-ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC);
-ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
-ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
-ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, char *name, int name_length, double value TSRMLS_DC);
-ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value TSRMLS_DC);
-ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value, int value_length TSRMLS_DC);
-
-ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, int name_length, zval *value TSRMLS_DC);
-ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *name, int name_length TSRMLS_DC);
-ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC);
-ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC);
-ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *name, int name_length, double value TSRMLS_DC);
-ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, const char *value TSRMLS_DC);
-ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, const char *value, int value_length TSRMLS_DC);
+ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC);
+ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC);
+ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC);
+ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC);
+ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, int value_length TSRMLS_DC);
+
+ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC);
+ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC);
+ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC);
+ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC);
+ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, int value_length TSRMLS_DC);
-ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC);
+ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_bool silent TSRMLS_DC);
-ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC);
+ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC);
-ZEND_API int zend_get_object_classname(const zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC);
+ZEND_API int zend_get_object_classname(const zval *object, const char **class_name, zend_uint *class_name_len TSRMLS_DC);
ZEND_API char *zend_get_type_by_const(int type);
#define getThis() (this_ptr)
@@ -348,6 +359,7 @@
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC);
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC);
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC);
+ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC);
@@ -412,8 +424,8 @@
ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC);
ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, long r TSRMLS_DC);
ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC);
-ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, char *str, int duplicate TSRMLS_DC);
-ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC);
+ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, const char *str, int duplicate TSRMLS_DC);
+ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, uint length, int duplicate TSRMLS_DC);
ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval *value TSRMLS_DC);
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n TSRMLS_CC)
@@ -490,7 +502,11 @@
ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...);
-ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC);
+ZEND_API void zend_delete_variable(zend_execute_data *ex, HashTable *ht, const char *name, int name_len, ulong hash_value TSRMLS_DC);
+
+ZEND_API int zend_delete_global_variable(const char *name, int name_len TSRMLS_DC);
+
+ZEND_API int zend_delete_global_variable_ex(const char *name, int name_len, ulong hash_value TSRMLS_DC);
ZEND_API void zend_reset_all_cv(HashTable *symbol_table TSRMLS_DC);
@@ -512,54 +528,64 @@
#define CHECK_ZVAL_STRING_REL(z)
#endif
-#define ZVAL_RESOURCE(z, l) { \
- Z_TYPE_P(z) = IS_RESOURCE; \
- Z_LVAL_P(z) = l; \
- }
+#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p)))
+#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
-#define ZVAL_BOOL(z, b) { \
- Z_TYPE_P(z) = IS_BOOL; \
- Z_LVAL_P(z) = ((b) != 0); \
- }
+#define ZVAL_RESOURCE(z, l) do { \
+ zval *__z = (z); \
+ Z_LVAL_P(__z) = l; \
+ Z_TYPE_P(__z) = IS_RESOURCE;\
+ } while (0)
+
+#define ZVAL_BOOL(z, b) do { \
+ zval *__z = (z); \
+ Z_LVAL_P(__z) = ((b) != 0); \
+ Z_TYPE_P(__z) = IS_BOOL; \
+ } while (0)
#define ZVAL_NULL(z) { \
Z_TYPE_P(z) = IS_NULL; \
}
#define ZVAL_LONG(z, l) { \
- Z_TYPE_P(z) = IS_LONG; \
- Z_LVAL_P(z) = l; \
+ zval *__z = (z); \
+ Z_LVAL_P(__z) = l; \
+ Z_TYPE_P(__z) = IS_LONG; \
}
#define ZVAL_DOUBLE(z, d) { \
- Z_TYPE_P(z) = IS_DOUBLE; \
- Z_DVAL_P(z) = d; \
- }
-
-#define ZVAL_STRING(z, s, duplicate) { \
- const char *__s=(s); \
- Z_STRLEN_P(z) = strlen(__s); \
- Z_STRVAL_P(z) = (duplicate?estrndup(__s, Z_STRLEN_P(z)):(char*)__s);\
- Z_TYPE_P(z) = IS_STRING; \
- }
-
-#define ZVAL_STRINGL(z, s, l, duplicate) { \
- const char *__s=(s); int __l=l; \
- Z_STRLEN_P(z) = __l; \
- Z_STRVAL_P(z) = (duplicate?estrndup(__s, __l):(char*)__s);\
- Z_TYPE_P(z) = IS_STRING; \
- }
-
-#define ZVAL_EMPTY_STRING(z) { \
- Z_STRLEN_P(z) = 0; \
- Z_STRVAL_P(z) = STR_EMPTY_ALLOC();\
- Z_TYPE_P(z) = IS_STRING; \
- }
+ zval *__z = (z); \
+ Z_DVAL_P(__z) = d; \
+ Z_TYPE_P(__z) = IS_DOUBLE; \
+ }
+
+#define ZVAL_STRING(z, s, duplicate) do { \
+ const char *__s=(s); \
+ zval *__z = (z); \
+ Z_STRLEN_P(__z) = strlen(__s); \
+ Z_STRVAL_P(__z) = (duplicate?estrndup(__s, Z_STRLEN_P(__z)):(char*)__s);\
+ Z_TYPE_P(__z) = IS_STRING; \
+ } while (0)
+
+#define ZVAL_STRINGL(z, s, l, duplicate) do { \
+ const char *__s=(s); int __l=l; \
+ zval *__z = (z); \
+ Z_STRLEN_P(__z) = __l; \
+ Z_STRVAL_P(__z) = (duplicate?estrndup(__s, __l):(char*)__s);\
+ Z_TYPE_P(__z) = IS_STRING; \
+ } while (0)
+
+#define ZVAL_EMPTY_STRING(z) do { \
+ zval *__z = (z); \
+ Z_STRLEN_P(__z) = 0; \
+ Z_STRVAL_P(__z) = STR_EMPTY_ALLOC();\
+ Z_TYPE_P(__z) = IS_STRING; \
+ } while (0)
#define ZVAL_ZVAL(z, zv, copy, dtor) { \
zend_uchar is_ref = Z_ISREF_P(z); \
zend_uint refcount = Z_REFCOUNT_P(z); \
- *(z) = *(zv); \
+ ZVAL_COPY_VALUE(z, zv); \
if (copy) { \
zval_copy_ctor(z); \
} \
diff -ur php-5.3.8/Zend/zend_alloc.h php-5.4.0RC2/Zend/zend_alloc.h
--- php-5.3.8/Zend/zend_alloc.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_alloc.h 2011-12-13 14:10:09.000000000 +0900
@@ -44,9 +44,9 @@
typedef struct _zend_leak_info {
void *addr;
size_t size;
- char *filename;
+ const char *filename;
uint lineno;
- char *orig_filename;
+ const char *orig_filename;
uint orig_lineno;
} zend_leak_info;
@@ -161,45 +161,31 @@
END_EXTERN_C()
-/* Macroses for zend_fast_cache.h compatibility */
-
-#define ZEND_FAST_ALLOC(p, type, fc_type) \
- (p) = (type *) emalloc(sizeof(type))
-
-#define ZEND_FAST_FREE(p, fc_type) \
- efree(p)
-
-#define ZEND_FAST_ALLOC_REL(p, type, fc_type) \
- (p) = (type *) emalloc_rel(sizeof(type))
-
-#define ZEND_FAST_FREE_REL(p, fc_type) \
- efree_rel(p)
-
/* fast cache for zval's */
#define ALLOC_ZVAL(z) \
- ZEND_FAST_ALLOC(z, zval, ZVAL_CACHE_LIST)
+ (z) = (zval *) emalloc(sizeof(zval))
#define FREE_ZVAL(z) \
- ZEND_FAST_FREE(z, ZVAL_CACHE_LIST)
+ efree_rel(z)
#define ALLOC_ZVAL_REL(z) \
- ZEND_FAST_ALLOC_REL(z, zval, ZVAL_CACHE_LIST)
+ (z) = (zval *) emalloc_rel(sizeof(zval))
#define FREE_ZVAL_REL(z) \
- ZEND_FAST_FREE_REL(z, ZVAL_CACHE_LIST)
+ efree_rel(z)
/* fast cache for HashTables */
#define ALLOC_HASHTABLE(ht) \
- ZEND_FAST_ALLOC(ht, HashTable, HASHTABLE_CACHE_LIST)
+ (ht) = (HashTable *) emalloc(sizeof(HashTable))
#define FREE_HASHTABLE(ht) \
- ZEND_FAST_FREE(ht, HASHTABLE_CACHE_LIST)
+ efree(ht)
#define ALLOC_HASHTABLE_REL(ht) \
- ZEND_FAST_ALLOC_REL(ht, HashTable, HASHTABLE_CACHE_LIST)
+ (ht) = (HashTable *) emalloc_rel(sizeof(HashTable))
#define FREE_HASHTABLE_REL(ht) \
- ZEND_FAST_FREE_REL(ht, HASHTABLE_CACHE_LIST)
+ efree_rel(ht)
/* Heap functions */
typedef struct _zend_mm_heap zend_mm_heap;
diff -ur php-5.3.8/Zend/zend_builtin_functions.h php-5.4.0RC2/Zend/zend_builtin_functions.h
--- php-5.3.8/Zend/zend_builtin_functions.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_builtin_functions.h 2011-12-13 14:10:09.000000000 +0900
@@ -25,7 +25,7 @@
int zend_startup_builtin_functions(TSRMLS_D);
BEGIN_EXTERN_C()
-ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options TSRMLS_DC);
+ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC);
END_EXTERN_C()
#endif /* ZEND_BUILTIN_FUNCTIONS_H */
diff -ur php-5.3.8/Zend/zend_closures.h php-5.4.0RC2/Zend/zend_closures.h
--- php-5.3.8/Zend/zend_closures.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_closures.h 2011-12-13 14:10:09.000000000 +0900
@@ -30,9 +30,10 @@
extern ZEND_API zend_class_entry *zend_ce_closure;
-ZEND_API void zend_create_closure(zval *res, zend_function *op_array TSRMLS_DC);
+ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zval *this_ptr TSRMLS_DC);
ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC);
ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC);
+ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC);
END_EXTERN_C()
diff -ur php-5.3.8/Zend/zend_compile.h php-5.4.0RC2/Zend/zend_compile.h
--- php-5.3.8/Zend/zend_compile.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_compile.h 2011-12-13 14:10:09.000000000 +0900
@@ -34,10 +34,10 @@
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
-#define SET_UNUSED(op) (op).op_type = IS_UNUSED
+#define SET_UNUSED(op) op ## _type = IS_UNUSED
-#define INC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { ((op_array)->backpatch_count++); }
-#define DEC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { ((op_array)->backpatch_count--); }
+#define INC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count++); }
+#define DEC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count--); }
#define HANDLE_INTERACTIVE() if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); }
#define DO_TICKS() if (Z_LVAL(CG(declarables).ticks)) { zend_do_ticks(TSRMLS_C); }
@@ -53,20 +53,44 @@
typedef struct _zend_op_array zend_op_array;
typedef struct _zend_op zend_op;
-typedef struct _znode {
+typedef struct _zend_compiler_context {
+ zend_uint opcodes_size;
+ int vars_size;
+ int literals_size;
+ int current_brk_cont;
+ int backpatch_count;
+ HashTable *labels;
+} zend_compiler_context;
+
+typedef struct _zend_literal {
+ zval constant;
+ zend_ulong hash_value;
+ zend_uint cache_slot;
+} zend_literal;
+
+#define Z_HASH_P(zv) \
+ (((zend_literal*)(zv))->hash_value)
+
+typedef union _znode_op {
+ zend_uint constant;
+ zend_uint var;
+ zend_uint num;
+ zend_ulong hash;
+ zend_uint opline_num; /* Needs to be signed */
+ zend_op *jmp_addr;
+ zval *zv;
+ zend_literal *literal;
+ void *ptr; /* Used for passing pointers from the compile to execution phase, currently used for traits */
+} znode_op;
+
+typedef struct _znode { /* used only during compilation */
int op_type;
union {
- zval constant;
-
- zend_uint var;
- zend_uint opline_num; /* Needs to be signed */
+ znode_op op;
+ zval constant; /* replaced by literal/zv */
zend_op_array *op_array;
- zend_op *jmp_addr;
- struct {
- zend_uint var; /* dummy */
- zend_uint type;
- } EA;
} u;
+ zend_uint EA; /* extended attributes */
} znode;
typedef struct _zend_execute_data zend_execute_data;
@@ -81,12 +105,15 @@
struct _zend_op {
opcode_handler_t handler;
- znode result;
- znode op1;
- znode op2;
+ znode_op op1;
+ znode_op op2;
+ znode_op result;
ulong extended_value;
uint lineno;
zend_uchar opcode;
+ zend_uchar op1_type;
+ zend_uchar op2_type;
+ zend_uchar result_type;
};
@@ -107,6 +134,11 @@
zend_uint catch_op; /* ketchup! */
} zend_try_catch_element;
+#if SIZEOF_LONG == 8
+#define THIS_HASHVAL 210728972157UL
+#else
+#define THIS_HASHVAL 275574653UL
+#endif
/* method flags (types) */
#define ZEND_ACC_STATIC 0x01
@@ -121,6 +153,7 @@
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS 0x20
#define ZEND_ACC_FINAL_CLASS 0x40
#define ZEND_ACC_INTERFACE 0x80
+#define ZEND_ACC_TRAIT 0x120
/* op_array flags */
#define ZEND_ACC_INTERACTIVE 0x10
@@ -151,21 +184,39 @@
/* class implement interface(s) flag */
#define ZEND_ACC_IMPLEMENT_INTERFACES 0x80000
+#define ZEND_ACC_IMPLEMENT_TRAITS 0x400000
+
+/* class constants updated */
+#define ZEND_ACC_CONSTANTS_UPDATED 0x100000
+
+/* user class has methods with static variables */
+#define ZEND_HAS_STATIC_IN_METHODS 0x800000
+
#define ZEND_ACC_CLOSURE 0x100000
/* function flag for internal user call handlers __call, __callstatic */
#define ZEND_ACC_CALL_VIA_HANDLER 0x200000
+/* disable inline caching */
+#define ZEND_ACC_NEVER_CACHE 0x400000
+
+#define ZEND_ACC_PASS_REST_BY_REFERENCE 0x1000000
+#define ZEND_ACC_PASS_REST_PREFER_REF 0x2000000
+
+#define ZEND_ACC_RETURN_REFERENCE 0x4000000
+#define ZEND_ACC_DONE_PASS_TWO 0x8000000
+
char *zend_visibility_string(zend_uint fn_flags);
typedef struct _zend_property_info {
zend_uint flags;
- char *name;
+ const char *name;
int name_length;
ulong h;
- char *doc_comment;
+ int offset;
+ const char *doc_comment;
int doc_comment_len;
zend_class_entry *ce;
} zend_property_info;
@@ -176,15 +227,27 @@
zend_uint name_len;
const char *class_name;
zend_uint class_name_len;
- zend_bool array_type_hint;
+ zend_uchar type_hint;
zend_bool allow_null;
zend_bool pass_by_reference;
- zend_bool return_reference;
- int required_num_args;
} zend_arg_info;
+/* the following structure repeats the layout of zend_arg_info,
+ * but its fields have different meaning. It's used as the first element of
+ * arg_info array to define properties of internal functions.
+ */
+typedef struct _zend_internal_function_info {
+ const char *_name;
+ zend_uint _name_len;
+ const char *_class_name;
+ zend_uint required_num_args;
+ zend_uchar _type_hint;
+ zend_bool return_reference;
+ zend_bool pass_rest_by_reference;
+} zend_internal_function_info;
+
typedef struct _zend_compiled_variable {
- char *name;
+ const char *name;
int name_len;
ulong hash_value;
} zend_compiled_variable;
@@ -192,32 +255,27 @@
struct _zend_op_array {
/* Common elements */
zend_uchar type;
- char *function_name;
+ const char *function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
- zend_bool pass_rest_by_reference;
- unsigned char return_reference;
/* END of common elements */
- zend_bool done_pass_two;
-
zend_uint *refcount;
zend_op *opcodes;
- zend_uint last, size;
+ zend_uint last;
zend_compiled_variable *vars;
- int last_var, size_var;
+ int last_var;
zend_uint T;
zend_brk_cont_element *brk_cont_array;
int last_brk_cont;
- int current_brk_cont;
zend_try_catch_element *try_catch_array;
int last_try_catch;
@@ -225,18 +283,21 @@
/* static variables support */
HashTable *static_variables;
- zend_op *start_op;
- int backpatch_count;
-
zend_uint this_var;
- char *filename;
+ const char *filename;
zend_uint line_start;
zend_uint line_end;
- char *doc_comment;
+ const char *doc_comment;
zend_uint doc_comment_len;
zend_uint early_binding; /* the linked list of delayed declarations */
+ zend_literal *literals;
+ int last_literal;
+
+ void **run_time_cache;
+ int last_cache_slot;
+
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
@@ -247,15 +308,13 @@
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
- char * function_name;
+ const char * function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
- zend_bool pass_rest_by_reference;
- unsigned char return_reference;
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
@@ -269,15 +328,13 @@
struct {
zend_uchar type; /* never used */
- char *function_name;
+ const char *function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
zend_uint num_args;
zend_uint required_num_args;
zend_arg_info *arg_info;
- zend_bool pass_rest_by_reference;
- unsigned char return_reference;
} common;
zend_op_array op_array;
@@ -324,7 +381,6 @@
zend_class_entry *current_called_scope;
zval *current_this;
zval *current_object;
- struct _zend_op *call_opline;
};
#define EX(element) execute_data.element
@@ -336,8 +392,7 @@
#define IS_UNUSED (1<<3) /* Unused variable */
#define IS_CV (1<<4) /* Compiled variable */
-#define EXT_TYPE_UNUSED (1<<0)
-#define EXT_TYPE_FREE_ON_RETURN (2<<0)
+#define EXT_TYPE_UNUSED (1<<5)
#include "zend_globals.h"
@@ -346,6 +401,7 @@
void init_compiler(TSRMLS_D);
void shutdown_compiler(TSRMLS_D);
void zend_init_compiler_data_structures(TSRMLS_D);
+void zend_init_compiler_context(TSRMLS_D);
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
@@ -361,8 +417,8 @@
ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D);
void zend_resolve_non_class_name(znode *element_name, zend_bool check_namespace TSRMLS_DC);
-void zend_resolve_class_name(znode *class_name, ulong *fetch_type, int check_ns_name TSRMLS_DC);
-ZEND_API char* zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var, int* name_len);
+void zend_resolve_class_name(znode *class_name, ulong fetch_type, int check_ns_name TSRMLS_DC);
+ZEND_API const char* zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var, int* name_len);
#ifdef ZTS
const char *zend_get_zendtext(TSRMLS_D);
@@ -374,7 +430,7 @@
void zend_do_binary_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
void zend_do_unary_op(zend_uchar op, znode *result, const znode *op1 TSRMLS_DC);
void zend_do_binary_assign_op(zend_uchar op, znode *result, const znode *op1, const znode *op2 TSRMLS_DC);
-void zend_do_assign(znode *result, znode *variable, const znode *value TSRMLS_DC);
+void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC);
void zend_do_assign_ref(znode *result, const znode *lvar, const znode *rvar TSRMLS_DC);
void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC);
void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar op TSRMLS_DC);
@@ -423,7 +479,7 @@
int zend_do_verify_access_types(const znode *current_access_type, const znode *new_modifier);
void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC);
void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC);
-void zend_do_receive_arg(zend_uchar op, const znode *var, const znode *offset, const znode *initialization, znode *class_type, const znode *varname, zend_bool pass_by_reference TSRMLS_DC);
+void zend_do_receive_arg(zend_uchar op, znode *varname, const znode *offset, const znode *initialization, znode *class_type, zend_bool pass_by_reference TSRMLS_DC);
int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace TSRMLS_DC);
void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC);
void zend_do_clone(znode *result, const znode *expr TSRMLS_DC);
@@ -435,21 +491,37 @@
void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
void zend_do_handle_exception(TSRMLS_D);
-void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference TSRMLS_DC);
+void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference, int is_static TSRMLS_DC);
void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC);
void zend_do_try(znode *try_token TSRMLS_DC);
-void zend_do_begin_catch(znode *try_token, znode *catch_class, const znode *catch_var, znode *first_catch TSRMLS_DC);
+void zend_do_begin_catch(znode *try_token, znode *catch_class, znode *catch_var, znode *first_catch TSRMLS_DC);
void zend_do_end_catch(const znode *try_token TSRMLS_DC);
void zend_do_throw(const znode *expr TSRMLS_DC);
-ZEND_API int do_bind_function(zend_op *opline, HashTable *function_table, zend_bool compile_time);
-ZEND_API zend_class_entry *do_bind_class(const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
-ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
+ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, HashTable *function_table, zend_bool compile_time);
+ZEND_API zend_class_entry *do_bind_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time TSRMLS_DC);
+ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time TSRMLS_DC);
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC);
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC);
void zend_do_implements_interface(znode *interface_znode TSRMLS_DC);
+/* Trait related functions */
+void zend_add_trait_precedence(znode *precedence_znode TSRMLS_DC);
+void zend_add_trait_alias(znode *alias_znode TSRMLS_DC);
+
+
+void zend_do_implements_trait(znode *interface_znode /*, znode* aliases */ TSRMLS_DC);
+ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC);
+ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC);
+void zend_prepare_trait_precedence(znode *result, znode *method_reference, znode *trait_list TSRMLS_DC);
+void zend_prepare_reference(znode *result, znode *class_name, znode *method_name TSRMLS_DC);
+void zend_prepare_trait_alias(znode *result, znode *method_reference, znode *modifiers, znode *alias TSRMLS_DC);
+
+void init_trait_alias_list(znode* result, const znode* trait_alias TSRMLS_DC);
+void add_trait_alias(znode* result, const znode* trait_alias TSRMLS_DC);
+void init_trait_alias(znode* result, const znode* method_name, const znode* alias, const znode* modifiers TSRMLS_DC);
+
ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC);
void zend_do_early_binding(TSRMLS_D);
ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC);
@@ -473,7 +545,6 @@
void zend_do_begin_class_declaration(const znode *class_token, znode *class_name, const znode *parent_class_name TSRMLS_DC);
void zend_do_end_class_declaration(const znode *class_token, const znode *parent_token TSRMLS_DC);
void zend_do_declare_property(const znode *var_name, const znode *value, zend_uint access_type TSRMLS_DC);
-void zend_do_declare_implicit_property(TSRMLS_D);
void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_DC);
void zend_do_fetch_property(znode *result, znode *object, const znode *property TSRMLS_DC);
@@ -500,6 +571,11 @@
void zend_do_new_list_begin(TSRMLS_D);
void zend_do_new_list_end(TSRMLS_D);
+/* Functions for a null terminated pointer list, used for traits parsing and compilation */
+void zend_init_list(void *result, void *item TSRMLS_DC);
+void zend_add_to_list(void *result, void *item TSRMLS_DC);
+
+
void zend_do_cast(znode *result, const znode *expr, int type TSRMLS_DC);
void zend_do_include_or_eval(int type, znode *result, const znode *op1 TSRMLS_DC);
@@ -552,6 +628,7 @@
ZEND_API void function_add_ref(zend_function *function);
#define INITIAL_OP_ARRAY_SIZE 64
+#define INITIAL_INTERACTIVE_OP_ARRAY_SIZE 8192
/* helper functions in zend_language_scanner.l */
@@ -564,6 +641,9 @@
ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC);
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC);
+ZEND_API int zend_cleanup_user_class_data(zend_class_entry **pce TSRMLS_DC);
+ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC);
+ZEND_API void zend_cleanup_internal_classes(TSRMLS_D);
ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
@@ -573,7 +653,7 @@
void zend_class_add_ref(zend_class_entry **ce);
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, const char *src1, int src1_length, const char *src2, int src2_length, int internal);
-ZEND_API int zend_unmangle_property_name(char *mangled_property, int mangled_property_len, char **prop_name, char **class_name);
+ZEND_API int zend_unmangle_property_name(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name);
#define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
@@ -593,22 +673,25 @@
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
int zend_get_class_fetch_type(const char *class_name, uint class_name_len);
-typedef zend_bool (*zend_auto_global_callback)(char *name, uint name_len TSRMLS_DC);
+typedef zend_bool (*zend_auto_global_callback)(const char *name, uint name_len TSRMLS_DC);
typedef struct _zend_auto_global {
- char *name;
+ const char *name;
uint name_len;
zend_auto_global_callback auto_global_callback;
+ zend_bool jit;
zend_bool armed;
} zend_auto_global;
-void zend_auto_global_dtor(zend_auto_global *auto_global);
-ZEND_API int zend_register_auto_global(const char *name, uint name_len, zend_auto_global_callback auto_global_callback TSRMLS_DC);
+ZEND_API int zend_register_auto_global(const char *name, uint name_len, zend_bool jit, zend_auto_global_callback auto_global_callback TSRMLS_DC);
+ZEND_API void zend_activate_auto_globals(TSRMLS_D);
ZEND_API zend_bool zend_is_auto_global(const char *name, uint name_len TSRMLS_DC);
-ZEND_API int zend_auto_global_disable_jit(const char *varname, zend_uint varname_length TSRMLS_DC);
+ZEND_API zend_bool zend_is_auto_global_quick(const char *name, uint name_len, ulong hashval TSRMLS_DC);
ZEND_API size_t zend_dirname(char *path, size_t len);
int zendlex(znode *zendlval TSRMLS_DC);
+int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC);
+
/* BEGIN: OPCODES */
#include "zend_vm_opcodes.h"
@@ -617,18 +700,6 @@
/* END: OPCODES */
-
-
-
-/* global/local fetches */
-#define ZEND_FETCH_GLOBAL 0
-#define ZEND_FETCH_LOCAL 1
-#define ZEND_FETCH_STATIC 2
-#define ZEND_FETCH_STATIC_MEMBER 3
-#define ZEND_FETCH_GLOBAL_LOCK 4
-#define ZEND_FETCH_LEXICAL 5
-
-
/* class fetches */
#define ZEND_FETCH_CLASS_DEFAULT 0
#define ZEND_FETCH_CLASS_SELF 1
@@ -638,6 +709,7 @@
#define ZEND_FETCH_CLASS_AUTO 5
#define ZEND_FETCH_CLASS_INTERFACE 6
#define ZEND_FETCH_CLASS_STATIC 7
+#define ZEND_FETCH_CLASS_TRAIT 14
#define ZEND_FETCH_CLASS_MASK 0x0f
#define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80
#define ZEND_FETCH_CLASS_SILENT 0x0100
@@ -680,23 +752,36 @@
#define ZEND_REQUIRE (1<<3)
#define ZEND_REQUIRE_ONCE (1<<4)
-#define ZEND_ISSET (1<<0)
-#define ZEND_ISEMPTY (1<<1)
-#define ZEND_ISSET_ISEMPTY_MASK (ZEND_ISSET | ZEND_ISEMPTY)
-#define ZEND_QUICK_SET (1<<2)
-
#define ZEND_CT (1<<0)
#define ZEND_RT (1<<1)
-#define ZEND_FETCH_STANDARD 0x00000000
-#define ZEND_FETCH_ADD_LOCK 0x08000000
-#define ZEND_FETCH_MAKE_REF 0x04000000
+/* global/local fetches */
+#define ZEND_FETCH_GLOBAL 0x00000000
+#define ZEND_FETCH_LOCAL 0x10000000
+#define ZEND_FETCH_STATIC 0x20000000
+#define ZEND_FETCH_STATIC_MEMBER 0x30000000
+#define ZEND_FETCH_GLOBAL_LOCK 0x40000000
+#define ZEND_FETCH_LEXICAL 0x50000000
+
+#define ZEND_FETCH_TYPE_MASK 0x70000000
+
+#define ZEND_FETCH_STANDARD 0x00000000
+#define ZEND_FETCH_ADD_LOCK 0x08000000
+#define ZEND_FETCH_MAKE_REF 0x04000000
+
+#define ZEND_ISSET 0x02000000
+#define ZEND_ISEMPTY 0x01000000
+#define ZEND_ISSET_ISEMPTY_MASK (ZEND_ISSET | ZEND_ISEMPTY)
+#define ZEND_QUICK_SET 0x00800000
+
+#define ZEND_FETCH_ARG_MASK 0x000fffff
#define ZEND_FE_FETCH_BYREF 1
#define ZEND_FE_FETCH_WITH_KEY 2
-#define ZEND_FE_RESET_VARIABLE 1
-#define ZEND_FE_RESET_REFERENCE 2
+#define ZEND_FE_RESET_VARIABLE (1<<0)
+#define ZEND_FE_RESET_REFERENCE (1<<1)
+#define EXT_TYPE_FREE_ON_RETURN (1<<2)
#define ZEND_MEMBER_FUNC_CALL 1<<0
@@ -709,22 +794,21 @@
#define ZEND_SEND_BY_REF 1
#define ZEND_SEND_PREFER_REF 2
-#define ARG_SEND_TYPE(zf, arg_num) \
- ((zf) ? \
- ((((zend_function*)(zf))->common.arg_info && \
- arg_num<=((zend_function*)(zf))->common.num_args) ? \
- ((zend_function *)(zf))->common.arg_info[arg_num-1].pass_by_reference : \
- ((zend_function *)(zf))->common.pass_rest_by_reference) : \
- ZEND_SEND_BY_VAL)
+#define CHECK_ARG_SEND_TYPE(zf, arg_num, m1, m2) \
+ ((zf) && \
+ ((((zend_function*)(zf))->common.arg_info && \
+ arg_num <= ((zend_function*)(zf))->common.num_args) ? \
+ (((zend_function *)(zf))->common.arg_info[arg_num-1].pass_by_reference & (m1)) : \
+ (((zend_function *)(zf))->common.fn_flags & (m2))))
#define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
- (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_BY_REF)
+ CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_BY_REF, ZEND_ACC_PASS_REST_BY_REFERENCE)
#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
- (ARG_SEND_TYPE(zf, arg_num) & (ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF))
+ CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF, ZEND_ACC_PASS_REST_BY_REFERENCE|ZEND_ACC_PASS_REST_PREFER_REF)
#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
- (ARG_SEND_TYPE(zf, arg_num) == ZEND_SEND_PREFER_REF)
+ CHECK_ARG_SEND_TYPE(zf, arg_num, ZEND_SEND_PREFER_REF, ZEND_ACC_PASS_REST_PREFER_REF)
#define ZEND_RETURN_VAL 0
#define ZEND_RETURN_REF 1
diff -ur php-5.3.8/Zend/zend_constants.h php-5.4.0RC2/Zend/zend_constants.h
--- php-5.3.8/Zend/zend_constants.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_constants.h 2011-12-13 14:10:09.000000000 +0900
@@ -69,6 +69,7 @@
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC);
void zend_copy_constants(HashTable *target, HashTable *sourc);
void copy_zend_constant(zend_constant *c);
+zend_constant *zend_quick_get_constant(const zend_literal *key, ulong flags TSRMLS_DC);
END_EXTERN_C()
#define ZEND_CONSTANT_DTOR (void (*)(void *)) free_zend_constant
Only in php-5.4.0RC2/Zend: zend_dtrace.h
diff -ur php-5.3.8/Zend/zend_errors.h php-5.4.0RC2/Zend/zend_errors.h
--- php-5.3.8/Zend/zend_errors.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_errors.h 2011-12-13 14:10:09.000000000 +0900
@@ -38,7 +38,7 @@
#define E_DEPRECATED (1<<13L)
#define E_USER_DEPRECATED (1<<14L)
-#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED)
+#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
#endif /* ZEND_ERRORS_H */
diff -ur php-5.3.8/Zend/zend_execute.h php-5.4.0RC2/Zend/zend_execute.h
--- php-5.3.8/Zend/zend_execute.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_execute.h 2011-12-13 14:10:09.000000000 +0900
@@ -35,16 +35,13 @@
zend_bool fcall_returned_reference;
} var;
struct {
- zval **ptr_ptr;
- zval *ptr;
- zend_bool fcall_returned_reference;
+ zval **ptr_ptr; /* shared with var.ptr_ptr */
zval *str;
zend_uint offset;
} str_offset;
struct {
- zval **ptr_ptr;
- zval *ptr;
- zend_bool fcall_returned_reference;
+ zval **ptr_ptr; /* shared with var.ptr_ptr */
+ zval *ptr; /* shared with var.ptr */
HashPointer fe_pos;
} fe;
zend_class_entry *class_entry;
@@ -62,7 +59,7 @@
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
ZEND_API int zend_is_true(zval *op);
#define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
-static inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+static zend_always_inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
TSRMLS_FETCH();
@@ -71,13 +68,37 @@
}
}
ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
-ZEND_API int zend_lookup_class_ex(const char *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
+ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
-static inline int i_zend_is_true(zval *op)
+ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, const char **class_name, zend_class_entry **pce TSRMLS_DC);
+ZEND_API int zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind TSRMLS_DC);
+
+static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
+{
+ if (!Z_DELREF_P(zval_ptr)) {
+ TSRMLS_FETCH();
+
+ if (zval_ptr != &EG(uninitialized_zval)) {
+ GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
+ zval_dtor(zval_ptr);
+ efree_rel(zval_ptr);
+ }
+ } else {
+ TSRMLS_FETCH();
+
+ if (Z_REFCOUNT_P(zval_ptr) == 1) {
+ Z_UNSET_ISREF_P(zval_ptr);
+ }
+
+ GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
+ }
+}
+
+static zend_always_inline int i_zend_is_true(zval *op)
{
int result;
@@ -140,7 +161,7 @@
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC);
/* dedicated Zend executor functions - do not use! */
-#define ZEND_VM_STACK_PAGE_SIZE ((64 * 1024) - 64)
+#define ZEND_VM_STACK_PAGE_SIZE ((16 * 1024) - 16)
struct _zend_vm_stack {
void **top;
@@ -159,7 +180,7 @@
} \
} while (0)
-static inline zend_vm_stack zend_vm_stack_new_page(int count) {
+static zend_always_inline zend_vm_stack zend_vm_stack_new_page(int count) {
zend_vm_stack page = (zend_vm_stack)emalloc(ZEND_MM_ALIGNED_SIZE(sizeof(*page)) + sizeof(void*) * count);
page->top = ZEND_VM_STACK_ELEMETS(page);
@@ -168,12 +189,12 @@
return page;
}
-static inline void zend_vm_stack_init(TSRMLS_D)
+static zend_always_inline void zend_vm_stack_init(TSRMLS_D)
{
EG(argument_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE);
}
-static inline void zend_vm_stack_destroy(TSRMLS_D)
+static zend_always_inline void zend_vm_stack_destroy(TSRMLS_D)
{
zend_vm_stack stack = EG(argument_stack);
@@ -184,30 +205,30 @@
}
}
-static inline void zend_vm_stack_extend(int count TSRMLS_DC)
+static zend_always_inline void zend_vm_stack_extend(int count TSRMLS_DC)
{
zend_vm_stack p = zend_vm_stack_new_page(count >= ZEND_VM_STACK_PAGE_SIZE ? count : ZEND_VM_STACK_PAGE_SIZE);
p->prev = EG(argument_stack);
EG(argument_stack) = p;
}
-static inline void **zend_vm_stack_top(TSRMLS_D)
+static zend_always_inline void **zend_vm_stack_top(TSRMLS_D)
{
return EG(argument_stack)->top;
}
-static inline void zend_vm_stack_push(void *ptr TSRMLS_DC)
+static zend_always_inline void zend_vm_stack_push(void *ptr TSRMLS_DC)
{
ZEND_VM_STACK_GROW_IF_NEEDED(1);
*(EG(argument_stack)->top++) = ptr;
}
-static inline void zend_vm_stack_push_nocheck(void *ptr TSRMLS_DC)
+static zend_always_inline void zend_vm_stack_push_nocheck(void *ptr TSRMLS_DC)
{
*(EG(argument_stack)->top++) = ptr;
}
-static inline void *zend_vm_stack_pop(TSRMLS_D)
+static zend_always_inline void *zend_vm_stack_pop(TSRMLS_D)
{
void *el = *(--EG(argument_stack)->top);
@@ -219,7 +240,7 @@
return el;
}
-static inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC)
+static zend_always_inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC)
{
void *ret;
@@ -248,7 +269,7 @@
return ret;
}
-static inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC)
+static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC)
{
if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) {
zend_vm_stack p = EG(argument_stack);
@@ -260,7 +281,7 @@
}
}
-static inline void zend_vm_stack_free(void *ptr TSRMLS_DC)
+static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC)
{
if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) {
zend_vm_stack p = EG(argument_stack);
@@ -278,7 +299,7 @@
}
}
-static inline void** zend_vm_stack_push_args(int count TSRMLS_DC)
+static zend_always_inline void** zend_vm_stack_push_args(int count TSRMLS_DC)
{
if (UNEXPECTED(EG(argument_stack)->top - ZEND_VM_STACK_ELEMETS(EG(argument_stack)) < count) ||
@@ -307,7 +328,7 @@
return EG(argument_stack)->top++;
}
-static inline void zend_vm_stack_clear_multiple(TSRMLS_D)
+static zend_always_inline void zend_vm_stack_clear_multiple(TSRMLS_D)
{
void **p = EG(argument_stack)->top - 1;
int delete_count = (int)(zend_uintptr_t) *p;
@@ -315,12 +336,12 @@
while (--delete_count>=0) {
zval *q = *(zval **)(--p);
*p = NULL;
- zval_ptr_dtor(&q);
+ i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
}
zend_vm_stack_free_int(p TSRMLS_CC);
}
-static inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC)
+static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC)
{
void **p = EG(current_execute_data)->prev_execute_data->function_state.arguments;
int arg_count = (int)(zend_uintptr_t) *p;
@@ -331,7 +352,7 @@
return (zval**)p - arg_count + requested_arg - 1;
}
-static inline void zend_arg_types_stack_2_pop(zend_ptr_stack *stack, zval **object, zend_function **fbc)
+static zend_always_inline void zend_arg_types_stack_2_pop(zend_ptr_stack *stack, zval **object, zend_function **fbc)
{
void *a, *b;
@@ -341,7 +362,7 @@
*fbc = (zend_function *) b;
}
-static inline void zend_arg_types_stack_3_pop(zend_ptr_stack *stack, zend_class_entry **called_scope, zval **object, zend_function **fbc)
+static zend_always_inline void zend_arg_types_stack_3_pop(zend_ptr_stack *stack, zend_class_entry **called_scope, zval **object, zend_function **fbc)
{
void *a, *b, *c;
@@ -356,9 +377,9 @@
/* services */
-ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
-ZEND_API char *get_active_function_name(TSRMLS_D);
-ZEND_API char *zend_get_executed_filename(TSRMLS_D);
+ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC);
+ZEND_API const char *get_active_function_name(TSRMLS_D);
+ZEND_API const char *zend_get_executed_filename(TSRMLS_D);
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
@@ -366,6 +387,7 @@
ZEND_API void zend_unset_timeout(TSRMLS_D);
ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(const char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
+ZEND_API zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC);
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
#ifdef ZEND_WIN32
@@ -404,11 +426,28 @@
/* int is_var; */
} zend_free_op;
-ZEND_API zval *zend_get_zval_ptr(znode *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
-ZEND_API zval **zend_get_zval_ptr_ptr(const znode *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
+ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
+ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
+#define CACHED_PTR(num) \
+ EG(active_op_array)->run_time_cache[(num)]
+
+#define CACHE_PTR(num, ptr) do { \
+ EG(active_op_array)->run_time_cache[(num)] = (ptr); \
+ } while (0)
+
+#define CACHED_POLYMORPHIC_PTR(num, ce) \
+ ((EG(active_op_array)->run_time_cache[(num)] == (ce)) ? \
+ EG(active_op_array)->run_time_cache[(num) + 1] : \
+ NULL)
+
+#define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
+ EG(active_op_array)->run_time_cache[(num)] = (ce); \
+ EG(active_op_array)->run_time_cache[(num) + 1] = (ptr); \
+ } while (0)
+
END_EXTERN_C()
#endif /* ZEND_EXECUTE_H */
diff -ur php-5.3.8/Zend/zend_extensions.h php-5.4.0RC2/Zend/zend_extensions.h
--- php-5.3.8/Zend/zend_extensions.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_extensions.h 2011-12-13 14:10:09.000000000 +0900
@@ -28,7 +28,7 @@
/* The first number is the engine version and the rest is the date.
* This way engine 2/3 API no. is always greater than engine 1 API no..
*/
-#define ZEND_EXTENSION_API_NO 220090626
+#define ZEND_EXTENSION_API_NO 220100525
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
Only in php-5.3.8/Zend: zend_fast_cache.h
diff -ur php-5.3.8/Zend/zend_gc.h php-5.4.0RC2/Zend/zend_gc.h
--- php-5.3.8/Zend/zend_gc.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_gc.h 2011-12-13 14:10:09.000000000 +0900
@@ -84,7 +84,7 @@
zend_object_handle handle; /* must be 0 for zval */
union {
zval *pz;
- zend_object_handlers *handlers;
+ const zend_object_handlers *handlers;
} u;
} gc_root_buffer;
diff -ur php-5.3.8/Zend/zend_globals.h php-5.4.0RC2/Zend/zend_globals.h
--- php-5.3.8/Zend/zend_globals.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_globals.h 2011-12-13 14:10:09.000000000 +0900
@@ -34,10 +34,8 @@
#include "zend_objects.h"
#include "zend_objects_API.h"
#include "zend_modules.h"
-
-#ifdef ZEND_MULTIBYTE
+#include "zend_float.h"
#include "zend_multibyte.h"
-#endif /* ZEND_MULTIBYTE */
/* Define ZTS if you want a thread-safe Zend */
/*#undef ZTS*/
@@ -68,6 +66,8 @@
} zend_declarables;
typedef struct _zend_vm_stack *zend_vm_stack;
+typedef struct _zend_ini_entry zend_ini_entry;
+
struct _zend_compiler_globals {
zend_stack bp_stack;
@@ -101,10 +101,10 @@
HashTable *auto_globals;
+ zend_bool parse_error;
zend_bool in_compilation;
zend_bool short_tags;
zend_bool asp_tags;
- zend_bool allow_call_time_pass_reference;
zend_declarables declarables;
@@ -137,25 +137,25 @@
zend_bool in_namespace;
zend_bool has_bracketed_namespaces;
- HashTable *labels;
- zend_stack labels_stack;
+ zend_compiler_context context;
+ zend_stack context_stack;
+
+ /* interned strings */
+ char *interned_strings_start;
+ char *interned_strings_end;
+ char *interned_strings_top;
+ char *interned_strings_snapshot_top;
+
+ HashTable interned_strings;
-#ifdef ZEND_MULTIBYTE
- zend_encoding **script_encoding_list;
+ const zend_encoding **script_encoding_list;
size_t script_encoding_list_size;
+ zend_bool multibyte;
zend_bool detect_unicode;
zend_bool encoding_declared;
- zend_encoding *internal_encoding;
-
- /* multibyte utility functions */
- zend_encoding_detector encoding_detector;
- zend_encoding_converter encoding_converter;
- zend_encoding_oddlen encoding_oddlen;
-#endif /* ZEND_MULTIBYTE */
-
#ifdef ZTS
- HashTable **static_members;
+ zval ***static_members_table;
int last_static_member;
#endif
};
@@ -240,6 +240,7 @@
HashTable *ini_directives;
HashTable *modified_ini_directives;
+ zend_ini_entry *error_reporting_ini_entry;
zend_objects_store objects_store;
zval *exception, *prev_exception;
@@ -254,7 +255,12 @@
zend_bool active;
- void *saved_fpu_cw;
+ zend_op *start_op;
+
+ void *saved_fpu_cw_ptr;
+#if XPFPA_HAVE_CW
+ XPFPA_CW_DATATYPE saved_fpu_cw;
+#endif
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
@@ -292,7 +298,6 @@
int yy_state;
zend_stack state_stack;
-#ifdef ZEND_MULTIBYTE
/* original (unfiltered) script */
unsigned char *script_org;
size_t script_org_size;
@@ -304,9 +309,7 @@
/* input/ouput filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
- zend_encoding *script_encoding;
- zend_encoding *internal_encoding;
-#endif /* ZEND_MULTIBYTE */
+ const zend_encoding *script_encoding;
};
#endif /* ZEND_GLOBALS_H */
diff -ur php-5.3.8/Zend/zend_hash.h php-5.4.0RC2/Zend/zend_hash.h
--- php-5.3.8/Zend/zend_hash.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_hash.h 2011-12-13 14:10:09.000000000 +0900
@@ -60,7 +60,7 @@
struct bucket *pListLast;
struct bucket *pNext;
struct bucket *pLast;
- char arKey[1]; /* Must be last element */
+ const char *arKey;
} Bucket;
typedef struct _hashtable {
@@ -83,7 +83,7 @@
typedef struct _zend_hash_key {
- char *arKey;
+ const char *arKey;
uint nKeyLength;
ulong h;
} zend_hash_key;
@@ -304,7 +304,7 @@
#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \
zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
-#define ZEND_HANDLE_NUMERIC(key, length, func) do { \
+#define ZEND_HANDLE_NUMERIC_EX(key, length, idx, func) do { \
register const char *tmp = key; \
\
if (*tmp == '-') { \
@@ -312,7 +312,6 @@
} \
if (*tmp >= '0' && *tmp <= '9') { /* possibly a numeric index */ \
const char *end = key + length - 1; \
- ulong idx; \
\
if ((*end != '\0') /* not a null terminated string */ \
|| (*tmp == '0' && length > 2) /* numbers with leading zeros */ \
@@ -335,11 +334,17 @@
} else if (idx > LONG_MAX) { /* overflow */ \
break; \
} \
- return func; \
+ func; \
} \
} \
} while (0)
+#define ZEND_HANDLE_NUMERIC(key, length, func) do { \
+ ulong idx; \
+ \
+ ZEND_HANDLE_NUMERIC_EX(key, length, idx, return func); \
+} while (0)
+
static inline int zend_symtable_update(HashTable *ht, const char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest) \
{
ZEND_HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
diff -ur php-5.3.8/Zend/zend_highlight.h php-5.4.0RC2/Zend/zend_highlight.h
--- php-5.3.8/Zend/zend_highlight.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_highlight.h 2011-12-13 14:10:09.000000000 +0900
@@ -26,7 +26,6 @@
#define HL_DEFAULT_COLOR "#0000BB" /* blue */
#define HL_HTML_COLOR "#000000" /* black */
#define HL_STRING_COLOR "#DD0000" /* red */
-#define HL_BG_COLOR "#FFFFFF" /* white */
#define HL_KEYWORD_COLOR "#007700" /* green */
diff -ur php-5.3.8/Zend/zend_ini.h php-5.4.0RC2/Zend/zend_ini.h
--- php-5.3.8/Zend/zend_ini.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_ini.h 2011-12-13 14:10:09.000000000 +0900
@@ -57,8 +57,6 @@
#endif
-typedef struct _zend_ini_entry zend_ini_entry;
-
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage TSRMLS_DC)
#define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
diff -ur php-5.3.8/Zend/zend_ini_parser.h php-5.4.0RC2/Zend/zend_ini_parser.h
--- php-5.3.8/Zend/zend_ini_parser.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_ini_parser.h 2011-12-13 14:10:09.000000000 +0900
@@ -1,10 +1,8 @@
+/* A Bison parser, made by GNU Bison 2.5. */
-/* A Bison parser, made by GNU Bison 2.4.1. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
+/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff -ur php-5.3.8/Zend/zend_ini_scanner_defs.h php-5.4.0RC2/Zend/zend_ini_scanner_defs.h
--- php-5.3.8/Zend/zend_ini_scanner_defs.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_ini_scanner_defs.h 2011-12-13 14:10:09.000000000 +0900
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Aug 1 12:07:43 2010 */
+/* Generated by re2c 0.13.5 on Wed Jun 29 02:53:12 2011 */
#line 3 "Zend/zend_ini_scanner_defs.h"
enum YYCONDTYPE {
diff -ur php-5.3.8/Zend/zend_interfaces.h php-5.4.0RC2/Zend/zend_interfaces.h
--- php-5.3.8/Zend/zend_interfaces.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_interfaces.h 2011-12-13 14:10:09.000000000 +0900
@@ -38,7 +38,7 @@
zval *value;
} zend_user_iterator;
-ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC);
+ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC);
#define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \
zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC)
diff -ur php-5.3.8/Zend/zend_language_parser.h php-5.4.0RC2/Zend/zend_language_parser.h
--- php-5.3.8/Zend/zend_language_parser.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_language_parser.h 2011-12-13 14:10:09.000000000 +0900
@@ -1,10 +1,8 @@
+/* A Bison parser, made by GNU Bison 2.5. */
-/* A Bison parser, made by GNU Bison 2.4.1. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
+/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,6 +37,7 @@
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
+ END = 0,
T_REQUIRE_ONCE = 258,
T_REQUIRE = 259,
T_EVAL = 260,
@@ -122,49 +121,54 @@
T_CATCH = 338,
T_THROW = 339,
T_USE = 340,
- T_GLOBAL = 341,
- T_PUBLIC = 342,
- T_PROTECTED = 343,
- T_PRIVATE = 344,
- T_FINAL = 345,
- T_ABSTRACT = 346,
- T_STATIC = 347,
- T_VAR = 348,
- T_UNSET = 349,
- T_ISSET = 350,
- T_EMPTY = 351,
- T_HALT_COMPILER = 352,
- T_CLASS = 353,
- T_INTERFACE = 354,
- T_EXTENDS = 355,
- T_IMPLEMENTS = 356,
- T_OBJECT_OPERATOR = 357,
- T_DOUBLE_ARROW = 358,
- T_LIST = 359,
- T_ARRAY = 360,
- T_CLASS_C = 361,
- T_METHOD_C = 362,
- T_FUNC_C = 363,
- T_LINE = 364,
- T_FILE = 365,
- T_COMMENT = 366,
- T_DOC_COMMENT = 367,
- T_OPEN_TAG = 368,
- T_OPEN_TAG_WITH_ECHO = 369,
- T_CLOSE_TAG = 370,
- T_WHITESPACE = 371,
- T_START_HEREDOC = 372,
- T_END_HEREDOC = 373,
- T_DOLLAR_OPEN_CURLY_BRACES = 374,
- T_CURLY_OPEN = 375,
- T_PAAMAYIM_NEKUDOTAYIM = 376,
- T_NAMESPACE = 377,
- T_NS_C = 378,
- T_DIR = 379,
- T_NS_SEPARATOR = 380
+ T_INSTEADOF = 341,
+ T_GLOBAL = 342,
+ T_PUBLIC = 343,
+ T_PROTECTED = 344,
+ T_PRIVATE = 345,
+ T_FINAL = 346,
+ T_ABSTRACT = 347,
+ T_STATIC = 348,
+ T_VAR = 349,
+ T_UNSET = 350,
+ T_ISSET = 351,
+ T_EMPTY = 352,
+ T_HALT_COMPILER = 353,
+ T_CLASS = 354,
+ T_TRAIT = 355,
+ T_INTERFACE = 356,
+ T_EXTENDS = 357,
+ T_IMPLEMENTS = 358,
+ T_OBJECT_OPERATOR = 359,
+ T_DOUBLE_ARROW = 360,
+ T_LIST = 361,
+ T_ARRAY = 362,
+ T_CALLABLE = 363,
+ T_CLASS_C = 364,
+ T_TRAIT_C = 365,
+ T_METHOD_C = 366,
+ T_FUNC_C = 367,
+ T_LINE = 368,
+ T_FILE = 369,
+ T_COMMENT = 370,
+ T_DOC_COMMENT = 371,
+ T_OPEN_TAG = 372,
+ T_OPEN_TAG_WITH_ECHO = 373,
+ T_CLOSE_TAG = 374,
+ T_WHITESPACE = 375,
+ T_START_HEREDOC = 376,
+ T_END_HEREDOC = 377,
+ T_DOLLAR_OPEN_CURLY_BRACES = 378,
+ T_CURLY_OPEN = 379,
+ T_PAAMAYIM_NEKUDOTAYIM = 380,
+ T_NAMESPACE = 381,
+ T_NS_C = 382,
+ T_DIR = 383,
+ T_NS_SEPARATOR = 384
};
#endif
/* Tokens. */
+#define END 0
#define T_REQUIRE_ONCE 258
#define T_REQUIRE 259
#define T_EVAL 260
@@ -248,46 +252,50 @@
#define T_CATCH 338
#define T_THROW 339
#define T_USE 340
-#define T_GLOBAL 341
-#define T_PUBLIC 342
-#define T_PROTECTED 343
-#define T_PRIVATE 344
-#define T_FINAL 345
-#define T_ABSTRACT 346
-#define T_STATIC 347
-#define T_VAR 348
-#define T_UNSET 349
-#define T_ISSET 350
-#define T_EMPTY 351
-#define T_HALT_COMPILER 352
-#define T_CLASS 353
-#define T_INTERFACE 354
-#define T_EXTENDS 355
-#define T_IMPLEMENTS 356
-#define T_OBJECT_OPERATOR 357
-#define T_DOUBLE_ARROW 358
-#define T_LIST 359
-#define T_ARRAY 360
-#define T_CLASS_C 361
-#define T_METHOD_C 362
-#define T_FUNC_C 363
-#define T_LINE 364
-#define T_FILE 365
-#define T_COMMENT 366
-#define T_DOC_COMMENT 367
-#define T_OPEN_TAG 368
-#define T_OPEN_TAG_WITH_ECHO 369
-#define T_CLOSE_TAG 370
-#define T_WHITESPACE 371
-#define T_START_HEREDOC 372
-#define T_END_HEREDOC 373
-#define T_DOLLAR_OPEN_CURLY_BRACES 374
-#define T_CURLY_OPEN 375
-#define T_PAAMAYIM_NEKUDOTAYIM 376
-#define T_NAMESPACE 377
-#define T_NS_C 378
-#define T_DIR 379
-#define T_NS_SEPARATOR 380
+#define T_INSTEADOF 341
+#define T_GLOBAL 342
+#define T_PUBLIC 343
+#define T_PROTECTED 344
+#define T_PRIVATE 345
+#define T_FINAL 346
+#define T_ABSTRACT 347
+#define T_STATIC 348
+#define T_VAR 349
+#define T_UNSET 350
+#define T_ISSET 351
+#define T_EMPTY 352
+#define T_HALT_COMPILER 353
+#define T_CLASS 354
+#define T_TRAIT 355
+#define T_INTERFACE 356
+#define T_EXTENDS 357
+#define T_IMPLEMENTS 358
+#define T_OBJECT_OPERATOR 359
+#define T_DOUBLE_ARROW 360
+#define T_LIST 361
+#define T_ARRAY 362
+#define T_CALLABLE 363
+#define T_CLASS_C 364
+#define T_TRAIT_C 365
+#define T_METHOD_C 366
+#define T_FUNC_C 367
+#define T_LINE 368
+#define T_FILE 369
+#define T_COMMENT 370
+#define T_DOC_COMMENT 371
+#define T_OPEN_TAG 372
+#define T_OPEN_TAG_WITH_ECHO 373
+#define T_CLOSE_TAG 374
+#define T_WHITESPACE 375
+#define T_START_HEREDOC 376
+#define T_END_HEREDOC 377
+#define T_DOLLAR_OPEN_CURLY_BRACES 378
+#define T_CURLY_OPEN 379
+#define T_PAAMAYIM_NEKUDOTAYIM 380
+#define T_NAMESPACE 381
+#define T_NS_C 382
+#define T_DIR 383
+#define T_NS_SEPARATOR 384
diff -ur php-5.3.8/Zend/zend_language_scanner.h php-5.4.0RC2/Zend/zend_language_scanner.h
--- php-5.3.8/Zend/zend_language_scanner.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_language_scanner.h 2011-12-13 14:10:09.000000000 +0900
@@ -36,7 +36,6 @@
uint lineno;
char *filename;
-#ifdef ZEND_MULTIBYTE
/* original (unfiltered) script */
unsigned char *script_org;
size_t script_org_size;
@@ -48,9 +47,7 @@
/* input/ouput filters */
zend_encoding_filter input_filter;
zend_encoding_filter output_filter;
- zend_encoding *script_encoding;
- zend_encoding *internal_encoding;
-#endif /* ZEND_MULTIBYTE */
+ const zend_encoding *script_encoding;
} zend_lex_state;
@@ -59,6 +56,8 @@
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC);
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC);
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC);
+ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC);
+ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC);
END_EXTERN_C()
diff -ur php-5.3.8/Zend/zend_language_scanner_defs.h php-5.4.0RC2/Zend/zend_language_scanner_defs.h
--- php-5.3.8/Zend/zend_language_scanner_defs.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_language_scanner_defs.h 2011-12-13 14:10:09.000000000 +0900
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Jan 3 05:56:03 2011 */
+/* Generated by re2c 0.13.5 on Tue Sep 13 17:29:46 2011 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
diff -ur php-5.3.8/Zend/zend_list.h php-5.4.0RC2/Zend/zend_list.h
--- php-5.3.8/Zend/zend_list.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_list.h 2011-12-13 14:10:09.000000000 +0900
@@ -48,7 +48,7 @@
rsrc_dtor_func_t list_dtor_ex;
rsrc_dtor_func_t plist_dtor_ex;
- char *type_name;
+ const char *type_name;
int module_number;
int resource_id;
@@ -58,7 +58,7 @@
#define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
-ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
+ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number);
void list_entry_destructor(void *ptr);
void plist_entry_destructor(void *ptr);
@@ -70,7 +70,7 @@
int zend_init_rsrc_list_dtors(void);
void zend_destroy_rsrc_list_dtors(void);
-ZEND_API int zend_list_insert(void *ptr, int type);
+ZEND_API int zend_list_insert(void *ptr, int type TSRMLS_DC);
ZEND_API int _zend_list_addref(int id TSRMLS_DC);
ZEND_API int _zend_list_delete(int id TSRMLS_DC);
ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC);
@@ -79,10 +79,10 @@
#define zend_list_delete(id) _zend_list_delete(id TSRMLS_CC)
#define zend_list_find(id, type) _zend_list_find(id, type TSRMLS_CC)
-ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
-ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
+ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC);
+ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
-ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
+ZEND_API const char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
ZEND_API int zend_fetch_list_dtor_id(char *type_name);
extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
@@ -107,7 +107,7 @@
(rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2))
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) \
- zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
+ zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type TSRMLS_CC);
#define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
if (le_id == 0) { \
diff -ur php-5.3.8/Zend/zend_modules.h php-5.4.0RC2/Zend/zend_modules.h
--- php-5.3.8/Zend/zend_modules.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_modules.h 2011-12-13 14:10:09.000000000 +0900
@@ -33,7 +33,7 @@
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module TSRMLS_DC
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module TSRMLS_CC
-#define ZEND_MODULE_API_NO 20090626
+#define ZEND_MODULE_API_NO 20100525
#ifdef ZTS
#define USING_ZTS 1
#else
@@ -98,7 +98,7 @@
unsigned char type;
void *handle;
int module_number;
- char *build_id;
+ const char *build_id;
};
#define MODULE_DEP_REQUIRED 1
diff -ur php-5.3.8/Zend/zend_multibyte.h php-5.4.0RC2/Zend/zend_multibyte.h
--- php-5.3.8/Zend/zend_multibyte.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_multibyte.h 2011-12-13 14:10:09.000000000 +0900
@@ -22,52 +22,60 @@
#ifndef ZEND_MULTIBYTE_H
#define ZEND_MULTIBYTE_H
-#ifdef ZEND_MULTIBYTE
-
-#define BOM_UTF32_BE "\x00\x00\xfe\xff"
-#define BOM_UTF32_LE "\xff\xfe\x00\x00"
-#define BOM_UTF16_BE "\xfe\xff"
-#define BOM_UTF16_LE "\xff\xfe"
-#define BOM_UTF8 "\xef\xbb\xbf"
+typedef struct _zend_encoding zend_encoding;
typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length TSRMLS_DC);
-typedef char* (*zend_encoding_detector)(const unsigned char *string, size_t length, char *list TSRMLS_DC);
-
-typedef int (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const char *encoding_to, const char *encoding_from TSRMLS_DC);
-
-typedef size_t (*zend_encoding_oddlen)(const unsigned char *string, size_t length, const char *encoding TSRMLS_DC);
-
-typedef struct _zend_encoding {
- zend_encoding_filter input_filter; /* escape input filter */
- zend_encoding_filter output_filter; /* escape output filter */
- const char *name; /* encoding name */
- const char *(*aliases)[]; /* encoding name aliases */
- zend_bool compatible; /* flex compatible or not */
-} zend_encoding;
-
+typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name TSRMLS_DC);
+typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding);
+typedef int (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding);
+typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC);
+typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC);
+typedef int (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC);
+typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(TSRMLS_D);
+typedef int (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding TSRMLS_DC);
+
+typedef struct _zend_multibyte_functions {
+ const char *provider_name;
+ zend_encoding_fetcher encoding_fetcher;
+ zend_encoding_name_getter encoding_name_getter;
+ zend_encoding_lexer_compatibility_checker lexer_compatibility_checker;
+ zend_encoding_detector encoding_detector;
+ zend_encoding_converter encoding_converter;
+ zend_encoding_list_parser encoding_list_parser;
+ zend_encoding_internal_encoding_getter internal_encoding_getter;
+ zend_encoding_internal_encoding_setter internal_encoding_setter;
+} zend_multibyte_functions;
/*
* zend multibyte APIs
*/
BEGIN_EXTERN_C()
-ZEND_API int zend_multibyte_set_script_encoding(const char *encoding_list,
-size_t encoding_list_size TSRMLS_DC);
-ZEND_API int zend_multibyte_set_internal_encoding(const char *encoding_name TSRMLS_DC);
-ZEND_API int zend_multibyte_set_functions(zend_encoding_detector encoding_detector, zend_encoding_converter encoding_converter, zend_encoding_oddlen encoding_oddlen TSRMLS_DC);
-ZEND_API int zend_multibyte_set_filter(zend_encoding *onetime_encoding TSRMLS_DC);
-ZEND_API zend_encoding* zend_multibyte_fetch_encoding(const char *encoding_name);
-ZEND_API size_t zend_multibyte_script_encoding_filter(unsigned char **to, size_t
-*to_length, const unsigned char *from, size_t from_length TSRMLS_DC);
-ZEND_API size_t zend_multibyte_internal_encoding_filter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC);
-
-/* in zend_language_scanner.l */
-ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, zend_encoding *old_encoding TSRMLS_DC);
-ZEND_API int zend_multibyte_yyinput(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC);
-ZEND_API int zend_multibyte_read_script(unsigned char *buf, size_t n TSRMLS_DC);
-END_EXTERN_C()
-#endif /* ZEND_MULTIBYTE */
+ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32be;
+ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32le;
+ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16be;
+ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le;
+ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
+
+/* multibyte utility functions */
+ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions TSRMLS_DC);
+ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(TSRMLS_D);
+
+ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name TSRMLS_DC);
+ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
+ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
+ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size TSRMLS_DC);
+ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from TSRMLS_DC);
+ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC);
+
+ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(TSRMLS_D);
+ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(TSRMLS_D);
+ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC);
+ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding TSRMLS_DC);
+ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length TSRMLS_DC);
+
+END_EXTERN_C()
#endif /* ZEND_MULTIBYTE_H */
diff -ur php-5.3.8/Zend/zend_multiply.h php-5.4.0RC2/Zend/zend_multiply.h
--- php-5.3.8/Zend/zend_multiply.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_multiply.h 2011-12-13 14:10:09.000000000 +0900
@@ -31,6 +31,18 @@
else (lval) = __tmpvar; \
} while (0)
+#elif defined(__x86_64__) && defined(__GNUC__)
+
+#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
+ long __tmpvar; \
+ __asm__ ("imulq %3,%0\n" \
+ "adcq $0,%1" \
+ : "=r"(__tmpvar),"=r"(usedval) \
+ : "0"(a), "r"(b), "1"(0)); \
+ if (usedval) (dval) = (double) (a) * (double) (b); \
+ else (lval) = __tmpvar; \
+} while (0)
+
#elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
diff -ur php-5.3.8/Zend/zend_object_handlers.h php-5.4.0RC2/Zend/zend_object_handlers.h
--- php-5.3.8/Zend/zend_object_handlers.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_object_handlers.h 2011-12-13 14:10:09.000000000 +0900
@@ -24,13 +24,14 @@
union _zend_function;
struct _zend_property_info;
+struct _zend_literal;
/* The following rule applies to read_property() and read_dimension() implementations:
If you return a zval which is not otherwise referenced by the extension or the engine's
symbol table, its reference count should be 0.
*/
/* Used to fetch property from the object, read-only */
-typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type TSRMLS_DC);
+typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, const struct _zend_literal *key TSRMLS_DC);
/* Used to fetch dimension from the object, read-only */
typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type TSRMLS_DC);
@@ -42,14 +43,14 @@
any changes. You should NOT modify the reference count of the value passed to you.
*/
/* Used to set property of the object */
-typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value TSRMLS_DC);
+typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value, const struct _zend_literal *key TSRMLS_DC);
/* Used to set dimension of the object */
typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
/* Used to create pointer to the property of the object, for future direct r/w access */
-typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member TSRMLS_DC);
+typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, const struct _zend_literal *key TSRMLS_DC);
/* Used to set object value. Can be used to override assignments and scalar
write ops (like ++, +=) on the object */
@@ -66,13 +67,13 @@
* 1 (set) whether property exists and is true
* 2 (exists) whether property exists
*/
-typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists TSRMLS_DC);
+typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, const struct _zend_literal *key TSRMLS_DC);
/* Used to check if a dimension of the object exists */
typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
/* Used to remove a property of the object */
-typedef void (*zend_object_unset_property_t)(zval *object, zval *member TSRMLS_DC);
+typedef void (*zend_object_unset_property_t)(zval *object, zval *member, const struct _zend_literal *key TSRMLS_DC);
/* Used to remove a dimension of the object */
typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
@@ -86,8 +87,8 @@
/* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
*/
-typedef int (*zend_object_call_method_t)(char *method, INTERNAL_FUNCTION_PARAMETERS);
-typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len TSRMLS_DC);
+typedef int (*zend_object_call_method_t)(const char *method, INTERNAL_FUNCTION_PARAMETERS);
+typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len, const struct _zend_literal *key TSRMLS_DC);
typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC);
/* Object maintenance/destruction */
@@ -97,7 +98,7 @@
typedef zend_object_value (*zend_object_clone_obj_t)(zval *object TSRMLS_DC);
typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zval *object TSRMLS_DC);
-typedef int (*zend_object_get_class_name_t)(const zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
+typedef int (*zend_object_get_class_name_t)(const zval *object, const char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
/* Cast an object to some other type
@@ -110,6 +111,8 @@
typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC);
+typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval ***table, int *n TSRMLS_DC);
+
struct _zend_object_handlers {
/* general object functions */
zend_object_add_ref_t add_ref;
@@ -138,19 +141,22 @@
zend_object_count_elements_t count_elements;
zend_object_get_debug_info_t get_debug_info;
zend_object_get_closure_t get_closure;
+ zend_object_get_gc_t get_gc;
};
extern ZEND_API zend_object_handlers std_object_handlers;
BEGIN_EXTERN_C()
-ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
-ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC);
-ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_name, int property_name_len TSRMLS_DC);
+ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, const char *function_name_strval, int function_name_strlen, const struct _zend_literal *key TSRMLS_DC);
+ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, const char *property_name, int property_name_len, zend_bool silent, const struct _zend_literal *key TSRMLS_DC);
+ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, const char *property_name, int property_name_len, const struct _zend_literal *key TSRMLS_DC);
ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC);
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC);
ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC);
ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
+ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, const struct _zend_literal *key TSRMLS_DC);
+ZEND_API void rebuild_object_properties(zend_object *zobj);
#define IS_ZEND_STD_OBJECT(z) (Z_TYPE(z) == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
@@ -160,7 +166,7 @@
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
-ZEND_API int zend_check_property_access(zend_object *zobj, char *prop_info_name, int prop_info_name_len TSRMLS_DC);
+ZEND_API int zend_check_property_access(zend_object *zobj, const char *prop_info_name, int prop_info_name_len TSRMLS_DC);
ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS);
END_EXTERN_C()
diff -ur php-5.3.8/Zend/zend_objects_API.h php-5.4.0RC2/Zend/zend_objects_API.h
--- php-5.3.8/Zend/zend_objects_API.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_objects_API.h 2011-12-13 14:10:09.000000000 +0900
@@ -68,7 +68,7 @@
ZEND_API void zend_objects_store_del_ref(zval *object TSRMLS_DC);
ZEND_API void zend_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC);
ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle, const zend_object_handlers *handlers TSRMLS_DC);
-static inline void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) {
+static zend_always_inline void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) {
zend_objects_store_del_ref_by_handle_ex(handle, NULL TSRMLS_CC);
}
ZEND_API zend_uint zend_objects_store_get_refcount(zval *object TSRMLS_DC);
diff -ur php-5.3.8/Zend/zend_operators.h php-5.4.0RC2/Zend/zend_operators.h
--- php-5.3.8/Zend/zend_operators.h 2011-12-13 14:10:07.000000000 +0900
+++ php-5.4.0RC2/Zend/zend_operators.h 2011-12-13 14:10:09.000000000 +0900
@@ -31,11 +31,14 @@
#endif
#include "zend_strtod.h"
+#include "zend_multiply.h"
#if 0&&HAVE_BCMATH
#include "ext/bcmath/libbcmath/src/bcmath.h"
#endif
+#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
+
BEGIN_EXTERN_C()
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
@@ -167,7 +170,7 @@
}
} else if (!(digits < SIZEOF_LONG * 2 || (digits == SIZEOF_LONG * 2 && ptr[-digits] <= '7'))) {
if (dval) {
- local_dval = zend_hex_strtod(str, (char **)&ptr);
+ local_dval = zend_hex_strtod(str, &ptr);
}
type = IS_DOUBLE;
}
@@ -178,7 +181,7 @@
/* If there's a dval, do the conversion; else continue checking
* the digits if we need to check for a full match */
if (dval) {
- local_dval = zend_strtod(str, (char **)&ptr);
+ local_dval = zend_strtod(str, &ptr);
} else if (allow_errors != 1 && dp_or_e != -1) {
dp_or_e = (*ptr++ == '.') ? 1 : 2;
goto check_digits;
@@ -256,17 +259,17 @@
return NULL;
}
-static inline void *zend_memrchr(const void *s, int c, size_t n)
+static inline const void *zend_memrchr(const void *s, int c, size_t n)
{
- register unsigned char *e;
+ register const unsigned char *e;
if (n <= 0) {
return NULL;
}
- for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
- if (*e == (unsigned char)c) {
- return (void *)e;
+ for (e = (const unsigned char *)s + n - 1; e >= (const unsigned char *)s; e--) {
+ if (*e == (const unsigned char)c) {
+ return (const void *)e;
}
}
@@ -298,7 +301,9 @@
ZEND_API int zval_is_true(zval *op);
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
+ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC);
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
+ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
#if HAVE_STRCOLL
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
#endif
@@ -448,6 +453,424 @@
#define zend_update_current_locale()
#endif
+static zend_always_inline int fast_increment_function(zval *op1)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__(
+ "incl (%0)\n\t"
+ "jno 0f\n\t"
+ "movl $0x0, (%0)\n\t"
+ "movl $0x41e00000, 0x4(%0)\n\t"
+ "movb $0x2,0xc(%0)\n"
+ "0:"
+ :
+ : "r"(op1));
+#elif defined(__GNUC__) && defined(__x86_64__)
+ __asm__(
+ "incq (%0)\n\t"
+ "jno 0f\n\t"
+ "movl $0x0, (%0)\n\t"
+ "movl $0x43e00000, 0x4(%0)\n\t"
+ "movb $0x2,0x14(%0)\n"
+ "0:"
+ :
+ : "r"(op1));
+#else
+ if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) {
+ /* switch to double */
+ Z_DVAL_P(op1) = (double)LONG_MAX + 1.0;
+ Z_TYPE_P(op1) = IS_DOUBLE;
+ } else {
+ Z_LVAL_P(op1)++;
+ }
+#endif
+ return SUCCESS;
+ }
+ return increment_function(op1);
+}
+
+static zend_always_inline int fast_decrement_function(zval *op1)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__(
+ "decl (%0)\n\t"
+ "jno 0f\n\t"
+ "movl $0x00200000, (%0)\n\t"
+ "movl $0xc1e00000, 0x4(%0)\n\t"
+ "movb $0x2,0xc(%0)\n"
+ "0:"
+ :
+ : "r"(op1));
+#elif defined(__GNUC__) && defined(__x86_64__)
+ __asm__(
+ "decq (%0)\n\t"
+ "jno 0f\n\t"
+ "movl $0x00000000, (%0)\n\t"
+ "movl $0xc3e00000, 0x4(%0)\n\t"
+ "movb $0x2,0x14(%0)\n"
+ "0:"
+ :
+ : "r"(op1));
+#else
+ if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MIN)) {
+ /* switch to double */
+ Z_DVAL_P(op1) = (double)LONG_MIN - 1.0;
+ Z_TYPE_P(op1) = IS_DOUBLE;
+ } else {
+ Z_LVAL_P(op1)--;
+ }
+#endif
+ return SUCCESS;
+ }
+ return decrement_function(op1);
+}
+
+static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__(
+ "movl (%1), %%eax\n\t"
+ "addl (%2), %%eax\n\t"
+ "jo 0f\n\t"
+ "movl %%eax, (%0)\n\t"
+ "movb $0x1,0xc(%0)\n\t"
+ "jmp 1f\n"
+ "0:\n\t"
+ "fildl (%1)\n\t"
+ "fildl (%2)\n\t"
+ "faddp %%st, %%st(1)\n\t"
+ "movb $0x2,0xc(%0)\n\t"
+ "fstpl (%0)\n"
+ "1:"
+ :
+ : "r"(result),
+ "r"(op1),
+ "r"(op2)
+ : "eax");
+#elif defined(__GNUC__) && defined(__x86_64__)
+ __asm__(
+ "movq (%1), %%rax\n\t"
+ "addq (%2), %%rax\n\t"
+ "jo 0f\n\t"
+ "movq %%rax, (%0)\n\t"
+ "movb $0x1,0x14(%0)\n\t"
+ "jmp 1f\n"
+ "0:\n\t"
+ "fildq (%1)\n\t"
+ "fildq (%2)\n\t"
+ "faddp %%st, %%st(1)\n\t"
+ "movb $0x2,0x14(%0)\n\t"
+ "fstpl (%0)\n"
+ "1:"
+ :
+ : "r"(result),
+ "r"(op1),
+ "r"(op2)
+ : "rax");
+#else
+ Z_LVAL_P(result) = Z_LVAL_P(op1) + Z_LVAL_P(op2);
+
+ if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
+ && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
+ Z_DVAL_P(result) = (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ } else {
+ Z_TYPE_P(result) = IS_LONG;
+ }
+#endif
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) + Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2));
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ }
+ return add_function(result, op1, op2 TSRMLS_CC);
+}
+
+static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__(
+ "movl (%1), %%eax\n\t"
+ "subl (%2), %%eax\n\t"
+ "jo 0f\n\t"
+ "movl %%eax, (%0)\n\t"
+ "movb $0x1,0xc(%0)\n\t"
+ "jmp 1f\n"
+ "0:\n\t"
+ "fildl (%2)\n\t"
+ "fildl (%1)\n\t"
+#if defined(__clang__) && (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 10))
+ "fsubp %%st(1), %%st\n\t" /* LLVM bug #9164 */
+#else
+ "fsubp %%st, %%st(1)\n\t"
+#endif
+ "movb $0x2,0xc(%0)\n\t"
+ "fstpl (%0)\n"
+ "1:"
+ :
+ : "r"(result),
+ "r"(op1),
+ "r"(op2)
+ : "eax");
+#elif defined(__GNUC__) && defined(__x86_64__)
+ __asm__(
+ "movq (%1), %%rax\n\t"
+ "subq (%2), %%rax\n\t"
+ "jo 0f\n\t"
+ "movq %%rax, (%0)\n\t"
+ "movb $0x1,0x14(%0)\n\t"
+ "jmp 1f\n"
+ "0:\n\t"
+ "fildq (%2)\n\t"
+ "fildq (%1)\n\t"
+#if defined(__clang__) && (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 10))
+ "fsubp %%st(1), %%st\n\t" /* LLVM bug #9164 */
+#else
+ "fsubp %%st, %%st(1)\n\t"
+#endif
+ "movb $0x2,0x14(%0)\n\t"
+ "fstpl (%0)\n"
+ "1:"
+ :
+ : "r"(result),
+ "r"(op1),
+ "r"(op2)
+ : "rax");
+#else
+ Z_LVAL_P(result) = Z_LVAL_P(op1) - Z_LVAL_P(op2);
+
+ if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
+ && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
+ Z_DVAL_P(result) = (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ } else {
+ Z_TYPE_P(result) = IS_LONG;
+ }
+#endif
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2));
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ }
+ return sub_function(result, op1, op2 TSRMLS_CC);
+}
+
+static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ long overflow;
+
+ ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow);
+ Z_TYPE_P(result) = overflow ? IS_DOUBLE : IS_LONG;
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) * Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ Z_DVAL_P(result) = Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2));
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ }
+ return mul_function(result, op1, op2 TSRMLS_CC);
+}
+
+static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
+ zend_error(E_WARNING, "Division by zero");
+ Z_LVAL_P(result) = 0;
+ Z_TYPE_P(result) = IS_BOOL;
+ return FAILURE;
+ } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN)) {
+ /* Prevent overflow error/crash */
+ Z_DVAL_P(result) = (double) LONG_MIN / -1;
+ Z_TYPE_P(result) = IS_DOUBLE;
+ } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) {
+ /* integer */
+ Z_LVAL_P(result) = Z_LVAL_P(op1) / Z_LVAL_P(op2);
+ Z_TYPE_P(result) = IS_LONG;
+ } else {
+ Z_DVAL_P(result) = ((double) Z_LVAL_P(op1)) / ((double)Z_LVAL_P(op2));
+ Z_TYPE_P(result) = IS_DOUBLE;
+ }
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ if (UNEXPECTED(Z_DVAL_P(op2) == 0)) {
+ zend_error(E_WARNING, "Division by zero");
+ Z_LVAL_P(result) = 0;
+ Z_TYPE_P(result) = IS_BOOL;
+ return FAILURE;
+ }
+ Z_DVAL_P(result) = ((double)Z_LVAL_P(op1)) / Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE) && 0) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
+ if (UNEXPECTED(Z_DVAL_P(op2) == 0)) {
+ zend_error(E_WARNING, "Division by zero");
+ Z_LVAL_P(result) = 0;
+ Z_TYPE_P(result) = IS_BOOL;
+ return FAILURE;
+ }
+ Z_DVAL_P(result) = Z_DVAL_P(op1) / Z_DVAL_P(op2);
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
+ zend_error(E_WARNING, "Division by zero");
+ Z_LVAL_P(result) = 0;
+ Z_TYPE_P(result) = IS_BOOL;
+ return FAILURE;
+ }
+ Z_DVAL_P(result) = Z_DVAL_P(op1) / ((double)Z_LVAL_P(op2));
+ Z_TYPE_P(result) = IS_DOUBLE;
+ return SUCCESS;
+ }
+ }
+ return div_function(result, op1, op2 TSRMLS_CC);
+}
+
+static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
+{
+ if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
+ if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
+ if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
+ zend_error(E_WARNING, "Division by zero");
+ Z_LVAL_P(result) = 0;
+ Z_TYPE_P(result) = IS_BOOL;
+ return FAILURE;
+ } else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
+ /* Prevent overflow error/crash if op1==LONG_MIN */