XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1469 lines
37 KiB

  1. dnl ================
  2. /* {{{ Pre-declare */
  3. DECL_STRUCT_P_FUNC(`zval')
  4. DECL_STRUCT_P_FUNC(`zval_ptr')
  5. DECL_STRUCT_P_FUNC(`zval_ptr_nullable')
  6. DECL_STRUCT_P_FUNC(`zend_op_array')
  7. DECL_STRUCT_P_FUNC(`zend_class_entry')
  8. #ifdef HAVE_XCACHE_CONSTANT
  9. DECL_STRUCT_P_FUNC(`zend_constant')
  10. #endif
  11. DECL_STRUCT_P_FUNC(`zend_function')
  12. DECL_STRUCT_P_FUNC(`xc_entry_var_t')
  13. DECL_STRUCT_P_FUNC(`xc_entry_php_t')
  14. #ifdef ZEND_ENGINE_2
  15. DECL_STRUCT_P_FUNC(`zend_property_info')
  16. #endif
  17. /* }}} */
  18. dnl ====================================================
  19. #ifdef IS_CV
  20. DEF_STRUCT_P_FUNC(`zend_compiled_variable', , `dnl {{{
  21. PROCESS(int, name_len)
  22. PROC_ZSTRING_L(, name, name_len)
  23. PROCESS(ulong, hash_value)
  24. ')
  25. dnl }}}
  26. #endif
  27. DEF_STRUCT_P_FUNC(`zend_uint', , `dnl {{{
  28. IFCOPY(`DST()[0] = SRC()[0];')
  29. IFDPRINT(`
  30. INDENT()
  31. fprintf(stderr, "%u\n", SRC()[0]);
  32. ')
  33. DONE_SIZE(sizeof(SRC()[0]))
  34. ')
  35. dnl }}}
  36. #ifndef ZEND_ENGINE_2
  37. DEF_STRUCT_P_FUNC(`int', , `dnl {{{
  38. IFCOPY(`*DST() = *SRC();')
  39. IFDPRINT(`
  40. INDENT()
  41. fprintf(stderr, "%d\n", SRC()[0]);
  42. ')
  43. DONE_SIZE(sizeof(SRC()[0]))
  44. ')
  45. dnl }}}
  46. #endif
  47. #ifdef ZEND_ENGINE_2
  48. DEF_STRUCT_P_FUNC(`zend_try_catch_element', , `dnl {{{
  49. PROCESS(zend_uint, try_op)
  50. PROCESS(zend_uint, catch_op)
  51. #ifdef ZEND_ENGINE_2_5
  52. PROCESS(zend_uint, finally_op)
  53. PROCESS(zend_uint, finally_end)
  54. #endif
  55. ')
  56. dnl }}}
  57. #endif
  58. DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `dnl {{{
  59. #ifdef ZEND_ENGINE_2_2
  60. PROCESS(int, start)
  61. #endif
  62. PROCESS(int, cont)
  63. PROCESS(int, brk)
  64. PROCESS(int, parent)
  65. ')
  66. dnl }}}
  67. DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr')
  68. DEF_HASH_TABLE_FUNC(`HashTable_zend_function', `zend_function')
  69. #ifdef ZEND_ENGINE_2
  70. DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info')
  71. #endif
  72. #ifdef IS_CONSTANT_AST
  73. define(`ZEND_AST_HELPER', `dnl {{{
  74. {
  75. IFCALCCOPY(`
  76. size_t zend_ast_size = ($1->kind == ZEND_CONST)
  77. ? sizeof(zend_ast) + sizeof(zval)
  78. : sizeof(zend_ast) + sizeof(zend_ast *) * ($1->children - 1);
  79. ')
  80. pushdef(`ALLOC_SIZE_HELPER', `zend_ast_size')
  81. $2
  82. popdef(`ALLOC_SIZE_HELPER')
  83. }
  84. ')
  85. dnl }}}
  86. DEF_STRUCT_P_FUNC(`zend_ast', , `dnl {{{
  87. zend_ushort i;
  88. PROCESS(zend_ushort, kind)
  89. PROCESS(zend_ushort, children)
  90. DONE(u)
  91. DISABLECHECK(`
  92. if (SRC()->kind == ZEND_CONST) {
  93. assert(SRC()->u.val);
  94. IFCOPY(`
  95. DST()->u.val = (zval *) (DST() + 1);
  96. memcpy(DST()->u.val, SRC()->u.val, sizeof(zval));
  97. ')
  98. STRUCT_P_EX(zval, DST()->u.val, SRC()->u.val, `[]', `', ` ')
  99. RELOCATE_EX(zval, DST()->u.val)
  100. }
  101. else {
  102. for (i = 0; i < SRC()->children; ++i) {
  103. zend_ast *src_ast = (&SRC()->u.child)[i];
  104. if (src_ast) {
  105. ZEND_AST_HELPER(`src_ast', `
  106. ALLOC(`(&DST()->u.child)[i]', zend_ast)
  107. STRUCT_P_EX(zend_ast, (&DST()->u.child)[i], src_ast, `[]', `', ` ')
  108. ')
  109. RELOCATE_EX(zend_ast, (&DST()->u.child)[i])
  110. }
  111. else {
  112. SETNULL_EX(`(&DST()->u.child)[i]', `[]')
  113. }
  114. }
  115. }
  116. ')
  117. ')
  118. dnl }}}
  119. #endif
  120. DEF_STRUCT_P_FUNC(`zend_object', , `dnl {{{
  121. IFCALC(`
  122. xc_var_collect_class(processor, SRC(ce) TSRMLS_CC);
  123. DONE(ce)
  124. ', `IFSTORE(`
  125. DST(ce) = (zend_class_entry *) xc_var_store_ce(processor, SRC(ce) TSRMLS_CC);
  126. DONE(ce)
  127. ', `IFRESTORE(`
  128. assert(processor->index_to_ce);
  129. DST(ce) = processor->index_to_ce[(size_t) SRC(ce)];
  130. DONE(ce)
  131. ', `
  132. PROCESS_SCALAR(ce, lu, unsigned long)
  133. ')')')
  134. STRUCT_P(HashTable, properties, HashTable_zval_ptr)
  135. #ifdef ZEND_ENGINE_2_4
  136. dnl TODO: how to rebuild properties_table
  137. STRUCT_ARRAY(int, ce->default_properties_count, zval_ptr, properties_table)
  138. #endif
  139. #ifdef ZEND_ENGINE_2
  140. COPYNULL(`guards')
  141. #endif
  142. ')
  143. dnl }}}
  144. #ifdef ZEND_ENGINE_2
  145. DEF_STRUCT_P_FUNC(`zend_object_value', , `dnl {{{
  146. IFCALC(`
  147. xc_var_collect_object(processor, SRC(handle) TSRMLS_CC);
  148. DONE(handle)
  149. ', `IFSTORE(`
  150. DST(handle) = (zend_object_handle) xc_var_store_handle(processor, SRC(handle) TSRMLS_CC);
  151. DONE(handle)
  152. ', `IFRESTORE(`
  153. DST(handle) = xc_var_restore_handle(processor, (size_t) SRC(handle) TSRMLS_CC);
  154. DONE(handle)
  155. ', `
  156. PROCESS(zend_object_handle, handle)
  157. ')')')
  158. COPY(handlers)
  159. ')
  160. dnl }}}
  161. #endif
  162. DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
  163. IFDASM(`do {
  164. zval_dtor(DST());
  165. *DST() = *SRC();
  166. zval_copy_ctor(DST());
  167. Z_SET_REFCOUNT(*DST(), 1);
  168. DONE(value)
  169. DONE(type)
  170. #ifdef ZEND_ENGINE_2_3
  171. DONE(is_ref__gc)
  172. DONE(refcount__gc)
  173. #else
  174. DONE(is_ref)
  175. DONE(refcount)
  176. #endif
  177. } while(0);
  178. ', `
  179. dnl IFDASM else
  180. /* Variable information */
  181. dnl {{{ zvalue_value
  182. DISABLECHECK(`
  183. switch ((Z_TYPE_P(SRC()) & IS_CONSTANT_TYPE_MASK)) {
  184. case IS_LONG:
  185. case IS_BOOL:
  186. PROCESS(long, value.lval)
  187. break;
  188. case IS_DOUBLE:
  189. PROCESS(double, value.dval)
  190. break;
  191. case IS_NULL:
  192. IFDPRINT(`INDENT()`'fprintf(stderr, "\tNULL\n");')
  193. break;
  194. case IS_CONSTANT:
  195. #ifdef IS_UNICODE
  196. if (UG(unicode)) {
  197. goto proc_unicode;
  198. }
  199. #endif
  200. case IS_STRING:
  201. #ifdef FLAG_IS_BC
  202. case FLAG_IS_BC:
  203. #endif
  204. PROCESS(int, value.str.len)
  205. IFRESTORE(`
  206. TRACE("%p, %p, %d", src->value.str.val, processor->entry_php_src->filepath.str, src->value.str.val == processor->entry_php_src->filepath.str);
  207. ')
  208. PROC_STRING_L(value.str.val, value.str.len)
  209. dnl IFSTORE(`
  210. dnl TRACE("%s, %d", dst->value.str.val, dst->value.str.val == processor->entry_php_dst->filepath.str);
  211. dnl ')
  212. break;
  213. #ifdef IS_UNICODE
  214. case IS_UNICODE:
  215. proc_unicode:
  216. PROCESS(int32_t, value.uni.len)
  217. PROC_ZSTRING_L(1, value.uni.val, value.uni.len)
  218. break;
  219. #endif
  220. case IS_ARRAY:
  221. #ifdef IS_CONSTANT_ARRAY
  222. case IS_CONSTANT_ARRAY:
  223. #endif
  224. assert(SRC()->value.ht);
  225. STRUCT_P(HashTable, value.ht, HashTable_zval_ptr)
  226. break;
  227. #ifdef IS_CONSTANT_AST
  228. case IS_CONSTANT_AST:
  229. assert(SRC()->value.ast);
  230. ZEND_AST_HELPER(`SRC()->value.ast', `STRUCT_P(zend_ast, value.ast)')
  231. break;
  232. #endif
  233. case IS_OBJECT:
  234. #ifdef ZEND_ENGINE_2
  235. STRUCT(zend_object_value, value.obj)
  236. #else
  237. STRUCT(zend_object, value.obj)
  238. #endif
  239. break;
  240. default:
  241. /* IS_RESOURCE */
  242. IFCOPY(`Z_TYPE_P(DST()) = IS_LONG;')
  243. PROCESS(long, value.lval)
  244. break;
  245. }
  246. ')
  247. dnl }}}
  248. DONE(value)
  249. PROCESS(xc_zval_type_t, type)
  250. #ifdef ZEND_ENGINE_2_3
  251. PROCESS(zend_uchar, is_ref__gc)
  252. #else
  253. PROCESS(zend_uchar, is_ref)
  254. #endif
  255. #ifdef ZEND_ENGINE_2_3
  256. PROCESS(zend_uint, refcount__gc)
  257. #elif defined(ZEND_ENGINE_2)
  258. PROCESS(zend_uint, refcount)
  259. #else
  260. PROCESS(zend_ushort, refcount)
  261. #endif
  262. ')dnl IFDASM
  263. ')
  264. dnl }}}
  265. DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
  266. IFDASM(`
  267. pushdefFUNC_NAME(`zval')
  268. FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
  269. popdef(`FUNC_NAME')
  270. ', `
  271. do {
  272. IFCALCCOPY(`
  273. if (processor->handle_reference) {
  274. zval_ptr *ppzv;
  275. if (zend_hash_find(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void **) &ppzv) == SUCCESS) {
  276. IFCOPY(`
  277. DST()[0] = *ppzv;
  278. /* *DST() is updated */
  279. dnl fprintf(stderr, "*DST() is set to %p, PROCESSOR_TYPE is_shm %d\n", DST()[0], xc_is_shm(DST()[0]));
  280. ')
  281. IFCALCSTORE(`processor->have_references = 1;')
  282. IFSTORE(`assert(xc_is_shm(DST()[0]));')
  283. IFRESTORE(`assert(!xc_is_shm(DST()[0]));')
  284. break;
  285. }
  286. }
  287. ')
  288. ALLOC(DST()[0], zval)
  289. IFCALCCOPY(`
  290. if (processor->handle_reference) {
  291. IFCALC(`
  292. /* make dummy */
  293. zval_ptr pzv = (zval_ptr)-1;
  294. ', `
  295. zval_ptr pzv = DST()[0];
  296. RELOCATE_EX(zval, pzv)
  297. ')
  298. if (zend_hash_add(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { /* first add, go on */
  299. dnl fprintf(stderr, "mark[%p] = %p\n", SRC()[0], pzv);
  300. }
  301. else {
  302. assert(0);
  303. }
  304. }
  305. ')
  306. IFCOPY(`
  307. dnl fprintf(stderr, "copy from %p to %p\n", SRC()[0], DST()[0]);
  308. ')
  309. IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) SRC()[0]);')
  310. STRUCT_P_EX(zval, DST()[0], SRC()[0], `[0]', `', ` ')
  311. RELOCATE_EX(zval, DST()[0])
  312. } while (0);
  313. ')
  314. DONE_SIZE(sizeof(zval_ptr))
  315. ')
  316. dnl }}}
  317. DEF_STRUCT_P_FUNC(`zval_ptr_nullable', , `dnl {{{
  318. if (SRC()[0]) {
  319. pushdef(`DASM_STRUCT_DIRECT')
  320. STRUCT_P_EX(zval_ptr, DST(), SRC(), `', `', ` ')
  321. popdef(`DASM_STRUCT_DIRECT')
  322. }
  323. else {
  324. IFCOPY(`COPYNULL_EX(DST()[0], SRC())')
  325. }
  326. DONE_SIZE(sizeof(zval_ptr_nullable))
  327. ')
  328. dnl }}}
  329. #ifdef ZEND_ENGINE_2
  330. DEF_STRUCT_P_FUNC(`zend_arg_info', , `dnl {{{
  331. PROCESS(zend_uint, name_len)
  332. PROC_ZSTRING_L(, name, name_len)
  333. PROCESS(zend_uint, class_name_len)
  334. PROC_ZSTRING_L(, class_name, class_name_len)
  335. #ifdef ZEND_ENGINE_2_4
  336. PROCESS(zend_uchar, type_hint)
  337. #elif defined(ZEND_ENGINE_2_1)
  338. PROCESS(zend_bool, array_type_hint)
  339. #endif
  340. #ifdef ZEND_ENGINE_2_6
  341. PROCESS(zend_uchar, pass_by_reference)
  342. #endif
  343. PROCESS(zend_bool, allow_null)
  344. #ifdef ZEND_ENGINE_2_6
  345. PROCESS(zend_bool, is_variadic)
  346. #else
  347. PROCESS(zend_bool, pass_by_reference)
  348. #endif
  349. #ifndef ZEND_ENGINE_2_4
  350. PROCESS(zend_bool, return_reference)
  351. PROCESS(int, required_num_args)
  352. #endif
  353. ')
  354. dnl }}}
  355. #endif
  356. #ifdef HAVE_XCACHE_CONSTANT
  357. DEF_STRUCT_P_FUNC(`zend_constant', , `dnl {{{
  358. STRUCT(zval, value)
  359. PROCESS(int, flags)
  360. PROCESS(uint, name_len)
  361. pushdef(`estrndup', `zend_strndup')
  362. PROC_ZSTRING_N(, name, name_len)
  363. popdef(`estrndup')
  364. PROCESS(int, module_number)
  365. ')
  366. dnl }}}
  367. #endif
  368. DEF_STRUCT_P_FUNC(`zend_function', , `dnl {{{
  369. DISABLECHECK(`
  370. switch (SRC(`type')) {
  371. case ZEND_INTERNAL_FUNCTION:
  372. case ZEND_OVERLOADED_FUNCTION:
  373. IFNOTMEMCPY(`IFCOPY(`memcpy(DST(), SRC(), sizeof(SRC()[0]));')')
  374. break;
  375. case ZEND_USER_FUNCTION:
  376. case ZEND_EVAL_CODE:
  377. DONE(type)
  378. STRUCT(zend_op_array, op_array)
  379. break;
  380. default:
  381. assert(0);
  382. }
  383. ')
  384. DONE_SIZE(sizeof(SRC()[0]))
  385. ')
  386. dnl }}}
  387. #ifdef ZEND_ENGINE_2
  388. DEF_STRUCT_P_FUNC(`zend_property_info', , `dnl {{{
  389. PROCESS(zend_uint, flags)
  390. PROCESS(int, name_length)
  391. PROC_ZSTRING_L(, name, name_length)
  392. PROCESS(ulong, h)
  393. #ifdef ZEND_ENGINE_2_4
  394. PROCESS(int, offset)
  395. #endif
  396. #ifdef ZEND_ENGINE_2_1
  397. PROCESS(int, doc_comment_len)
  398. PROC_ZSTRING_L(, doc_comment, doc_comment_len)
  399. #endif
  400. dnl isnt in php6 yet
  401. #if defined(ZEND_ENGINE_2_2)
  402. PROC_CLASS_ENTRY_P(ce)
  403. #endif
  404. ')
  405. dnl }}}
  406. #endif
  407. #ifdef ZEND_ENGINE_2_4
  408. DEF_STRUCT_P_FUNC(`zend_trait_method_reference', , `dnl {{{
  409. PROCESS(unsigned int, mname_len)
  410. PROC_STRING_L(method_name, mname_len)
  411. COPYNULL(ce)
  412. PROCESS(unsigned int, cname_len)
  413. PROC_STRING_L(class_name, cname_len)
  414. ')
  415. dnl }}}
  416. DEF_STRUCT_P_FUNC(`zend_trait_alias', , `dnl {{{
  417. STRUCT_P(zend_trait_method_reference, trait_method)
  418. PROCESS(unsigned int, alias_len)
  419. PROC_STRING_L(alias, alias_len)
  420. PROCESS(zend_uint, modifiers)
  421. #ifndef ZEND_ENGINE_2_5
  422. COPYNULL(function)
  423. #endif
  424. ')
  425. dnl }}}
  426. DEF_STRUCT_P_FUNC(`zend_trait_precedence', , `dnl {{{
  427. STRUCT_P(zend_trait_method_reference, trait_method)
  428. PROCESS_ARRAY(, xc_ztstring, exclude_from_classes, zend_class_entry*)
  429. #ifndef ZEND_ENGINE_2_5
  430. COPYNULL(function)
  431. #endif
  432. ')
  433. dnl }}}
  434. DEF_STRUCT_P_FUNC(`zend_trait_alias_ptr', , `dnl {{{
  435. IFDASM(`
  436. pushdefFUNC_NAME(`zend_trait_alias')
  437. FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
  438. popdef(`FUNC_NAME')
  439. ', `
  440. ALLOC(DST()[0], zend_trait_alias)
  441. STRUCT_P_EX(zend_trait_alias, DST()[0], SRC()[0], `[0]', `', ` ')
  442. RELOCATE_EX(zend_trait_alias, DST()[0])
  443. ')
  444. DONE_SIZE(sizeof(zend_trait_alias))
  445. ')
  446. dnl }}}
  447. DEF_STRUCT_P_FUNC(`zend_trait_precedence_ptr', , `dnl {{{
  448. IFDASM(`
  449. pushdefFUNC_NAME(`zend_trait_precedence')
  450. FUNC_NAME (dasm, DST(), SRC()[0] TSRMLS_CC);
  451. popdef(`FUNC_NAME')
  452. ', `
  453. ALLOC(DST()[0], zend_trait_precedence)
  454. STRUCT_P_EX(zend_trait_precedence, DST()[0], SRC()[0], `[0]', `', ` ')
  455. RELOCATE_EX(zend_trait_precedence, DST()[0])
  456. ')
  457. DONE_SIZE(sizeof(zend_trait_precedence))
  458. ')
  459. dnl }}}
  460. #endif
  461. DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
  462. IFCALCCOPY(`
  463. processor->active_class_entry_src = SRC();
  464. IFCOPY(`processor->active_class_entry_dst = DST();')
  465. ')
  466. PROCESS(char, type)
  467. PROCESS(zend_uint, name_length)
  468. PROC_ZSTRING_L(, name, name_length)
  469. IFRESTORE(`
  470. #ifndef ZEND_ENGINE_2
  471. /* just copy parent and resolve on install_class */
  472. COPYPOINTER(parent)
  473. #else
  474. PROC_CLASS_ENTRY_P(parent)
  475. #endif
  476. ', `
  477. PROC_CLASS_ENTRY_P(parent)
  478. ')
  479. #ifdef ZEND_ENGINE_2
  480. PROCESS(int, refcount)
  481. #else
  482. STRUCT_P(int, refcount)
  483. #endif
  484. #ifndef ZEND_ENGINE_2_4
  485. PROCESS(zend_bool, constants_updated)
  486. #endif
  487. #ifdef ZEND_ENGINE_2
  488. PROCESS(zend_uint, ce_flags)
  489. #endif
  490. #ifdef ZEND_ENGINE_2
  491. STRUCT(HashTable, properties_info, HashTable_zend_property_info)
  492. #endif
  493. #ifdef ZEND_ENGINE_2_4
  494. STRUCT_ARRAY(int, default_properties_count, zval_ptr_nullable, default_properties_table)
  495. PROCESS(int, default_properties_count)
  496. STRUCT_ARRAY(int, default_static_members_count, zval_ptr_nullable, default_static_members_table)
  497. PROCESS(int, default_static_members_count)
  498. IFCOPY(`DST(`static_members_table') = DST(`default_static_members_table');')
  499. DONE(static_members_table)
  500. #else
  501. IFCOPY(`DST(`builtin_functions') = SRC(`builtin_functions');')
  502. DONE(builtin_functions)
  503. STRUCT(HashTable, default_properties, HashTable_zval_ptr)
  504. # ifdef ZEND_ENGINE_2_1
  505. STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
  506. IFCOPY(`DST(`static_members') = &DST(`default_static_members');')
  507. DONE(static_members)
  508. # elif defined(ZEND_ENGINE_2)
  509. STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
  510. # endif
  511. #endif /* ZEND_ENGINE_2_4 */
  512. #ifdef ZEND_ENGINE_2
  513. STRUCT(HashTable, constants_table, HashTable_zval_ptr)
  514. #ifdef ZEND_ENGINE_2_2
  515. dnl runtime binding: ADD_INTERFACE will deal with it
  516. COPYNULL(`interfaces')
  517. COPYZERO(`num_interfaces')
  518. # ifdef ZEND_ENGINE_2_4
  519. dnl runtime binding: ADD_TRAIT will deal with it
  520. COPYNULL(traits)
  521. COPYZERO(num_traits)
  522. STRUCT_ARRAY(, , zend_trait_alias_ptr, trait_aliases)
  523. STRUCT_ARRAY(, , zend_trait_precedence_ptr, trait_precedences)
  524. # endif
  525. #else
  526. IFRESTORE(`
  527. if (SRC(`num_interfaces')) {
  528. CALLOC(DST(`interfaces'), zend_class_entry*, SRC(`num_interfaces'))
  529. DONE(`interfaces')
  530. }
  531. else {
  532. COPYNULL(`interfaces')
  533. }
  534. ', `
  535. DONE(`interfaces')
  536. ')
  537. PROCESS(zend_uint, num_interfaces)
  538. #endif
  539. # ifdef ZEND_ENGINE_2_4
  540. DISABLECHECK(`
  541. IFRESTORE(`DST(`info.user.filename') = processor->entry_php_src->filepath.str;', `PROC_STRING(info.user.filename)')
  542. PROCESS(zend_uint, info.user.line_start)
  543. PROCESS(zend_uint, info.user.line_end)
  544. PROCESS(zend_uint, info.user.doc_comment_len)
  545. PROC_ZSTRING_L(, info.user.doc_comment, info.user.doc_comment_len)
  546. ')
  547. DONE(info)
  548. # else
  549. IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath.str;DONE(filename)', `PROC_STRING(filename)')
  550. PROCESS(zend_uint, line_start)
  551. PROCESS(zend_uint, line_end)
  552. PROCESS(zend_uint, doc_comment_len)
  553. PROC_ZSTRING_L(, doc_comment, doc_comment_len)
  554. # endif
  555. /* # NOT DONE */
  556. # ifdef ZEND_ENGINE_2_1
  557. PROCESS_CTEXTPOINTER(serialize_func)
  558. PROCESS_CTEXTPOINTER(unserialize_func)
  559. # endif
  560. PROCESS_CTEXTPOINTER(iterator_funcs)
  561. PROCESS_CTEXTPOINTER(create_object)
  562. PROCESS_CTEXTPOINTER(get_iterator)
  563. PROCESS_CTEXTPOINTER(interface_gets_implemented)
  564. # ifdef ZEND_ENGINE_2_3
  565. PROCESS_CTEXTPOINTER(get_static_method)
  566. # endif
  567. # ifdef ZEND_ENGINE_2_1
  568. PROCESS_CTEXTPOINTER(serialize)
  569. PROCESS_CTEXTPOINTER(unserialize)
  570. # endif
  571. /* deal with it inside xc_fix_method */
  572. SETNULL(constructor)
  573. PROCESS_CTEXTPOINTER(destructor)
  574. PROCESS_CTEXTPOINTER(clone)
  575. PROCESS_CTEXTPOINTER(__get)
  576. PROCESS_CTEXTPOINTER(__set)
  577. /* should be >5.1 */
  578. # ifdef ZEND_ENGINE_2_1
  579. PROCESS_CTEXTPOINTER(__unset)
  580. PROCESS_CTEXTPOINTER(__isset)
  581. # endif
  582. PROCESS_CTEXTPOINTER(__call)
  583. # ifdef ZEND_CALLSTATIC_FUNC_NAME
  584. PROCESS_CTEXTPOINTER(__callstatic)
  585. # endif
  586. # if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
  587. PROCESS_CTEXTPOINTER(__tostring)
  588. # endif
  589. # if defined(ZEND_ENGINE_2_6)
  590. PROCESS_CTEXTPOINTER(__debugInfo)
  591. # endif
  592. # ifndef ZEND_ENGINE_2_4
  593. /* # NOT DONE */
  594. PROCESS_CTEXTPOINTER(module)
  595. # endif
  596. #else /* ZEND_ENGINE_2 */
  597. PROCESS_CTEXTPOINTER(handle_function_call)
  598. PROCESS_CTEXTPOINTER(handle_property_get)
  599. PROCESS_CTEXTPOINTER(handle_property_set)
  600. #endif
  601. dnl must do after SETNULL(constructor) and DST()->parent
  602. STRUCT(HashTable, function_table, HashTable_zend_function)
  603. IFRESTORE(`DST(`function_table.pDestructor') = ZEND_FUNCTION_DTOR;')
  604. IFCALCCOPY(`
  605. processor->active_class_entry_src = NULL;
  606. IFCOPY(`processor->active_class_entry_dst = NULL;')
  607. ')
  608. ')
  609. dnl }}}
  610. #ifdef ZEND_ENGINE_2_4
  611. undefine(`UNION_znode_op')
  612. define(`UNION_znode_op', `dnl {{{
  613. #ifndef NDEBUG
  614. switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
  615. case IS_CONST:
  616. case IS_VAR:
  617. case IS_CV:
  618. case IS_TMP_VAR:
  619. case IS_UNUSED:
  620. break;
  621. default:
  622. assert(0);
  623. }
  624. #endif
  625. dnl dirty dispatch
  626. DISABLECHECK(`
  627. switch ((SRC(`$1_type') ifelse($1, `result', & ~EXT_TYPE_UNUSED))) {
  628. case IS_CONST:
  629. ifelse($1, `result', `
  630. PROCESS(zend_uint, $1.constant)
  631. ', `
  632. IFDASM(`{
  633. zval *zv;
  634. zval *srczv = &dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
  635. ALLOC_ZVAL(zv);
  636. MAKE_COPY_ZVAL(&srczv, zv);
  637. add_assoc_zval_ex(DST(), XCACHE_STRS("$1.constant"), zv);
  638. }
  639. ', `
  640. IFCOPY(`
  641. DST(`$1') = SRC(`$1');
  642. ', `
  643. PROCESS(zend_uint, $1.constant)
  644. ')
  645. ')
  646. ')
  647. break;
  648. IFCOPY(`
  649. IFNOTMEMCPY(`
  650. default:
  651. DST(`$1') = SRC(`$1');
  652. ')
  653. ', `
  654. case IS_VAR:
  655. case IS_TMP_VAR:
  656. case IS_CV:
  657. PROCESS(zend_uint, $1.var)
  658. break;
  659. case IS_UNUSED:
  660. IFDASM(`PROCESS(zend_uint, $1.var)')
  661. PROCESS(zend_uint, $1.opline_num)
  662. break;
  663. ')
  664. }
  665. ')
  666. DONE($1)
  667. ')
  668. dnl }}}
  669. #else
  670. DEF_STRUCT_P_FUNC(`znode', , `dnl {{{
  671. PROCESS(xc_op_type, op_type)
  672. #ifdef IS_CV
  673. # define XCACHE_IS_CV IS_CV
  674. #else
  675. /* compatible with zend optimizer */
  676. # define XCACHE_IS_CV 16
  677. #endif
  678. assert(SRC(`op_type') == IS_CONST ||
  679. SRC(`op_type') == IS_VAR ||
  680. SRC(`op_type') == XCACHE_IS_CV ||
  681. SRC(`op_type') == IS_TMP_VAR ||
  682. SRC(`op_type') == IS_UNUSED);
  683. dnl dirty dispatch
  684. DISABLECHECK(`
  685. switch (SRC(`op_type')) {
  686. case IS_CONST:
  687. STRUCT(zval, u.constant)
  688. break;
  689. IFCOPY(`
  690. IFNOTMEMCPY(`
  691. default:
  692. DST(`u') = SRC(`u');
  693. ')
  694. ', `
  695. case IS_VAR:
  696. case IS_TMP_VAR:
  697. case XCACHE_IS_CV:
  698. PROCESS(zend_uint, u.var)
  699. PROCESS(zend_uint, u.EA.type)
  700. break;
  701. case IS_UNUSED:
  702. IFDASM(`PROCESS(zend_uint, u.var)')
  703. PROCESS(zend_uint, u.opline_num)
  704. #ifndef ZEND_ENGINE_2
  705. PROCESS(zend_uint, u.fetch_type)
  706. #endif
  707. PROCESS(zend_uint, u.EA.type)
  708. break;
  709. ')
  710. }
  711. ')
  712. DONE(u)
  713. #if 0
  714. DONE(EA)
  715. #endif
  716. #undef XCACHE_IS_CV
  717. ')
  718. dnl }}}
  719. #endif
  720. DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
  721. PROCESS(xc_opcode, opcode)
  722. #ifdef ZEND_ENGINE_2_4
  723. IFRESTORE(`', `
  724. switch (SRC(`opcode')) {
  725. case ZEND_BIND_TRAITS:
  726. ((zend_op *) SRC())->op2_type = IS_UNUSED;
  727. break;
  728. }
  729. ')
  730. UNION_znode_op(result)
  731. UNION_znode_op(op1)
  732. UNION_znode_op(op2)
  733. #else
  734. STRUCT(znode, result)
  735. STRUCT(znode, op1)
  736. STRUCT(znode, op2)
  737. #endif
  738. PROCESS(ulong, extended_value)
  739. PROCESS(uint, lineno)
  740. #ifdef ZEND_ENGINE_2_4
  741. PROCESS(zend_uchar, op1_type)
  742. PROCESS(zend_uchar, op2_type)
  743. PROCESS(zend_uchar, result_type)
  744. #endif
  745. IFCOPY(`
  746. assert(processor->active_op_array_src);
  747. assert(processor->active_op_array_dst);
  748. #ifdef ZEND_ENGINE_2_4
  749. pushdef(`UNION_znode_op_literal', `
  750. if (SRC(`$1_type') == IS_CONST) {
  751. DST(`$1').constant = SRC(`$1.literal') - processor->active_op_array_src->literals;
  752. DST(`$1').literal = &processor->active_op_array_dst->literals[DST(`$1').constant];
  753. }
  754. ')
  755. UNION_znode_op_literal(op1)
  756. UNION_znode_op_literal(op2)
  757. #endif
  758. popdef(`UNION_znode_op_literal')
  759. #ifdef ZEND_ENGINE_2
  760. switch (SRC(`opcode')) {
  761. # ifdef ZEND_GOTO
  762. case ZEND_GOTO:
  763. # endif
  764. case ZEND_JMP:
  765. # ifdef ZEND_FAST_CALL
  766. case ZEND_FAST_CALL:
  767. # endif
  768. assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes);
  769. assert(Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
  770. Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
  771. assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
  772. assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
  773. RELOCATE_EX(zend_op, `Z_OP(DST(`op1')).jmp_addr')
  774. break;
  775. case ZEND_JMPZ:
  776. case ZEND_JMPNZ:
  777. case ZEND_JMPZ_EX:
  778. case ZEND_JMPNZ_EX:
  779. # ifdef ZEND_JMP_SET
  780. case ZEND_JMP_SET:
  781. # endif
  782. # ifdef ZEND_JMP_SET_VAR
  783. case ZEND_JMP_SET_VAR:
  784. # endif
  785. assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes);
  786. assert(Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
  787. Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
  788. assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
  789. assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
  790. RELOCATE_EX(zend_op, `Z_OP(DST(`op2')).jmp_addr')
  791. break;
  792. default:
  793. break;
  794. }
  795. # endif
  796. ')
  797. #ifdef ZEND_ENGINE_2
  798. PROCESS(opcode_handler_t, handler)
  799. #endif
  800. ')
  801. dnl }}}
  802. #ifdef ZEND_ENGINE_2_4
  803. DEF_STRUCT_P_FUNC(`zend_literal', , `dnl {{{
  804. STRUCT(zval, constant)
  805. PROCESS(zend_ulong, hash_value)
  806. PROCESS(zend_uint, cache_slot)
  807. ')
  808. dnl }}}
  809. #endif
  810. DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
  811. IFCOPY(`
  812. processor->active_op_array_dst = DST();
  813. processor->active_op_array_src = SRC();
  814. ')
  815. IFDASM(`
  816. dasm->active_op_array_src = SRC();
  817. ')
  818. {
  819. IFRESTORE(`
  820. const xc_op_array_info_t *op_array_info = &processor->active_op_array_infos_src[processor->active_op_array_index++];
  821. dnl shadow copy must NOT meet:
  822. dnl readonly_protection=on
  823. dnl main op_array && have early binding
  824. #ifdef ZEND_COMPILE_DELAYED_BINDING
  825. zend_bool need_early_binding = 0;
  826. #else
  827. zend_bool need_early_binding = processor->php_src->have_early_binding;
  828. #endif
  829. zend_bool shallow_copy = !processor->readonly_protection && !(SRC() == processor->php_src->op_array && need_early_binding);
  830. if (shallow_copy) {
  831. zend_bool gc_arg_info = 0;
  832. zend_bool gc_opcodes = 0;
  833. #ifdef ZEND_ENGINE_2_4
  834. zend_bool gc_literals = 0;
  835. #endif
  836. /* really fast shallow copy */
  837. memcpy(DST(), SRC(), sizeof(SRC()[0]));
  838. DST(`refcount') = &XG(op_array_dummy_refcount_holder);
  839. XG(op_array_dummy_refcount_holder) = ((zend_uint) -1) / 2;
  840. #ifdef ZEND_ACC_ALIAS
  841. if ((processor->active_class_entry_src && (processor->active_class_entry_src->ce_flags & ZEND_ACC_TRAIT))) {
  842. PROC_ZSTRING(, function_name)
  843. }
  844. #endif
  845. /* deep */
  846. STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
  847. #ifdef ZEND_ENGINE_2
  848. if (SRC(`arg_info')) {
  849. gc_arg_info = 1;
  850. STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
  851. }
  852. #endif
  853. DST(`filename') = processor->entry_php_src->filepath.str;
  854. #ifdef ZEND_ENGINE_2_4
  855. if (SRC(`literals') && op_array_info->constantinfo_cnt) {
  856. gc_opcodes = 1;
  857. gc_literals = 1;
  858. }
  859. #else
  860. if (op_array_info->constantinfo_cnt) {
  861. gc_opcodes = 1;
  862. }
  863. #endif
  864. #ifdef ZEND_ENGINE_2_4
  865. if (gc_literals) {
  866. dnl used when copying opcodes
  867. COPY_N_EX(last_literal, zend_literal, literals)
  868. }
  869. #endif
  870. if (gc_opcodes) {
  871. zend_op *opline, *end;
  872. COPY_N_EX(last, zend_op, opcodes)
  873. for (opline = DST(`opcodes'), end = opline + SRC(`last'); opline < end; ++opline) {
  874. #ifdef ZEND_ENGINE_2_4
  875. pushdef(`UNION_znode_op_literal', `
  876. if (opline->$1_type == IS_CONST) {
  877. opline->$1.literal = &DST(`literals[opline->$1.literal - SRC(`literals')]');
  878. }
  879. ')
  880. UNION_znode_op_literal(op1)
  881. UNION_znode_op_literal(op2)
  882. popdef(`UNION_znode_op_literal')
  883. #endif
  884. switch (opline->opcode) {
  885. #ifdef ZEND_GOTO
  886. case ZEND_GOTO:
  887. #endif
  888. case ZEND_JMP:
  889. #ifdef ZEND_FAST_CALL
  890. case ZEND_FAST_CALL:
  891. #endif
  892. #ifdef ZEND_ENGINE_2
  893. Z_OP(opline->op1).jmp_addr = &DST(`opcodes[Z_OP(opline->op1).jmp_addr') - SRC(`opcodes')];
  894. #endif
  895. break;
  896. case ZEND_JMPZ:
  897. case ZEND_JMPNZ:
  898. case ZEND_JMPZ_EX:
  899. case ZEND_JMPNZ_EX:
  900. #ifdef ZEND_JMP_SET
  901. case ZEND_JMP_SET:
  902. #endif
  903. #ifdef ZEND_JMP_SET_VAR
  904. case ZEND_JMP_SET_VAR:
  905. #endif
  906. #ifdef ZEND_ENGINE_2
  907. Z_OP(opline->op2).jmp_addr = &DST(`opcodes[Z_OP(opline->op2).jmp_addr') - SRC(`opcodes')];
  908. #endif
  909. break;
  910. default:
  911. break;
  912. }
  913. }
  914. }
  915. if (gc_arg_info || gc_opcodes
  916. #ifdef ZEND_ENGINE_2_4
  917. || gc_literals
  918. #endif
  919. ) {
  920. xc_gc_op_array_t gc_op_array;
  921. #ifdef ZEND_ENGINE_2
  922. gc_op_array.num_args = gc_arg_info ? DST(`num_args') : 0;
  923. gc_op_array.arg_info = gc_arg_info ? DST(`arg_info') : NULL;
  924. #endif
  925. gc_op_array.opcodes = gc_opcodes ? DST(`opcodes') : NULL;
  926. #ifdef ZEND_ENGINE_2_4
  927. gc_op_array.literals = gc_literals ? DST(`literals') : NULL;
  928. #endif
  929. xc_gc_add_op_array(&gc_op_array TSRMLS_CC);
  930. }
  931. IFAUTOCHECK(`xc_autocheck_skip = 1;')
  932. }
  933. else
  934. ')
  935. do {
  936. dnl RESTORE is done above!
  937. /* Common elements */
  938. PROCESS(zend_uchar, type)
  939. PROC_ZSTRING(, function_name)
  940. #ifdef ZEND_ENGINE_2
  941. PROCESS(zend_uint, fn_flags)
  942. STRUCT_ARRAY(zend_uint, num_args, zend_arg_info, arg_info)
  943. PROCESS(zend_uint, num_args)
  944. PROCESS(zend_uint, required_num_args)
  945. # ifndef ZEND_ENGINE_2_4
  946. PROCESS(zend_bool, pass_rest_by_reference)
  947. # endif
  948. #else
  949. if (SRC(`arg_types')) {
  950. ALLOC(`DST(`arg_types')', zend_uchar, SRC(`arg_types[0]') + 1)
  951. IFCOPY(`memcpy(DST(`arg_types'), SRC(`arg_types'), sizeof(SRC(`arg_types[0]')) * (SRC(`arg_types[0]')+1));')
  952. IFDASM(`do {
  953. int i;
  954. zval *zv;
  955. ALLOC_INIT_ZVAL(zv);
  956. array_init(zv);
  957. for (i = 0; i < SRC(`arg_types[0]'); i ++) {
  958. add_next_index_long(zv, SRC(`arg_types[i + 1]'));
  959. }
  960. add_assoc_zval_ex(DST(), ZEND_STRS("arg_types"), zv);
  961. } while (0);')
  962. DONE(arg_types)
  963. }
  964. else {
  965. COPYNULL(arg_types)
  966. }
  967. #endif
  968. #ifndef ZEND_ENGINE_2_4
  969. PROCESS(unsigned char, return_reference)
  970. #endif
  971. /* END of common elements */
  972. #ifdef IS_UNICODE
  973. dnl SETNULL(u_twin)
  974. #endif
  975. IFSTORE(`pushdef(`RELOCATE_EX')')
  976. STRUCT_P(zend_uint, refcount)
  977. IFSTORE(`
  978. popdef(`RELOCATE_EX')
  979. DST(`refcount[0]') = 1;
  980. RELOCATE(zend_uint, refcount)
  981. ')
  982. #ifdef ZEND_ENGINE_2_4
  983. dnl used when copying opcodes
  984. STRUCT_ARRAY(int, last_literal, zend_literal, literals)
  985. PROCESS(int, last_literal)
  986. #endif
  987. dnl uses literals
  988. STRUCT_ARRAY(zend_uint, last, zend_op, opcodes)
  989. PROCESS(zend_uint, last)
  990. #ifndef ZEND_ENGINE_2_4
  991. IFCOPY(`DST(`size') = SRC(`last');DONE(size)', `PROCESS(zend_uint, size)')
  992. #endif
  993. #ifdef IS_CV
  994. STRUCT_ARRAY(int, last_var, zend_compiled_variable, vars)
  995. PROCESS(int, last_var)
  996. # ifndef ZEND_ENGINE_2_4
  997. IFCOPY(`DST(`size_var') = SRC(`last_var');DONE(size_var)', `PROCESS(zend_uint, size_var)')
  998. # endif
  999. #else
  1000. dnl zend_cv.m4 is illegal to be made public, don not ask me for it
  1001. IFDASM(`
  1002. sinclude(__dir__`/zend_cv.m4')
  1003. ')
  1004. #endif
  1005. PROCESS(zend_uint, T)
  1006. #ifdef ZEND_ENGINE_2_5
  1007. PROCESS(zend_uint, nested_calls)
  1008. PROCESS(zend_uint, used_stack)
  1009. #endif
  1010. STRUCT_ARRAY(last_brk_cont_t, last_brk_cont, zend_brk_cont_element, brk_cont_array)
  1011. PROCESS(last_brk_cont_t, last_brk_cont)
  1012. #ifndef ZEND_ENGINE_2_4
  1013. PROCESS(zend_uint, current_brk_cont)
  1014. #endif
  1015. #ifndef ZEND_ENGINE_2
  1016. PROCESS(zend_bool, uses_globals)
  1017. #endif
  1018. #ifdef ZEND_ENGINE_2
  1019. STRUCT_ARRAY(int, last_try_catch, zend_try_catch_element, try_catch_array)
  1020. PROCESS(int, last_try_catch)
  1021. #endif
  1022. #ifdef ZEND_ENGINE_2_5
  1023. PROCESS(zend_bool, has_finally_block)
  1024. #endif
  1025. STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
  1026. #ifndef ZEND_ENGINE_2_4
  1027. COPYPOINTER(start_op)
  1028. PROCESS(int, backpatch_count)
  1029. #endif
  1030. #ifdef ZEND_ENGINE_2_3
  1031. PROCESS(zend_uint, this_var)
  1032. #endif
  1033. #ifndef ZEND_ENGINE_2_4
  1034. PROCESS(zend_bool, done_pass_two)
  1035. #endif
  1036. /* 5.0 <= ver < 5.3 */
  1037. #if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_3)
  1038. PROCESS(zend_bool, uses_this)
  1039. #endif
  1040. IFRESTORE(`DST(`filename') = processor->entry_php_src->filepath.str; DONE(filename)', `PROC_STRING(filename)')
  1041. #ifdef IS_UNICODE
  1042. IFRESTORE(`
  1043. COPYPOINTER(script_encoding)
  1044. ', `
  1045. PROC_STRING(script_encoding)
  1046. ')
  1047. #endif
  1048. #ifdef ZEND_ENGINE_2
  1049. PROCESS(zend_uint, line_start)
  1050. PROCESS(zend_uint, line_end)
  1051. PROCESS(int, doc_comment_len)
  1052. PROC_ZSTRING_L(, doc_comment, doc_comment_len)
  1053. #endif
  1054. #ifdef ZEND_COMPILE_DELAYED_BINDING
  1055. PROCESS(zend_uint, early_binding);
  1056. #endif
  1057. /* reserved */
  1058. DONE(reserved)
  1059. #if defined(HARDENING_PATCH) && HARDENING_PATCH
  1060. PROCESS(zend_bool, created_by_eval)
  1061. #endif
  1062. #ifdef ZEND_ENGINE_2_4
  1063. SETNULL(run_time_cache)
  1064. PROCESS(int, last_cache_slot)
  1065. #endif
  1066. } while (0);
  1067. IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, DST(), shallow_copy, op_array_info TSRMLS_CC);')
  1068. #ifdef ZEND_ENGINE_2
  1069. dnl mark it as -1 on store, and lookup parent on restore
  1070. IFSTORE(`DST(`prototype') = (processor->active_class_entry_src && SRC(`prototype')) ? (zend_function *) -1 : NULL;', `
  1071. IFRESTORE(`do {
  1072. zend_function *parent;
  1073. if (SRC(`prototype') != NULL
  1074. && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
  1075. UG(unicode) ? IS_UNICODE : IS_STRING,
  1076. SRC(`function_name'), xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, SRC(`function_name')) + 1,
  1077. (void **) &parent) == SUCCESS) {
  1078. /* see do_inherit_method_check() */
  1079. if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)) {
  1080. DST(`prototype') = parent;
  1081. } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) {
  1082. /* ctors only have a prototype if it comes from an interface */
  1083. DST(`prototype') = parent->common.prototype ? parent->common.prototype : parent;
  1084. }
  1085. else {
  1086. DST(`prototype') = NULL;
  1087. }
  1088. }
  1089. else {
  1090. DST(`prototype') = NULL;
  1091. }
  1092. } while (0);
  1093. ')
  1094. ')
  1095. DONE(prototype)
  1096. #endif
  1097. #ifdef ZEND_ENGINE_2
  1098. PROC_CLASS_ENTRY_P(scope)
  1099. IFCOPY(`
  1100. if (SRC(`scope')) {
  1101. xc_fix_method(processor, DST() TSRMLS_CC);
  1102. }
  1103. ')
  1104. #endif
  1105. IFRESTORE(`
  1106. if (xc_have_op_array_ctor) {
  1107. zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) xc_zend_extension_op_array_ctor_handler, DST() TSRMLS_CC);
  1108. }
  1109. ')
  1110. }
  1111. IFCOPY(`
  1112. processor->active_op_array_dst = NULL;
  1113. processor->active_op_array_src = NULL;
  1114. ')
  1115. IFDASM(`
  1116. dasm->active_op_array_src = NULL;
  1117. ')
  1118. ')
  1119. dnl }}}
  1120. #ifdef HAVE_XCACHE_CONSTANT
  1121. DEF_STRUCT_P_FUNC(`xc_constinfo_t', , `dnl {{{
  1122. PROCESS(zend_uint, key_size)
  1123. #ifdef IS_UNICODE
  1124. PROCESS(zend_uchar, type)
  1125. #endif
  1126. IFRESTORE(`COPYPOINTER(key)', `
  1127. PROC_ZSTRING_N(type, key, key_size)
  1128. ')
  1129. PROCESS(ulong, h)
  1130. STRUCT(zend_constant, constant)
  1131. ')
  1132. dnl }}}
  1133. #endif
  1134. IFRESTORE(`', `
  1135. DEF_STRUCT_P_FUNC(`xc_constant_info_t', , `dnl {{{
  1136. PROCESS(zend_uint, index)
  1137. PROCESS(zend_uint, info)
  1138. ')
  1139. dnl }}}
  1140. DEF_STRUCT_P_FUNC(`xc_op_array_info_t', , `dnl {{{
  1141. PROCESS(zend_uint, constantinfo_cnt)
  1142. STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
  1143. ')
  1144. dnl }}}
  1145. ')
  1146. DEF_STRUCT_P_FUNC(`xc_funcinfo_t', , `dnl {{{
  1147. PROCESS(zend_uint, key_size)
  1148. #ifdef IS_UNICODE
  1149. PROCESS(zend_uchar, type)
  1150. #endif
  1151. IFRESTORE(`COPYPOINTER(key)', `
  1152. PROC_ZSTRING_N(type, key, key_size)
  1153. ')
  1154. PROCESS(ulong, h)
  1155. IFRESTORE(`COPYPOINTER(op_array_info)', `
  1156. STRUCT(xc_op_array_info_t, op_array_info)
  1157. ')
  1158. IFRESTORE(`
  1159. processor->active_op_array_infos_src = &SRC(`op_array_info');
  1160. processor->active_op_array_index = 0;
  1161. ')
  1162. STRUCT(zend_function, func)
  1163. ')
  1164. dnl }}}
  1165. DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{
  1166. PROCESS(zend_uint, key_size)
  1167. #ifdef IS_UNICODE
  1168. PROCESS(zend_uchar, type)
  1169. #endif
  1170. IFRESTORE(`COPYPOINTER(key)', `
  1171. PROC_ZSTRING_N(type, key, key_size)
  1172. ')
  1173. PROCESS(ulong, h)
  1174. PROCESS(zend_uint, methodinfo_cnt)
  1175. IFRESTORE(`COPYPOINTER(methodinfos)', `
  1176. STRUCT_ARRAY(zend_uint, methodinfo_cnt, xc_op_array_info_t, methodinfos)
  1177. ')
  1178. #ifdef ZEND_ENGINE_2
  1179. PROCESS(zend_uint, constantinfo_cnt)
  1180. IFRESTORE(`COPYPOINTER(constantinfos)', `
  1181. STRUCT_ARRAY(zend_uint, constantinfo_cnt, xc_constant_info_t, constantinfos)
  1182. ')
  1183. #endif
  1184. IFRESTORE(`
  1185. processor->active_op_array_infos_src = SRC(`methodinfos');
  1186. processor->active_op_array_index = 0;
  1187. ')
  1188. #ifdef ZEND_ENGINE_2
  1189. STRUCT_P(zend_class_entry, cest)
  1190. #else
  1191. STRUCT(zend_class_entry, cest)
  1192. #endif
  1193. #ifdef ZEND_ENGINE_2
  1194. IFRESTORE(`xc_fix_class_info(processor->entry_php_src, DST(), 0 TSRMLS_CC);')
  1195. #endif
  1196. #ifndef ZEND_COMPILE_DELAYED_BINDING
  1197. PROCESS(int, oplineno)
  1198. #endif
  1199. ')
  1200. dnl }}}
  1201. IFRESTORE(`', `
  1202. #ifdef ZEND_ENGINE_2_1
  1203. DEF_STRUCT_P_FUNC(`xc_autoglobal_t', , `dnl {{{
  1204. PROCESS(zend_uint, key_len)
  1205. #ifdef IS_UNICODE
  1206. PROCESS(zend_uchar, type)
  1207. #endif
  1208. IFRESTORE(`COPYPOINTER(key)', `
  1209. PROC_ZSTRING_L(type, key, key_len)
  1210. ')
  1211. PROCESS(ulong, h)
  1212. ')
  1213. dnl }}}
  1214. #endif
  1215. ')
  1216. IFRESTORE(`', `
  1217. #ifdef XCACHE_ERROR_CACHING
  1218. DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
  1219. PROCESS(int, type)
  1220. PROCESS(uint, lineno)
  1221. PROCESS(int, error_len)
  1222. PROC_STRING_L(error, error_len)
  1223. ')
  1224. dnl }}}
  1225. #endif
  1226. ')
  1227. DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
  1228. IFCOPY(`
  1229. processor->php_dst = DST();
  1230. processor->php_src = SRC();
  1231. ')
  1232. /* skip */
  1233. DONE(next)
  1234. PROCESS(xc_hash_value_t, hvalue)
  1235. PROCESS(xc_md5sum_t, md5)
  1236. PROCESS(zend_ulong, refcount)
  1237. PROCESS(zend_ulong, hits)
  1238. PROCESS(size_t, size)
  1239. IFRESTORE(`COPYPOINTER(op_array_info)', `
  1240. STRUCT(xc_op_array_info_t, op_array_info)
  1241. ')
  1242. IFRESTORE(`
  1243. processor->active_op_array_infos_src = &DST(`op_array_info');
  1244. processor->active_op_array_index = 0;
  1245. ')
  1246. STRUCT_P(zend_op_array, op_array)
  1247. #ifdef HAVE_XCACHE_CONSTANT
  1248. PROCESS(zend_uint, constinfo_cnt)
  1249. STRUCT_ARRAY(zend_uint, constinfo_cnt, xc_constinfo_t, constinfos)
  1250. #endif
  1251. PROCESS(zend_uint, funcinfo_cnt)
  1252. STRUCT_ARRAY(zend_uint, funcinfo_cnt, xc_funcinfo_t, funcinfos)
  1253. PROCESS(zend_uint, classinfo_cnt)
  1254. STRUCT_ARRAY(zend_uint, classinfo_cnt, xc_classinfo_t, classinfos, , IFCOPY(`processor->active_class_index'))
  1255. #ifdef ZEND_ENGINE_2_1
  1256. PROCESS(zend_uint, autoglobal_cnt)
  1257. IFRESTORE(`
  1258. COPYPOINTER(autoglobals)
  1259. ', `
  1260. STRUCT_ARRAY(zend_uint, autoglobal_cnt, xc_autoglobal_t, autoglobals)
  1261. ')
  1262. #endif
  1263. #ifdef XCACHE_ERROR_CACHING
  1264. PROCESS(zend_uint, compilererror_cnt)
  1265. IFRESTORE(`
  1266. COPYPOINTER(compilererrors)
  1267. ', `
  1268. STRUCT_ARRAY(zend_uint, compilererror_cnt, xc_compilererror_t, compilererrors)
  1269. ')
  1270. #endif
  1271. #ifndef ZEND_COMPILE_DELAYED_BINDING
  1272. PROCESS(zend_bool, have_early_binding)
  1273. #endif
  1274. PROCESS(zend_bool, have_references)
  1275. ')
  1276. dnl }}}
  1277. DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
  1278. /* skip */
  1279. DONE(next)
  1280. PROCESS(size_t, size)
  1281. PROCESS(time_t, ctime)
  1282. PROCESS(time_t, atime)
  1283. PROCESS(time_t, dtime)
  1284. PROCESS(long, ttl)
  1285. PROCESS(zend_ulong, hits)
  1286. DONE(name) dnl handle in xc_entry_php_t and xc_entry_var_t
  1287. ')
  1288. dnl }}}
  1289. DEF_STRUCT_P_FUNC(`xc_constant_string_t', , `dnl {{{
  1290. PROCESS(size_t, len)
  1291. IFRESTORE(`COPYPOINTER(str)', `PROC_STRING_L(str, len)')
  1292. ')
  1293. dnl }}}
  1294. #ifdef IS_UNICODE
  1295. DEF_STRUCT_P_FUNC(`xc_constant_u_string_t', , `dnl {{{
  1296. PROCESS(size_t, len)
  1297. IFRESTORE(`COPYPOINTER(str)', `PROC_USTRING_L(str, len)')
  1298. ')
  1299. dnl }}}
  1300. #endif
  1301. DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
  1302. STRUCT(xc_entry_t, entry)
  1303. DISABLECHECK(`
  1304. PROCESS(int, entry.name.str.len)
  1305. IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
  1306. PROC_STRING_L(entry.name.str.val, entry.name.str.len)
  1307. ')
  1308. ')
  1309. IFCALCCOPY(`COPYPOINTER(php)', `STRUCT_P(xc_entry_data_php_t, php)')
  1310. IFSTORE(`DST(`refcount') = 0; DONE(refcount)', `PROCESS(long, refcount)')
  1311. PROCESS(time_t, file_mtime)
  1312. PROCESS(size_t, file_size)
  1313. PROCESS(size_t, file_device)
  1314. PROCESS(size_t, file_inode)
  1315. STRUCT(xc_constant_string_t, filepath)
  1316. #ifdef ZEND_ENGINE_2_3
  1317. STRUCT(xc_constant_string_t, dirpath)
  1318. #endif
  1319. #ifdef IS_UNICODE
  1320. STRUCT(xc_constant_u_string_t, u_filepath)
  1321. STRUCT(xc_constant_u_string_t, u_dirpath)
  1322. #endif
  1323. ')
  1324. dnl }}}
  1325. DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
  1326. IFCALCSTORE(`xc_entry_var_t *vsrc = /* const_cast */ (xc_entry_var_t *) src;')
  1327. IFRESTORE(`processor->entry_var_src = src;')
  1328. dnl restore is done in foot.m4
  1329. STRUCT(xc_entry_t, entry)
  1330. #ifdef IS_UNICODE
  1331. PROCESS(zend_uchar, name_type)
  1332. #endif
  1333. dnl {{{ entry.name
  1334. DISABLECHECK(`
  1335. #ifdef IS_UNICODE
  1336. if (SRC(`name_type') == IS_UNICODE) {
  1337. PROCESS(int32_t, entry.name.ustr.len)
  1338. }
  1339. else {
  1340. PROCESS(int, entry.name.str.len)
  1341. }
  1342. #else
  1343. PROCESS(int, entry.name.str.len)
  1344. #endif
  1345. IFRESTORE(`COPYPOINTER(entry.name.str.val)', `
  1346. #ifdef IS_UNICODE
  1347. PROC_ZSTRING_L(name_type, entry.name.uni.val, entry.name.uni.len)
  1348. #else
  1349. PROC_STRING_L(entry.name.str.val, entry.name.str.len)
  1350. #endif
  1351. ')
  1352. ')
  1353. dnl }}}
  1354. IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
  1355. STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
  1356. #ifdef ZEND_ENGINE_2
  1357. IFCALC(`
  1358. dnl objects = collect_from(value);
  1359. pushdef(`src', `vsrc')
  1360. SRC(objects_count) = xc_vector_size(&processor->object_handles);
  1361. SRC(objects) = xc_vector_detach(zend_object, &processor->object_handles);
  1362. popdef(`src')
  1363. xc_vector_destroy(&processor->object_handles);
  1364. ')
  1365. dnl must be after calc .value
  1366. PROCESS(zend_uint, objects_count)
  1367. STRUCT_ARRAY(zend_uint, objects_count, zend_object, objects)
  1368. IFSTORE(`{
  1369. /* no longer needed */
  1370. if (vsrc->objects_count) {
  1371. efree(vsrc->objects);
  1372. vsrc->objects_count = 0;
  1373. vsrc->objects = NULL;
  1374. zend_hash_destroy(&processor->handle_to_index);
  1375. }
  1376. }')
  1377. #endif
  1378. dnl classe_
  1379. IFCALC(`
  1380. dnl class_names = collect_from(object_handles);
  1381. pushdef(`src', `vsrc')
  1382. SRC(class_names_count) = xc_vector_size(&processor->class_names);
  1383. SRC(class_names) = xc_vector_detach(xc_constant_string_t, &processor->class_names);
  1384. popdef(`src')
  1385. xc_vector_destroy(&processor->class_names);
  1386. ')
  1387. PROCESS(zend_uint, class_names_count)
  1388. STRUCT_ARRAY(zend_uint, class_names_count, xc_constant_string_t, class_names)
  1389. IFSTORE(`
  1390. /* no longer needed */
  1391. if (vsrc->class_names_count) {
  1392. efree(vsrc->class_names);
  1393. vsrc->class_names_count = 0;
  1394. vsrc->class_names = NULL;
  1395. zend_hash_destroy(&processor->class_name_to_index);
  1396. }
  1397. ')
  1398. PROCESS(zend_bool, have_references)
  1399. DONE(value)
  1400. ')
  1401. dnl }}}
  1402. dnl ====================================================