• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 #ifndef PANDA_INTERPRETER_DISPATCH_TABLE_H_
16 #define PANDA_INTERPRETER_DISPATCH_TABLE_H_
17 
18 #include <array>
19 #include <cstddef>
20 #include <cstdint>
21 
22 #ifdef PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES
23 #include "arch/global_regs.h"
24 #endif
25 
26 namespace panda::interpreter {
27 
28 #ifdef PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES
29 
SetDispatchTable(const void * const * dispatch_table)30 ALWAYS_INLINE inline void SetDispatchTable(const void *const *dispatch_table)
31 {
32     arch::regs::SetDispatchTable(dispatch_table);
33 }
34 
GetDispatchTable(const void * const * dispatch_table)35 ALWAYS_INLINE inline const void *const *GetDispatchTable([[maybe_unused]] const void *const *dispatch_table)
36 {
37     return arch::regs::GetDispatchTable();
38 }
39 
40 #else
41 
42 ALWAYS_INLINE inline void SetDispatchTable([[maybe_unused]] const void *const *dispatch_table) {}
43 
44 ALWAYS_INLINE inline const void *const *GetDispatchTable(const void *const *dispatch_table)
45 {
46     return dispatch_table;
47 }
48 
49 #endif  // PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES
50 
51 }  // namespace panda::interpreter
52 
53 #endif  // PANDA_INTERPRETER_DISPATCH_TABLE_H_
54