Changeset 716 for trunk/utils.c
- Timestamp:
- 04/09/2011 09:07:48 AM (2 years ago)
- Files:
-
- 1 modified
-
trunk/utils.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/utils.c
r705 r716 20 20 21 21 #define OP_ZVAL_DTOR(op) do { \ 22 Z_UNSET_ISREF( (op).u.constant); \23 zval_dtor(& (op).u.constant); \22 Z_UNSET_ISREF(Z_OP_CONSTANT(op)); \ 23 zval_dtor(&Z_OP_CONSTANT(op)); \ 24 24 } while(0) 25 25 xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, /* {{{ */ … … 135 135 zend_op *opline, *end; 136 136 137 #ifndef ZEND_ENGINE_2_4 137 138 if (!op_array->done_pass_two) { 138 139 return 0; 139 140 } 141 #endif 140 142 141 143 opline = op_array->opcodes; … … 148 150 #endif 149 151 case ZEND_JMP: 150 opline->op1.u.opline_num = opline->op1.u.jmp_addr - op_array->opcodes;151 assert( opline->op1.u.opline_num < op_array->last);152 Z_OP(opline->op1).opline_num = Z_OP(opline->op1).jmp_addr - op_array->opcodes; 153 assert(Z_OP(opline->op1).opline_num < op_array->last); 152 154 break; 153 155 case ZEND_JMPZ: … … 158 160 case ZEND_JMP_SET: 159 161 #endif 160 opline->op2.u.opline_num = opline->op2.u.jmp_addr - op_array->opcodes;161 assert( opline->op2.u.opline_num < op_array->last);162 Z_OP(opline->op2).opline_num = Z_OP(opline->op2).jmp_addr - op_array->opcodes; 163 assert(Z_OP(opline->op2).opline_num < op_array->last); 162 164 break; 163 165 } … … 165 167 opline++; 166 168 } 169 #ifndef ZEND_ENGINE_2_4 167 170 op_array->done_pass_two = 0; 171 #endif 168 172 169 173 return 0; … … 174 178 zend_op *opline, *end; 175 179 180 #ifndef ZEND_ENGINE_2_4 176 181 if (op_array->done_pass_two) { 177 182 return 0; 178 183 } 184 #endif 179 185 180 186 /* … … 186 192 end = opline + op_array->last; 187 193 while (opline < end) { 188 if ( opline->op1.op_type== IS_CONST) {189 Z_SET_ISREF( opline->op1.u.constant);190 Z_SET_REFCOUNT( opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */191 192 } 193 if ( opline->op2.op_type== IS_CONST) {194 Z_SET_ISREF( opline->op2.u.constant);195 Z_SET_REFCOUNT( opline->op2.u.constant, 2);194 if (Z_OP_TYPE(opline->op1) == IS_CONST) { 195 Z_SET_ISREF(Z_OP_CONSTANT(opline->op1)); 196 Z_SET_REFCOUNT(Z_OP_CONSTANT(opline->op1), 2); /* Make sure is_ref won't be reset */ 197 198 } 199 if (Z_OP_TYPE(opline->op2) == IS_CONST) { 200 Z_SET_ISREF(Z_OP_CONSTANT(opline->op2)); 201 Z_SET_REFCOUNT(Z_OP_CONSTANT(opline->op2), 2); 196 202 } 197 203 #ifdef ZEND_ENGINE_2_1 … … 201 207 #endif 202 208 case ZEND_JMP: 203 assert( opline->op1.u.opline_num < op_array->last);204 opline->op1.u.jmp_addr = op_array->opcodes + opline->op1.u.opline_num;209 assert(Z_OP(opline->op1).opline_num < op_array->last); 210 Z_OP(opline->op1).jmp_addr = op_array->opcodes + Z_OP(opline->op1).opline_num; 205 211 break; 206 212 case ZEND_JMPZ: … … 211 217 case ZEND_JMP_SET: 212 218 #endif 213 assert( opline->op2.u.opline_num < op_array->last);214 opline->op2.u.jmp_addr = op_array->opcodes + opline->op2.u.opline_num;219 assert(Z_OP(opline->op2).opline_num < op_array->last); 220 Z_OP(opline->op2).jmp_addr = op_array->opcodes + Z_OP(opline->op2).opline_num; 215 221 break; 216 222 } … … 220 226 } 221 227 228 #ifndef ZEND_ENGINE_2_4 222 229 op_array->done_pass_two = 1; 230 #endif 223 231 return 0; 224 232 } … … 226 234 227 235 #ifdef HAVE_XCACHE_OPCODE_SPEC_DEF 228 static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, z node *znode, int type TSRMLS_DC) /* {{{ */236 static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, zend_uchar *op_type, znode_op *op, int type TSRMLS_DC) /* {{{ */ 229 237 { 230 238 #ifdef ZEND_ENGINE_2 231 if (( znode->op_type != IS_UNUSED && (spec == OPSPEC_UCLASS || spec == OPSPEC_CLASS)) ||239 if ((*op_type != IS_UNUSED && (spec == OPSPEC_UCLASS || spec == OPSPEC_CLASS)) || 232 240 spec == OPSPEC_FETCH) { 233 241 if (tofix) { 234 switch ( znode->op_type) {242 switch (*op_type) { 235 243 case IS_VAR: 236 244 case IS_TMP_VAR: … … 239 247 default: 240 248 /* TODO: data lost, find a way to keep it */ 241 /* assert( znode->op_type == IS_CONST); */242 znode->op_type = IS_TMP_VAR;249 /* assert(*op_type == IS_CONST); */ 250 *op_type = IS_TMP_VAR; 243 251 } 244 252 } 245 253 } 246 switch ( znode->op_type) {254 switch (*op_type) { 247 255 case IS_TMP_VAR: 248 256 case IS_VAR: 249 257 if (tofix) { 250 znode->u.var /= sizeof(temp_variable);258 Z_OP(*op).var /= sizeof(temp_variable); 251 259 } 252 260 else { 253 znode->u.var *= sizeof(temp_variable);261 Z_OP(*op).var *= sizeof(temp_variable); 254 262 } 255 263 } … … 270 278 spec = xc_get_opcode_spec(opline->opcode); 271 279 272 xc_fix_opcode_ex_znode(tofix, spec->op1, & opline->op1, 0 TSRMLS_CC);273 xc_fix_opcode_ex_znode(tofix, spec->op2, & opline->op2, 1 TSRMLS_CC);274 xc_fix_opcode_ex_znode(tofix, spec->res, & opline->result, 2 TSRMLS_CC);280 xc_fix_opcode_ex_znode(tofix, spec->op1, &Z_OP_TYPE(opline->op1), &opline->op1, 0 TSRMLS_CC); 281 xc_fix_opcode_ex_znode(tofix, spec->op2, &Z_OP_TYPE(opline->op2), &opline->op2, 1 TSRMLS_CC); 282 xc_fix_opcode_ex_znode(tofix, spec->res, &Z_OP_TYPE(opline->result), &opline->result, 2 TSRMLS_CC); 275 283 } 276 284 } … … 304 312 #endif 305 313 case ZEND_JMP: 306 next = begin + opline->op1.u.opline_num;314 next = begin + Z_OP(opline->op1).opline_num; 307 315 break; 308 316 309 317 case ZEND_JMPZNZ: 310 next = begin + max( opline->op2.u.opline_num, opline->extended_value);318 next = begin + max(Z_OP(opline->op2).opline_num, opline->extended_value); 311 319 break; 312 320 … … 318 326 case ZEND_JMP_SET: 319 327 #endif 320 next = begin + opline->op2.u.opline_num;328 next = begin + Z_OP(opline->op2).opline_num; 321 329 break; 322 330 … … 371 379 } 372 380 373 parent_name = &( opline - 1)->op2.u.constant;381 parent_name = &(Z_OP_CONSTANT((opline - 1)->op2)); 374 382 TRACE("binding with parent %s", Z_STRVAL_P(parent_name)); 375 383 if (zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) { … … 387 395 zend_op *fetch_class_opline = opline - 1; 388 396 389 TRACE("%s %p", Z_STRVAL( fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant));397 TRACE("%s %p", Z_STRVAL(Z_OP_CONSTANT(fetch_class_opline->op2)), Z_STRVAL(Z_OP_CONSTANT(fetch_class_opline->op2))); 390 398 OP_ZVAL_DTOR(fetch_class_opline->op2); 391 399 fetch_class_opline->opcode = ZEND_NOP; … … 421 429 } 422 430 423 zend_hash_del(class_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len);431 zend_hash_del(class_table, Z_OP_CONSTANT(opline->op1).value.str.val, Z_OP_CONSTANT(opline->op1).value.str.len); 424 432 OP_ZVAL_DTOR(opline->op1); 425 433 OP_ZVAL_DTOR(opline->op2); … … 512 520 ZESW(&stored_ce_ptr, NULL) 513 521 ) == FAILURE) { 514 CG(zend_lineno) = ZESW(0, cep->line_start);522 CG(zend_lineno) = ZESW(0, Z_CLASS_INFO(*cep).line_start); 515 523 #ifdef IS_UNICODE 516 524 zend_error(E_ERROR, "Cannot redeclare class %R", type, cep->name);

