diff options
author | 2015-08-28 15:17:15 +0800 | |
---|---|---|
committer | 2015-11-06 14:44:20 +0800 | |
commit | 751beff19b36f777d9e3a966d754fd9cfad5d534 (patch) | |
tree | 450cb7ef8cb9f955a6d689c394bd85bc9eea14f1 /runtime/code_simulator_container.cc | |
parent | 4bbe7807f313bb8e59131812c31bf31513094f8f (diff) |
Revert "Revert "Introduce support for hardware simulators, starting with ARM64""
This reverts commit 4cd27d64b0bbdde61fa3f6674ceb24221853ac2c.
This depends on VIXL 1.11.
Change-Id: I402c1fd6bbb218ba80ef8e59af203c9276151059
Diffstat (limited to 'runtime/code_simulator_container.cc')
-rw-r--r-- | runtime/code_simulator_container.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/runtime/code_simulator_container.cc b/runtime/code_simulator_container.cc new file mode 100644 index 0000000000..d884c58782 --- /dev/null +++ b/runtime/code_simulator_container.cc @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlfcn.h> + +#include "code_simulator_container.h" +#include "globals.h" + +namespace art { + +CodeSimulatorContainer::CodeSimulatorContainer(InstructionSet target_isa) + : libart_simulator_handle_(nullptr), + simulator_(nullptr) { + const char* libart_simulator_so_name = + kIsDebugBuild ? "libartd-simulator.so" : "libart-simulator.so"; + libart_simulator_handle_ = dlopen(libart_simulator_so_name, RTLD_NOW); + // It is not a real error when libart-simulator does not exist, e.g., on target. + if (libart_simulator_handle_ == nullptr) { + VLOG(simulator) << "Could not load " << libart_simulator_so_name << ": " << dlerror(); + } else { + typedef CodeSimulator* (*create_code_simulator_ptr_)(InstructionSet target_isa); + create_code_simulator_ptr_ create_code_simulator_ = + reinterpret_cast<create_code_simulator_ptr_>( + dlsym(libart_simulator_handle_, "CreateCodeSimulator")); + DCHECK(create_code_simulator_ != nullptr) << "Fail to find symbol of CreateCodeSimulator: " + << dlerror(); + simulator_ = create_code_simulator_(target_isa); + } +} + +CodeSimulatorContainer::~CodeSimulatorContainer() { + // Free simulator object before closing libart-simulator because destructor of + // CodeSimulator lives in it. + if (simulator_ != nullptr) { + delete simulator_; + } + if (libart_simulator_handle_ != nullptr) { + dlclose(libart_simulator_handle_); + } +} + +} // namespace art |