From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/vm/HelperThreadTask.h | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 js/src/vm/HelperThreadTask.h (limited to 'js/src/vm/HelperThreadTask.h') diff --git a/js/src/vm/HelperThreadTask.h b/js/src/vm/HelperThreadTask.h new file mode 100644 index 0000000000..d27e53033d --- /dev/null +++ b/js/src/vm/HelperThreadTask.h @@ -0,0 +1,76 @@ +/* -*- 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 vm_HelperThreadTask_h +#define vm_HelperThreadTask_h + +#include "mozilla/TimeStamp.h" + +#include "js/Utility.h" + +namespace js { + +class AutoLockHelperThreadState; +struct DelazifyTask; +struct FreeDelazifyTask; +class SourceCompressionTask; + +namespace jit { +class IonCompileTask; +class IonFreeTask; +} // namespace jit +namespace wasm { +struct Tier2GeneratorTask; +} // namespace wasm + +template +struct MapTypeToThreadType {}; + +template <> +struct MapTypeToThreadType { + static const ThreadType threadType = THREAD_TYPE_ION; +}; + +template <> +struct MapTypeToThreadType { + static const ThreadType threadType = THREAD_TYPE_WASM_GENERATOR_TIER2; +}; + +template <> +struct MapTypeToThreadType { + static const ThreadType threadType = THREAD_TYPE_DELAZIFY; +}; + +template <> +struct MapTypeToThreadType { + static const ThreadType threadType = THREAD_TYPE_DELAZIFY_FREE; +}; + +template <> +struct MapTypeToThreadType { + static const ThreadType threadType = THREAD_TYPE_COMPRESS; +}; + +struct HelperThreadTask { + virtual void runHelperThreadTask(AutoLockHelperThreadState& locked) = 0; + virtual ThreadType threadType() = 0; + virtual ~HelperThreadTask() = default; + + template + bool is() { + return MapTypeToThreadType::threadType == threadType(); + } + + template + T* as() { + MOZ_ASSERT(this->is()); + return static_cast(this); + } +}; + +} // namespace js + +#endif /* vm_HelperThreadTask_h */ -- cgit v1.2.3