com php-src: Optimize is_scalar($x) into a TYPE _CHECK opcode: Zend/zend_compile.c

From: Date: Tue, 12 Nov 2019 07:17:10 +0000
Subject: com php-src: Optimize is_scalar($x) into a TYPE _CHECK opcode: Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-109246@lists.php.net to get a copy of this message
Commit: 937fa6d9e2f38b5e70a2a510b87ce0be4839a404 Author: Tyson Andre <tysonandre775@hotmail.com> Mon, 11 Nov 2019 19:56:20 -0500 Committer: Dmitry Stogov <dmitry@zend.com> Tue, 12 Nov 2019 10:17:10 +0300 Parents: ad0a3f28867d92d4f59a917ba6c87250b55101df Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=937fa6d9e2f38b5e70a2a510b87ce0be4839a404 Log: Optimize is_scalar($x) into a TYPE_CHECK opcode Optimizations such as specializations for is_resource were first added in dfb4f6b38d9efedafab7d2d98b9333715561256 I don't see any mention of is_scalar (and optimizing it) in the commit history, or in prior PRs on github, or searching for is_scalar in externals.io Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 53fe9afde8c..c7853b29693 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3394,6 +3394,21 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ } /* }}} */ +static int zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ +{ + znode arg_node; + zend_op *opline; + + if (args->children != 1) { + return FAILURE; + } + + zend_compile_expr(&arg_node, args->child[0]); + opline = zend_emit_op_tmp(result, ZEND_TYPE_CHECK, &arg_node, NULL); + opline->extended_value = (1 << IS_FALSE | 1 << IS_TRUE | 1 << IS_DOUBLE | 1 << IS_LONG | 1 << IS_STRING); + return SUCCESS; +} + int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; @@ -3912,6 +3927,8 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l return zend_compile_func_typecheck(result, args, IS_OBJECT); } else if (zend_string_equals_literal(lcname, "is_resource")) { return zend_compile_func_typecheck(result, args, IS_RESOURCE); + } else if (zend_string_equals_literal(lcname, "is_scalar")) { + return zend_compile_func_is_scalar(result, args); } else if (zend_string_equals_literal(lcname, "boolval")) { return zend_compile_func_cast(result, args, _IS_BOOL); } else if (zend_string_equals_literal(lcname, "intval")) {

« previous php.cvs (#109246) next »