CommonRuntimeTestImpl::~CommonRuntimeTestImpl() { // Ensure the dex files are cleaned up before the runtime.
loaded_dex_files_.clear();
runtime_.reset();
}
// Technically this is redundant w/ common_art_test, but still check.
options.push_back(std::make_pair("-XX:SlowDebug=true", nullptr)); staticbool gSlowDebugTestFlag = false;
RegisterRuntimeDebugFlag(&gSlowDebugTestFlag);
// Create default compiler callbacks. `SetUpRuntimeOptions()` can replace or remove this.
callbacks_.reset(new NoopCompilerCallbacks());
SetUpRuntimeOptions(&options);
// Install compiler-callbacks if SetUpRuntimeOptions hasn't deleted them. if (callbacks_.get() != nullptr) {
options.push_back(std::make_pair("compilercallbacks", callbacks_.get()));
}
// Runtime::Create acquired the mutator_lock_ that is normally given away when we // Runtime::Start, give it away now and then switch to a more managable ScopedObjectAccess.
Thread::Current()->TransitionFromRunnableToSuspended(ThreadState::kNative);
// Get the boot class path from the runtime so it can be used in tests.
boot_class_path_ = class_linker_->GetBootClassPath();
ASSERT_FALSE(boot_class_path_.empty());
java_lang_dex_file_ = boot_class_path_[0];
FinalizeSetup();
if (kIsDebugBuild) { // Ensure that we're really running with debug checks enabled.
CHECK(gSlowDebugTestFlag);
}
}
void CommonRuntimeTestImpl::FinalizeSetup() { // Initialize maps for unstarted runtime. This needs to be here, as running clinits needs this // set up. if (!unstarted_initialized_) {
interpreter::UnstartedRuntime::Initialize();
unstarted_initialized_ = true;
} else {
interpreter::UnstartedRuntime::Reinitialize();
}
runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test // Reduce timinig-dependent flakiness in OOME behavior (eg StubTest.AllocObject).
runtime_->GetHeap()->SetMinIntervalHomogeneousSpaceCompactionByOom(0U);
}
void CommonRuntimeTestImpl::TearDown() {
CommonArtTestImpl::TearDown(); if (runtime_ != nullptr) {
runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption after the test
}
}
// Check that for target builds we have ART_TARGET_NATIVETEST_DIR set. #ifdef ART_TARGET #ifndef ART_TARGET_NATIVETEST_DIR #error"ART_TARGET_NATIVETEST_DIR not set." #endif // Wrap it as a string literal. #define ART_TARGET_NATIVETEST_DIR_STRING STRINGIFY(ART_TARGET_NATIVETEST_DIR) "/" #else #define ART_TARGET_NATIVETEST_DIR_STRING "" #endif
// Verify that the result has the correct class.
CHECK_EQ(h_loader_class.Get(), result->GetClass()); // Verify that the parent is not null. The boot class loader will be set up as a // proper object.
ObjPtr<mirror::ClassLoader> actual_parent(result->GetParent());
CHECK(actual_parent != nullptr);
if (parent_loader != nullptr) { // We were given a parent. Verify that it's what we expect.
CHECK_EQ(h_parent_loader.Get(), actual_parent);
} else { // No parent given. The parent must be the BootClassLoader.
CHECK(class_linker->IsBootClassLoader(actual_parent));
}
}
// Class java.lang.Object.
Handle<mirror::Class> c(handle_scope->NewHandle(
class_linker->FindSystemClass(self, "Ljava/lang/Object;"))); // Array helps to fill memory faster.
Handle<mirror::Class> ca(handle_scope->NewHandle(
class_linker->FindSystemClass(self, "[Ljava/lang/Object;")));
// Start allocating with ~128K
size_t length = 128 * KB; while (length > 40) { const int32_t array_length = length / 4; // Object[] has elements of size 4.
MutableHandle<mirror::Object> h(handle_scope->NewHandle<mirror::Object>(
mirror::ObjectArray<mirror::Object>::Alloc(self, ca.Get(), array_length))); if (self->IsExceptionPending() || h == nullptr) {
self->ClearException();
// Try a smaller length
length = length / 2; // Use at most a quarter the reported free space.
size_t mem = Runtime::Current()->GetHeap()->GetFreeMemory(); if (length * 4 > mem) {
length = mem / 4;
}
}
}
// Allocate simple objects till it fails. while (!self->IsExceptionPending()) {
handle_scope->NewHandle<mirror::Object>(c->AllocObject(self));
}
self->ClearException();
}
void CommonRuntimeTestImpl::SetUpRuntimeOptionsForFillHeap(RuntimeOptions *options) { // Use a smaller heap bool found = false; for (std::pair<std::string, constvoid*>& pair : *options) { if (pair.first.find("-Xmx") == 0) {
pair.first = "-Xmx4M"; // Smallest we can go.
found = true;
}
} if (!found) {
options->emplace_back("-Xmx4M", nullptr);
}
}
Runtime* runtime = Runtime::Current(); if (use_runtime_bcp_and_image && runtime->GetHeap()->GetBootImageSpaces().empty()) {
*error_msg = "No image location found for Dex2Oat."; returnfalse;
}
argv->push_back(runtime->GetCompilerExecutable()); if (runtime->IsJavaDebuggable()) {
argv->push_back("--debuggable");
}
runtime->AddCurrentRuntimeFeaturesAsDex2OatArguments(argv);
if (use_runtime_bcp_and_image) {
argv->push_back("--runtime-arg");
argv->push_back(GetClassPathOption("-Xbootclasspath:", GetLibCoreDexFileNames()));
argv->push_back("--runtime-arg");
argv->push_back(GetClassPathOption("-Xbootclasspath-locations:", GetLibCoreDexLocations()));
void CheckJniAbortCatcher::Check(constchar* expected_text) {
EXPECT_TRUE(actual_.find(expected_text) != std::string::npos) << "\n"
<< "Expected to find: " << expected_text << "\n"
<< "In the output : " << actual_;
actual_.clear();
}
void CheckJniAbortCatcher::Hook(void* data, const std::string& reason) { // We use += because when we're hooking the aborts like this, multiple problems can be found.
*reinterpret_cast<std::string*>(data) += reason;
}
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.