Add InitializedStaticStorage table
A non-null entry in the table not only provides access to the storage,
it also implies that the referenced type is initialized.
Change-Id: Ief9e88b7e58b65b6f9456a4218b7fe87f71c17bb
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 41a1c55..8236739 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -434,7 +434,8 @@
AllocObjectArray<Class>(dex_file.NumTypeIds()),
AllocObjectArray<Method>(dex_file.NumMethodIds()),
AllocObjectArray<Field>(dex_file.NumFieldIds()),
- AllocCodeAndDirectMethods(dex_file.NumMethodIds()));
+ AllocCodeAndDirectMethods(dex_file.NumMethodIds()),
+ AllocObjectArray<StaticStorageBase>(dex_file.NumTypeIds()));
return dex_cache;
}
@@ -767,10 +768,11 @@
dst->access_flags_ = src.access_flags_;
dst->dex_cache_strings_ = klass->dex_cache_->GetStrings();
- dst->dex_cache_types_ = klass->dex_cache_->GetTypes();
- dst->dex_cache_methods_ = klass->dex_cache_->GetMethods();
- dst->dex_cache_fields_ = klass->dex_cache_->GetFields();
+ dst->dex_cache_resolved_types_ = klass->dex_cache_->GetResolvedTypes();
+ dst->dex_cache_resolved_methods_ = klass->dex_cache_->GetResolvedMethods();
+ dst->dex_cache_resolved_fields_ = klass->dex_cache_->GetResolvedFields();
dst->dex_cache_code_and_direct_methods_ = klass->dex_cache_->GetCodeAndDirectMethods();
+ dst->dex_cache_initialized_static_storage_ = klass->dex_cache_->GetInitializedStaticStorage();
dst->is_direct_ = is_direct;
@@ -1277,6 +1279,19 @@
return !Thread::Current()->IsExceptionPending();
}
+StaticStorageBase* ClassLinker::InitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer) {
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ Class* klass = class_linker->ResolveType(type_idx, referrer);
+ if (klass == NULL) {
+ UNIMPLEMENTED(FATAL) << "throw exception due to unresolved class";
+ }
+ if (!class_linker->EnsureInitialized(klass)) {
+ CHECK(Thread::Current()->IsExceptionPending());
+ UNIMPLEMENTED(FATAL) << "throw exception due to class initializtion problem";
+ }
+ return klass;
+}
+
void ClassLinker::InitializeStaticFields(Class* klass) {
size_t num_static_fields = klass->NumStaticFields();
if (num_static_fields == 0) {