Skip to content

Commit

Permalink
Revert^3 "VIXL simulator for ART (Stage1)"
Browse files Browse the repository at this point in the history
This reverts commit e886d68.

Reason for revert: simulator implemention is not ready yet.

Test: lunch aosp_cf_x86_phone-userdebug && m
Test: art/test.py --run-test --optimizing --host
Change-Id: I03c8c09ea348205b0238d7a26caef3477cd6ae3b
  • Loading branch information
Ulya Trafimovich committed Jul 29, 2020
1 parent 483bf78 commit 5439f05
Show file tree
Hide file tree
Showing 30 changed files with 48 additions and 1,393 deletions.
1 change: 1 addition & 0 deletions build/apex/art_apex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ def run(self):

# Check ART test (internal) libraries.
self._checker.check_native_library('libart-gtest')
self._checker.check_native_library('libartd-simulator-container')

# Check ART test tools.
self._checker.check_executable('signal_dumper')
Expand Down
5 changes: 1 addition & 4 deletions compiler/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,10 @@ art_cc_test {
"libnativehelper_header_only",
],

static_libs: [
"libartd-simulator-container",
],

shared_libs: [
"libprofiled",
"libartd-compiler",
"libartd-simulator-container",
"libvixld",

"libbacktrace",
Expand Down
15 changes: 6 additions & 9 deletions compiler/optimizing/codegen_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,12 @@ static void VerifyGeneratedCode(InstructionSet target_isa,
Expected expected) {
ASSERT_TRUE(CanExecute(target_isa)) << "Target isa is not executable.";

// Simulator cannot run without runtime, because it needs quick entrypoints.
if (Runtime::Current() != nullptr) {
// Verify on simulator.
CodeSimulatorContainer simulator(target_isa);
if (simulator.CanSimulate()) {
Expected result = SimulatorExecute<Expected>(simulator.Get(), f);
if (has_result) {
ASSERT_EQ(expected, result);
}
// Verify on simulator.
CodeSimulatorContainer simulator(target_isa);
if (simulator.CanSimulate()) {
Expected result = SimulatorExecute<Expected>(simulator.Get(), f);
if (has_result) {
ASSERT_EQ(expected, result);
}
}

Expand Down
4 changes: 0 additions & 4 deletions runtime/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ libart_cc_defaults {
export_generated_headers: ["cpp-define-generator-asm-support"],
header_libs: [
"art_cmdlineparser_headers",
"libart_simulator_headers",
"cpp-define-generator-definitions",
"jni_platform_headers",
"libnativehelper_header_only",
Expand Down Expand Up @@ -467,7 +466,6 @@ libart_static_cc_defaults {
name: "libart_static_base_defaults",
static_libs: [
"libartpalette",
"libart-simulator-container",
"libbacktrace",
"libbase",
"liblog",
Expand Down Expand Up @@ -559,7 +557,6 @@ art_cc_library {
],
static_libs: [
"libelffile",
"libart-simulator-container",
],
shared_libs: [
"libartbase",
Expand Down Expand Up @@ -594,7 +591,6 @@ art_cc_library {
],
static_libs: [
"libelffiled",
"libartd-simulator-container",
],
shared_libs: [
"libartbased",
Expand Down
21 changes: 3 additions & 18 deletions runtime/art_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#include <cstddef>

#include "android-base/stringprintf.h"

#include "arch/context.h"
#include "art_method-inl.h"
#include "base/enums.h"
#include "base/stl_util.h"
#include "class_linker-inl.h"
#include "class_root-inl.h"
#include "code_simulator.h"
#include "code_simulator_container.h"
#include "debugger.h"
#include "dex/class_accessor-inl.h"
#include "dex/descriptors_names.h"
Expand Down Expand Up @@ -102,11 +101,6 @@ ArtMethod* ArtMethod::GetSingleImplementation(PointerSize pointer_size) {
return reinterpret_cast<ArtMethod*>(GetDataPtrSize(pointer_size));
}

bool ArtMethod::CanBeSimulated() REQUIRES_SHARED(Locks::mutator_lock_) {
CodeSimulatorContainer* simulator = Thread::Current()->GetSimulator();
return simulator->Get()->CanSimulate(this);
}

ArtMethod* ArtMethod::FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa,
jobject jlr_method) {
ObjPtr<mirror::Executable> executable = soa.Decode<mirror::Executable>(jlr_method);
Expand Down Expand Up @@ -361,9 +355,7 @@ void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue*
}

// Ensure that we won't be accidentally calling quick compiled code when -Xint.
if (kIsDebugBuild &&
runtime->GetInstrumentation()->IsForcedInterpretOnly() &&
!Runtime::SimulatorMode()) {
if (kIsDebugBuild && runtime->GetInstrumentation()->IsForcedInterpretOnly()) {
CHECK(!runtime->UseJitCompilation());
const void* oat_quick_code =
(IsNative() || !IsInvokable() || IsProxyMethod() || IsObsolete())
Expand All @@ -373,10 +365,7 @@ void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue*
<< "Don't call compiled code when -Xint " << PrettyMethod();
}

if (Runtime::SimulatorMode() && CanBeSimulated()) {
CodeSimulatorContainer* simulator = Thread::Current()->GetSimulator();
simulator->Get()->Invoke(this, args, args_size, self, result, shorty, IsStatic());
} else if (!IsStatic()) {
if (!IsStatic()) {
(*art_quick_invoke_stub)(this, args, args_size, self, result, shorty);
} else {
(*art_quick_invoke_static_stub)(this, args, args_size, self, result, shorty);
Expand Down Expand Up @@ -581,10 +570,6 @@ const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) {
return nullptr;
}

if (Runtime::SimulatorMode()) {
return nullptr;
}

Runtime* runtime = Runtime::Current();
const void* existing_entry_point = GetEntryPointFromQuickCompiledCode();
CHECK(existing_entry_point != nullptr) << PrettyMethod() << "@" << this;
Expand Down
2 changes: 0 additions & 2 deletions runtime/art_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ class ArtMethod final {
ClearAccessFlags(kAccSkipAccessChecks);
}

bool CanBeSimulated() REQUIRES_SHARED(Locks::mutator_lock_);

// Returns true if this method could be overridden by a default method.
bool IsOverridableByDefaultMethod() REQUIRES_SHARED(Locks::mutator_lock_);

Expand Down
19 changes: 5 additions & 14 deletions runtime/class_linker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2184,14 +2184,9 @@ bool ClassLinker::AddImageSpace(
header.VisitPackedArtMethods([&](ArtMethod& method) REQUIRES_SHARED(Locks::mutator_lock_) {
if (!method.IsRuntimeMethod()) {
DCHECK(method.GetDeclaringClass() != nullptr);
if (!method.IsResolutionMethod()) {
if (!method.IsNative()) {
method.SetEntryPointFromQuickCompiledCodePtrSize(GetQuickToInterpreterBridge(),
image_pointer_size_);
} else if (Runtime::SimulatorMode()) {
method.SetEntryPointFromQuickCompiledCodePtrSize(GetQuickGenericJniStub(),
image_pointer_size_);
}
if (!method.IsNative() && !method.IsResolutionMethod()) {
method.SetEntryPointFromQuickCompiledCodePtrSize(GetQuickToInterpreterBridge(),
image_pointer_size_);
}
}
}, space->Begin(), image_pointer_size_);
Expand Down Expand Up @@ -3558,10 +3553,6 @@ bool ClassLinker::ShouldUseInterpreterEntrypoint(ArtMethod* method, const void*
return true;
}

if (Runtime::SimulatorMode()) {
return !method->CanBeSimulated();
}

Runtime* runtime = Runtime::Current();
instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
if (instr->InterpretOnly()) {
Expand Down Expand Up @@ -3679,7 +3670,7 @@ void ClassLinker::FixupStaticTrampolines(Thread* self, ObjPtr<mirror::Class> kla
}

// Check whether the method is native, in which case it's generic JNI.
if ((Runtime::SimulatorMode() || quick_code == nullptr) && method->IsNative()) {
if (quick_code == nullptr && method->IsNative()) {
quick_code = GetQuickGenericJniStub();
} else if (ShouldUseInterpreterEntrypoint(method, quick_code)) {
// Use interpreter entry point.
Expand Down Expand Up @@ -3739,7 +3730,7 @@ static void LinkCode(ClassLinker* class_linker,
// Note: this mimics the logic in image_writer.cc that installs the resolution
// stub only if we have compiled code and the method needs a class initialization
// check.
if (quick_code == nullptr || Runtime::SimulatorMode()) {
if (quick_code == nullptr) {
method->SetEntryPointFromQuickCompiledCode(
method->IsNative() ? GetQuickGenericJniStub() : GetQuickToInterpreterBridge());
} else if (enter_interpreter) {
Expand Down
5 changes: 2 additions & 3 deletions runtime/elf_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "base/utils.h"
#include "elf/elf_utils.h"
#include "elf_file_impl.h"
#include "runtime.h"

namespace art {

Expand Down Expand Up @@ -1101,9 +1100,9 @@ bool ElfFileImpl<ElfTypes>::Load(File* file,

if (executable) {
InstructionSet elf_ISA = GetInstructionSetFromELF(GetHeader().e_machine, GetHeader().e_flags);
if (elf_ISA != Runtime::GetQuickCodeISA()) {
if (elf_ISA != kRuntimeISA) {
std::ostringstream oss;
oss << "Expected ISA " << Runtime::GetQuickCodeISA() << " but found " << elf_ISA;
oss << "Expected ISA " << kRuntimeISA << " but found " << elf_ISA;
*error_msg = oss.str();
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions runtime/entrypoints_order_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ class EntrypointsOrderTest : public CommonRuntimeTest {
EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_mark_stack, async_exception, sizeof(void*));
EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, async_exception, top_reflective_handle_scope,
sizeof(void*));
EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, top_reflective_handle_scope, simulator, sizeof(void*));
// The first field after tlsPtr_ is forced to a 16 byte alignment so it might have some space.
auto offset_tlsptr_end = OFFSETOF_MEMBER(Thread, tlsPtr_) +
sizeof(decltype(reinterpret_cast<Thread*>(16)->tlsPtr_));
CHECKED(offset_tlsptr_end - OFFSETOF_MEMBER(Thread, tlsPtr_.simulator) == sizeof(void*),
"simulator last field");
CHECKED(offset_tlsptr_end - OFFSETOF_MEMBER(Thread, tlsPtr_.top_reflective_handle_scope) ==
sizeof(void*),
"async_exception last field");
}

void CheckJniEntryPoints() {
Expand Down
3 changes: 0 additions & 3 deletions runtime/interpreter/mterp/mterp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ bool CanUseMterp()
runtime->IsStarted() &&
!runtime->IsAotCompiler() &&
!runtime->GetInstrumentation()->IsActive() &&
// In simulator mode, mterp and its fast path are avoided to ensure every
// called method can go through ArtMethod::Invoke().
!Runtime::SimulatorMode() &&
// mterp only knows how to deal with the normal exits. It cannot handle any of the
// non-standard force-returns.
!runtime->AreNonStandardExitsEnabled() &&
Expand Down
6 changes: 2 additions & 4 deletions runtime/native/java_lang_VMClassLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ static jobjectArray VMClassLoader_getBootClassPathEntries(JNIEnv* env, jclass) {
const DexFile* dex_file = path[i];

// For multidex locations, e.g., x.jar!classes2.dex, we want to look into x.jar.
std::string location(DexFileLoader::GetBaseLocation(dex_file->GetLocation()));
if (Runtime::SimulatorMode()) {
location = getenv("ANDROID_PRODUCT_OUT") + location;
}
const std::string location(DexFileLoader::GetBaseLocation(dex_file->GetLocation()));

ScopedLocalRef<jstring> javaPath(env, env->NewStringUTF(location.c_str()));
if (javaPath.get() == nullptr) {
DCHECK(env->ExceptionCheck());
Expand Down
4 changes: 2 additions & 2 deletions runtime/oat_file_assistant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ OatFileAssistant::OatFileAssistant(const char* dex_location,

dex_location_.assign(dex_location);

if (load_executable_ && isa != Runtime::GetQuickCodeISA()) {
if (load_executable_ && isa != kRuntimeISA) {
LOG(WARNING) << "OatFileAssistant: Load executable specified, "
<< "but isa is not executable isa. Will not attempt to load executable.";
<< "but isa is not kRuntimeISA. Will not attempt to load executable.";
load_executable_ = false;
}

Expand Down
8 changes: 4 additions & 4 deletions runtime/oat_file_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ std::vector<std::unique_ptr<const DexFile>> OatFileManager::OpenDexFilesFromOat(
std::unique_ptr<ClassLoaderContext> context(
ClassLoaderContext::CreateContextForClassLoader(class_loader, dex_elements));

OatFileAssistant oat_file_assistant(dex_location,
Runtime::GetQuickCodeISA(),
runtime->GetOatFilesExecutable(),
only_use_system_oat_files_);
OatFileAssistant oat_file_assistant(dex_location,
kRuntimeISA,
runtime->GetOatFilesExecutable(),
only_use_system_oat_files_);

// Get the oat file on disk.
std::unique_ptr<const OatFile> oat_file(oat_file_assistant.GetBestOatFile().release());
Expand Down
5 changes: 0 additions & 5 deletions runtime/parsed_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,6 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize
.WithType<bool>()
.WithValueMap({{"false", false}, {"true", true}})
.IntoKey(M::PerfettoHprof)
.Define("--simulate-isa=_")
.WithType<InstructionSet>()
.WithValueMap({{"none", InstructionSet::kNone},
{"arm64", InstructionSet::kArm64}})
.IntoKey(M::SimulateInstructionSet)
.Ignore({
"-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa",
"-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_",
Expand Down
15 changes: 0 additions & 15 deletions runtime/parsed_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ TEST_F(ParsedOptionsTest, ParsedOptions) {
EXPECT_FALSE(VLOG_IS_ON(startup));
EXPECT_FALSE(VLOG_IS_ON(third_party_jni));
EXPECT_FALSE(VLOG_IS_ON(threads));
EXPECT_PARSED_EQ(InstructionSet::kNone, Opt::SimulateInstructionSet);

auto&& properties_list = map.GetOrDefault(Opt::PropertiesList);
ASSERT_EQ(2U, properties_list.size());
Expand Down Expand Up @@ -182,18 +181,4 @@ TEST_F(ParsedOptionsTest, ParsedOptionsInstructionSet) {
}
}

TEST_F(ParsedOptionsTest, ParsedOptionSimulateInstructionSet) {
RuntimeOptions options;
options.push_back(std::make_pair("--simulate-isa=arm64", nullptr));

RuntimeArgumentMap map;
bool parsed = ParsedOptions::Parse(options, false, &map);
ASSERT_TRUE(parsed);
ASSERT_NE(0u, map.Size());

using Opt = RuntimeArgumentMap;

EXPECT_PARSED_EQ(InstructionSet::kArm64, Opt::SimulateInstructionSet);
}

} // namespace art
Loading

0 comments on commit 5439f05

Please sign in to comment.