Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SerialExecutor to Support #1404

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API/hermes/inspector/chrome/tests/AsyncHermesRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <memory>
#include <mutex>

#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/SerialExecutor.h>

#include <hermes/hermes.h>
#include <jsi/jsi.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <functional>
#include <memory>
#include <mutex>
#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__)
#if LLVM_ADDRESS_SANITIZER_BUILD
#include <pthread.h>
#else
#include <thread>
Expand All @@ -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_;
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ add_subdirectory(ConsoleHost)
add_subdirectory(Regex)
add_subdirectory(Platform)
add_subdirectory(InternalBytecode)
add_subdirectory(SerialExecutor)
7 changes: 0 additions & 7 deletions lib/SerialExecutor/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_hermes_library(hermesSupport
PageAccessTrackerPosix.cpp
PerfSection.cpp
SemaphorePosix.cpp
SerialExecutor.cpp
SHA1.cpp
SNPrintfBuf.cpp
SourceErrorManager.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,29 @@
* LICENSE file in the root directory of this source tree.
*/

#include "hermes/SerialExecutor/SerialExecutor.h"
#include <cassert>

#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
Expand All @@ -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();
Expand Down Expand Up @@ -82,7 +80,7 @@ void SerialExecutor::run() {
}
}

#if !defined(_WINDOWS) && !defined(__EMSCRIPTEN__)
#ifdef LLVM_ADDRESS_SANITIZER_BUILD
void *SerialExecutor::threadMain(void *p) {
static_cast<SerialExecutor *>(p)->run();
pthread_exit(nullptr);
Expand Down
2 changes: 1 addition & 1 deletion tools/hcdp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/hcdp/hcdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ int main(void) {
#include <sstream>

#include <hermes/Parser/JSONParser.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/JSONEmitter.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/cdp/CDPAgent.h>
#include <hermes/cdp/CDPDebugAPI.h>
#include <hermes/cdp/MessageTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion unittests/API/AsyncDebuggerAPITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <gtest/gtest.h>

#include <hermes/AsyncDebuggerAPI.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/hermes.h>
#include <jsi/jsi.h>

Expand Down
2 changes: 1 addition & 1 deletion unittests/API/CDPAgentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include <hermes/AsyncDebuggerAPI.h>
#include <hermes/CompileJS.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/JSONEmitter.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/cdp/CDPAgent.h>
#include <hermes/cdp/CDPDebugAPI.h>
#include <hermes/cdp/JSONValueInterfaces.h>
Expand Down
2 changes: 1 addition & 1 deletion unittests/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading