user_config.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. /*************** feature settings ***************/
  3. // Whether to compile os-related modules or not
  4. #define PK_ENABLE_OS 1
  5. // Enable this if you are working with multi-threading (experimental)
  6. // This triggers necessary locks to make the VM thread-safe
  7. #define PK_ENABLE_THREAD 1
  8. // Enable this for `vm->_ceval_on_step`
  9. #define PK_ENABLE_CEVAL_CALLBACK 1
  10. // Whether to use `std::function` to do bindings or not
  11. // By default, functions to be binded must be a C function pointer without capture
  12. // However, someone thinks it's not convenient.
  13. // By setting this to 1, capturing lambdas can be binded,
  14. // but it's slower and may cause severe "code bloat", also needs more time to compile.
  15. #define PK_ENABLE_STD_FUNCTION 0
  16. /*************** debug settings ***************/
  17. // Enable this may help you find bugs
  18. #define PK_DEBUG_EXTRA_CHECK 0
  19. // Do not edit the following settings unless you know what you are doing
  20. #define PK_DEBUG_NO_BUILTINS 0
  21. #define PK_DEBUG_DIS_EXEC 0
  22. #define PK_DEBUG_CEVAL_STEP 0
  23. #define PK_DEBUG_FULL_EXCEPTION 0
  24. #define PK_DEBUG_MEMORY_POOL 0
  25. #define PK_DEBUG_NO_MEMORY_POOL 0
  26. #define PK_DEBUG_NO_AUTO_GC 0
  27. #define PK_DEBUG_GC_STATS 0
  28. /*************** internal settings ***************/
  29. // This is the maximum size of the value stack in void* units
  30. // The actual size in bytes equals `sizeof(void*) * PK_VM_STACK_SIZE`
  31. #define PK_VM_STACK_SIZE 32768
  32. // This is the maximum number of arguments in a function declaration
  33. // including positional arguments, keyword-only arguments, and varargs
  34. // (not recommended to change this / it should be less than 200)
  35. #define PK_MAX_CO_VARNAMES 32
  36. // Hash table load factor (smaller ones mean less collision but more memory)
  37. // For class instance
  38. #define PK_INST_ATTR_LOAD_FACTOR 0.67
  39. // For class itself
  40. #define PK_TYPE_ATTR_LOAD_FACTOR 0.5
  41. #ifdef _WIN32
  42. #define PK_PLATFORM_SEP '\\'
  43. #else
  44. #define PK_PLATFORM_SEP '/'
  45. #endif
  46. #ifdef _MSC_VER
  47. #pragma warning (disable:4267)
  48. #pragma warning (disable:4100)
  49. #pragma warning (disable:4244)
  50. #pragma warning (disable:4996)
  51. #endif
  52. #ifdef _MSC_VER
  53. #define PK_ENABLE_COMPUTED_GOTO 0
  54. #define PK_UNREACHABLE() __assume(0);
  55. #else
  56. #define PK_ENABLE_COMPUTED_GOTO 1
  57. #define PK_UNREACHABLE() __builtin_unreachable();
  58. #endif
  59. #if PK_DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO)
  60. #undef PK_ENABLE_COMPUTED_GOTO
  61. #endif