user_config.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. namespace pkpy{
  37. // Hash table load factor (smaller ones mean less collision but more memory)
  38. // For class instance
  39. inline const float kInstAttrLoadFactor = 0.67f;
  40. // For class itself
  41. inline const float kTypeAttrLoadFactor = 0.5f;
  42. #ifdef _WIN32
  43. inline const char kPlatformSep = '\\';
  44. #else
  45. inline const char kPlatformSep = '/';
  46. #endif
  47. }
  48. #ifdef _MSC_VER
  49. #pragma warning (disable:4267)
  50. #pragma warning (disable:4100)
  51. #pragma warning (disable:4244)
  52. #pragma warning (disable:4996)
  53. #endif
  54. #ifdef _MSC_VER
  55. #define PK_ENABLE_COMPUTED_GOTO 0
  56. #define UNREACHABLE() __assume(0)
  57. #else
  58. #define PK_ENABLE_COMPUTED_GOTO 1
  59. #define UNREACHABLE() __builtin_unreachable()
  60. #endif
  61. #if PK_DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO)
  62. #undef PK_ENABLE_COMPUTED_GOTO
  63. #endif