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

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1205317936@cvsserver>
dmitry		Wed Mar 12 10:32:16 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src	NEWS 
    /ZendEngine2	zend_compile.c zend_vm_def.h zend_vm_execute.h 
  Log:
  Optimized ZEND_FETCH_CLASS + ZEND_ADD_INTERFACE into single ZEND_ADD_INTERFACE opcode
dmitry-20080312103216.txt (text/plain, 8 KB)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.136&r2=1.2027.2.547.2.965.2.137&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.136 php-src/NEWS:1.2027.2.547.2.965.2.137
--- php-src/NEWS:1.2027.2.547.2.965.2.136	Wed Mar 12 09:46:41 2008
+++ php-src/NEWS	Wed Mar 12 10:32:11 2008
@@ -88,6 +88,8 @@
     ZEND_HANDLE_EXCEPTION opcode in the end. (Dmitry)
   . Optimized require_once() and include_once() by eliminating fopen(3) on
     second usage. (Dmitry)
+  . Optimized ZEND_FETCH_CLASS + ZEND_ADD_INTERFACE into single
+    ZEND_ADD_INTERFACE opcode (Dmitry)
 - Improved php.ini handling: (Jani)
   . Added ".htaccess" style user-defined php.ini files support for CGI/FastCGI
   . Added support for special [PATH=/opt/httpd/www.example.com/] and
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.47&r2=1.647.2.27.2.41.2.48&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.47 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.48
--- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.47	Wed Mar 12 09:46:41 2008
+++ ZendEngine2/zend_compile.c	Wed Mar 12 10:32:11 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.47 2008/03/12 09:46:41 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.48 2008/03/12 10:32:11 dmitry Exp $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -3261,35 +3261,25 @@
 
 void zend_do_implements_interface(znode *interface_name TSRMLS_DC)
 {
-	znode interface_node;
 	zend_op *opline;
 
-	zend_do_fetch_class(&interface_node, interface_name TSRMLS_CC);
-	switch (interface_node.u.EA.type) {
+	switch (zend_get_class_fetch_type(Z_STRVAL(interface_name->u.constant), Z_STRLEN(interface_name->u.constant))) {
 		case ZEND_FETCH_CLASS_SELF:
-			zend_error(E_COMPILE_ERROR, "Cannot use 'self' as interface name as it is reserved");
-			break;
 		case ZEND_FETCH_CLASS_PARENT:
-			zend_error(E_COMPILE_ERROR, "Cannot use 'parent' as interface name as it is reserved");
-			break;
 		case ZEND_FETCH_CLASS_STATIC:
-			zend_error(E_COMPILE_ERROR, "Cannot use 'static' as interface name as it is reserved");
+			zend_error(E_COMPILE_ERROR, "Cannot use '%s' as interface name as it is reserved", Z_STRVAL(interface_name->u.constant));
 			break;
 		default:
-			if (CG(active_op_array)->last > 0) {
-				opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
-				if (opline->opcode == ZEND_FETCH_CLASS) {
-					opline->extended_value = (opline->extended_value & ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_INTERFACE;
-				}
-			}
 			break;
 	}
 
 	opline = get_next_op(CG(active_op_array) TSRMLS_CC);
 	opline->opcode = ZEND_ADD_INTERFACE;
 	opline->op1 = CG(implementing_class);
-	opline->op2 = interface_node;
-	opline->extended_value = CG(active_class_entry)->num_interfaces++;
+	zend_resolve_class_name(interface_name, &opline->extended_value, 0 TSRMLS_CC);
+	opline->extended_value = (opline->extended_value & ~ZEND_FETCH_CLASS_MASK) | ZEND_FETCH_CLASS_INTERFACE;
+	opline->op2 = *interface_name;
+	CG(active_class_entry)->num_interfaces++;
 }
 
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.48.2.41&r2=1.59.2.29.2.48.2.42&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.41 ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.42
--- ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.41	Wed Mar  5 13:34:12 2008
+++ ZendEngine2/zend_vm_def.h	Wed Mar 12 10:32:11 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.41 2008/03/05 13:34:12 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.42 2008/03/12 10:32:11 dmitry Exp $ */
 
 /* If you change this file, please regenerate the zend_vm_execute.h and
  * zend_vm_opcodes.h files by running:
@@ -4008,11 +4008,11 @@
 	ZEND_VM_NEXT_OPCODE();
 }
 
-ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, ANY)
+ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, CONST)
 {
 	zend_op *opline = EX(opline);
 	zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
-	zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry;
+	zend_class_entry *iface = zend_fetch_class(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);
 
 	if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
 		zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.49.2.40&r2=1.62.2.30.2.49.2.41&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.40 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.41
--- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.40	Wed Mar  5 13:34:12 2008
+++ ZendEngine2/zend_vm_execute.h	Wed Mar 12 10:32:12 2008
@@ -498,21 +498,6 @@
 	ZEND_VM_NEXT_OPCODE();
 }
 
-static int ZEND_ADD_INTERFACE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
-{
-	zend_op *opline = EX(opline);
-	zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
-	zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry;
-
-	if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
-		zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
-	}
-
-	zend_do_implement_interface(ce, iface TSRMLS_CC);
-
-	ZEND_VM_NEXT_OPCODE();
-}
-
 static int ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 {
 	zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes;
@@ -775,6 +760,21 @@
 	ZEND_VM_JMP(EX(op_array)->opcodes + el->cont);
 }
 
+static int ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
+{
+	zend_op *opline = EX(opline);
+	zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
+	zend_class_entry *iface = zend_fetch_class(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);
+
+	if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
+		zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
+	}
+
+	zend_do_implement_interface(ce, iface TSRMLS_CC);
+
+	ZEND_VM_NEXT_OPCODE();
+}
+
 static int ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 {
 	zend_op *opline = EX(opline);
@@ -32965,31 +32965,31 @@
   	ZEND_NULL_HANDLER,
   	ZEND_NULL_HANDLER,
   	ZEND_NULL_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
-  	ZEND_ADD_INTERFACE_SPEC_HANDLER,
+  	ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
+  	ZEND_NULL_HANDLER,
   	ZEND_NULL_HANDLER,
   	ZEND_NULL_HANDLER,
   	ZEND_NULL_HANDLER,
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.