Skip to content

Commit

Permalink
Move SerialExecutor to Support (#1404)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1404

- Move SerialExecutor
- convert `throw`s to `assert`s so it can be built without exceptions
- only adjust the stack for ASAN if in an ASAN build

Reviewed By: neildhar

Differential Revision: D57689126

fbshipit-source-id: 06114de4be9493391507c9dc2fe2d689ec52b8ba
  • Loading branch information
Matt Blagden authored and facebook-github-bot committed Jun 3, 2024
1 parent 8d6af89 commit d208805
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 24 deletions.
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
File renamed without changes.
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,7 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

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

#include "hermes/Support/SerialExecutor.h"

namespace hermes {

Expand All @@ -14,22 +16,18 @@ SerialExecutor::SerialExecutor(size_t stackSize) {
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 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)

0 comments on commit d208805

Please sign in to comment.