blob: a21971508a060a64be9bb4674d1065ee85aab226 [file] [log] [blame]
Phil Wang751beff2015-08-28 15:17:15 +08001/*
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 Gampe71da4872017-07-26 10:02:07 -070017#ifndef ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
18#define ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
Phil Wang751beff2015-08-28 15:17:15 +080019
Andreas Gampe57943812017-12-06 21:39:13 -080020#include <android-base/logging.h>
21
Phil Wang751beff2015-08-28 15:17:15 +080022#include "arch/instruction_set.h"
Phil Wang751beff2015-08-28 15:17:15 +080023
24namespace art {
25
Andreas Gampe71da4872017-07-26 10:02:07 -070026class CodeSimulator;
27
Phil Wang751beff2015-08-28 15:17:15 +080028// This container dynamically opens and closes libart-simulator.
29class 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 Gampe71da4872017-07-26 10:02:07 -070057#endif // ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_