aboutsummaryrefslogtreecommitdiffstats
path: root/src/etc/patches/mozjs-stack-bounds.diff
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc/patches/mozjs-stack-bounds.diff')
-rw-r--r--src/etc/patches/mozjs-stack-bounds.diff77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/etc/patches/mozjs-stack-bounds.diff b/src/etc/patches/mozjs-stack-bounds.diff
new file mode 100644
index 00000000000..5f82df03dde
--- /dev/null
+++ b/src/etc/patches/mozjs-stack-bounds.diff
@@ -0,0 +1,77 @@
+diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
+index 5571fc0..7e1e30d 100644
+--- a/js/src/jsapi.cpp
++++ b/js/src/jsapi.cpp
+@@ -735,6 +735,7 @@ JSRuntime::JSRuntime()
+ #endif
+ selfHostedGlobal_(NULL),
+ nativeStackBase(0),
++ nativeStackEnd(0),
+ nativeStackQuota(0),
+ interpreterFrames(NULL),
+ cxCallback(NULL),
+@@ -7084,6 +7085,18 @@ JS_SetRuntimeThread(JSRuntime *rt)
+ #endif
+ }
+
++extern JS_PUBLIC_API(void)
++JS_SetNativeStackBounds(JSRuntime *rt, uintptr_t minValue, uintptr_t maxValue)
++{
++#if JS_STACK_GROWTH_DIRECTION < 0
++ rt->nativeStackBase = maxValue;
++ rt->nativeStackEnd = minValue;
++#else
++ rt->nativeStackBase = minValue;
++ rt->nativeStackEnd = maxValue;
++#endif
++}
++
+ extern JS_NEVER_INLINE JS_PUBLIC_API(void)
+ JS_AbortIfWrongThread(JSRuntime *rt)
+ {
+diff --git a/js/src/jsapi.h b/js/src/jsapi.h
+index c8ab0f0..9ac582e 100644
+--- a/js/src/jsapi.h
++++ b/js/src/jsapi.h
+@@ -6248,6 +6248,9 @@ JS_ClearRuntimeThread(JSRuntime *rt);
+ extern JS_PUBLIC_API(void)
+ JS_SetRuntimeThread(JSRuntime *rt);
+
++extern JS_PUBLIC_API(void)
++JS_SetNativeStackBounds(JSRuntime *rt, uintptr_t minValue, uintptr_t maxValue);
++
+ #ifdef __cplusplus
+ JS_END_EXTERN_C
+
+diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h
+index 0bb6d1c..32e016e 100644
+--- a/js/src/jscntxt.h
++++ b/js/src/jscntxt.h
+@@ -439,6 +439,9 @@ struct JSRuntime : js::RuntimeFriendFields
+ /* Base address of the native stack for the current thread. */
+ uintptr_t nativeStackBase;
+
++ /* Base address of the native stack for the current thread. */
++ uintptr_t nativeStackEnd;
++
+ /* The native stack size limit that runtime should not exceed. */
+ size_t nativeStackQuota;
+
+diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
+index f5cbc62..eae29da 100644
+--- a/js/src/jsgc.cpp
++++ b/js/src/jsgc.cpp
+@@ -1177,9 +1177,11 @@ MarkConservativeStackRoots(JSTracer *trc, bool useSavedRoots)
+ uintptr_t *stackMin, *stackEnd;
+ #if JS_STACK_GROWTH_DIRECTION > 0
+ stackMin = rt->nativeStackBase;
+- stackEnd = cgcd->nativeStackTop;
++ stackEnd = rt->nativeStackEnd ? reinterpret_cast<uintptr_t*>(rt->nativeStackEnd)
++ : cgcd->nativeStackTop;
+ #else
+- stackMin = cgcd->nativeStackTop + 1;
++ stackMin = rt->nativeStackEnd ? reinterpret_cast<uintptr_t*>(rt->nativeStackEnd)
++ : cgcd->nativeStackTop + 1;
+ stackEnd = reinterpret_cast<uintptr_t *>(rt->nativeStackBase);
+ #endif
+