From: Dmitry Stogov Date: Wed, 22 Nov 2017 12:36:09 +0000 (+0300) Subject: Allowed modification of VM stack page size. Exported few functions. Green light for... X-Git-Tag: php-7.3.0alpha1~972 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6780c746198e01f52affb86f998108419a8621ed;p=php Allowed modification of VM stack page size. Exported few functions. Green light for Fibers/Coroutines. --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index b44922f395..51ad74f4f2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -166,9 +166,6 @@ ZEND_API const zend_internal_function zend_pass_function = { #define ZEND_VM_STACK_PAGE_SIZE (ZEND_VM_STACK_PAGE_SLOTS * sizeof(zval)) -#define ZEND_VM_STACK_FREE_PAGE_SIZE \ - ((ZEND_VM_STACK_PAGE_SLOTS - ZEND_VM_STACK_HEADER_SLOTS) * sizeof(zval)) - #define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size) \ (((size) + ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval) \ + (ZEND_VM_STACK_PAGE_SIZE - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE - 1)) @@ -184,6 +181,7 @@ static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend ZEND_API void zend_vm_stack_init(void) { + EG(vm_stack_page_size) = ZEND_VM_STACK_PAGE_SIZE; EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE, NULL); EG(vm_stack)->top++; EG(vm_stack_top) = EG(vm_stack)->top; @@ -209,8 +207,8 @@ ZEND_API void* zend_vm_stack_extend(size_t size) stack = EG(vm_stack); stack->top = EG(vm_stack_top); EG(vm_stack) = stack = zend_vm_stack_new_page( - EXPECTED(size < ZEND_VM_STACK_FREE_PAGE_SIZE) ? - ZEND_VM_STACK_PAGE_SIZE : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size), + EXPECTED(size < EG(vm_stack_page_size) - (ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval))) ? + EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size), stack); ptr = stack->top; EG(vm_stack_top) = (void*)(((char*)ptr) + size); @@ -2092,7 +2090,7 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec } /* }}} */ -void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */ +ZEND_API void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */ { i_free_compiled_variables(execute_data); } @@ -2500,7 +2498,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, } /* }}} */ -void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) { +ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) { cleanup_unfinished_calls(execute_data, op_num); cleanup_live_vars(execute_data, op_num, catch_op_num); } diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 44524beded..a8798aed5e 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -322,8 +322,8 @@ typedef zval* zend_free_op; ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type); ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table); -void zend_free_compiled_variables(zend_execute_data *execute_data); -void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num); +ZEND_API void zend_free_compiled_variables(zend_execute_data *execute_data); +ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num); ZEND_API int ZEND_FASTCALL zend_do_fcall_overloaded(zend_execute_data *call, zval *ret); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index d9e872ae0e..5555a3863b 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -155,6 +155,7 @@ struct _zend_executor_globals { zval *vm_stack_top; zval *vm_stack_end; zend_vm_stack vm_stack; + size_t vm_stack_page_size; struct _zend_execute_data *current_execute_data; zend_class_entry *fake_scope; /* used to avoid checks accessing properties */