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

Build SpiderMonkey from mozilla-central #367

Merged
merged 44 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
77a8c0f
chore: build SpiderMonkey from mozilla-central
Xmader Jun 19, 2024
cb468af
chore: `mozcentral.version` file is required for building from source
Xmader Jun 19, 2024
5e1d162
chore: Rust v1.76 is required to build the latest SpiderMonkey
Xmader Jun 19, 2024
e4c37db
chore: force the SpiderMonkey build system not to verify the macOS SD…
Xmader Jun 19, 2024
12ed88b
Revert "chore: force the SpiderMonkey build system not to verify the …
Xmader Jun 19, 2024
647d083
chore: update `setup.sh`
Xmader Jun 19, 2024
b685d83
chore: WIP: only macOS 14 runners can use SDK 14.4 (XCode 15.3)
Xmader Jun 19, 2024
4fdc927
chore: WIP: can macOS 13 actually use SDK version 14.4?
Xmader Jun 19, 2024
2d73bd5
chore: SpiderMonkey 125 should be good as it switched to macOS 14.4 S…
Xmader Jun 19, 2024
3a07532
chore: try SpiderMonkey 120
Xmader Jun 19, 2024
275b0bf
chore: switch back to SpiderMonkey 115 should be fail-proof
Xmader Jun 19, 2024
8f70da7
chore: rollback
Xmader Jun 19, 2024
21e4719
Revert "chore: switch back to SpiderMonkey 115 should be fail-proof"
Xmader Jun 19, 2024
72565d7
Revert "chore: try SpiderMonkey 120"
Xmader Jun 19, 2024
a4ef58c
chore: force the build system not to verify the macOS SDK version
Xmader Jun 19, 2024
ff396af
chore: change back to the tip commit
Xmader Jun 19, 2024
04d028b
chore: WIP: ignore Windows builds for now
Xmader Jun 19, 2024
492fa80
fix: passing a column number offset for JS source code now requires t…
Xmader Jun 20, 2024
f3df728
fix: extending `JS::JobQueue` class now needs to implement the `isDra…
Xmader Jun 20, 2024
79b6437
fix: for `JS::NewExternalArrayBuffer`, the custom destructor is now w…
Xmader Jun 20, 2024
09bacb5
fix: `JSErrorReport`'s `filename` property is now a `JS::UniqueChars`…
Xmader Jun 20, 2024
53af133
fix: `setWeakRefsEnabled` and `setIteratorHelpersEnabled` no longer p…
Xmader Jun 20, 2024
0415557
feat: SpiderMonkey now supports APIs for one-byte latin1 JSExternalSt…
Xmader Jun 20, 2024
42e3f53
fix: forcibly enable FinalizationRegistry and iterator helpers
Xmader Jun 20, 2024
ec75f13
fix: `JSErrorReport`'s `filename` property should now be a `JS::Const…
Xmader Jun 20, 2024
39ee6af
WIP: bug in defining the debugger global object, disable pmdb for now
Xmader Jun 20, 2024
eb153ee
fix: update the test suite to reflect the change that property access…
Xmader Jun 25, 2024
67d017b
fix: `timers-force-exit.simple` to have a longer timeout because 2s i…
Xmader Jun 25, 2024
d2d9396
fix: `tests/js/commonjs-modules.bash` needs a much longer timeout if …
Xmader Jun 25, 2024
180303f
fix: pmdb's debugger global object now requires to be in a cross-comp…
Xmader Jun 25, 2024
ec74f8b
fix: `JS_Utf8BufferIsCompilableUnit` would still generate exception f…
Xmader Jun 25, 2024
891d2a8
Merge branch 'Xmader/ci/fix-windows-uncrustify' into Xmader/chore/moz…
Xmader Jun 28, 2024
46c148a
chore: re-enable Windows builds
Xmader Jun 28, 2024
82bf020
fix: in SpiderMonkey's `js/src/configure` script, the `--without-syst…
Xmader Jul 2, 2024
ddfc424
chore(CI): switch to the Windows 2022 runner to build SpiderMonkey
Xmader Jul 2, 2024
6168acb
chore: fix uncrustify build on Windows
Xmader Jul 2, 2024
4556799
fix: crash in Debug Build of SpiderMonkey
Xmader Jul 2, 2024
3f78041
docs(CI): explain why we need Windows 2022 runner to build SpiderMonkey
Xmader Jul 2, 2024
48bda0a
chore(CI): use the Windows 2022 runner entirely
Xmader Jul 2, 2024
da4f0da
The `JS_Utf8BufferIsCompilableUnit` issue got fixed within 24 hours a…
Xmader Jul 2, 2024
a7b92e8
chore(CI): create a CI action that automatically create pull request …
Xmader Jul 4, 2024
75c45be
Merge branch 'main' into Xmader/chore/moz-central
philippedistributive Jul 8, 2024
69ed8c0
Update include/JobQueue.hh
philippedistributive Jul 9, 2024
76cccdf
Update setup.sh
philippedistributive Jul 9, 2024
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
28 changes: 18 additions & 10 deletions .github/workflows/test-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
- 'ubuntu-20.04'
- 'macos-12'
- 'macos-14'
- 'windows-2019'
- 'windows-2022'
debug_enabled_python:
type: choice
description: Choose a Python version to run the build with SSH debugging on
Expand Down Expand Up @@ -69,13 +69,15 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Read the mozilla-central commit hash to be used
run: echo "MOZCENTRAL_VERSION=$(cat mozcentral.version)" >> $GITHUB_ENV
- name: Cache spidermonkey build
id: cache-spidermonkey
uses: actions/cache@v4
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
key: spidermonkey-${{ env.MOZCENTRAL_VERSION }}-${{ runner.os }}-${{ runner.arch }}
lookup-only: true # skip download
- name: Setup XCode
if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
Expand All @@ -86,16 +88,20 @@ jobs:
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: ./setup.sh
build-spidermonkey-win:
runs-on: windows-2019
runs-on: windows-2022
# SpiderMonkey requires Visual Studio 2022 or newer.
# The Windows 2019 runner only has Visual Studio Enterprise 2019 installed.
steps:
- uses: actions/checkout@v4
- name: Read the mozilla-central commit hash to be used
run: echo "MOZCENTRAL_VERSION=$(cat mozcentral.version)" >> $GITHUB_ENV
- name: Cache spidermonkey build
id: cache-spidermonkey
uses: actions/cache@v4
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
key: spidermonkey-${{ env.MOZCENTRAL_VERSION }}-${{ runner.os }}-${{ runner.arch }}
lookup-only: true # skip download
- name: Install dependencies
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
Expand All @@ -104,7 +110,7 @@ jobs:
# Already installed in Github Actions runner
# choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' # add CMake to system PATH
# choco install -y llvm gnuwin32-m4
choco install -y wget make
choco install -y wget make unzip
- name: Install MozillaBuild
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: |
Expand All @@ -123,7 +129,7 @@ jobs:
fail-fast: false
matrix:
# The lowest supported version is Ubuntu 20.04 + Python 3.8 or macOS 12 + Python 3.9
os: [ 'ubuntu-20.04', 'macos-12', 'macos-14', 'windows-2019' ]
os: [ 'ubuntu-20.04', 'macos-12', 'macos-14', 'windows-2022' ]
python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
exclude:
# actions/setup-python: The version '3.8'/'3.9' with architecture 'arm64' was not found for macOS.
Expand Down Expand Up @@ -154,7 +160,7 @@ jobs:
sudo apt-get install -y cmake llvm
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
brew update || true # allow failure
brew install cmake pkg-config wget coreutils # `coreutils` installs the `realpath` command
brew install cmake pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command
fi
echo "Installing python deps"
poetry self add "poetry-dynamic-versioning[plugin]"
Expand All @@ -177,12 +183,14 @@ jobs:
with:
name: docs-${{ github.run_id }}-${{ github.sha }}
path: ./build/docs/html/
- name: Read the mozilla-central commit hash to be used
run: echo "MOZCENTRAL_VERSION=$(cat mozcentral.version)" >> $GITHUB_ENV
- name: Use cached spidermonkey build
uses: actions/cache@v4
with:
path: |
./_spidermonkey_install/*
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
key: spidermonkey-${{ env.MOZCENTRAL_VERSION }}-${{ runner.os }}-${{ runner.arch }}
fail-on-cache-miss: true # SpiderMonkey is expected to be cached in its dedicated job
- name: Build pminit
run: |
Expand All @@ -203,7 +211,7 @@ jobs:
name: wheel-${{ github.run_id }}-${{ github.sha }}
path: ./dist/
- name: Set cores to get stored in /cores
if: ${{ matrix.os != 'windows-2019' }}
if: ${{ matrix.os != 'windows-2022' }}
# TODO (Caleb Aikens) figure out how to get Windows core dumps
run: |
sudo mkdir -p /cores
Expand Down Expand Up @@ -238,7 +246,7 @@ jobs:
credentials: "admin:admin"
- name: Upload core dumps as CI artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.os != 'windows-2019' && failure() }}
if: ${{ matrix.os != 'windows-2022' && failure() }}
# TODO (Caleb Aikens) figure out how to get Windows core dumps
with:
name: cores-${{ matrix.os }}-${{ matrix.python_version }}
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/update-mozcentral-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Create pull requests to update mozilla-central version to the latest'

on:
schedule:
- cron: "00 14 * * 1" # run every Monday at 14:00 UTC (10:00 Eastern Daylight Time)
workflow_call:
workflow_dispatch: # or you can run it manually

defaults:
run:
shell: bash

jobs:
update:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Check Version
# Check the latest changes on mozilla-central via the Mercurial pushlog HTTP API
# See https://mozilla-version-control-tools.readthedocs.io/en/latest/hgmo/pushlog.html#hgweb-commands
run: |
COMMIT_HASH=$(
curl -s "https://hg.mozilla.org/mozilla-central/json-pushes?tipsonly=1&version=2" |\
jq --join-output '(.lastpushid | tostring) as $pushid | empty, .pushes[$pushid].changesets[0]'
)
echo "MOZCENTRAL_VERSION=$COMMIT_HASH" >> $GITHUB_ENV
- name: Update `mozcentral.version` File
run: echo $MOZCENTRAL_VERSION > mozcentral.version
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: mozcentral.version
commit-message: |
chore(deps): upgrade SpiderMonkey to `${{ env.MOZCENTRAL_VERSION }}`
branch: chore/upgrade-spidermonkey-to-${{ env.MOZCENTRAL_VERSION }}
title: Upgrade SpiderMonkey to mozilla-central commit `${{ env.MOZCENTRAL_VERSION }}`
body: |
Changeset: https://hg.mozilla.org/mozilla-central/rev/${{ env.MOZCENTRAL_VERSION }}
labels: dependencies
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ lib/*
.pytest_cache
.DS_Store
firefox-*.tar.xz
firefox-*.zip
firefox-*/
mozilla-central-*
__pycache__
Testing/Temporary
_spidermonkey_install
_spidermonkey_install*
uncrustify-*.tar.gz
uncrustify-*/
uncrustify
Expand Down
23 changes: 18 additions & 5 deletions cmake/modules/FindSpiderMonkey.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
# SPIDERMONKEY_FOUND - True if SpiderMonkey found.
# SPIDERMONKEY_THREADSAFE - True if SpiderMonkey is compiled with multi threading support.

