cvs: ZendEngine2(PHP_5_3) / zend_compile.c zend_compile.h php-src NEWS

"Dmitry Stogov" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsdmitry1216961648@cvsserver>
dmitry		Fri Jul 25 04:54:08 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src	NEWS 
    /ZendEngine2	zend_compile.c zend_compile.h 
  Log:
  Substitute persistent constants by their values at compile time. (Matt)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.220&r2=1.2027.2.547.2.965.2.221&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.220 php-src/NEWS:1.2027.2.547.2.965.2.221
--- php-src/NEWS:1.2027.2.547.2.965.2.220	Thu Jul 24 15:54:41 2008
+++ php-src/NEWS	Fri Jul 25 04:54:08 2008
@@ -43,6 +43,7 @@
   . Added ability to handle exceptions in destructors. (Marcus)
 
 - Improved PHP runtime speed and memory usage:
+  . Substitute persistent constants by their values at compile time. (Matt)
   . Optimized ZEND_SIGNED_MULTIPLY_LONG() (Matt)
   . Removed direct executor recursion. (Dmitry)
   . Use fastcall calling convention in executor on x86. (Dmitry)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.76&r2=1.647.2.27.2.41.2.77&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.76 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.77
--- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.76	Thu Jul 24 22:21:38 2008
+++ ZendEngine2/zend_compile.c	Fri Jul 25 04:54:08 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.76 2008/07/24 22:21:38 moriyoshi Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.77 2008/07/25 04:54:08 dmitry Exp $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -3804,6 +3804,13 @@
 	if (c->flags & CONST_CT_SUBST) {
 		return c;
 	}
+	if ((c->flags & CONST_PERSISTENT) &&
+	    !CG(current_namespace) &&
+	    !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION) &&
+	    Z_TYPE(c->value) != IS_CONSTANT &&
+	    Z_TYPE(c->value) != IS_CONSTANT_ARRAY) {
+		return c;
+	}
 	return NULL;
 }
 /* }}} */
@@ -5171,12 +5178,14 @@
 void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */
 {
 	zend_op *opline;
+	zend_constant *c;
 
 	if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
 		zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants");
 	}
 
-	if (zend_get_ct_const(&name->u.constant TSRMLS_CC)) {
+	c = zend_get_ct_const(&name->u.constant TSRMLS_CC);
+	if (c && (c->flags & CONST_CT_SUBST)) {
 		zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%s'", Z_STRVAL(name->u.constant));
 	}
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.316.2.8.2.12.2.27&r2=1.316.2.8.2.12.2.28&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.27 ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.28
--- ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.27	Thu Jul 24 11:47:49 2008
+++ ZendEngine2/zend_compile.h	Fri Jul 25 04:54:08 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h,v 1.316.2.8.2.12.2.27 2008/07/24 11:47:49 dmitry Exp $ */
+/* $Id: zend_compile.h,v 1.316.2.8.2.12.2.28 2008/07/25 04:54:08 dmitry Exp $ */
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
@@ -762,6 +762,9 @@
 /* generate ZEND_DECLARE_INHERITED_CLASS_DELAYED opcode to delay early binding */
 #define ZEND_COMPILE_DELAYED_BINDING			(1<<4)
 
+/* disable constant substitution at compile-time */
+#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION	(1<<5)
+
 /* The default value for CG(compiler_options) */
 #define ZEND_COMPILE_DEFAULT					ZEND_COMPILE_HANDLE_OP_ARRAY
 



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.