CommonExternalApiImpl.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 "RuntimeLibraryPch.h"
  6. #include "Base/Exception.h"
  7. #include "Base/ThreadContextTlsEntry.h"
  8. void JsUtil::ExternalApi::RecoverUnusedMemory()
  9. {
  10. Js::Exception::RecoverUnusedMemory();
  11. }
  12. bool JsUtil::ExternalApi::RaiseOnIntOverflow()
  13. {
  14. ::Math::DefaultOverflowPolicy();
  15. }
  16. bool JsUtil::ExternalApi::RaiseOutOfMemoryIfScriptActive()
  17. {
  18. return Js::Exception::RaiseIfScriptActive(nullptr, Js::Exception::ExceptionKind_OutOfMemory);
  19. }
  20. bool JsUtil::ExternalApi::RaiseStackOverflowIfScriptActive(Js::ScriptContext * scriptContext, PVOID returnAddress)
  21. {
  22. return Js::Exception::RaiseIfScriptActive(scriptContext, Js::Exception::ExceptionKind_StackOverflow, returnAddress);
  23. }
  24. ThreadContextId JsUtil::ExternalApi::GetCurrentThreadContextId()
  25. {
  26. return ThreadContextTLSEntry::GetCurrentThreadContextId();
  27. }
  28. #if DBG || defined(EXCEPTION_CHECK)
  29. BOOL JsUtil::ExternalApi::IsScriptActiveOnCurrentThreadContext()
  30. {
  31. return ThreadContext::GetContextForCurrentThread() != nullptr &&
  32. ThreadContext::GetContextForCurrentThread()->IsScriptActive();
  33. }
  34. #endif