art\runtime\class_linker.cc::LoadField
LoadField设置ArtField结构中字段的一些值
void ClassLinker::LoadField(const ClassDataItemIterator& it,Handle<mirror::Class> klass,ArtField* dst) {const uint32_t field_idx = it.GetMemberIndex();dst->SetDexFieldIndex(field_idx);dst->SetDeclaringClass(klass.Get());dst->SetAccessFlags(it.GetFieldAccessFlags());}art\runtime\class_linker.cc::LoadMethod
LoadMethod函数主要做设置ArtMethod结构的一些属性 , 比如函数的MethodIdx,CodeItem在dex文件中的偏移 , 函数的AccessFlag等 。
void ClassLinker::LoadMethod(const DexFile& dex_file,const ClassDataItemIterator& it,Handle<mirror::Class> klass,ArtMethod* dst){uint32_t dex_method_idx = it.GetMemberIndex();const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);const char* method_name = dex_file.StringDataByIdx(method_id.name_idx_);ScopedAssertNoThreadSuspension ants("LoadMethod");dst->SetDexMethodIndex(dex_method_idx);dst->SetDeclaringClass(klass.Get());dst->SetCodeItemOffset(it.GetMethodCodeItemOffset());dst->SetDexCacheResolvedMethods(klass->GetDexCache()->GetResolvedMethods(), image_pointer_size_);uint32_t access_flags = it.GetMethodAccessFlags();......dst->SetAccessFlags(access_flags);}延申:ArtMethod是存储Java函数在虚拟机内相关信息的结构,它不同于mirror命名空间下的Method类,ArtMethod在Java层没有类与之直接映射 。
art\runtime\class_linker.cc::LinkCode
LinkCode函数主要功能是判断代码是否编译从而为函数设置入口代码 。
static void LinkCode(ClassLinker* class_linker,ArtMethod* method,const OatFile::OatClass* oat_class,uint32_t class_def_method_index){Runtime* const runtime = Runtime::Current();if (runtime->IsAotCompiler()) {// The following code only applies to a non-compiler runtime.return;}// Method shouldn't have already been linked.DCHECK(method->GetEntryPointFromQuickCompiledCode() == nullptr);if (oat_class != nullptr) {// Every kind of method should at least get an invoke stub from the oat_method.// non-abstract methods also get their code pointers.const OatFile::OatMethod oat_method = oat_class->GetOatMethod(class_def_method_index);oat_method.LinkMethod(method);}// Install entry point from interpreter.const void* quick_code = method->GetEntryPointFromQuickCompiledCode();bool enter_interpreter = class_linker->ShouldUseInterpreterEntrypoint(method, quick_code);if (!method->IsInvokable()) {EnsureThrowsInvocationError(class_linker, method);return;}if (method->IsStatic() && !method->IsConstructor()) {// For static methods excluding the class initializer, install the trampoline.// It will be replaced by the proper entry point by ClassLinker::FixupStaticTrampolines// after initializing class (see ClassLinker::InitializeClass method).method->SetEntryPointFromQuickCompiledCode(GetQuickResolutionStub());} else if (quick_code == nullptr && method->IsNative()) {method->SetEntryPointFromQuickCompiledCode(GetQuickGenericJniStub());} else if (enter_interpreter) {// Set entry point from compiled code if there's no code or in interpreter only mode.method->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge());}if (method->IsNative()) {// Unregistering restores the dlsym lookup stub.method->UnregisterNative();if (enter_interpreter || quick_code == nullptr) {// We have a native method here without code. Then it should have either the generic JNI// trampoline as entrypoint (non-static), or the resolution trampoline (static).// TODO: this doesn't handle all the cases where trampolines may be installed.const void* entry_point = method->GetEntryPointFromQuickCompiledCode();DCHECK(class_linker->IsQuickGenericJniStub(entry_point) ||class_linker->IsQuickResolutionStub(entry_point));}}}
推荐阅读
-
-
-
-
我前几年经营了一个个体户,后来不干了,因为当时没有缴税,所以没有注销,现在注销需要怎么做?
-
【养生知识】枇杷和梨果酱怎么做 枇杷可以和山楂一起煮吗
-
-
微信gif表情过大怎么办 ios 微信gif表情过大怎么办
-
-
-
-
-
-
-
惠普主板bios设置中文 惠普笔记本主板bios设置图解教程
-
jre和jdk的区别 jre和jdk安装在一个文件夹里吗
-
-
-
博士毕业送老师礼物排行榜 博士节日给导师送什么礼物
-
-