blob: 10178bac673080cd7d57c0dd3d33a7513aef3cff [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
17#ifndef ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_
18#define ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_
19
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#include "simulator/code_simulator.h"
23
24namespace art {
25
26// This container dynamically opens and closes libart-simulator.
27class CodeSimulatorContainer {
28 public:
29 explicit CodeSimulatorContainer(InstructionSet target_isa);
30 ~CodeSimulatorContainer();
31
32 bool CanSimulate() const {
33 return simulator_ != nullptr;
34 }
35
36 CodeSimulator* Get() {
37 DCHECK(CanSimulate());
38 return simulator_;
39 }
40
41 const CodeSimulator* Get() const {
42 DCHECK(CanSimulate());
43 return simulator_;
44 }
45
46 private:
47 void* libart_simulator_handle_;
48 CodeSimulator* simulator_;
49
50 DISALLOW_COPY_AND_ASSIGN(CodeSimulatorContainer);
51};
52
53} // namespace art
54
55#endif // ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_