From ae76050318575db96f17c02918855dcdcb8c398d Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 24 Oct 2014 14:51:03 +0200 Subject: [PATCH] useless 'instanceof' removal pass --- Optimizer/pass1_5.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Optimizer/pass1_5.c b/Optimizer/pass1_5.c index ca5b882..8beb2c7 100644 --- a/Optimizer/pass1_5.c +++ b/Optimizer/pass1_5.c @@ -13,6 +13,20 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { while (opline < end) { switch (opline->opcode) { + case ZEND_INSTANCEOF: + if ((opline + 1)->opcode == ZEND_FREE) { /* useless instanceof */ + MAKE_NOP(opline); + MAKE_NOP((opline + 1)); + + /* It is safe to remove FETCH_CLASS, it was ZEND_FETCH_CLASS_NO_AUTOLOAD anyway */ + if ((opline - 1)->opcode == ZEND_FETCH_CLASS) { + if (ZEND_OP2_TYPE(opline - 1) == IS_CONST) { + literal_dtor(&ZEND_OP2_LITERAL(opline - 1)); + } + MAKE_NOP((opline -1)); + } + } + break; case ZEND_ADD: case ZEND_SUB: case ZEND_MUL: