Skip to content

Commit

Permalink
Upgrade SpiderMonkey to mozilla-central commit `250be4ca3c669db9a3974…
Browse files Browse the repository at this point in the history
…56402f68249aa15d8d5`

Merge pull request #459 from Distributive-Network/chore/upgrade-spidermonkey-to-250be4c
  • Loading branch information
Xmader authored Jan 9, 2025
2 parents 26e1406 + aaa7e4d commit 02528c5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
14 changes: 11 additions & 3 deletions include/JobQueue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ explicit JobQueue(JSContext *cx);
bool init(JSContext *cx);

/**
* @brief Ask the embedding for the incumbent global.
* @brief Ask the embedding for the host defined data.
*
* SpiderMonkey doesn't itself have a notion of incumbent globals as defined
* SpiderMonkey doesn't itself have a notion of host defined data as defined
* by the HTML spec, so we need the embedding to provide this. See
* dom/script/ScriptSettings.h for details.
*
* If the embedding has the host defined data, this method should return the
* host defined data via the `data` out parameter and return `true`.
* The object in the `data` out parameter can belong to any compartment.
* If the embedding doesn't need the host defined data, this method should
* set the `data` out parameter to `nullptr` and return `true`.
* If any error happens while generating the host defined data, this method
* should set a pending exception to `cx` and return `false`.
*/
JSObject *getIncumbentGlobal(JSContext *cx) override;
bool getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const override;

/**
* @brief Enqueue a reaction job `job` for `promise`, which was allocated at
Expand Down
2 changes: 1 addition & 1 deletion mozcentral.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4bdfb2c22e6e4b5600f66612c6d6121fe99769a1
250be4ca3c669db9a397456402f68249aa15d8d5
9 changes: 6 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ cd firefox-source
# Apply patching
# making it work for both GNU and BSD (macOS) versions of sed
sed -i'' -e 's/os not in ("WINNT", "OSX", "Android")/os not in ("WINNT", "Android")/' ./build/moz.configure/pkg.configure # use pkg-config on macOS
sed -i'' -e '/"WindowsDllMain.cpp"/d' ./mozglue/misc/moz.build # https://discourse.mozilla.org/t/105671, https://bugzilla.mozilla.org/show_bug.cgi?id=1751561
sed -i'' -e '/"winheap.cpp"/d' ./memory/mozalloc/moz.build # https://bugzilla.mozilla.org/show_bug.cgi?id=1802675
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 # would generate a Makefile to install the binary files from an invalid path prefix
Expand All @@ -66,6 +64,7 @@ sed -i'' -e 's/return !IsIteratorHelpersEnabled()/return false/' ./js/src/vm/Glo
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`
sed -i'' -e 's/"-fuse-ld=ld"/"-ld64" if c_compiler.version > "14.0.0" else "-fuse-ld=ld"/' ./build/moz.configure/toolchain.configure # XCode 15 changed the linker behaviour. See https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking
sed -i'' -e 's/defined(XP_WIN)/defined(_WIN32)/' ./mozglue/baseprofiler/public/BaseProfilerUtils.h # this header file is introduced to js/Debug.h in https://phabricator.services.mozilla.com/D221102, but it would be compiled without XP_WIN in this building configuration

cd js/src
mkdir -p _build
Expand All @@ -79,7 +78,11 @@ mkdir -p ../../../../_spidermonkey_install/
--disable-jemalloc \
--disable-tests \
$(if [[ "$OSTYPE" == "darwin"* ]]; then echo "--enable-linker=ld64"; fi) \
--enable-optimize
--enable-optimize \
--disable-explicit-resource-management
# disable-explicit-resource-management: Disable the `using` syntax that is enabled by default in SpiderMonkey nightly, otherwise the header files will disagree with the compiled lib .so file
# when it's using a `IF_EXPLICIT_RESOURCE_MANAGEMENT` macro, e.g., the `enum JSProtoKey` index would be off by 1 (header `JSProto_Uint8Array` 27 will be interpreted as `JSProto_Int8Array` in lib as lib has an extra element)
# https://bugzilla.mozilla.org/show_bug.cgi?id=1940342
make -j$CPUS
echo "Done building spidermonkey"

Expand Down
5 changes: 3 additions & 2 deletions src/JobQueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ JobQueue::JobQueue(JSContext *cx) {
finalizationRegistryCallbacks = new JS::PersistentRooted<FunctionVector>(cx); // Leaks but it's OK since freed at process exit
}

JSObject *JobQueue::getIncumbentGlobal(JSContext *cx) {
return JS::CurrentGlobalOrNull(cx);
bool JobQueue::getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const {
data.set(nullptr); // We don't need the host defined data
return true; // `true` indicates no error
}

bool JobQueue::enqueuePromiseJob(JSContext *cx,
Expand Down

0 comments on commit 02528c5

Please sign in to comment.