зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1726737 - Part 8: Add public header for wait callbacks. r=arai
Similar to the two previous patches in this stack, add a separate header file for these callback functions. The header file name matches the file name of the other two files (i.e. ends with "Callbacks" and not "Callback"), even though the function name is `SetWaitCallback`. Differential Revision: https://phabricator.services.mozilla.com/D123199
This commit is contained in:
Родитель
164e667138
Коммит
0cf457e591
|
@ -0,0 +1,54 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef js_WaitCallbacks_h
|
||||||
|
#define js_WaitCallbacks_h
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "jstypes.h"
|
||||||
|
|
||||||
|
struct JS_PUBLIC_API JSRuntime;
|
||||||
|
|
||||||
|
namespace JS {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the JSRuntime is about to block in an Atomics.wait() JS call or in a
|
||||||
|
* `wait` instruction in WebAssembly, it can notify the host by means of a call
|
||||||
|
* to BeforeWaitCallback. After the wait, it can notify the host by means of a
|
||||||
|
* call to AfterWaitCallback. Both callbacks must be null, or neither.
|
||||||
|
*
|
||||||
|
* (If you change the callbacks from null to not-null or vice versa while some
|
||||||
|
* thread on the runtime is in a wait, you will be sorry.)
|
||||||
|
*
|
||||||
|
* The argument to the BeforeWaitCallback is a pointer to uninitialized
|
||||||
|
* stack-allocated working memory of size WAIT_CALLBACK_CLIENT_MAXMEM bytes.
|
||||||
|
* The caller of SetWaitCallback() must pass the amount of memory it will need,
|
||||||
|
* and this amount will be checked against that limit and the process will crash
|
||||||
|
* reliably if the check fails.
|
||||||
|
*
|
||||||
|
* The value returned by the BeforeWaitCallback will be passed to the
|
||||||
|
* AfterWaitCallback.
|
||||||
|
*
|
||||||
|
* The AfterWaitCallback will be called even if the wakeup is spurious and the
|
||||||
|
* thread goes right back to waiting again. Of course the thread will call the
|
||||||
|
* BeforeWaitCallback once more before it goes to sleep in this situation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static constexpr size_t WAIT_CALLBACK_CLIENT_MAXMEM = 32;
|
||||||
|
|
||||||
|
using BeforeWaitCallback = void* (*)(uint8_t* memory);
|
||||||
|
using AfterWaitCallback = void (*)(void* cookie);
|
||||||
|
|
||||||
|
extern JS_PUBLIC_API void SetWaitCallback(JSRuntime* rt,
|
||||||
|
BeforeWaitCallback beforeWait,
|
||||||
|
AfterWaitCallback afterWait,
|
||||||
|
size_t requiredMemory);
|
||||||
|
|
||||||
|
} // namespace JS
|
||||||
|
|
||||||
|
#endif // js_WaitCallbacks_h
|
|
@ -28,6 +28,7 @@
|
||||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||||
#include "js/PropertySpec.h"
|
#include "js/PropertySpec.h"
|
||||||
#include "js/Result.h"
|
#include "js/Result.h"
|
||||||
|
#include "js/WaitCallbacks.h"
|
||||||
#include "vm/GlobalObject.h"
|
#include "vm/GlobalObject.h"
|
||||||
#include "vm/Time.h"
|
#include "vm/Time.h"
|
||||||
#include "vm/TypedArrayObject.h"
|
#include "vm/TypedArrayObject.h"
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "js/String.h" // JS::MaxStringLength
|
#include "js/String.h" // JS::MaxStringLength
|
||||||
#include "js/Symbol.h"
|
#include "js/Symbol.h"
|
||||||
#include "js/Utility.h"
|
#include "js/Utility.h"
|
||||||
|
#include "js/WaitCallbacks.h"
|
||||||
#include "js/WasmModule.h"
|
#include "js/WasmModule.h"
|
||||||
#include "js/Wrapper.h"
|
#include "js/Wrapper.h"
|
||||||
#include "js/WrapperCallbacks.h"
|
#include "js/WrapperCallbacks.h"
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "js/Value.h"
|
#include "js/Value.h"
|
||||||
#include "js/ValueArray.h"
|
#include "js/ValueArray.h"
|
||||||
#include "js/Vector.h"
|
#include "js/Vector.h"
|
||||||
|
#include "js/WaitCallbacks.h"
|
||||||
#include "js/WeakMap.h"
|
#include "js/WeakMap.h"
|
||||||
#include "js/WrapperCallbacks.h"
|
#include "js/WrapperCallbacks.h"
|
||||||
#include "js/Zone.h"
|
#include "js/Zone.h"
|
||||||
|
@ -1076,39 +1077,6 @@ class MOZ_RAII AutoHideScriptedCaller {
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] extern JS_PUBLIC_API bool DisableWasmHugeMemory();
|
[[nodiscard]] extern JS_PUBLIC_API bool DisableWasmHugeMemory();
|
||||||
|
|
||||||
/**
|
|
||||||
* When the JSRuntime is about to block in an Atomics.wait() JS call or in a
|
|
||||||
* `wait` instruction in WebAssembly, it can notify the host by means of a call
|
|
||||||
* to BeforeWaitCallback. After the wait, it can notify the host by means of a
|
|
||||||
* call to AfterWaitCallback. Both callbacks must be null, or neither.
|
|
||||||
*
|
|
||||||
* (If you change the callbacks from null to not-null or vice versa while some
|
|
||||||
* thread on the runtime is in a wait, you will be sorry.)
|
|
||||||
*
|
|
||||||
* The argument to the BeforeWaitCallback is a pointer to uninitialized
|
|
||||||
* stack-allocated working memory of size WAIT_CALLBACK_CLIENT_MAXMEM bytes.
|
|
||||||
* The caller of SetWaitCallback() must pass the amount of memory it will need,
|
|
||||||
* and this amount will be checked against that limit and the process will crash
|
|
||||||
* reliably if the check fails.
|
|
||||||
*
|
|
||||||
* The value returned by the BeforeWaitCallback will be passed to the
|
|
||||||
* AfterWaitCallback.
|
|
||||||
*
|
|
||||||
* The AfterWaitCallback will be called even if the wakeup is spurious and the
|
|
||||||
* thread goes right back to waiting again. Of course the thread will call the
|
|
||||||
* BeforeWaitCallback once more before it goes to sleep in this situation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static constexpr size_t WAIT_CALLBACK_CLIENT_MAXMEM = 32;
|
|
||||||
|
|
||||||
using BeforeWaitCallback = void* (*)(uint8_t* memory);
|
|
||||||
using AfterWaitCallback = void (*)(void* cookie);
|
|
||||||
|
|
||||||
extern JS_PUBLIC_API void SetWaitCallback(JSRuntime* rt,
|
|
||||||
BeforeWaitCallback beforeWait,
|
|
||||||
AfterWaitCallback afterWait,
|
|
||||||
size_t requiredMemory);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true iff the given object is either a SavedFrame object or wrapper
|
* Return true iff the given object is either a SavedFrame object or wrapper
|
||||||
* around a SavedFrame object, and it is not the SavedFrame.prototype object.
|
* around a SavedFrame object, and it is not the SavedFrame.prototype object.
|
||||||
|
|
|
@ -222,6 +222,7 @@ EXPORTS.js += [
|
||||||
"../public/Value.h",
|
"../public/Value.h",
|
||||||
"../public/ValueArray.h",
|
"../public/ValueArray.h",
|
||||||
"../public/Vector.h",
|
"../public/Vector.h",
|
||||||
|
"../public/WaitCallbacks.h",
|
||||||
"../public/Warnings.h",
|
"../public/Warnings.h",
|
||||||
"../public/WasmFeatures.h",
|
"../public/WasmFeatures.h",
|
||||||
"../public/WasmModule.h",
|
"../public/WasmModule.h",
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "js/UniquePtr.h"
|
#include "js/UniquePtr.h"
|
||||||
#include "js/Utility.h"
|
#include "js/Utility.h"
|
||||||
#include "js/Vector.h"
|
#include "js/Vector.h"
|
||||||
|
#include "js/WaitCallbacks.h"
|
||||||
#include "js/Warnings.h" // JS::WarningReporter
|
#include "js/Warnings.h" // JS::WarningReporter
|
||||||
#include "js/WrapperCallbacks.h"
|
#include "js/WrapperCallbacks.h"
|
||||||
#include "js/Zone.h"
|
#include "js/Zone.h"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче