mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 987995, part 2 - Add a data parameter to two memory-pressure-related callbacks. r=luke.
This commit is contained in:
parent
961997c4b5
commit
1387145693
@ -2913,7 +2913,7 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
|
||||
}
|
||||
|
||||
static void
|
||||
OnLargeAllocationFailure()
|
||||
OnLargeAllocationFailure(void* data)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
mozilla::services::GetObserverService();
|
||||
@ -2981,7 +2981,7 @@ nsJSContext::EnsureStatics()
|
||||
};
|
||||
JS::SetAsmJSCacheOps(sRuntime, &asmJSCacheOps);
|
||||
|
||||
JS::SetLargeAllocationFailureCallback(sRuntime, OnLargeAllocationFailure);
|
||||
JS::SetLargeAllocationFailureCallback(sRuntime, OnLargeAllocationFailure, nullptr);
|
||||
|
||||
// Set these global xpconnect options...
|
||||
Preferences::RegisterCallbackAndCall(ReportAllJSExceptionsPrefChangedCallback,
|
||||
|
@ -6576,14 +6576,17 @@ JSAutoByteString::encodeLatin1(ExclusiveContext *cx, JSString *str)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SetLargeAllocationFailureCallback(JSRuntime *rt, JS::LargeAllocationFailureCallback lafc)
|
||||
JS::SetLargeAllocationFailureCallback(JSRuntime *rt, JS::LargeAllocationFailureCallback lafc,
|
||||
void *data)
|
||||
{
|
||||
rt->largeAllocationFailureCallback = lafc;
|
||||
rt->largeAllocationFailureCallbackData = data;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS::SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb)
|
||||
JS::SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb, void *data)
|
||||
{
|
||||
rt->oomCallback = cb;
|
||||
rt->oomCallbackData = data;
|
||||
}
|
||||
|
||||
|
@ -5059,10 +5059,10 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {
|
||||
*/
|
||||
|
||||
typedef void
|
||||
(* LargeAllocationFailureCallback)();
|
||||
(* LargeAllocationFailureCallback)(void *data);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetLargeAllocationFailureCallback(JSRuntime *rt, LargeAllocationFailureCallback afc);
|
||||
SetLargeAllocationFailureCallback(JSRuntime *rt, LargeAllocationFailureCallback afc, void *data);
|
||||
|
||||
/*
|
||||
* Unlike the error reporter, which is only called if the exception for an OOM
|
||||
@ -5076,10 +5076,10 @@ SetLargeAllocationFailureCallback(JSRuntime *rt, LargeAllocationFailureCallback
|
||||
*/
|
||||
|
||||
typedef void
|
||||
(* OutOfMemoryCallback)(JSContext *cx);
|
||||
(* OutOfMemoryCallback)(JSContext *cx, void *data);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb);
|
||||
SetOutOfMemoryCallback(JSRuntime *rt, OutOfMemoryCallback cb, void *data);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
|
@ -376,7 +376,7 @@ js_ReportOutOfMemory(ThreadSafeContext *cxArg)
|
||||
/* Report the oom. */
|
||||
if (JS::OutOfMemoryCallback oomCallback = cx->runtime()->oomCallback) {
|
||||
AutoSuppressGC suppressGC(cx);
|
||||
oomCallback(cx);
|
||||
oomCallback(cx, cx->runtime()->oomCallbackData);
|
||||
}
|
||||
|
||||
if (JS_IsRunning(cx)) {
|
||||
|
@ -5016,7 +5016,7 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
}
|
||||
|
||||
static void
|
||||
my_OOMCallback(JSContext *cx)
|
||||
my_OOMCallback(JSContext *cx, void *data)
|
||||
{
|
||||
// If a script is running, the engine is about to throw the string "out of
|
||||
// memory", which may or may not be caught. Otherwise the engine will just
|
||||
@ -6263,7 +6263,7 @@ main(int argc, char **argv, char **envp)
|
||||
if (!rt)
|
||||
return 1;
|
||||
|
||||
JS::SetOutOfMemoryCallback(rt, my_OOMCallback);
|
||||
JS::SetOutOfMemoryCallback(rt, my_OOMCallback, nullptr);
|
||||
if (!SetRuntimeOptions(rt, op))
|
||||
return 1;
|
||||
|
||||
|
@ -772,7 +772,7 @@ JSRuntime::onOutOfMemoryCanGC(void *p, size_t bytes)
|
||||
{
|
||||
if (!largeAllocationFailureCallback || bytes < LARGE_ALLOCATION)
|
||||
return nullptr;
|
||||
largeAllocationFailureCallback();
|
||||
largeAllocationFailureCallback(largeAllocationFailureCallbackData);
|
||||
return onOutOfMemory(p, bytes);
|
||||
}
|
||||
|
||||
|
@ -1395,8 +1395,11 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
|
||||
/* See comment for JS::SetLargeAllocationFailureCallback in jsapi.h. */
|
||||
JS::LargeAllocationFailureCallback largeAllocationFailureCallback;
|
||||
void *largeAllocationFailureCallbackData;
|
||||
|
||||
/* See comment for JS::SetOutOfMemoryCallback in jsapi.h. */
|
||||
JS::OutOfMemoryCallback oomCallback;
|
||||
void *oomCallbackData;
|
||||
|
||||
/*
|
||||
* These variations of malloc/calloc/realloc will call the
|
||||
|
@ -1437,7 +1437,7 @@ XPCJSRuntime::InterruptCallback(JSContext *cx)
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
XPCJSRuntime::OutOfMemoryCallback(JSContext *cx)
|
||||
XPCJSRuntime::OutOfMemoryCallback(JSContext *cx, void *data)
|
||||
{
|
||||
if (!Preferences::GetBool("memory.dump_reports_on_oom")) {
|
||||
return;
|
||||
@ -3178,7 +3178,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
js::SetActivityCallback(runtime, ActivityCallback, this);
|
||||
js::SetCTypesActivityCallback(runtime, CTypesActivityCallback);
|
||||
JS_SetInterruptCallback(runtime, InterruptCallback);
|
||||
JS::SetOutOfMemoryCallback(runtime, OutOfMemoryCallback);
|
||||
JS::SetOutOfMemoryCallback(runtime, OutOfMemoryCallback, nullptr);
|
||||
|
||||
// The JS engine needs to keep the source code around in order to implement
|
||||
// Function.prototype.toSource(). It'd be nice to not have to do this for
|
||||
|
@ -547,7 +547,7 @@ public:
|
||||
static void CTypesActivityCallback(JSContext *cx,
|
||||
js::CTypesActivityType type);
|
||||
static bool InterruptCallback(JSContext *cx);
|
||||
static void OutOfMemoryCallback(JSContext *cx);
|
||||
static void OutOfMemoryCallback(JSContext *cx, void *data);
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user