1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef JSVM_UTIL_H
17 #define JSVM_UTIL_H
18
19 #include <array>
20 #include <cassert>
21 #include <climits>
22 #include <cstddef>
23 #include <cstdio>
24 #include <cstdlib>
25 #include <cstring>
26 #include <limits>
27 #include <memory>
28 #include <set>
29 #include <sstream>
30 #include <stack>
31 #include <string>
32 #include <string_view>
33 #include <type_traits>
34 #include <unordered_map>
35 #include <utility>
36 #include <vector>
37
38 // jsvm header
39 #include "jsvm_dfx.h"
40 #include "jsvm_log.h"
41 #include "jsvm_version.h"
42 #include "platform/platform.h"
43
44 // v8 header
45 #include "v8-inspector.h"
46 #include "v8-platform.h"
47 #include "v8-profiler.h"
48 #include "v8.h"
49
50
51 #ifdef __GNUC__
52 #define FORCE_INLINE __attribute__((always_inline))
53 #else
54 #define FORCE_INLINE
55 #endif
56
57 namespace jsvm {
58 template<typename T, size_t N>
ArraySize(const T (&)[N])59 constexpr size_t ArraySize(const T (&)[N])
60 {
61 return N;
62 }
63 } // namespace jsvm
64
65 namespace v8impl {
66 template<typename T>
67 using Persistent = v8::Global<T>;
68 } // namespace v8impl
69
70 enum ByteSize : uint8_t {
71 SIZE_0_BYTES = 0,
72 SIZE_1_BYTES = 1,
73 SIZE_2_BYTES = 2,
74 SIZE_4_BYTES = 4,
75 SIZE_8_BYTES = 8,
76 };
77
78 #endif