From 9e403d65d8515422edf87949bcb60667cd737996 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 5 Dec 2019 14:51:36 +0100 Subject: [PATCH] Add DCE support for ARRAY_KEY_EXISTS --- ext/opcache/Optimizer/dce.c | 1 + ext/opcache/Optimizer/zend_inference.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ext/opcache/Optimizer/dce.c b/ext/opcache/Optimizer/dce.c index 2992bb60b3..ea81687bf4 100644 --- a/ext/opcache/Optimizer/dce.c +++ b/ext/opcache/Optimizer/dce.c @@ -124,6 +124,7 @@ static inline zend_bool may_have_side_effects( case ZEND_IN_ARRAY: case ZEND_FUNC_NUM_ARGS: case ZEND_FUNC_GET_ARGS: + case ZEND_ARRAY_KEY_EXISTS: /* No side effects */ return 0; case ZEND_ROPE_END: diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 975853a9eb..1838fe387b 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -4634,6 +4634,14 @@ int zend_may_throw(const zend_op *opline, const zend_op_array *op_array, zend_ss default: return 1; } + case ZEND_ARRAY_KEY_EXISTS: + if ((t2 & MAY_BE_ANY) != MAY_BE_ARRAY) { + return 1; + } + if ((t1 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) { + return 1; + } + return 0; default: return 1; } -- 2.50.1