Implement suspend flags as atomic variable (#2361)

We have observed a significant performance degradation after merging
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1991
Instead of protecting suspend flags with a mutex, we implement the flags
as atomic variable and only use mutex when atomics are not available
on a given platform.
This commit is contained in:
Marcin Kolny
2023-07-21 01:27:09 +01:00
committed by GitHub
parent fbe072c0d3
commit 0f4edf9735
8 changed files with 135 additions and 45 deletions

View File

@ -16,6 +16,7 @@
#include "bh_log.h"
#include "bh_queue.h"
#include "bh_vector.h"
#include "gnuc.h"
#include "runtime_timer.h"
/**

14
core/shared/utils/gnuc.h Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#if !defined(__GNUC_PREREQ) && (defined(__GNUC__) || defined(__GNUG__)) \
&& !defined(__clang__) && defined(__GNUC_MINOR__)
/* Depending on the platform the macro is defined in sys/features.h or
features.h Given the macro is simple, we re-implement it here instead of
dealing with two different paths.
*/
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#endif