Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: PRE_NEW_VM_GEN…
Fetching contributors…

Cannot retrieve contributors at this time

file 393 lines (299 sloc) 10.965 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@zend.com> |
+----------------------------------------------------------------------+
*/

/* $Id$ */

#ifndef ZEND_VM_H
#define ZEND_VM_H

#define ZEND_VM_HAVE_OLD_EXECUTOR

#define ZEND_VM_KIND_CALL 1
#define ZEND_VM_KIND_SWITCH 2
#define ZEND_VM_KIND_GOTO 3

#ifndef ZEND_VM_OLD_EXECUTOR
/*# define ZEND_VM_KIND ZEND_VM_KIND_CALL */
# define ZEND_VM_SPEC
#endif

/* don't edit the rest of the file */

#ifdef ZEND_VM_HAVE_OLD_EXECUTOR
ZEND_API void zend_vm_use_old_executor();
void zend_vm_set_opcode_handler(zend_op* opcode);
#endif

#define _CONST_CODE 0
#define _TMP_CODE 1
#define _VAR_CODE 2
#define _UNUSED_CODE 3
#define _CV_CODE 4

#ifndef ZEND_VM_KIND
# ifdef __GNUC__
# define ZEND_VM_KIND ZEND_VM_KIND_GOTO
# else
# define ZEND_VM_KIND ZEND_VM_KIND_CALL
# endif
#endif

#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(ZEND_VM_OLD_EXECUTOR)
# define ZEND_VM_ALWAYS_INLINE __attribute__ ((always_inline))
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
/*extern void zend_error_noreturn(int type, const char *format, ...) __asm__("zend_error") __attribute__ ((noreturn));*/
#else
# define ZEND_VM_ALWAYS_INLINE
# define zend_error_noreturn zend_error
#endif

#ifndef ZEND_VM_SPEC
# define ZEND_VM_CODE(opcode, op1, op2) opcode
# define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) opcode
# ifdef ZEND_VM_HAVE_OLD_EXECUTOR
# define ZEND_VM_SET_OPCODE_HANDLER(opline) \
zend_vm_set_opcode_handler(opline)
# else
# define ZEND_VM_SET_OPCODE_HANDLER(opline) \
opline->handler = zend_opcode_handlers[opline->opcode]
# endif
#else
static const int zend_vm_decode[] = {
_UNUSED_CODE, /* 0 */
_CONST_CODE, /* 1 = IS_CONST */
_TMP_CODE, /* 2 = IS_TMP_VAR */
_UNUSED_CODE, /* 3 */
_VAR_CODE, /* 4 = IS_VAR */
_UNUSED_CODE, /* 5 */
_UNUSED_CODE, /* 6 */
_UNUSED_CODE, /* 7 */
_UNUSED_CODE, /* 8 = IS_UNUSED */
_UNUSED_CODE, /* 9 */
_UNUSED_CODE, /* 10 */
_UNUSED_CODE, /* 11 */
_UNUSED_CODE, /* 12 */
_UNUSED_CODE, /* 13 */
_UNUSED_CODE, /* 14 */
_UNUSED_CODE, /* 15 */
_CV_CODE /* 16 = IS_CV */
};

# define ZEND_VM_CODE(opcode, op1, op2) \
opcode * 25 + op1 * 5 + op2
# define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) \
ZEND_VM_CODE(opcode, zend_vm_decode[op1], zend_vm_decode[op2])
# ifdef ZEND_VM_HAVE_OLD_EXECUTOR
# define ZEND_VM_SET_OPCODE_HANDLER(opline) \
zend_vm_set_opcode_handler(opline)
# else
# define ZEND_VM_SET_OPCODE_HANDLER(opline) \
opline->handler = zend_opcode_handlers[ZEND_VM_SPEC_OPCODE(opline->opcode, opline->op1.op_type, opline->op2.op_type)]
# endif
#endif


#if ZEND_VM_KIND == ZEND_VM_KIND_CALL

# define EXECUTE_DATA execute_data

# define ZEND_VM_HELPER_VAR(X)

# define ZEND_VM_DISPATCH() \
if (EX(opline)->handler(&execute_data TSRMLS_CC) > 0)

# define ZEND_VM_CONTINUE_LABEL

# define ZEND_VM_HANDLER(OP) \
static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_HANDLER_EX(OP) \
static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_HELPER(NAME) \
static int NAME(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_HELPER_EX(NAME,PARAM) \
static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_SPEC_HANDLER(OP, CODE) \
static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \
static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_SPEC_HELPER(NAME) \
static int NAME(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \
static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_NULL_HANDLER() \
int ZEND_VM_NULL(ZEND_OPCODE_HANDLER_ARGS)

# define ZEND_VM_DISPATCH_TO_HANDLER(OP) \
return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_DISPATCH_TO_HELPER(NAME) \
return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \
return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \
return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)

# define ZEND_VM_CONTINUE() \
return 0

# define ZEND_VM_NEXT_OPCODE() \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
return 0

# define ZEND_VM_SET_OPCODE(new_op) \
CHECK_SYMBOL_TABLES() \
EX(opline) = new_op

# define ZEND_VM_INC_OPCODE() \
if (!EG(exception)) { \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
}

# define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \
free_alloca(EX(CVs)); \
if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
free_alloca(EX(Ts)); \
} else { \
efree(EX(Ts)); \
} \
EG(in_execution) = EX(original_in_execution); \
EG(current_execute_data) = EX(prev_execute_data); \
return 1;

