RuntimeConfig.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "RuntimeConfig.h"
  2. #include "vm/Exception.h"
  3. namespace hybridclr
  4. {
  5. static int32_t s_threadObjectStackSize = 1024 * 128;
  6. static int32_t s_threadFrameStackSize = 1024 * 2;
  7. static int32_t s_threadExceptionFlowSize = 512;
  8. static int32_t s_maxMethodBodyCacheSize = 1024;
  9. static int32_t s_maxMethodInlineDepth = 3;
  10. int32_t RuntimeConfig::GetRuntimeOption(RuntimeOptionId optionId)
  11. {
  12. switch (optionId)
  13. {
  14. case RuntimeOptionId::InterpreterThreadObjectStackSize:
  15. return s_threadObjectStackSize;
  16. case RuntimeOptionId::InterpreterThreadFrameStackSize:
  17. return s_threadFrameStackSize;
  18. case RuntimeOptionId::InterpreterThreadExceptionFlowSize:
  19. return s_threadExceptionFlowSize;
  20. case RuntimeOptionId::MaxMethodBodyCacheSize:
  21. return s_maxMethodBodyCacheSize;
  22. case RuntimeOptionId::MaxMethodInlineDepth:
  23. return s_maxMethodInlineDepth;
  24. default:
  25. {
  26. TEMP_FORMAT(optionIdStr, "%d", optionId);
  27. il2cpp::vm::Exception::Raise(il2cpp::vm::Exception::GetArgumentException(optionIdStr, "invalid runtime option id"));
  28. return 0;
  29. }
  30. }
  31. }
  32. void RuntimeConfig::SetRuntimeOption(RuntimeOptionId optionId, int32_t value)
  33. {
  34. switch (optionId)
  35. {
  36. case hybridclr::RuntimeOptionId::InterpreterThreadObjectStackSize:
  37. s_threadObjectStackSize = value;
  38. break;
  39. case hybridclr::RuntimeOptionId::InterpreterThreadFrameStackSize:
  40. s_threadFrameStackSize = value;
  41. break;
  42. case hybridclr::RuntimeOptionId::InterpreterThreadExceptionFlowSize:
  43. s_threadExceptionFlowSize = value;
  44. break;
  45. case RuntimeOptionId::MaxMethodBodyCacheSize:
  46. s_maxMethodBodyCacheSize = value;
  47. break;
  48. case RuntimeOptionId::MaxMethodInlineDepth:
  49. s_maxMethodInlineDepth = value;
  50. break;
  51. default:
  52. {
  53. TEMP_FORMAT(optionIdStr, "%d", optionId);
  54. il2cpp::vm::Exception::Raise(il2cpp::vm::Exception::GetArgumentException(optionIdStr, "invalid runtime option id"));
  55. break;
  56. }
  57. }
  58. }
  59. uint32_t RuntimeConfig::GetInterpreterThreadObjectStackSize()
  60. {
  61. return s_threadObjectStackSize;
  62. }
  63. uint32_t RuntimeConfig::GetInterpreterThreadFrameStackSize()
  64. {
  65. return s_threadFrameStackSize;
  66. }
  67. uint32_t RuntimeConfig::GetInterpreterThreadExceptionFlowSize()
  68. {
  69. return s_threadExceptionFlowSize;
  70. }
  71. int32_t RuntimeConfig::GetMaxMethodBodyCacheSize()
  72. {
  73. return s_maxMethodBodyCacheSize;
  74. }
  75. int32_t RuntimeConfig::GetMaxMethodInlineDepth()
  76. {
  77. return s_maxMethodInlineDepth;
  78. }
  79. }