#Last Change: 2022-10-03 (Caleb Aikens)

include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
Expand All @@ -36,11 +34,26 @@ if(SPIDERMONKEY_FOUND)
set(SPIDERMONKEY_FIND_QUIETLY TRUE)
endif()

# Get the SpiderMonkey major version number
# See https://hg.mozilla.org/releases/mozilla-esr102/file/tip/js/src/old-configure.in#l1081
file(GLOB LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install")
execute_process(COMMAND
"sh" "-c" "./js*-config --version" # Run "_spidermonkey_install/bin/js*-config --version" to print the full version number
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install/bin"
OUTPUT_VARIABLE MOZILLA_VERSION
)
string(STRIP ${MOZILLA_VERSION} MOZILLA_VERSION)
string(REGEX REPLACE "^([0-9]+)(\\.[0-9]+)*([ab][0-9]|)?" # Only the MAJOR and the "a1" (indicator of nightly build) part is needed
"\\1\\3" # see https://hg.mozilla.org/releases/mozilla-esr102/file/tip/build/moz.configure/init.configure#l959
MOZILLA_SYMBOLVERSION
${MOZILLA_VERSION}
)

# SpiderMonkey search paths
set(SPIDERMONKEY_PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install"
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install/include/mozjs-115"
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install/include/mozjs-${MOZILLA_SYMBOLVERSION}"
${SPIDERMONKEY_ROOT}
$ENV{SPIDERMONKEY_ROOT}
~/Library/Frameworks
Expand All @@ -60,7 +73,7 @@ set(SPIDERMONKEY_PATHS
set(SPIDERMONKEY_HEADERS jsapi.h js/RequiredDefines.h)

# SpiderMonkey include suffix paths
set(SPIDERMONKEY_INCLUDE_SUFFIX_PATHS include/mozjs-115/)
set(SPIDERMONKEY_INCLUDE_SUFFIX_PATHS include/mozjs-${MOZILLA_SYMBOLVERSION}/)

# Find SpiderMonkey include path
find_path(SPIDERMONKEY_INCLUDE_DIR ${SPIDERMONKEY_HEADERS}
Expand All @@ -71,7 +84,7 @@ find_path(SPIDERMONKEY_INCLUDE_DIR ${SPIDERMONKEY_HEADERS}
)

# SpiderMonkey libs
set(SPIDERMONKEY_LIBRARY_NAMES libmozjs-115.so libmozjs-115.dylib mozjs-115.lib)
set(SPIDERMONKEY_LIBRARY_NAMES libmozjs-${MOZILLA_SYMBOLVERSION}.so libmozjs-${MOZILLA_SYMBOLVERSION}.dylib mozjs-${MOZILLA_SYMBOLVERSION}.lib)

set(SPIDERMONKEY_LIB_SUFFIX_PATHS js/src/build lib)

Expand Down
5 changes: 5 additions & 0 deletions include/JobQueue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ void runJobs(JSContext *cx) override;
*/
bool empty() const override;

/**
* @return true if the job queue stops draining, which results in `empty()` being false after `runJobs()`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return true if the job queue stops draining, which results in `empty()` being false after `runJobs()`.
* @return true if the job queue stopped draining, which results in `empty()` being false after `runJobs()`.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't understand why you'll need to change this.
Is this grammatically incorrect?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, yes, "stops" refers to the present or future, whereas "stopped" refers to the past

*/
bool isDrainingStopped() const override;

/**
* @brief Appends a callback to the queue of FinalizationRegistry callbacks
*
Expand Down
3 changes: 3 additions & 0 deletions include/jsTypeFactory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ public:
* @return PyObject* - the PyObject string
*/
static PyObject *getPyString(const char16_t *chars);
static PyObject *getPyString(const JS::Latin1Char *chars);

/**
* @brief decrefs the underlying PyObject string when the JSString is finalized
*
* @param chars - The char buffer of the string
*/
void finalize(char16_t *chars) const override;
void finalize(JS::Latin1Char *chars) const override;

size_t sizeOfBuffer(const char16_t *chars, mozilla::MallocSizeOf mallocSizeOf) const override;
size_t sizeOfBuffer(const JS::Latin1Char *chars, mozilla::MallocSizeOf mallocSizeOf) const override;
};
extern PythonExternalString PythonExternalStringCallbacks;

Expand Down
1 change: 1 addition & 0 deletions mozcentral.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d25c9bdacb64ae50779dc91f5919ca0189ad6c36
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include = [
{ path = "tests", format = "sdist" },
{ path = "CMakeLists.txt", format = "sdist" },
{ path = "*.sh", format = "sdist" },
{ path = "mozcentral.version", format = "sdist" },
]


Expand Down
4 changes: 2 additions & 2 deletions python/pythonmonkey/lib/pmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def enable(debuggerGlobalObject=pm.eval("debuggerGlobal")):
return # already enabled, skipping

debuggerGlobalObject._pmdbEnabled = True
debuggerGlobalObject.eval("""(debuggerInput, _pythonPrint, _pythonExit) => {
pm.eval("debuggerGlobal.eval")("""(mainGlobal, debuggerInput, _pythonPrint, _pythonExit) => {
const dbg = new Debugger()
const mainDebuggee = dbg.addDebuggee(mainGlobal)
dbg.uncaughtExceptionHook = (e) => {
Expand Down Expand Up @@ -177,4 +177,4 @@ def enable(debuggerGlobalObject=pm.eval("debuggerGlobal")):
// Enter debugger on `debugger;` statement
dbg.onDebuggerStatement = (frame) => enterDebuggerLoop(frame)

}""")(debuggerInput, print, lambda status: exit(int(status)))
}""")(pm.globalThis, debuggerInput, print, lambda status: exit(int(status)))
26 changes: 17 additions & 9 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
SUDO='sudo'
fi
$SUDO apt-get update --yes
$SUDO apt-get install --yes cmake graphviz llvm clang pkg-config m4 \
$SUDO apt-get install --yes cmake graphviz llvm clang pkg-config m4 unzip \
wget curl python3-distutils python3-dev
# Install Doxygen
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
Expand All @@ -28,15 +28,16 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
brew update || true # allow failure
brew install cmake doxygen pkg-config wget coreutils # `coreutils` installs the `realpath` command
brew install cmake doxygen pkg-config wget unzip coreutils # `coreutils` installs the `realpath` command
elif [[ "$OSTYPE" == "msys"* ]]; then # Windows
echo "Dependencies are not going to be installed automatically on Windows."
else
echo "Unsupported OS"
exit 1
fi
# Install rust compiler
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.69 # force to use Rust 1.69 because 1.70 has linking issues on Windows
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.76
cargo install cbindgen
# Setup Poetry
curl -sSL https://install.python-poetry.org | python3 - --version "1.7.1"
if [[ "$OSTYPE" == "msys"* ]]; then # Windows
Expand All @@ -51,15 +52,15 @@ echo "Done installing dependencies"
echo "Downloading uncrustify source code"
wget -c -q https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.78.1.tar.gz
mkdir -p uncrustify-source
tar -xzvf uncrustify-0.78.1.tar.gz -C uncrustify-source --strip-components=1 # strip the root folder
tar -xzf uncrustify-0.78.1.tar.gz -C uncrustify-source --strip-components=1 # strip the root folder
echo "Done downloading uncrustify source code"

echo "Building uncrustify"
cd uncrustify-source
mkdir -p build
cd build
if [[ "$OSTYPE" == "msys"* ]]; then # Windows
cmake ../ -T ClangCL
cmake ../
cmake --build . -j$CPUS --config Release
cp Release/uncrustify.exe ../../uncrustify.exe
else
Expand All @@ -71,9 +72,10 @@ cd ../..
echo "Done building uncrustify"

echo "Downloading spidermonkey source code"
wget -c -q https://ftp.mozilla.org/pub/firefox/releases/115.8.0esr/source/firefox-115.8.0esr.source.tar.xz
mkdir -p firefox-source
tar xf firefox-115.8.0esr.source.tar.xz -C firefox-source --strip-components=1 # strip the root folder
# Read the commit hash for mozilla-central from the `mozcentral.version` file
MOZCENTRAL_VERSION=$(cat mozcentral.version)
wget -c -q -O firefox-source-${MOZCENTRAL_VERSION}.zip https://hg.mozilla.org/mozilla-central/archive/${MOZCENTRAL_VERSION}.zip
unzip -q firefox-source-${MOZCENTRAL_VERSION}.zip && mv mozilla-central-${MOZCENTRAL_VERSION} firefox-source
echo "Done downloading spidermonkey source code"

echo "Building spidermonkey"
Expand All @@ -85,14 +87,20 @@ sed -i'' -e '/"winheap.cpp"/d' ./memory/mozalloc/moz.build # https://bugzilla.mo
sed -i'' -e 's/"install-name-tool"/"install_name_tool"/' ./moz.configure # `install-name-tool` does not exist, but we have `install_name_tool`
sed -i'' -e 's/bool Unbox/JS_PUBLIC_API bool Unbox/g' ./js/public/Class.h # need to manually add JS_PUBLIC_API to js::Unbox until it gets fixed in Spidermonkey
sed -i'' -e 's/bool js::Unbox/JS_PUBLIC_API bool js::Unbox/g' ./js/src/vm/JSObject.cpp # same here
sed -i'' -e 's/shared_lib = self._pretty_path(libdef.output_path, backend_file)/shared_lib = libdef.lib_name/' ./python/mozbuild/mozbuild/backend/recursivemake.py
sed -i'' -e 's/if version < Version(mac_sdk_min_version())/if False/' ./build/moz.configure/toolchain.configure # do not verify the macOS SDK version as the reqiuired version is not available on Github Actions runner
philippedistributive marked this conversation as resolved.
Show resolved Hide resolved
sed -i'' -e 's/return JS::GetWeakRefsEnabled() == JS::WeakRefSpecifier::Disabled/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable FinalizationRegistry
Xmader marked this conversation as resolved.
Show resolved Hide resolved
sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/GlobalObject.cpp # forcibly enable iterator helpers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caleb-distributive is this truly needed? Doesn't the switch in PyInit_pythonmonkey cover this?

Copy link
Member Author

@Xmader Xmader Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the commit message in 42e3f53

sed -i'' -e '/MOZ_CRASH_UNSAFE_PRINTF/,/__PRETTY_FUNCTION__);/d' ./mfbt/LinkedList.h # would crash in Debug Build: in `~LinkedList()` it should have removed all this list's elements before the list's destruction
sed -i'' -e '/MOZ_ASSERT(stackRootPtr == nullptr);/d' ./js/src/vm/JSContext.cpp # would assert false in Debug Build since we extensively use `new JS::Rooted`
cd js/src
mkdir -p _build
cd _build
mkdir -p ../../../../_spidermonkey_install/
../configure \
--prefix=$(realpath $PWD/../../../../_spidermonkey_install) \
--with-intl-api \
--without-system-zlib \
$(if [[ "$OSTYPE" != "msys"* ]]; then echo "--without-system-zlib"; fi) \
--disable-debug-symbols \
--disable-jemalloc \
--disable-tests \
Expand Down
7 changes: 5 additions & 2 deletions src/BufferType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ JSObject *BufferType::toJsTypedArray(JSContext *cx, PyObject *pyObject) {
// Create a new ExternalArrayBuffer object
// Note: data will be copied instead of transferring the ownership when this external ArrayBuffer is "transferred" to a worker thread.
// see https://hg.mozilla.org/releases/mozilla-esr102/file/a03fde6/js/public/ArrayBuffer.h#l86
mozilla::UniquePtr<void, JS::BufferContentsDeleter> dataPtr(
view->buf /* data pointer */,
{BufferType::_releasePyBuffer, view /* the `bufView` argument to `_releasePyBuffer` */}
);
arrayBuffer = JS::NewExternalArrayBuffer(cx,
view->len /* byteLength */, view->buf /* data pointer */,
BufferType::_releasePyBuffer, view /* the `bufView` argument to `_releasePyBuffer` */
view->len /* byteLength */, std::move(dataPtr)
);
} else { // empty buffer
arrayBuffer = JS::NewArrayBuffer(cx, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/ExceptionType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ JSObject *ExceptionType::toJsError(JSContext *cx, PyObject *exceptionValue, PyOb
JS::RootedString filename(cx, JS_NewStringCopyZ(cx, PyUnicode_AsUTF8(fileName)));
JS::RootedString message(cx, JS_NewStringCopyZ(cx, msgStream.str().c_str()));
// stack argument cannot be passed in as a string anymore (deprecated), and could not find a proper example using the new argument type
if (!JS::CreateError(cx, JSExnType::JSEXN_ERR, nullptr, filename, lineno, 0, nullptr, message, JS::NothingHandleValue, &rval)) {
if (!JS::CreateError(cx, JSExnType::JSEXN_ERR, nullptr, filename, lineno, JS::ColumnNumberOneOrigin(1), nullptr, message, JS::NothingHandleValue, &rval)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no longer 0?

Copy link
Member Author

@Xmader Xmader Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS::ColumnNumberOneOrigin(1)

One Origin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS::CreateError()'s function signature changed to CreateError(..., JS::ColumnNumberOneOrigin column,...)

See https://hg.mozilla.org/mozilla-central/file/d25c9bd/js/public/ErrorReport.h#l537

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return NULL;
}

Expand Down Expand Up @@ -306,7 +306,7 @@ JSObject *ExceptionType::toJsError(JSContext *cx, PyObject *exceptionValue, PyOb
JS::RootedString filename(cx, JS_NewStringCopyZ(cx, "")); // cannot be null or omitted, but is overriden by the errorReport
JS::RootedString message(cx, JS_NewStringCopyZ(cx, msgStream.str().c_str()));
// filename cannot be null
if (!JS::CreateError(cx, JSExnType::JSEXN_ERR, nullptr, filename, 0, 0, errorReport, message, JS::NothingHandleValue, &rval)) {
if (!JS::CreateError(cx, JSExnType::JSEXN_ERR, nullptr, filename, 0, JS::ColumnNumberOneOrigin(1), errorReport, message, JS::NothingHandleValue, &rval)) {
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/JSFunctionProxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PyObject *JSFunctionProxyMethodDefinitions::JSFunctionProxy_call(PyObject *self,
JSContext *cx = GLOBAL_CX;
JS::RootedValue jsFunc(GLOBAL_CX, JS::ObjectValue(**((JSFunctionProxy *)self)->jsFunc));
JSObject *jsFuncObj = jsFunc.toObjectOrNull();
JS::RootedObject thisObj(GLOBAL_CX, JS::GetNonCCWObjectGlobal(jsFuncObj)); // if jsFunc is not bound, assume `this` is `globalThis`
JS::RootedObject thisObj(GLOBAL_CX, JS::CurrentGlobalOrNull(GLOBAL_CX)); // if jsFunc is not bound, assume `this` is `globalThis`

JS::RootedVector<JS::Value> jsArgsVector(cx);
Py_ssize_t nargs = PyTuple_Size(args);
Expand Down
Loading
Loading