1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
diff --git a/contrib/restricted/wavm/Include/WAVM/Inline/Assert.h b/contrib/restricted/wavm/Include/WAVM/Inline/Assert.h
--- a/contrib/restricted/wavm/Include/WAVM/Inline/Assert.h
+++ b/contrib/restricted/wavm/Include/WAVM/Inline/Assert.h
@@ -1,42 +1,35 @@
#pragma once
#include <cstdarg>
+#include <stdexcept>
#include "WAVM/Inline/Config.h"
#include "WAVM/Platform/Defines.h"
#include "WAVM/Platform/Error.h"
-#define WAVM_ENABLE_ASSERTS (WAVM_DEBUG || WAVM_ENABLE_RELEASE_ASSERTS)
+#define WAVM_ENABLE_ASSERTS 1
-#if WAVM_ENABLE_ASSERTS
-#define WAVM_ASSERT(condition) \
- if(!(condition)) \
- { \
- for(static const WAVM::Platform::AssertMetadata wavmAssertMetadata{ \
- #condition, __FILE__, __LINE__}; \
- ;) \
- { \
- WAVM::Platform::handleAssertionFailure(wavmAssertMetadata); \
- WAVM_DEBUG_TRAP(); \
- break; \
- } \
- }
-#else
-#define WAVM_ASSERT(condition) \
- if(false && !(condition)) {}
+#ifndef WAVM_STRINGIZE
+#define WAVM_STRINGIZE_DETAIL(x) #x
+#define WAVM_STRINGIZE(x) WAVM_STRINGIZE_DETAIL(x)
#endif
-#define WAVM_ERROR_UNLESS(condition) \
- if(!(condition)) \
- { \
- for(static const WAVM::Platform::AssertMetadata wavmAssertMetadata{ \
- #condition, __FILE__, __LINE__}; \
- ;) \
- { \
- WAVM::Platform::handleAssertionFailure(wavmAssertMetadata); \
- WAVM_UNREACHABLE(); \
- break; \
- } \
+#define WAVM_ASSERT(condition) \
+ if(!(condition)) \
+ { \
+ const char* message = "WAVM assertion failed at " __FILE__ ":" WAVM_STRINGIZE(__LINE__) " (" #condition ")"; \
+ throw std::runtime_error(message); \
}
-#define WAVM_UNREACHABLE() \
- while(true) { WAVM_DEBUG_TRAP(); };
+#define WAVM_ERROR_UNLESS(condition) \
+ if(!(condition)) \
+ { \
+ const char* message = "WAVM error unless failed at " __FILE__ ":" WAVM_STRINGIZE(__LINE__) " (" #condition ")"; \
+ throw std::runtime_error(message); \
+ }
+
+#define WAVM_UNREACHABLE(condition) \
+ while(true) \
+ { \
+ const char* message = "WAVM unreachable at " __FILE__ ":" WAVM_STRINGIZE(__LINE__) " (" #condition ")"; \
+ throw std::runtime_error(message); \
+ }
diff --git a/contrib/restricted/wavm/Include/WAVM/RuntimeABI/RuntimeABI.h b/contrib/restricted/wavm/Include/WAVM/RuntimeABI/RuntimeABI.h
--- a/contrib/restricted/wavm/Include/WAVM/RuntimeABI/RuntimeABI.h
+++ b/contrib/restricted/wavm/Include/WAVM/RuntimeABI/RuntimeABI.h
@@ -5,6 +5,7 @@
//
#include <atomic>
+#include <cassert>
#include <map>
#include "WAVM/IR/Types.h"
#include "WAVM/IR/Value.h"
@@ -185,7 +186,7 @@ namespace WAVM { namespace Runtime {
~FunctionMutableData()
{
- WAVM_ASSERT(numRootReferences.load(std::memory_order_acquire) == 0);
+ assert(numRootReferences.load(std::memory_order_acquire) == 0);
if(finalizeUserData) { (*finalizeUserData)(userData); }
}
};
diff --git a/contrib/restricted/wavm/Lib/Runtime/Invoke.cpp b/contrib/restricted/wavm/Lib/Runtime/Invoke.cpp
--- a/contrib/restricted/wavm/Lib/Runtime/Invoke.cpp
+++ b/contrib/restricted/wavm/Lib/Runtime/Invoke.cpp
@@ -39,7 +39,7 @@ void Runtime::invokeFunction(Context* context,
// Assert that the function, the context, and any reference arguments are all in the same
// compartment.
- if(WAVM_ENABLE_ASSERTS)
+ if(false)
{
WAVM_ASSERT(isInCompartment(asObject(function), context->compartment));
for(Uptr argumentIndex = 0; argumentIndex < invokeSig.params().size(); ++argumentIndex)
|