Skip to content
Merged
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
4 changes: 4 additions & 0 deletions runtime/fastly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ add_builtin(fastly::html_rewriter

add_compile_definitions(PUBLIC RUNTIME_VERSION=${RUNTIME_VERSION})

if(DEFINED FASTLY_GC_FREQUENCY)
add_compile_definitions(PUBLIC FASTLY_GC_FREQUENCY=${FASTLY_GC_FREQUENCY})
endif()

project(FastlyJS)
31 changes: 29 additions & 2 deletions runtime/fastly/build-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,37 @@ set -euo pipefail
set -x

cd "$(dirname "$0")" || exit 1

# Parse command line arguments
KEEP_DEBUG_INFO=0
GC_FREQUENCY=""

while [[ $# -gt 0 ]]; do
case $1 in
--keep-debug-info)
KEEP_DEBUG_INFO=1
shift
;;
--gc-frequency)
if [[ -n "${2:-}" ]]; then
GC_FREQUENCY="-DFASTLY_GC_FREQUENCY=$2"
shift 2
else
echo "Error: --gc-frequency requires a value"
exit 1
fi
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done

RUNTIME_VERSION=$(npm pkg get version --json --prefix=../../ | jq -r)
HOST_API=$(realpath host-api) cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILTIN_WEB_FETCH=0 -DENABLE_BUILTIN_WEB_FETCH_FETCH_EVENT=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUNTIME_VERSION="\"$RUNTIME_VERSION-debug\"" -DENABLE_JS_DEBUGGER=OFF
HOST_API=$(realpath host-api) cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILTIN_WEB_FETCH=0 -DENABLE_BUILTIN_WEB_FETCH_FETCH_EVENT=0 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUNTIME_VERSION="\"$RUNTIME_VERSION-debug\"" -DENABLE_JS_DEBUGGER=OFF "$GC_FREQUENCY"
cmake --build build-debug --parallel 10
if [ "${1:-default}" != "--keep-debug-info" ]; then
if [ "$KEEP_DEBUG_INFO" -eq 0 ]; then
wasm-tools strip build-debug/starling-raw.wasm/starling-raw.wasm -d ".debug_(info|loc|ranges|abbrev|line|str)" -o ../../fastly.debug.wasm
else
cp build-debug/starling-raw.wasm/starling-raw.wasm ../../fastly.debug.wasm
Expand Down
3 changes: 3 additions & 0 deletions runtime/fastly/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ api::Engine *ENGINE;

// Install corresponds to Wizer time, so we configure the engine here
bool install(api::Engine *engine) {
#if defined(JS_GC_ZEAL) && defined(FASTLY_GC_FREQUENCY)
JS::SetGCZeal(engine->cx(), 2, FASTLY_GC_FREQUENCY);
#endif
ENGINE = engine;
return true;
}
Expand Down
Loading