# define ZEND_VM_LABEL(OP) OP##_HANDLER
# define ZEND_VM_NULL_LABEL ZEND_VM_NULL
# define ZEND_VM_SPEC_LABEL(OP,CODE) OP##_HANDLER
# define ZEND_VM_SPEC_NULL_LABEL ZEND_VM_NULL

#elif ZEND_VM_KIND == ZEND_VM_KIND_SWITCH

# define EXECUTE_DATA &execute_data

# define ZEND_VM_HELPER_VAR(X) X;

# define ZEND_VM_DISPATCH() \
switch ((int)EX(opline)->handler)

# define ZEND_VM_CONTINUE_LABEL \
zend_vm_continue:

# define ZEND_VM_HANDLER(OP) \
case OP:

# define ZEND_VM_HANDLER_EX(OP) \
case OP: \
OP##_LABEL:

# define ZEND_VM_HELPER(NAME) \
NAME:

# define ZEND_VM_HELPER_EX(NAME,PARAM) \
NAME:

# define ZEND_VM_SPEC_HANDLER(OP, CODE) \
case CODE:

# define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \
case CODE: \
OP##_LABEL:

# define ZEND_VM_SPEC_HELPER(NAME) \
NAME:

# define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \
NAME:

# define ZEND_VM_NULL_HANDLER() \
default:

# define ZEND_VM_DISPATCH_TO_HANDLER(OP) \
goto OP##_LABEL

# define ZEND_VM_DISPATCH_TO_HELPER(NAME) \
goto NAME

# define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
VAR = VAL; \
goto NAME

# define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \
goto OP##_LABEL

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \
goto NAME

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
VAR = VAL; \
goto NAME

# define ZEND_VM_CONTINUE() \
goto zend_vm_continue

# define ZEND_VM_NEXT_OPCODE() \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
ZEND_VM_CONTINUE()

# define ZEND_VM_SET_OPCODE(new_op) \
CHECK_SYMBOL_TABLES() \
EX(opline) = new_op

# define ZEND_VM_INC_OPCODE() \
if (!EG(exception)) { \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
}

# define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \
free_alloca(EX(CVs)); \
if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
free_alloca(EX(Ts)); \
} else { \
efree(EX(Ts)); \
} \
EG(in_execution) = EX(original_in_execution); \
EG(current_execute_data) = EX(prev_execute_data); \
return;

# define ZEND_VM_LABEL(OP) (opcode_handler_t)OP
# define ZEND_VM_NULL_LABEL (opcode_handler_t)-1
# define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)(CODE)
# define ZEND_VM_SPEC_NULL_LABEL (opcode_handler_t)-1

#elif ZEND_VM_KIND == ZEND_VM_KIND_GOTO

# define EXECUTE_DATA &execute_data

# define ZEND_VM_HELPER_VAR(X) X;

# define ZEND_VM_DISPATCH() \
goto *(void**)(EX(opline)->handler);

# define ZEND_VM_CONTINUE_LABEL

# define ZEND_VM_HANDLER(OP) \
OP##_HANDLER:

# define ZEND_VM_HANDLER_EX(OP) \
OP##_HANDLER:

# define ZEND_VM_HELPER(NAME) \
NAME:

# define ZEND_VM_HELPER_EX(NAME,PARAM) \
NAME:

# define ZEND_VM_SPEC_HANDLER(OP, CODE) \
OP##_HANDLER:

# define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \
OP##_HANDLER:

# define ZEND_VM_SPEC_HELPER(NAME) \
NAME:

# define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \
NAME:

# define ZEND_VM_NULL_HANDLER() \
ZEND_VM_NULL:

# define ZEND_VM_DISPATCH_TO_HANDLER(OP) \
goto OP##_HANDLER

# define ZEND_VM_DISPATCH_TO_HELPER(NAME) \
goto NAME

# define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
VAR = VAL; \
goto NAME

# define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \
goto OP##_HANDLER

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \
goto NAME

# define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \
VAR = VAL; \
goto NAME

# define ZEND_VM_CONTINUE() \
goto *(void**)(EX(opline)->handler)

# define ZEND_VM_NEXT_OPCODE() \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
ZEND_VM_CONTINUE()

# define ZEND_VM_SET_OPCODE(new_op) \
CHECK_SYMBOL_TABLES() \
EX(opline) = new_op

# define ZEND_VM_INC_OPCODE() \
if (!EG(exception)) { \
CHECK_SYMBOL_TABLES() \
EX(opline)++; \
}

# define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \
free_alloca(EX(CVs)); \
if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
free_alloca(EX(Ts)); \
} else { \
efree(EX(Ts)); \
} \
EG(in_execution) = EX(original_in_execution); \
EG(current_execute_data) = EX(prev_execute_data); \
return;

# define ZEND_VM_LABEL(OP) (opcode_handler_t)&&OP##_HANDLER
# define ZEND_VM_NULL_LABEL &&ZEND_VM_NULL
# define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)&&OP##_HANDLER
# define ZEND_VM_SPEC_NULL_LABEL &&ZEND_VM_NULL

#else
# error "Unknown ZEND_VM_KIND"
#endif

#define ZEND_VM_CONTINUE_JMP() ZEND_VM_CONTINUE()

#endif
Something went wrong with that request. Please try again.