Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andreas Gampe | 71da487 | 2017-07-26 10:02:07 -0700 | [diff] [blame] | 17 | #ifndef ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_ |
| 18 | #define ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_ |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 19 | |
Andreas Gampe | 5794381 | 2017-12-06 21:39:13 -0800 | [diff] [blame] | 20 | #include <android-base/logging.h> |
| 21 | |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 22 | #include "arch/instruction_set.h" |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
Andreas Gampe | 71da487 | 2017-07-26 10:02:07 -0700 | [diff] [blame] | 26 | class CodeSimulator; |
| 27 | |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 28 | // This container dynamically opens and closes libart-simulator. |
| 29 | class CodeSimulatorContainer { |
| 30 | public: |
| 31 | explicit CodeSimulatorContainer(InstructionSet target_isa); |
| 32 | ~CodeSimulatorContainer(); |
| 33 | |
| 34 | bool CanSimulate() const { |
| 35 | return simulator_ != nullptr; |
| 36 | } |
| 37 | |
| 38 | CodeSimulator* Get() { |
| 39 | DCHECK(CanSimulate()); |
| 40 | return simulator_; |
| 41 | } |
| 42 | |
| 43 | const CodeSimulator* Get() const { |
| 44 | DCHECK(CanSimulate()); |
| 45 | return simulator_; |
| 46 | } |
| 47 | |
| 48 | private: |
| 49 | void* libart_simulator_handle_; |
| 50 | CodeSimulator* simulator_; |
| 51 | |
| 52 | DISALLOW_COPY_AND_ASSIGN(CodeSimulatorContainer); |
| 53 | }; |
| 54 | |
| 55 | } // namespace art |
| 56 | |
Andreas Gampe | 71da487 | 2017-07-26 10:02:07 -0700 | [diff] [blame] | 57 | #endif // ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_ |