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

Initial gc handling implementation #520

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
ignore = dirty
[submodule "deps/quickjs"]
path = deps/quickjs
url = https://github.com/quickjs-ng/quickjs.git
url = https://github.com/KaruroChori/quickjs.git
branch = gc-callbacks
[submodule "deps/mimalloc"]
path = deps/mimalloc
url = https://github.com/microsoft/mimalloc
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ set(TJS__VERSION_MINOR 12)
set(TJS__VERSION_PATCH 0)
set(TJS__VERSION_SUFFIX "")
configure_file(
"${CMAKE_SOURCE_DIR}/src/version.h.in"
"${CMAKE_SOURCE_DIR}/src/version.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/version.h"
)

macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
Expand Down Expand Up @@ -68,9 +68,8 @@ endif()

find_package(CURL REQUIRED)

add_executable(tjs
add_library(tjs STATIC
src/builtins.c
src/cli.c
src/curl-utils.c
src/curl-websocket.c
src/dns.c
Expand Down Expand Up @@ -101,7 +100,7 @@ add_executable(tjs
src/bundles/c/core/polyfills.c
src/bundles/c/core/run-main.c
src/bundles/c/core/worker-bootstrap.c
../deps/quickjs/cutils.c
deps/quickjs/cutils.c
)

if(NOT MINGW)
Expand All @@ -113,7 +112,7 @@ add_library(ffi-test SHARED
)

if(NOT USE_EXTERNAL_FFI AND NOT MINGW AND NOT APPLE)
set(LIBFFI_SRC "${CMAKE_SOURCE_DIR}/deps/libffi")
set(LIBFFI_SRC "${CMAKE_CURRENT_SOURCE_DIR}/deps/libffi")
set(TMP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ffi_root")
if(MINGW)
set(LIBFFI_STATIC_PATH ${TMP_INSTALL_DIR}/usr/local/lib/libffi.dll.a)
Expand Down Expand Up @@ -152,13 +151,22 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} TJS_PLATFORM)
target_compile_options(tjs PRIVATE ${tjs_cflags})
target_compile_definitions(tjs PRIVATE TJS__PLATFORM="${TJS_PLATFORM}")
target_include_directories(tjs PRIVATE ${CURL_INCLUDE_DIRS})
target_include_directories(tjs PUBLIC src)
target_link_libraries(tjs qjs uv_a m3 sqlite3 m pthread ${CURL_LIBRARIES})

if (BUILD_WITH_MIMALLOC)
target_compile_definitions(tjs PRIVATE TJS__HAS_MIMALLOC)
target_link_libraries(tjs mimalloc-static)
endif()

add_executable(tjs-cli
src/cli.c
)
target_link_libraries(tjs-cli tjs)
set_target_properties(tjs-cli
PROPERTIES OUTPUT_NAME tjs
)

add_executable(tjsc EXCLUDE_FROM_ALL
src/qjsc.c
)
Expand Down
Empty file added deps/extras/CMakeLists.txt
Empty file.
9 changes: 8 additions & 1 deletion docs/types/txikijs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ declare global {
/**
* Triggers a garbage collection cycle.
*/
function gc(): void;
interface gc {
run: ()=>void;
enabled: boolean;
threshold: number;
fixThreshold: boolean;
onBefore: ()=>boolean;
onAfter: ()=>void;
}

/**
* The txiki.js version.
Expand Down
Loading