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/ABIArgGenerator.h | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 js/src/jit/ABIArgGenerator.h (limited to 'js/src/jit/ABIArgGenerator.h') diff --git a/js/src/jit/ABIArgGenerator.h b/js/src/jit/ABIArgGenerator.h new file mode 100644 index 0000000000..d78a21e242 --- /dev/null +++ b/js/src/jit/ABIArgGenerator.h @@ -0,0 +1,109 @@ +/* -*- 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_ABIArgGenerator_h +#define jit_ABIArgGenerator_h + +#include "mozilla/Assertions.h" + +#include + +#include "jit/Assembler.h" +#include "jit/IonTypes.h" +#include "jit/RegisterSets.h" +#include "wasm/WasmFrame.h" + +namespace js::jit { + +static inline MIRType ToMIRType(MIRType t) { return t; } + +static inline MIRType ToMIRType(ABIArgType argType) { + switch (argType) { + case ArgType_General: + return MIRType::Pointer; + case ArgType_Float64: + return MIRType::Double; + case ArgType_Float32: + return MIRType::Float32; + case ArgType_Int32: + return MIRType::Int32; + case ArgType_Int64: + return MIRType::Int64; + default: + break; + } + MOZ_CRASH("unexpected argType"); +} + +template +class ABIArgIterBase { + ABIArgGeneratorT gen_; + const VecT& types_; + unsigned i_; + + void settle() { + if (!done()) gen_.next(ToMIRType(types_[i_])); + } + + public: + explicit ABIArgIterBase(const VecT& types) : types_(types), i_(0) { + settle(); + } + void operator++(int) { + MOZ_ASSERT(!done()); + i_++; + settle(); + } + bool done() const { return i_ == types_.length(); } + + ABIArg* operator->() { + MOZ_ASSERT(!done()); + return &gen_.current(); + } + ABIArg& operator*() { + MOZ_ASSERT(!done()); + return gen_.current(); + } + + unsigned index() const { + MOZ_ASSERT(!done()); + return i_; + } + MIRType mirType() const { + MOZ_ASSERT(!done()); + return ToMIRType(types_[i_]); + } + uint32_t stackBytesConsumedSoFar() const { + return gen_.stackBytesConsumedSoFar(); + } +}; + +// This is not an alias because we want to allow class template argument +// deduction. +template +class ABIArgIter : public ABIArgIterBase { + public: + explicit ABIArgIter(const VecT& types) + : ABIArgIterBase(types) {} +}; + +class WasmABIArgGenerator : public ABIArgGenerator { + public: + WasmABIArgGenerator() { + increaseStackOffset(wasm::FrameWithInstances::sizeOfInstanceFields()); + } +}; + +template +class WasmABIArgIter : public ABIArgIterBase { + public: + explicit WasmABIArgIter(const VecT& types) + : ABIArgIterBase(types) {} +}; + +} // namespace js::jit + +#endif /* jit_ABIArgGenerator_h */ -- cgit v1.2.3