StubExternalApi.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "Common.h"
  6. #include "CommonInl.h" // TODO: Try to remove this later
  7. #include "Core/ConfigParser.h"
  8. // TODO: REMOVE
  9. void js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count)
  10. {
  11. Assert((count) <= (sizeInBytes));
  12. if ((count) <= (sizeInBytes))
  13. memcpy((dst), (src), (count));
  14. else
  15. ReportFatalException(NULL, E_FAIL, Fatal_Internal_Error, 2);
  16. }
  17. void js_wmemcpy_s(__ecount(sizeInWords) char16 *dst, size_t sizeInWords, __in_ecount(count) const char16 *src, size_t count)
  18. {
  19. //Multiplication Overflow check
  20. Assert(count <= sizeInWords && count <= SIZE_MAX/sizeof(char16));
  21. if(!(count <= sizeInWords && count <= SIZE_MAX/sizeof(char16)))
  22. {
  23. ReportFatalException((ULONG_PTR) NULL, E_FAIL, Fatal_Internal_Error, 2);
  24. }
  25. else
  26. {
  27. memcpy(dst, src, count * sizeof(char16));
  28. }
  29. }
  30. bool ConfigParserAPI::FillConsoleTitle(__ecount(cchBufferSize) LPWSTR buffer, size_t cchBufferSize, __in LPWSTR moduleName)
  31. {
  32. swprintf_s(buffer, cchBufferSize, _u("Chakra GC: %d - %s"), GetCurrentProcessId(), moduleName);
  33. return true;
  34. }
  35. void ConfigParserAPI::DisplayInitialOutput(__in LPWSTR moduleName)
  36. {
  37. Output::Print(_u("Chakra GC\n"));
  38. Output::Print(_u("INIT: PID : %d\n"), GetCurrentProcessId());
  39. Output::Print(_u("INIT: DLL Path : %s\n"), moduleName);
  40. }
  41. #ifdef ENABLE_JS_ETW
  42. void EtwCallbackApi::OnSessionChange(ULONG /* controlCode */, PVOID /* callbackContext */)
  43. {
  44. // Does nothing
  45. }
  46. #endif
  47. // Include this file got get the default behavior for JsUtil::ExternalApi functions.
  48. void JsUtil::ExternalApi::RecoverUnusedMemory()
  49. {
  50. }
  51. bool JsUtil::ExternalApi::RaiseOutOfMemoryIfScriptActive()
  52. {
  53. return false;
  54. }
  55. bool JsUtil::ExternalApi::RaiseStackOverflowIfScriptActive(Js::ScriptContext * scriptContext, PVOID returnAddress)
  56. {
  57. return false;
  58. }
  59. ThreadContextId JsUtil::ExternalApi::GetCurrentThreadContextId()
  60. {
  61. return (ThreadContextId)::GetCurrentThreadId();
  62. }
  63. bool JsUtil::ExternalApi::RaiseOnIntOverflow()
  64. {
  65. return false;
  66. }
  67. LPCWSTR JsUtil::ExternalApi::GetFeatureKeyName()
  68. {
  69. return _u("Software\\Microsoft\\Internet Explorer\\ChakraRecycler");
  70. }
  71. #if DBG || defined(EXCEPTION_CHECK)
  72. BOOL JsUtil::ExternalApi::IsScriptActiveOnCurrentThreadContext()
  73. {
  74. return false;
  75. }
  76. #endif
  77. extern "C"
  78. {
  79. bool IsMessageBoxWPresent()
  80. {
  81. return true;
  82. }
  83. }
  84. bool GetDeviceFamilyInfo(
  85. _Out_opt_ ULONGLONG* /*pullUAPInfo*/,
  86. _Out_opt_ ULONG* /*pulDeviceFamily*/,
  87. _Out_opt_ ULONG* /*pulDeviceForm*/);
  88. void
  89. ChakraBinaryAutoSystemInfoInit(AutoSystemInfo * autoSystemInfo)
  90. {
  91. ULONGLONG UAPInfo;
  92. ULONG DeviceFamily;
  93. ULONG DeviceForm;
  94. if (GetDeviceFamilyInfo(&UAPInfo, &DeviceFamily, &DeviceForm))
  95. {
  96. bool isMobile = (DeviceFamily == 0x00000004 /*DEVICEFAMILYINFOENUM_MOBILE*/);
  97. autoSystemInfo->shouldQCMoreFrequently = isMobile;
  98. autoSystemInfo->supportsOnlyMultiThreadedCOM = isMobile; //TODO: pick some other platform to the list
  99. autoSystemInfo->isLowMemoryDevice = isMobile; //TODO: pick some other platform to the list
  100. }
  101. }
  102. enum MemProtectHeapCollectFlags {};
  103. enum MemProtectHeapCreateFlags {};
  104. HRESULT MemProtectHeapCreate(void ** heapHandle, MemProtectHeapCreateFlags flags) { return E_NOTIMPL; };
  105. void * MemProtectHeapRootAlloc(void * heapHandle, size_t size) { return nullptr; };
  106. void * MemProtectHeapRootAllocLeaf(void * heapHandle, size_t size) { return nullptr; };
  107. HRESULT MemProtectHeapUnrootAndZero(void * heapHandle, void * memory) { return E_NOTIMPL; };
  108. HRESULT MemProtectHeapMemSize(void * heapHandle, void * memory, size_t * outSize) { return E_NOTIMPL; };
  109. HRESULT MemProtectHeapDestroy(void * heapHandle) { return E_NOTIMPL; };
  110. HRESULT MemProtectHeapCollect(void * heapHandle, MemProtectHeapCollectFlags flags) { return E_NOTIMPL; };
  111. HRESULT MemProtectHeapProtectCurrentThread(void * heapHandle, void(__stdcall* threadWake)(void* threadWakeArgument), void* threadWakeArgument) { return E_NOTIMPL; };
  112. HRESULT MemProtectHeapUnprotectCurrentThread(void * heapHandle) { return E_NOTIMPL; };
  113. HRESULT MemProtectHeapSynchronizeWithCollector(void * heapHandle) { return E_NOTIMPL; };
  114. #if DBG && defined(INTERNAL_MEM_PROTECT_HEAP_ALLOC)
  115. void MemProtectHeapSetDisableConcurrentThreadExitedCheck(void * heapHandle) {};
  116. #endif
  117. #ifdef ENABLE_BASIC_TELEMETRY
  118. namespace Js
  119. {
  120. void GCTelemetry::LogGCPauseStartTime() {};
  121. void GCTelemetry::LogGCPauseEndTime() {};
  122. };
  123. #endif