config.h 2.4 KB

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