From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/jit/ABIFunctions.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 js/src/jit/ABIFunctions.h (limited to 'js/src/jit/ABIFunctions.h') diff --git a/js/src/jit/ABIFunctions.h b/js/src/jit/ABIFunctions.h new file mode 100644 index 0000000000..d6bd15555f --- /dev/null +++ b/js/src/jit/ABIFunctions.h @@ -0,0 +1,73 @@ +/* -*- 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 jit_ABIFunctions_h +#define jit_ABIFunctions_h + +#include "jstypes.h" // JS_FUNC_TO_DATA_PTR + +namespace js { +namespace jit { + +// This class is used to ensure that all known targets of callWithABI are +// registered here. Otherwise, this would raise a static assertion at compile +// time. +template +struct ABIFunctionData { + static const bool registered = false; +}; + +template +struct ABIFunction { + void* address() const { return JS_FUNC_TO_DATA_PTR(void*, fun); } + + // If this assertion fails, you are likely in the context of a + // `callWithABI()` call. This error indicates that ABIFunction has + // not been specialized for `` by the time of this call. + // + // This can be fixed by adding the function signature to either + // ABIFUNCTION_LIST or ABIFUNCTION_AND_TYPE_LIST (if overloaded) within + // `ABIFunctionList-inl.h` and to add an `#include` statement of this header + // in the file which is making the call to `callWithABI()`. + static_assert(ABIFunctionData::registered, + "ABI function is not registered."); +}; + +template +struct ABIFunctionSignatureData { + static const bool registered = false; +}; + +template +struct ABIFunctionSignature { + void* address(Sig fun) const { return JS_FUNC_TO_DATA_PTR(void*, fun); } + + // If this assertion fails, you are likely in the context of a + // `DynamicFunction(fn)` call. This error indicates that + // ABIFunctionSignature has not been specialized for `Sig` by the time of this + // call. + // + // This can be fixed by adding the function signature to ABIFUNCTIONSIG_LIST + // within `ABIFunctionList-inl.h` and to add an `#include` statement of this + // header in the file which is making the call to `DynamicFunction(fn)`. + static_assert(ABIFunctionSignatureData::registered, + "ABI function signature is not registered."); +}; + +// This is a structure created to ensure that the dynamically computed +// function pointer is well typed. +// +// It is meant to be created only through DynamicFunction function calls. In +// extremelly rare cases, such as VMFunctions, it might be produced as a result +// of GetVMFunctionTarget. +struct DynFn { + void* address; +}; + +} // namespace jit +} // namespace js + +#endif /* jit_VMFunctions_h */ -- cgit v1.2.3