summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-08-11 22:36:47 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-08-11 22:36:47 +0200
commit7c003948c618adb2a6691f529057388f02202f09 (patch)
treec7d4c3ce4c90487dad819c38d514a4aa8ae92393
parentdbd8edbbd08fbb2906ee9b540348b340715b5dbe (diff)
downloadphp-git-7c003948c618adb2a6691f529057388f02202f09.tar.gz
Simplify ZEND_EXIT and count boolean values to it as exit status
-rw-r--r--NEWS2
-rw-r--r--UPGRADING1
-rw-r--r--Zend/zend_vm_def.h27
-rw-r--r--Zend/zend_vm_execute.h96
-rw-r--r--Zend/zend_vm_gen.php4
5 files changed, 54 insertions, 76 deletions
diff --git a/NEWS b/NEWS
index 3d02db773c..74ccbce8d2 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ PHP NEWS
. Fixed bug #70198 (Checking liveness does not work as expected).
(Shafreeck Sea, Anatol Belski)
. Fixed bug #70241 (Skipped assertions affect Generator returns). (Bob)
+ . exit() and die() interpret all scalars except strings as exit_status now.
+ (Bob)
- CLI server:
. Fixed bug #66606 (Sets HTTP_CONTENT_TYPE but not CONTENT_TYPE).
diff --git a/UPGRADING b/UPGRADING
index 6f420650d2..b9b4c6964e 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -425,6 +425,7 @@ Other language changes
. Removed support for #-style comments in ini files. Use ;-style comments
instead.
. $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
+ . exit() and die() interpret all scalars except strings as exit_status now.
Standard library changes
========================
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index c968fd2907..9286f41ca7 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -6637,22 +6637,17 @@ ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMPVAR|UNUSED|CV, ANY)
SAVE_OPLINE();
if (OP1_TYPE != IS_UNUSED) {
zend_free_op free_op1;
- zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
-
- do {
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- } else {
- if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
- ptr = Z_REFVAL_P(ptr);
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- break;
- }
- }
- zend_print_variable(ptr);
- }
- } while (0);
+ zval *ptr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
+
+ if (Z_TYPE_P(ptr) == IS_LONG) {
+ EG(exit_status) = Z_LVAL_P(ptr);
+ } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+ EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+ } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+ EG(exit_status) = (int) Z_DVAL_P(ptr);
+ } else {
+ zend_print_variable(ptr);
+ }
FREE_OP1();
}
zend_bailout();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 5645ed625a..3f9583a642 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -3966,20 +3966,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_O
zval *ptr = EX_CONSTANT(opline->op1);
- do {
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- } else {
- if ((IS_CONST & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
- ptr = Z_REFVAL_P(ptr);
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- break;
- }
- }
- zend_print_variable(ptr);
- }
- } while (0);
+ if (Z_TYPE_P(ptr) == IS_LONG) {
+ EG(exit_status) = Z_LVAL_P(ptr);
+ } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+ EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+ } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+ EG(exit_status) = (int) Z_DVAL_P(ptr);
+ } else {
+ zend_print_variable(ptr);
+ }
}
zend_bailout();
@@ -22771,20 +22766,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_UNUSED_HANDLER(ZEND_
zval *ptr = NULL;
- do {
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- } else {
- if ((IS_UNUSED & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
- ptr = Z_REFVAL_P(ptr);
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- break;
- }
- }
- zend_print_variable(ptr);
- }
- } while (0);
+ if (Z_TYPE_P(ptr) == IS_LONG) {
+ EG(exit_status) = Z_LVAL_P(ptr);
+ } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+ EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+ } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+ EG(exit_status) = (int) Z_DVAL_P(ptr);
+ } else {
+ zend_print_variable(ptr);
+ }
}
zend_bailout();
@@ -29365,22 +29355,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCO
SAVE_OPLINE();
if (IS_CV != IS_UNUSED) {
- zval *ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var);
+ zval *ptr = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var);
- do {
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- } else {
- if ((IS_CV & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
- ptr = Z_REFVAL_P(ptr);
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- break;
- }
- }
- zend_print_variable(ptr);
- }
- } while (0);
+ if (Z_TYPE_P(ptr) == IS_LONG) {
+ EG(exit_status) = Z_LVAL_P(ptr);
+ } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+ EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+ } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+ EG(exit_status) = (int) Z_DVAL_P(ptr);
+ } else {
+ zend_print_variable(ptr);
+ }
}
zend_bailout();
@@ -40507,22 +40492,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_TMPVAR_HANDLER(ZEND_
SAVE_OPLINE();
if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) {
zend_free_op free_op1;
- zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1);
+ zval *ptr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1);
- do {
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- } else {
- if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
- ptr = Z_REFVAL_P(ptr);
- if (Z_TYPE_P(ptr) == IS_LONG) {
- EG(exit_status) = Z_LVAL_P(ptr);
- break;
- }
- }
- zend_print_variable(ptr);
- }
- } while (0);
+ if (Z_TYPE_P(ptr) == IS_LONG) {
+ EG(exit_status) = Z_LVAL_P(ptr);
+ } else if (Z_TYPE_P(ptr) == IS_TRUE || Z_TYPE_P(ptr) == IS_FALSE || Z_TYPE_P(ptr) == IS_NULL) {
+ EG(exit_status) = Z_TYPE_P(ptr) == IS_TRUE;
+ } else if (Z_TYPE_P(ptr) == IS_DOUBLE) {
+ EG(exit_status) = (int) Z_DVAL_P(ptr);
+ } else {
+ zend_print_variable(ptr);
+ }
zval_ptr_dtor_nogc(free_op1);
}
zend_bailout();
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index cb4ac8433b..a66002c1aa 100644
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -186,7 +186,7 @@ $op1_get_zval_ptr_deref = array(
"CONST" => "EX_CONSTANT(opline->op1)",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var)",
- "TMPVAR" => "???",
+ "TMPVAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
);
$op2_get_zval_ptr_deref = array(
@@ -196,7 +196,7 @@ $op2_get_zval_ptr_deref = array(
"CONST" => "EX_CONSTANT(opline->op2)",
"UNUSED" => "NULL",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var)",
- "TMPVAR" => "???",
+ "TMPVAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
);
$op1_get_zval_ptr_undef = array(