blob: 31a915e4f18fa01a9103d3958e7724ae1647d166 [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
20#include "arch/instruction_set.h"
Andreas Gampebda1d602016-08-29 17:43:45 -070021#include "base/logging.h"
Phil Wang751beff2015-08-28 15:17:15 +080022
23namespace art {
24
Andreas Gampe71da4872017-07-26 10:02:07 -070025class CodeSimulator;
26
Phil Wang751beff2015-08-28 15:17:15 +080027// This container dynamically opens and closes libart-simulator.
28class CodeSimulatorContainer {
29 public:
30 explicit CodeSimulatorContainer(InstructionSet target_isa);
31 ~CodeSimulatorContainer();
32
33 bool CanSimulate() const {
34 return simulator_ != nullptr;
35 }
36
37 CodeSimulator* Get() {
38 DCHECK(CanSimulate());
39 return simulator_;
40 }
41
42 const CodeSimulator* Get() const {
43 DCHECK(CanSimulate());
44 return simulator_;
45 }
46
47 private:
48 void* libart_simulator_handle_;
49 CodeSimulator* simulator_;
50
51 DISALLOW_COPY_AND_ASSIGN(CodeSimulatorContainer);
52};
53
54} // namespace art
55
Andreas Gampe71da4872017-07-26 10:02:07 -070056#endif // ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_