From: Dmitry Stogov Date: Tue, 7 Mar 2017 07:18:34 +0000 (+0300) Subject: Fixed pointer allignment X-Git-Tag: php-7.1.4RC1~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9231b16670cd450544cb0f050c72af9809e47e7;p=php Fixed pointer allignment --- diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 47f4337991..3bdc0310e6 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -1640,11 +1640,11 @@ static int zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {{ ALLOCA_FLAG(use_heap); worklist = do_alloca( - sizeof(zend_ulong) * worklist_len + - sizeof(int) * ssa->vars_count + + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ulong) * worklist_len) + + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->vars_count) + sizeof(int) * ssa->sccs, use_heap); - next_scc_var = (int*)(worklist + worklist_len); - scc_var = next_scc_var + ssa->vars_count; + next_scc_var = (int*)((char*)worklist + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ulong) * worklist_len)); + scc_var = (int*)((char*)next_scc_var + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->vars_count)); LOG_SSA_RANGE("Range Inference\n"); diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index 83b52707d8..c902e51766 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -77,12 +77,12 @@ static zend_ssa_phi *add_pi( } phi = zend_arena_calloc(arena, 1, - sizeof(zend_ssa_phi) + - sizeof(int) * ssa->cfg.blocks[to].predecessors_count + + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ssa_phi)) + + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->cfg.blocks[to].predecessors_count) + sizeof(void*) * ssa->cfg.blocks[to].predecessors_count); - phi->sources = (int*)(((char*)phi) + sizeof(zend_ssa_phi)); + phi->sources = (int*)(((char*)phi) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ssa_phi))); memset(phi->sources, 0xff, sizeof(int) * ssa->cfg.blocks[to].predecessors_count); - phi->use_chains = (zend_ssa_phi**)(((char*)phi->sources) + sizeof(int) * ssa->cfg.blocks[to].predecessors_count); + phi->use_chains = (zend_ssa_phi**)(((char*)phi->sources) + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->cfg.blocks[to].predecessors_count)); phi->pi = from; phi->var = var; @@ -947,13 +947,13 @@ int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_ if (!zend_bitset_empty(phi + j * set_size, set_size)) { ZEND_BITSET_REVERSE_FOREACH(phi + j * set_size, set_size, i) { zend_ssa_phi *phi = zend_arena_calloc(arena, 1, - sizeof(zend_ssa_phi) + - sizeof(int) * blocks[j].predecessors_count + + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ssa_phi)) + + ZEND_MM_ALIGNED_SIZE(sizeof(int) * blocks[j].predecessors_count) + sizeof(void*) * blocks[j].predecessors_count); - phi->sources = (int*)(((char*)phi) + sizeof(zend_ssa_phi)); + phi->sources = (int*)(((char*)phi) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_ssa_phi))); memset(phi->sources, 0xff, sizeof(int) * blocks[j].predecessors_count); - phi->use_chains = (zend_ssa_phi**)(((char*)phi->sources) + sizeof(int) * ssa->cfg.blocks[j].predecessors_count); + phi->use_chains = (zend_ssa_phi**)(((char*)phi->sources) + ZEND_MM_ALIGNED_SIZE(sizeof(int) * ssa->cfg.blocks[j].predecessors_count)); phi->pi = -1; phi->var = i;