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.

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