summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_compile.c4
-rw-r--r--Zend/zend_compile.h3
2 files changed, 7 insertions, 0 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a6fe6954b7..ebefacf523 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4732,6 +4732,10 @@ static zend_uchar determine_switch_jumptable_type(zend_ast_list *cases) {
}
static zend_bool should_use_jumptable(zend_ast_list *cases, zend_uchar jumptable_type) {
+ if (CG(compiler_options) & ZEND_COMPILE_NO_JUMPTABLES) {
+ return 0;
+ }
+
/* Thresholds are chosen based on when the average switch time for equidistributed
* input becomes smaller when using the jumptable optimization. */
if (jumptable_type == IS_LONG) {
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 0d7019c988..5afdbcc625 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -1062,6 +1062,9 @@ END_EXTERN_C()
/* this flag is set when compiler invoked during preloading */
#define ZEND_COMPILE_PRELOAD (1<<14)
+/* disable jumptable optimization for switch statements */
+#define ZEND_COMPILE_NO_JUMPTABLES (1<<15)
+
/* The default value for CG(compiler_options) */
#define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY