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.
 
 
 
 
 
 

70 lines
2.5 KiB

  1. #ifdef ZEND_ENGINE_2
  2. static void xc_var_collect_object(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC) /* {{{ */
  3. {
  4. size_t next_index;
  5. if (!xc_vector_initialized(&processor->object_handles)) {
  6. xc_vector_init(zend_object, &processor->object_handles);
  7. zend_hash_init(&processor->handle_to_index, 0, NULL, NULL, 0);
  8. }
  9. next_index = xc_vector_size(&processor->object_handles);
  10. if (_zend_hash_index_update_or_next_insert(&processor->handle_to_index, handle, (void *) &next_index, sizeof(next_index), NULL, HASH_ADD ZEND_FILE_LINE_CC) == SUCCESS) {
  11. zend_object *object = zend_object_store_get_object_by_handle(handle TSRMLS_CC);
  12. xc_vector_push_back(&processor->object_handles, object);
  13. }
  14. }
  15. /* }}} */
  16. static size_t xc_var_store_handle(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC) /* {{{ */
  17. {
  18. size_t *index;
  19. if (zend_hash_index_find(&processor->handle_to_index, handle, (void **) &index) != SUCCESS) {
  20. php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: handle %d not found on store", handle);
  21. return (size_t) -1;
  22. }
  23. return *index;
  24. }
  25. /* }}} */
  26. static zend_object_handle xc_var_restore_handle(xc_processor_t *processor, size_t index TSRMLS_DC) /* {{{ */
  27. {
  28. zend_object_handle handle = xc_vector_data(zend_object_handle, &processor->object_handles)[index];
  29. zend_objects_store_add_ref_by_handle(handle TSRMLS_CC);
  30. return handle;
  31. }
  32. /* }}} */
  33. #endif
  34. static void xc_var_collect_class(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
  35. {
  36. size_t next_index;
  37. if (!xc_vector_initialized(&processor->class_names)) {
  38. xc_vector_init(xc_constant_string_t, &processor->class_names);
  39. zend_hash_init(&processor->class_name_to_index, 0, NULL, NULL, 0);
  40. }
  41. /* HashTable <=PHP_4 cannot handle NULL pointers, +1 needed */
  42. next_index = xc_vector_size(&processor->class_names) + 1;
  43. if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) {
  44. xc_constant_string_t class_name;
  45. class_name.str = (char *) ce->name;
  46. class_name.len = ce->name_length;
  47. xc_vector_push_back(&processor->class_names, &class_name);
  48. }
  49. }
  50. /* }}} */
  51. static size_t xc_var_store_ce(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
  52. {
  53. size_t *index;
  54. if (zend_hash_find(&processor->class_name_to_index, ce->name, ce->name_length, (void **) &index) != SUCCESS) {
  55. php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: class name not found in class names");
  56. return (size_t) - 1;
  57. }
  58. return *index - 1;
  59. }
  60. /* }}} */
  61. /* on restore */