summaryrefslogtreecommitdiff
path: root/Zend/zend.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend.c')
-rw-r--r--Zend/zend.c73
1 files changed, 45 insertions, 28 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index cbd5aef42b..c76a7e6fba 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -34,6 +34,7 @@
#include "zend_cpuinfo.h"
#include "zend_attributes.h"
#include "zend_observer.h"
+#include "Optimizer/zend_optimizer.h"
static size_t global_map_ptr_last = 0;
@@ -60,7 +61,7 @@ ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_API zend_utility_values zend_uv;
-ZEND_API zend_bool zend_dtrace_enabled;
+ZEND_API bool zend_dtrace_enabled;
/* version information */
static char *zend_version_info;
@@ -72,15 +73,15 @@ static uint32_t zend_version_info_length;
ZEND_API zend_class_entry *zend_standard_class_def = NULL;
ZEND_API size_t (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
-ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
-ZEND_API zend_result (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
+ZEND_API FILE *(*zend_fopen)(zend_string *filename, zend_string **opened_path);
+ZEND_API zend_result (*zend_stream_open_function)(zend_file_handle *handle);
ZEND_API void (*zend_ticks_function)(int ticks);
ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
-ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
+ZEND_API zend_string *(*zend_resolve_path)(zend_string *filename);
ZEND_API zend_result (*zend_post_startup_cb)(void) = NULL;
ZEND_API void (*zend_post_shutdown_cb)(void) = NULL;
ZEND_API zend_result (*zend_preload_autoload)(zend_string *filename) = NULL;
@@ -92,7 +93,7 @@ static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
static zval *(*zend_get_configuration_directive_p)(zend_string *name);
#if ZEND_RC_DEBUG
-ZEND_API zend_bool zend_rc_debug = 0;
+ZEND_API bool zend_rc_debug = 0;
#endif
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
@@ -108,7 +109,7 @@ static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
{
- zend_bool val;
+ bool val;
val = zend_ini_parse_bool(new_value);
gc_enable(val);
@@ -290,7 +291,7 @@ ZEND_API zend_string *zend_strpprintf_unchecked(size_t max_len, const char *form
static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent);
-static void print_hash(smart_str *buf, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
+static void print_hash(smart_str *buf, HashTable *ht, int indent, bool is_object) /* {{{ */
{
zval *tmp;
zend_string *string_key;
@@ -456,11 +457,22 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
{
HashTable *properties;
- zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
+ zend_object *zobj = Z_OBJ_P(expr);
+ zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(zobj);
smart_str_appends(buf, ZSTR_VAL(class_name));
zend_string_release_ex(class_name, 0);
- smart_str_appends(buf, " Object\n");
+ if (!(zobj->ce->ce_flags & ZEND_ACC_ENUM)) {
+ smart_str_appends(buf, " Object\n");
+ } else {
+ smart_str_appends(buf, " Enum");
+ if (zobj->ce->enum_backing_type != IS_UNDEF) {
+ smart_str_appendc(buf, ':');
+ smart_str_appends(buf, zend_get_type_by_const(zobj->ce->enum_backing_type));
+ }
+ smart_str_appendc(buf, '\n');
+ }
+
if (GC_IS_RECURSIVE(Z_OBJ_P(expr))) {
smart_str_appends(buf, " *RECURSION*");
return;
@@ -514,17 +526,17 @@ ZEND_API void zend_print_zval_r(zval *expr, int indent) /* {{{ */
}
/* }}} */
-static FILE *zend_fopen_wrapper(const char *filename, zend_string **opened_path) /* {{{ */
+static FILE *zend_fopen_wrapper(zend_string *filename, zend_string **opened_path) /* {{{ */
{
if (opened_path) {
- *opened_path = zend_string_init(filename, strlen(filename), 0);
+ *opened_path = zend_string_copy(filename);
}
- return fopen(filename, "rb");
+ return fopen(ZSTR_VAL(filename), "rb");
}
/* }}} */
#ifdef ZTS
-static zend_bool short_tags_default = 1;
+static bool short_tags_default = 1;
static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
#else
# define short_tags_default 1
@@ -659,6 +671,7 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);
compiler_globals->script_encoding_list = NULL;
+ compiler_globals->current_linking_class = NULL;
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
/* Map region is going to be created and resized at run-time. */
@@ -712,7 +725,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
zend_init_exception_op();
zend_init_call_trampoline_op();
memset(&executor_globals->trampoline, 0, sizeof(zend_op_array));
- executor_globals->lambda_count = 0;
+ executor_globals->capture_warnings_during_sccp = 0;
ZVAL_UNDEF(&executor_globals->user_error_handler);
ZVAL_UNDEF(&executor_globals->user_exception_handler);
executor_globals->in_autoload = NULL;
@@ -784,15 +797,10 @@ static void module_destructor_zval(zval *zv) /* {{{ */
}
/* }}} */
-static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
+static bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
{
- zval globals;
-
- /* IS_ARRAY, but with ref-counter 1 and not IS_TYPE_REFCOUNTED */
- ZVAL_ARR(&globals, &EG(symbol_table));
- Z_TYPE_FLAGS_P(&globals) = 0;
- ZVAL_NEW_REF(&globals, &globals);
- zend_hash_update(&EG(symbol_table), name, &globals);
+ /* While we keep registering $GLOBALS as an auto-global, we do not create an
+ * actual variable for it. Access to it handled specially by the compiler. */
return 0;
}
/* }}} */
@@ -958,6 +966,8 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
php_win32_cp_setup();
#endif
+ zend_optimizer_startup();
+
#ifdef ZTS
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
tsrm_set_shutdown_handler(zend_interned_strings_dtor);
@@ -1117,6 +1127,8 @@ void zend_shutdown(void) /* {{{ */
}
#endif
zend_destroy_rsrc_list_dtors();
+
+ zend_optimizer_shutdown();
}
/* }}} */
@@ -1292,12 +1304,20 @@ static ZEND_COLD void zend_error_impl(
zval params[4];
zval retval;
zval orig_user_error_handler;
- zend_bool in_compilation;
+ bool in_compilation;
zend_class_entry *saved_class_entry;
zend_stack loop_var_stack;
zend_stack delayed_oplines_stack;
int type = orig_type & E_ALL;
+ /* If we're executing a function during SCCP, count any warnings that may be emitted,
+ * but don't perform any other error handling. */
+ if (EG(capture_warnings_during_sccp)) {
+ ZEND_ASSERT(!(type & E_FATAL_ERRORS) && "Fatal error during SCCP");
+ EG(capture_warnings_during_sccp)++;
+ return;
+ }
+
/* Report about uncaught exception in case of fatal errors */
if (EG(exception)) {
zend_execute_data *ex;
@@ -1596,7 +1616,7 @@ ZEND_API ZEND_COLD void zend_value_error(const char *format, ...) /* {{{ */
va_end(va);
} /* }}} */
-ZEND_API ZEND_COLD void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */
+ZEND_API ZEND_COLD void zend_output_debug_string(bool trigger_break, const char *format, ...) /* {{{ */
{
#if ZEND_DEBUG
va_list args;
@@ -1665,9 +1685,6 @@ ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count
}
if (ret == FAILURE) {
- /* If a failure occurred in one of the earlier files,
- * only destroy the following file handles. */
- zend_file_handle_dtor(file_handle);
continue;
}
@@ -1675,7 +1692,6 @@ ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count
if (file_handle->opened_path) {
zend_hash_add_empty_element(&EG(included_files), file_handle->opened_path);
}
- zend_destroy_file_handle(file_handle);
if (op_array) {
zend_execute(op_array, retval);
zend_exception_restore();
@@ -1687,6 +1703,7 @@ ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count
ret = zend_exception_error(EG(exception), E_ERROR);
}
}
+ zend_destroy_static_vars(op_array);
destroy_op_array(op_array);
efree_size(op_array, sizeof(zend_op_array));
} else if (type==ZEND_REQUIRE) {