InterpreterRuntime::_new为解释器查找常量池后,发觉需要resolve类时候调用。方法在interpreterRuntime.cpp里面。
void InterpreterRuntime::_new(JavaThread* thread, constantPoolOopDesc* pool, int index){
klassOop k_oop = pool->klass_at(index, CHECK);
/*上面pool->klass_at调用constantPoolOopDesc::klass_at_impl。方法在klassOop k_oop =SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD)代码里面对类进行解析。这在《类的加载》里面有简单的描述。*/
instanceKlassHandle klass (THREAD, k_oop);
klass->check_valid_for_instantiation(true, CHECK);
//对klass进行初始化
klass->initialize(CHECK);
oop obj = klass->allocate_instance(CHECK);
thread->set_vm_result(obj);
}
具体分析一下allocate_instance
instanceOop instanceKlass::allocate_instance(TRAPS) {
bool has_finalizer_flag = has_finalizer(); // Query before possible GC
int size = size_helper(); // Query before forming handle.
KlassHandle h_k(THREAD, as_klassOop());
instanceOop i;
i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
if (has_finalizer_flag && !RegisterFinalizersAtInit) {
i = register_finalizer(i, CHECK_NULL);
}
return i;
}
看看上面的size,size来自k_oop,在classFileParser::parseClassFile里
nstance_size = align_object_size(next_nonstatic_type_offset / wordSize);
jint lh = Klass::instance_layout_helper(instance_size, false);
this_klass->set_layout_helper(lh);
包含了类中非静态字段的大小。instance_size == align_object_size(instanceOopDesc::header_size() + nonstatic_field_size),这就是每个创建的对象中都会包含了object_header,object_header中的mark位可能会用做垃圾回收标志,锁标志等
分享到:
相关推荐
What’s New in Python What’s New In Python 3.6 Summary – Release highlights New Features PEP 498: Formatted string literals PEP 526: Syntax for variable annotations PEP 515: Underscores in ...
executing AcpiWalkNamespace and the AML interpreter. This condition was removed by modifying AcpiWalkNamespace to (by default) ignore all temporary namespace entries created during any concurrent ...
ema An ARM interpreter. To test the installation was successful type ./build/bin/ema test/wc configure modifiy PATH environment variable: PATH=$PATH:$HOME/SimIt-ARM-3.0-gk/build/bin ; export PATH 2...
*New* full support for AutoIT v3.2.6++ :) ... mmh here's what I merely missed in the 'public sources 3.1.0' This program is for studying the 'Compiled' AutoIt3 format. AutoHotKey was developed from...
4. **线程安全**:由于Ruby内部的全局解释器锁(Global Interpreter Lock, GIL),在同一时刻只有一个线程能够执行Ruby代码。这意味着即使在多核处理器上,Ruby线程也不能实现真正的并行执行。然而,通过合理的设计...
- **Declarative Programming**: Describes what the result should be, leaving the "how" to the programming language's interpreter or compiler. - **The Evolution of .NET**: - **.NET as a Reaction to ...
Python中的多线程是编程中实现并发执行任务的重要方式,虽然由于全局解释器锁(Global Interpreter Lock,简称GIL)的限制,Python的多线程并不能实现真正的并行计算,但依然可以在IO密集型任务中发挥提升效率的作用...
A shell is an interactive command-line interpreter that runs programs and manages processes on behalf of users. It provides a way to interact with the operating system and execute commands. In Unix ...
The generator allows you to create tables, queries and databases in run-time. Built-in dialog designer allows you creation of dialog forms (they can be used for asking some parameters before printing...
interpreter, for MS Windows or Linux as well as how to verify that Python is correctly installed. This chapter explains how to create complete working programs that can be run on client computers ...
Python interpreter and should work without requiring any additional software. Windows has a packaged version of the Python script using PyInstaller, and so does not require Python to be installed. 3...
A built-in dialog designer to request parameters before running a report, plus a macro-language interpreter (four languages available - C++Script, PascalScript, BasicScript, JScript) that handles non-...
What you see(design-time) is what you get(run-time) Provides stable converting tool to transfer your existing project smoothly Provides SkinBuilder tool to create your own skins, with it which ...
Python interpreter and should work without requiring any additional software. Windows has a packaged version of the Python script using PyInstaller, and so does not require Python to be installed. 3...
Starting the Python Interpreter x Some Simple Math Stuff x Evaluating Expressions x Variables x Strings x Writing Programs x Hello World! x The Difference Between Statements and Expressions x "My ...
repository or when new dialogs have been added. Thereafter just execute the eric5.py script. Tray starter eric5 comes with a little utility called "eric5-tray". This embeds an icon in the ...
2.8 A Go interpreter ......................................................................................................27 Chapter 3—Editors, IDE’s and Other tools..................................
2.8 A Go interpreter ......................................................................................................27 Chapter 3—Editors, IDE’s and Other tools..................................