- 浏览: 103566 次
- 性别:
- 来自: 武汉
最新评论
-
hatedance:
这个bytecodeInterpreter应该已经被遗弃了,现 ...
openjdk中的同步代码 -
Mr_lee_2012:
是啊,好文章,谢过。
java栈帧中的对象引用 -
ZangXT:
有些性能要求比较高的系统会考虑这一点的,典型的如JPC,尽量避 ...
java中调用接口及调用继承类效率区别 -
tinywind:
你有没有注意到load_classfile开始定义了个Reso ...
hotsphot中的ResourceArea -
qianli-2010:
java中调用接口及调用继承类效率区别
instanceKlassHandle ClassFileParser::parseClassFile(symbolHandle name,
Handle class_loader,
Handle protection_domain,
symbolHandle& parsed_name,
TRAPS)
是一个非常复杂的方法。
unsigned char *cached_class_file_bytes = NULL;
jint cached_class_file_length;
//加载的类文件流
ClassFileStream* cfs = stream();
// Timing
PerfTraceTime vmtimer(ClassLoader::perf_accumulated_time());
_has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
if (JvmtiExport::should_post_class_file_load_hook()) {
unsigned char* ptr = cfs->buffer();
unsigned char* end_ptr = cfs->buffer() + cfs->length();
JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain,
&ptr, &end_ptr,
&cached_class_file_bytes,
&cached_class_file_length);
if (ptr != cfs->buffer()) {
cfs = new ClassFileStream(ptr, end_ptr - ptr, cfs->source());
set_stream(cfs);
}
}
instanceKlassHandle nullHandle;
// Figure out whether we can skip format checking (matching classic VM behavior)
_need_verify = Verifier::should_verify_for(class_loader());
// Set the verify flag in stream
cfs->set_verify(_need_verify);
// 类名不能为空
_class_name = name.not_null()? name : vmSymbolHandles::unknown_class_name();
cfs->guarantee_more(8, CHECK_(nullHandle)); // magic, major, minor
// 文件模数,看是否java文件格式
u4 magic = cfs->get_u4_fast();
guarantee_property(magic == JAVA_CLASSFILE_MAGIC,
"Incompatible magic value %u in class file %s",
magic, CHECK_(nullHandle));
// jdk的版本号
u2 minor_version = cfs->get_u2_fast();
u2 major_version = cfs->get_u2_fast();
// Check version numbers - we check this even with verifier off
if (!is_supported_version(major_version, minor_version)) {
if (name.is_null()) {
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbolHandles::java_lang_UnsupportedClassVersionError(),
"Unsupported major.minor version %u.%u",
major_version,
minor_version);
} else {
ResourceMark rm(THREAD);
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbolHandles::java_lang_UnsupportedClassVersionError(),
"%s : Unsupported major.minor version %u.%u",
name->as_C_string(),
major_version,
minor_version);
}
return nullHandle;
}
_major_version = major_version;
_minor_version = minor_version;
// Check if verification needs to be relaxed for this class file
// Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376)
_relax_verify = Verifier::relax_verify_for(class_loader());
// 对常量池进行解析,常量池存放文件字符串、final变量值、类名、方法名等常量。
constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle));
int cp_size = cp->length();
cfs->guarantee_more(8, CHECK_(nullHandle)); // flags, this_class, super_class, infs_len
// Access flags
AccessFlags access_flags;
...
u2 super_class_index = cfs->get_u2_fast();
//只有java.lang.Object没有超类
if (super_class_index == 0) {
check_property(class_name() == vmSymbols::java_lang_Object(),
"Invalid superclass index %u in class file %s",
super_class_index,
CHECK_(nullHandle));
} else {
check_property(valid_cp_range(super_class_index, cp_size) &&
cp->tag_at(super_class_index).is_unresolved_klass(),
"Invalid superclass index %u in class file %s",
super_class_index,
CHECK_(nullHandle));
// The class name should be legal because it is checked when parsing constant pool.
// However, make sure it is not an array type.
if (_need_verify) {
guarantee_property(cp->unresolved_klass_at(super_class_index)->byte_at(0) != JVM_SIGNATURE_ARRAY,
"Bad superclass name in class file %s", CHECK_(nullHandle));
}
}
//先解析类的接口
u2 itfs_len = cfs->get_u2_fast();
objArrayHandle local_interfaces;
if (itfs_len == 0) {
local_interfaces = objArrayHandle(THREAD, Universe::the_empty_system_obj_array());
} else {
local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, &vmtimer, _class_name, CHECK_(nullHandle));
}
// Fields (offsets are filled in later)
struct FieldAllocationCount fac = {0,0,0,0,0,0,0,0,0,0};
objArrayHandle fields_annotations;
typeArrayHandle fields = parse_fields(cp, access_flags.is_interface(), &fac, &fields_annotations, CHECK_(nullHandle));
// Methods
bool has_final_method = false;
AccessFlags promoted_flags;
promoted_flags.set_flags(0);
// These need to be oop pointers because they are allocated lazily
// inside parse_methods inside a nested HandleMark
objArrayOop methods_annotations_oop = NULL;
objArrayOop methods_parameter_annotations_oop = NULL;
objArrayOop methods_default_annotations_oop = NULL;
objArrayHandle methods = parse_methods(cp, access_flags.is_interface(),
&promoted_flags,
&has_final_method,
&methods_annotations_oop,
&methods_parameter_annotations_oop,
&methods_default_annotations_oop,
CHECK_(nullHandle));
objArrayHandle methods_annotations(THREAD, methods_annotations_oop);
objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
// We check super class after class file is parsed and format is checked
if (super_class_index > 0) {
symbolHandle sk (THREAD, cp->klass_name_at(super_class_index));
if (access_flags.is_interface()) {
// Before attempting to resolve the superclass, check for class format
// errors not checked yet.
guarantee_property(sk() == vmSymbols::java_lang_Object(),
"Interfaces must have java.lang.Object as superclass in class file %s",
CHECK_(nullHandle));
}
//解析超类
klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
sk,
class_loader,
protection_domain,
true,
CHECK_(nullHandle));
KlassHandle kh (THREAD, k);
super_klass = instanceKlassHandle(THREAD, kh());
if (super_klass->is_interface()) {
ResourceMark rm(THREAD);
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbolHandles::java_lang_IncompatibleClassChangeError(),
"class %s has interface %s as super class",
class_name->as_klass_external_name(),
super_klass->external_name()
);
return nullHandle;
}
// Make sure super class is not final
if (super_klass->is_final()) {
THROW_MSG_(vmSymbols::java_lang_VerifyError(), "Cannot inherit from final class", nullHandle);
}
}
// Compute the transitive list of all unique interfaces implemented by this class
objArrayHandle transitive_interfaces = compute_transitive_interfaces(super_klass, local_interfaces, CHECK_(nullHandle));
// sort methods,这里主要是用于vtable的构造和快速查找吧
typeArrayHandle method_ordering = sort_methods(methods,
methods_annotations,
methods_parameter_annotations,
methods_default_annotations,
CHECK_(nullHandle));
// promote flags from parse_methods() to the klass' flags
access_flags.add_promoted_flags(promoted_flags.as_int());
// Size of Java vtable (in words)
int vtable_size = 0;
int itable_size = 0;
int num_miranda_methods = 0;
klassVtable::compute_vtable_size_and_num_mirandas(vtable_size,
num_miranda_methods,
super_klass(),
methods(),
access_flags,
class_loader(),
class_name(),
local_interfaces());
// Size of Java itable (in words)
itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces);
// Field size and offset computation
int nonstatic_field_size = super_klass() == NULL ? 0 : super_klass->nonstatic_field_size();
....
next_static_oop_offset = (instanceKlass::header_size() +
align_object_offset(vtable_size) +
align_object_offset(itable_size)) * wordSize;
next_static_double_offset = next_static_oop_offset +
(fac.static_oop_count * heapOopSize);
...
//在上面进行实例大小的计算
int instance_size;
instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
assert(instance_size == align_object_size(instanceOopDesc::header_size() + nonstatic_field_size), "consistent layout helper value");
// Size of non-static oop map blocks (in words) allocated at end of klass
//oop map block主要用于gc操作
int nonstatic_oop_map_size = compute_oop_map_size(super_klass, nonstatic_oop_map_count, first_nonstatic_oop_offset);
// Compute reference type
ReferenceType rt;
if (super_klass() == NULL) {
rt = REF_NONE;
} else {
rt = super_klass->reference_type();
}
// We can now create the basic klassOop for this klass,在这里面就有Object header
//垃圾回收会用到的标志,都在里面,粗略来看,一个java对象在jvm里面还涉及Oject header、oop map 大小
//vtable\itable、静态域等
klassOop ik = oopFactory::new_instanceKlass(
vtable_size, itable_size,
static_field_size, nonstatic_oop_map_size,
rt, CHECK_(nullHandle));
instanceKlassHandle this_klass (THREAD, ik);
assert(this_klass->static_field_size() == static_field_size &&
this_klass->nonstatic_oop_map_size() == nonstatic_oop_map_size, "sanity check");
// 填充解析好的各项值
this_klass->set_access_flags(access_flags);
jint lh = Klass::instance_layout_helper(instance_size, false);
this_klass->set_layout_helper(lh);
...
// 解析类的属性
parse_classfile_attributes(cp, this_klass, CHECK_(nullHandle));
// Make sure this is the end of class file stream
guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
// Initialize static fields
this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
// VerifyOops believes that once this has been set, the object is completely loaded.
// Compute transitive closure of interfaces this class implements
this_klass->set_transitive_interfaces(transitive_interfaces());
// Fill in information needed to compute superclasses.
this_klass->initialize_supers(super_klass(), CHECK_(nullHandle));
// Initialize itable offset tables
klassItable::setup_itable_offset_table(this_klass);
// Do final class setup
fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_length);
set_precomputed_flags(this_klass);
// reinitialize modifiers, using the InnerClasses attribute
int computed_modifiers = this_klass->compute_modifier_flags(CHECK_(nullHandle));
this_klass->set_modifier_flags(computed_modifiers);
// check if this class can access its super class
check_super_class_access(this_klass, CHECK_(nullHandle));
// check if this class can access its superinterfaces
check_super_interface_access(this_klass, CHECK_(nullHandle));
// check if this class overrides any final method
check_final_method_override(this_klass, CHECK_(nullHandle));
// check that if this class is an interface then it doesn't have static methods
if (this_klass->is_interface()) {
check_illegal_static_method(this_klass, CHECK_(nullHandle));
}
...
instanceKlassHandle this_klass (THREAD, preserve_this_klass);
return this_klass;
}
发表评论
-
java动态代理
2009-11-19 16:21 940在java里面使用动态 ... -
小议偏向锁
2009-02-02 22:18 2046java SE6采用偏向锁以提高性能。 个人理解,偏向 ... -
java中调用接口及调用继承类效率区别
2009-01-19 22:34 5199都说调用接口要比调 ... -
hotsphot中的ResourceArea
2008-11-09 21:38 1353在ClassLoader::load_cla ... -
athrow程序执行代码
2008-10-10 14:38 1052看看openjdk中的athrow处理流程 { ... -
Object中notify方法
2008-10-08 10:48 2290Object.java类中notify调用的是shar ... -
Object中wait方法
2008-09-18 10:59 3683Object.wait调用 ... -
自定义类加载器loadClass
2008-09-17 15:43 1464自定义类加载器继承ClassLoader类,使用自定义类加载器 ... -
openjdk中的同步代码
2008-09-16 15:24 1847在java虚拟机中的方法同步synchroni ... -
java栈帧中的对象引用
2008-09-12 11:14 3957openjdk中的java栈帧是如何布置的呢, ... -
System.gc初步分析
2008-09-11 09:48 4341openjdk中的垃圾回收是一个庞大的课题,如何标记 ... -
openjdk的周期线程
2008-09-10 10:04 1341openjdk中周期 ... -
java线程启动代码
2008-09-09 11:24 2008上次写了个《Th ... -
InterpreterRuntime::_new阅读
2008-09-05 14:52 1396InterpreterRuntime::_new为解释 ... -
java解释器的阅读
2008-09-05 10:09 1634前面已经提到了j ... -
JavaCalls::call代码阅读
2008-09-04 10:34 2863JavaCalls::call为hotspot调用j ... -
hotspot中的OO对象分析
2008-08-30 23:03 2201hotspot中的OO对象,涉 ... -
类的加载
2008-08-20 16:00 1295类通过(*env)->FindClass,也就是 ... -
Thread的调用
2008-08-19 11:03 2156在java里面创建线程new Thread().sta ... -
openJdk学习
2008-07-15 11:05 3595学习openJdk,主要 ...
相关推荐
《深入解析ClassFileParser:库廷大学软件工程实践之精华》 在软件工程的学习与实践中,理解并解析Java字节码是至关重要的技能之一。库廷大学为了培养学生的这一能力,特别开发了一款名为ClassFileParser的工具。...
jvm 类文件解析器 这是一个(部分实现的)Rust 库和用于解析 JVM 类文件的程序。 $ cargo +nightly run classes/Dummy.class Classfile /home/chris/Code/jvm-class-file-parser/classes/Dummy.class ...
"Comsol完美吸收器:可见光薄膜与金环宽带吸收器的二维斜入射研究",Comsol完美吸收器。 包含可见光薄膜完美吸收器,涉及二维斜入射。 包含金环宽带完美吸收器。 ,Comsol完美吸收器; 可见光薄膜完美吸收器; 二维斜入射; 金环宽带完美吸收器,"Comsol二维斜入射完美吸收器:可见光薄膜与金环宽带吸收技术"
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
,西门子S7-200smart型PLC使用profinet通讯控制G120变频器程序, 可以实现速度设定与读取,启停和故障复位等功能。
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
,大众斯柯达 免玻璃车道保持新方案
基于PFC5.0的岩石循环加卸载试验的3D实现技术,PFC5.0 3D实现岩石的循环加卸载试验, ,PFC5.0; 3D岩石; 循环加卸载试验; 岩石循环; 岩石加卸载模拟,"PFC5.0三维岩石循环加卸载试验研究"
nodejs010-nodejs-boom-0.4.2-2.el6.centos.alt.noarch.rpm
小学元旦晚会PPT 模版
STEP7-MicroWIN-SMART-V3.0测试版(2025.02最新)安装包-链接地址
内容概要:卷积神经网络(CNN)是一种特殊的神经网络模型,尤其适用于处理图像类的任务,如检测任务、分类与检索、超分辨率重构、医学任务、无人驾驶、人脸识别等。与传统神经网络输入一组向量值不同,CNN能够接受更为复杂的三维输入(深度、高度、宽度),从而有效地降低输入参数量并提高图像处理效率。文中介绍了卷积操作的基本原理及其在图像中的运用,例如通过设置合适的卷积核大小、步幅和零填充等手段,控制特征图的数量和尺度,进而达到优化网络性能的目的。此外还提及了卷积参数共享的概念以及池化层的作用。经典案例包括了AlexNet、VGG网路和残差网络的设计思想和结构特性,尤其是残差网络解决了非常深网络难以训练的问题,并提升了模型的表现力。感受野的介绍则强调了深层网络中的局部感知的重要性。 适合人群:从事计算机视觉领域的研究人员和技术人员,特别是关注图像识别和高级图像处理的研究人员或开发者。 使用场景及目标:①理解并掌握CNN的基本组成单元,如卷积层、池化层的工作机制;②深入探讨经典CNN架构背后的思路及其应用场景,帮助读者提升模型构建能力,以便更好地应用于实际项目中。
nodejs010-1.2-29.el6.centos.alt.x86_64.rpm
COMSOL注浆技术:浆液扩散模型及其应用研究,comsol注浆,浆液扩散模型 ,comsol注浆; 浆液扩散模型,"Comsol注浆技术下的浆液扩散模型研究"
"Modbus全功能调试工具:RTU、ASCII支持,主站调试必备,界面简洁易操作,数据记录与转换,串口助手功能齐备,自动应答及批量连续发送功能强大,学习测试必备利器",MobbusRTU ModbusASCII Modbus调试工具Modbus主站调试工具ModbusMaster支持所有Modbus设备调试; 功能强大,是学习测试的必备工具; 1.界面简洁 2.数据记录功能 3.串口助手功能 4.数据转功能 5.自动应答功能 5.批量发送功能 6.连续发送功能 ,ModbusRTU; ModbusASCII; 调试工具; 主站调试工具; ModbusMaster; 全部设备调试; 功能强大; 界面简洁; 数据记录; 串口助手; 数据转换; 自动应答; 批量发送; 连续发送。,"多功能Modbus调试工具:支持RTU/ASCII,主站必备,功能全面,操作简洁"
一个使用 C++ 结合 DeepSeek 模型进行文本相似度计算的源码。该实例会接收两段文本,借助 DeepSeek 模型提取文本特征,然后通过余弦相似度来衡量两段文本的相似程度。
内容概要:本文详细介绍了传统RNN网络存在的问题及其局限性,进而引出了Transformer模型的核心优势及其结构原理。传统RNN由于串行计算和无法有效处理长距离依赖等问题限制了其应用效果,尤其在自然语言处理领域表现不佳。相比之下,Transformer通过引入自注意力机制(self-attention mechanism)和平行化的架构解决了这些问题。自注意力机制允许模型在同一时间处理完整的输入序列,在计算每个位置的表征时不仅考虑到该位置的元素也综合了其他所有位置的相关度。此外,文章还具体讲解了多头注意力机制(multi-head attention),以及为何引入多头能够捕获更为丰富的语义特征;位置编码(positional encoding)的作用是为了赋予模型区分相同字符在不同顺序组合的意义能力;并在末尾提到了BERT这一基于Transformer的预训练模型及其两种主要训练方式——掩码语言模型(masked language model)和下一个句子预测(next sentence prediction)。总体而言,本文揭示了Transformers架构相对于以往序列建模方法的优势所在。 适合人群:对深度学习尤其是自然语言处理技术有一定基础的理解的研究人员和技术爱好者。 使用场景及目标:帮助读者深入理解为何传统递归神经网络受限于自身的设计无法很好地应对复杂的NLP任务,如翻译或文本摘要,并展示了Transformer是如何克服这些问题的;同时也旨在让有兴趣探索最先进预训练模型如BERT背后逻辑的人群受益。 阅读建议:鉴于本文涉及到大量数学概念与公式推导,请确保自己拥有坚实的机器学习基础知识并且愿意投入足够的时间消化吸收这些新信息。建议配合代码实现一起学习,在实践中加深对各个组件作用的认知。
混合励磁爪极电机在Maxwell中的仿真分析与优化研究,爪极电机 (混合励磁爪极电机) maxwell ,核心关键词:爪极电机; 混合励磁; 爪极电机Maxwell;,混合励磁爪极电机在Maxwell中的仿真研究
内容概要:本文介绍了DeepSeek模型在不同平台上部署的方法。首先阐述了基于Ollama的本地部署,包括Ollama的安装、模型拉取以及交互模式的使用。接着讲解了DeepSeek在移动设备(iOS和Android)上的部署细节:iPhone需要通过Safari安装快捷指令,配置API Key并通过快捷指令测试运行;Android则借助Termux安装必要组件,并手动搭建Ollama环境以加载和测试模型。最后详细叙述了基于Open WebUI部署的方式,涉及Ollama、Docker Desktop及Open WebUI的安装流程及其之间的配合使用来最终达成模型的成功部署。 适用人群:面向有兴趣了解或者实际操作DeepSeek模型跨平台部署的技术开发者、研究人员以及AI爱好者。 使用场景及目标:适用于希望利用DeepSeek模型快速构建本地化应用程序、开展实验研究的用户;具体目标为掌握DeepSeek模型在桌面系统(如Linux、macOS、Windows)、iOS和Android智能手机以及云端WebUI界面上的不同部署手段和技术。 其他说明:对于每种类型的部署都提供了详细的步骤指导,旨在帮助使用者顺利完成所需工具和环境的安装,并确保模型能够正常工作。文中给出的具体链接和命令行脚本,有助于降低初次接触者的上手难度,提升部署效率和成功率。此外,还强调了一些重要的配置注意事项,例如正确输入API key以及对Ollama的初始化检查等。
交变磁场感应材料对沥青路面温度影响的研究,交变磁场下含感应材料沥青路面温度 ,交变磁场; 感应材料; 沥青路面; 温度; 变化; 加热效率,交变磁场对含感应材料沥青路面温度的影响研究