diff --git a/API/hermes/inspector/chrome/tests/AsyncHermesRuntime.h b/API/hermes/inspector/chrome/tests/AsyncHermesRuntime.h index 70b413b116f..aaaf9cd04c8 100644 --- a/API/hermes/inspector/chrome/tests/AsyncHermesRuntime.h +++ b/API/hermes/inspector/chrome/tests/AsyncHermesRuntime.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include diff --git a/include/hermes/SerialExecutor/SerialExecutor.h b/include/hermes/Support/SerialExecutor.h similarity index 92% rename from include/hermes/SerialExecutor/SerialExecutor.h rename to include/hermes/Support/SerialExecutor.h index 3735c5821df..3c18a740ab7 100644 --- a/include/hermes/SerialExecutor/SerialExecutor.h +++ b/include/hermes/Support/SerialExecutor.h @@ -15,7 +15,7 @@ #include #include #include -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#if LLVM_ADDRESS_SANITIZER_BUILD #include #else #include @@ -29,7 +29,7 @@ namespace hermes { class SerialExecutor { private: // The thread on which all work is done. -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#ifdef LLVM_ADDRESS_SANITIZER_BUILD pthread_t tid_; #else std::thread workerThread_; @@ -52,7 +52,7 @@ class SerialExecutor { /// they are posted. This stops running when shouldStop_ is set to true. void run(); -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#if LLVM_ADDRESS_SANITIZER_BUILD /// Main function of the new thread. static void *threadMain(void *p); #endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d0d83b7ac51..9c7d2724fcb 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -70,4 +70,3 @@ add_subdirectory(ConsoleHost) add_subdirectory(Regex) add_subdirectory(Platform) add_subdirectory(InternalBytecode) -add_subdirectory(SerialExecutor) diff --git a/lib/SerialExecutor/CMakeLists.txt b/lib/SerialExecutor/CMakeLists.txt deleted file mode 100644 index 7583aadec6d..00000000000 --- a/lib/SerialExecutor/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -add_hermes_library(hermesSerialExecutor SerialExecutor.cpp) -target_compile_options(hermesSerialExecutor PRIVATE -frtti -fexceptions) diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index e293423b21d..dde15857506 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt @@ -27,6 +27,7 @@ add_hermes_library(hermesSupport PageAccessTrackerPosix.cpp PerfSection.cpp SemaphorePosix.cpp + SerialExecutor.cpp SHA1.cpp SNPrintfBuf.cpp SourceErrorManager.cpp diff --git a/lib/SerialExecutor/SerialExecutor.cpp b/lib/Support/SerialExecutor.cpp similarity index 80% rename from lib/SerialExecutor/SerialExecutor.cpp rename to lib/Support/SerialExecutor.cpp index 51aa5a0e6dd..054c2df5e29 100644 --- a/lib/SerialExecutor/SerialExecutor.cpp +++ b/lib/Support/SerialExecutor.cpp @@ -5,31 +5,29 @@ * LICENSE file in the root directory of this source tree. */ -#include "hermes/SerialExecutor/SerialExecutor.h" +#include + +#include "hermes/Support/SerialExecutor.h" namespace hermes { SerialExecutor::SerialExecutor(size_t stackSize) { -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#ifdef LLVM_ADDRESS_SANITIZER_BUILD pthread_attr_t attr; int ret; + (void)ret; ret = pthread_attr_init(&attr); - if (ret != 0) { - throw std::runtime_error("Failed pthread_attr_init"); - } + assert(ret != 0 && "Failed pthread_attr_init"); if (stackSize != 0) { ret = pthread_attr_setstacksize(&attr, stackSize); - if (ret != 0) { - throw std::runtime_error("Failed pthread_attr_setstacksize"); - } + assert(ret != 0 && "Failed pthread_attr_setstacksize"); } ret = pthread_create(&tid_, &attr, SerialExecutor::threadMain, this); - if (ret != 0) { - throw std::runtime_error("Failed pthread_create"); - } + assert(ret != 0 && "Failed pthread_create"); + #else workerThread_ = std::thread([this]() { this->run(); }); #endif @@ -42,7 +40,7 @@ SerialExecutor::~SerialExecutor() { shouldStop_ = true; wakeUpSig_.notify_one(); } -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#ifdef LLVM_ADDRESS_SANITIZER_BUILD pthread_join(tid_, nullptr); #else workerThread_.join(); @@ -82,7 +80,7 @@ void SerialExecutor::run() { } } -#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__) +#ifdef LLVM_ADDRESS_SANITIZER_BUILD void *SerialExecutor::threadMain(void *p) { static_cast(p)->run(); pthread_exit(nullptr); diff --git a/tools/hcdp/CMakeLists.txt b/tools/hcdp/CMakeLists.txt index 7747e60430c..8c0e8e4021c 100644 --- a/tools/hcdp/CMakeLists.txt +++ b/tools/hcdp/CMakeLists.txt @@ -28,7 +28,7 @@ add_hermes_tool(hcdp ${ALL_HEADER_FILES} ) -target_link_libraries(hcdp hermesSerialExecutor libhermes hermesParser) +target_link_libraries(hcdp hermesSupport libhermes hermesParser) install(TARGETS hcdp RUNTIME DESTINATION bin diff --git a/tools/hcdp/hcdp.cpp b/tools/hcdp/hcdp.cpp index cc06362b6e4..caab79259cd 100644 --- a/tools/hcdp/hcdp.cpp +++ b/tools/hcdp/hcdp.cpp @@ -22,8 +22,8 @@ int main(void) { #include #include -#include #include +#include #include #include #include diff --git a/unittests/API/AsyncDebuggerAPITest.cpp b/unittests/API/AsyncDebuggerAPITest.cpp index c966529a9d7..0808717103c 100644 --- a/unittests/API/AsyncDebuggerAPITest.cpp +++ b/unittests/API/AsyncDebuggerAPITest.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/unittests/API/CDPAgentTest.cpp b/unittests/API/CDPAgentTest.cpp index fbb6a6201cf..2fce14d1861 100644 --- a/unittests/API/CDPAgentTest.cpp +++ b/unittests/API/CDPAgentTest.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/unittests/API/CMakeLists.txt b/unittests/API/CMakeLists.txt index e6352321c5a..eaefe2d6eac 100644 --- a/unittests/API/CMakeLists.txt +++ b/unittests/API/CMakeLists.txt @@ -56,7 +56,7 @@ add_hermes_unittest(APITests ${APITestsSources}) target_link_libraries(APITests libhermes compileJS SegmentTestCompile traceInterpreter timerStats hermesABIRuntimeWrapper hermesabi - hermesSandboxRuntime hermesSerialExecutor cdpInternal) + hermesSandboxRuntime hermesSupport cdpInternal) add_hermes_unittest(APILeanTests APILeanTest.cpp) target_link_libraries(APILeanTests libhermes_lean jsi)