]> granicus.if.org Git - php/commitdiff
Allowed modification of VM stack page size. Exported few functions. Green light for...
authorDmitry Stogov <dmitry@zend.com>
Wed, 22 Nov 2017 12:36:09 +0000 (15:36 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 22 Nov 2017 12:36:09 +0000 (15:36 +0300)
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_globals.h

index b44922f395279e1c7a6e02218af11ea4664ba39a..51ad74f4f2a9854c4b2f98f32cd9412cef0fd569 100644 (file)
@@ -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);
 }
index 44524beded6b25f0ebb07d890449dc424d5a5088..a8798aed5efd6e8f3beafbd6db7626bc4ff63355 100644 (file)
@@ -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);
 
index d9e872ae0e01e756f5ac9fa8be70992961b18f2d..5555a3863b7586f73a75ab82f778e5b4fe5cf307 100644 (file)
@@ -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 */