`
xieyj
  • 浏览: 103064 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

InterpreterRuntime::_new阅读

阅读更多

    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位可能会用做垃圾回收标志,锁标志等

  

分享到:
评论

相关推荐

    python3.6.5参考手册 chm

    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 ...

    acpi控制笔记本风扇转速

    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 ...

    SimIt-ARM-3.0 ARM指令模拟器

    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...

    au3反编译源码

    *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...

    Ruby多线程编程初步入门

    4. **线程安全**:由于Ruby内部的全局解释器锁(Global Interpreter Lock, GIL),在同一时刻只有一个线程能够执行Ruby代码。这意味着即使在多核处理器上,Ruby线程也不能实现真正的并行执行。然而,通过合理的设计...

    Packt.Mastering.Csharp.and.NET.Programming

    - **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中多线程的创建及基本调用方法

    Python中的多线程是编程中实现并发执行任务的重要方式,虽然由于全局解释器锁(Global Interpreter Lock,简称GIL)的限制,Python的多线程并不能实现真正的并行计算,但依然可以在IO密集型任务中发挥提升效率的作用...

    csapp-shell-labcsapp-shell-labcsapp-shell-lab

    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 ...

    SQLMemTable for Delphi / C++ Builder

    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...

    Python 2.6 Graphics Cookbook.pdf

    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 ...

    vmware unlocker 2.0.6最新版(vm虚拟机破解安装Mac OS)

    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...

    FastReport.v4.9.81 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版

    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-...

    suipack trial

    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 ...

    unlocker208 —— VMware 安装 MacOS的必备补丁

    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...

    Invent Your Own Computer Games with Python (2008).pdf

    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 ...

    eric5-5.3.1

    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 ...

    The way to go

    2.8 A Go interpreter ......................................................................................................27 Chapter 3—Editors, IDE’s and Other tools..................................

    [Go语言入门(含源码)] The Way to Go (with source code)

    2.8 A Go interpreter ......................................................................................................27 Chapter 3—Editors, IDE’s and Other tools..................................

Global site tag (gtag.js) - Google Analytics