How JVM works in Java

1. Class Loader Subsystem

Java’s dynamic class loads, links and initializes the class when it refers to a class for the first time at runtime, not at compile-time. It performs three major functionality such as Loading, Linking, and Initialization.

1.1 Loading

BootStrap ClassLoader

Extension ClassLoader

Application ClassLoader

1.2 Linking

Verify Prepare Resolve

1.3 Initialization

This is the final phase of Class Loading, here all static variable will be assigned with the original values and static block will be executed.

2. Runtime Data Area

  1.Method Area – All the Class level data will be stored here including static variables. Method Area is one per JVM and it is a shared resource.

  2. Heap Area – All the Objects and its corresponding instance variables and arrays will be stored here. Heap Area is also one per JVM since Method area and Heap area shares memory for multiple threads the data stored is not thread safe.

  3.Stack Area – For every thread, a separate runtime stack will be created. For every method call, one entry will be made in the stack memory which is called as Stack Frame. All local variables will be created in the stack memory. Stack area is thread safe since it is not a shared resource. Stack Frame is divided into three sub-entities such as

    4.Local Variable Array – Related to the method how many local variables are involved and the corresponding values will be stored here.

    5.Operand stack – If any intermediate operation is required to perform, operand stack act as runtime workspace to perform the operation.

    6.Frame data – All symbols corresponding to the method is stored here. In the case of any exception, the catch block information will be maintained in the frame data.

      7.PC Registers – Each thread will have separate PC Registers, to hold address of current executing instruction once the instruction is executed the PC register will be updated with the next instruction

      8.Native Method stacks – Native Method Stack holds native method information. For every thread, separate native method stack will be created.

3. Execution Engine

1.Interpreter

2.JIT Compiler

    1)Intermediate Code generator – produces intermediate code

    2)Code Optimizer – Code Optimizer is responsible for optimizing the intermediate code generated above

      3)Target Code Generator – Target Code Generator is responsible for Generating Machine Code/ Native Code

Profiler – Profiler is a special component, it is responsible for finding the hotspots (i.e) Used to identify whether the method is called multiple time or not.

3.Garbage Collector

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 年末遭遇各种不顺利,在床上躺了两天之后决定换一种方式消化悲伤。恰逢各种节日,为求一个解脱,选择背包游荡。一...
    楚慈Human阅读 1,688评论 0 3
  • 玩游戏和做事的思维方式是否互相呼应? 我发现每次玩游戏,都很容易把自己束缚在一个空间内。只玩自己熟悉的东西,很多操...
    圆柱体阅读 1,706评论 0 0
  • 其一 悄然秋暮冷清宵,五岭冥冥碧海遥。 槛外长灯倾斗柄,场中铁索挂天桥。 车鸣人啸沙尘急,锤响桩隆滤网摇。 翻遍《...
    歧堂阅读 3,214评论 0 1
  • 看着羽毛笔的图片,我内心多么想拥有一支属于我的羽毛笔,洁白的颜色,像雪花一样。羽毛笔啊羽毛笔,我想像这你在我手中挥...
    tadashi阅读 3,468评论 0 1

友情链接更多精彩内容