gc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef VIRTUALMATH_GC_H
  2. #define VIRTUALMATH_GC_H
  3. struct Inter;
  4. struct Value;
  5. struct LinkValue;
  6. struct HashTable;
  7. struct Var;
  8. struct VarList;
  9. #if START_GC
  10. struct GCStatus{
  11. long int tmp_link; // tmp link的次数
  12. long int statement_link; // statement link的次数
  13. long int link; // 被直接link的次数
  14. enum {
  15. not_free,
  16. run_del,
  17. need_free,
  18. } c_value; // value的计数 (先call __del__ 后释放)
  19. bool continue_; // 是否迭代过
  20. };
  21. #else
  22. struct GCStatus {};
  23. #endif
  24. typedef struct GCStatus GCStatus;
  25. #if START_GC
  26. void setGC(GCStatus *gcs);
  27. void gc_addTmpLink(GCStatus *gcs);
  28. void gc_addStatementLink(GCStatus *gcs);
  29. void gc_freeTmpLink(GCStatus *gcs);
  30. void gc_freeStatementLink(GCStatus *gcs);
  31. void gc_runDelAll(struct Inter *inter);
  32. void gc_freeze(struct Inter *inter, struct VarList *freeze, struct VarList *base, bool is_lock);
  33. void gc_run(struct Inter *inter, struct VarList *run_var, int var_list, int link_value, int value, ...);
  34. #else
  35. #define gc_freeze(...)
  36. #define gc_run(...)
  37. #define setGC(...)
  38. #define gc_addTmpLink(...)
  39. #define gc_addStatementLink(...)
  40. #define gc_freeTmpLink(...)
  41. #define gc_freeStatementLink(...)
  42. #define gc_runDelAll(...)
  43. #endif
  44. #endif //VIRTUALMATH_GC_H