第 26 - Operation of the Virtual Biode Code Directive

Operating the number stack management related bytecode instructions are shown in the following table.

0x57

pop

Browse the top numerical population(Value cannot belongOrdoubleType)

0x58

pop2

One of the top of the stacklongordoubleType)Or two numerical pop-up (other)

0x59

dup

Copy the top value of the stack and press the copy value into the top

0x5a

dup_x1

Copy the top value of the stack and press the two copy values ​​into the stack

0x5b

dup_x2

Copy the value of the stack and press the three (or two) copy values ​​into the top

0x5c

dup2

Copy the top of the stack (longordoubleType)Or two (other) values ​​and press the copy value into the stack

0x5d

dup2_x1

dup_x1 Double version of the instruction

0x5e

dup2_x2

dup_x2 Double version of the instruction

0x5f

swap

Interchange the two values ​​of the top of the stack(Value cannot belongordoubleType)

The template corresponding to the byte code instruction is as follows:

def(Bytecodes::_pop         , ____|____|____|____, vtos, vtos, pop         ,  _           );def(Bytecodes::_pop2        , ____|____|____|____, vtos, vtos, pop2        ,  _           );def(Bytecodes::_dup         , ____|____|____|____, vtos, vtos, dup         ,  _           );def(Bytecodes::_dup_x1      , ____|____|____|____, vtos, vtos, dup_x1      ,  _           );def(Bytecodes::_dup_x2      , ____|____|____|____, vtos, vtos, dup_x2      ,  _           );def(Bytecodes::_dup2        , ____|____|____|____, vtos, vtos, dup2        ,  _           );def(Bytecodes::_dup2_x1     , ____|____|____|____, vtos, vtos, dup2_x1     ,  _           );def(Bytecodes::_dup2_x2     , ____|____|____|____, vtos, vtos, dup2_x2     ,  _           );def(Bytecodes::_swap        , ____|____|____|____, vtos, vtos, swap        ,  _           );

Pop instruction pops the top numerical population。对应的汇编代码如下:

add    $0x8,%rsp   

POP2 instructions populates the top numerical population. The corresponding assembly code is as follows:

Add $ 0x10,% RSP

DUP instructions Copy the top value of the stack and presses the copy value into the top. The corresponding assembly code is as follows:

mov    (%rsp),%raxpush   %rax

SWAP instructionInterchange the two values ​​of the top of the stack (Value cannot belongordoubleType). The corresponding assembly code is as follows:

mov    0x8(%rsp),%rcxmov    (%rsp),%raxmov    %rcx,(%rsp)mov    %rax,0x8(%rsp)

The execution logic of the instruction is relatively simple, and it will not be more introduced here.

Recommended reading:

Article 1 – Simple Some of the JVM

Part 2 -JVM virtual machine calls the main () method of the Java primary class

Article 3 – Creation of CallStub New Stack Frame

Article 4 -JVM finally started calling the main () method of the primary class of Java

Article 5 – Bounce the stack frame and process return result after calling the Java method

Article 6 – Java method creation of new stack frames

Section 7 – Creating a stack frame for the Java method

Article 8 -Dispatch_next () function assignment by section code

Nine – Definition of bytecode instructions

​​10th – Initialization template table

11th – Know Stub and Stubqueue

12th – Know Codeletmark

Article 13 – Storage Machine Instructions by Interpretercodelet

Article 14 – Generate important routines

Chapter 15 – Interpreter and Interpreter Builder

Chapter 16 – Assembler in the virtual machine

Chapter 17 -X86-64 Register

Chapter 18 -X86 Common Directive

Article 19 – Loading and Storage Directive (1)

Article 20 – LDC and _fast_ALDC Directive (2) loaded with the storage instructions (2)

Article 21 – Accounting Directive of Virtual Machine

Article 22 – Type conversion of virtual machine character code instructions

Article 23 – GetStatic, Virtual Machine Operation Directive

Article 24 – Getfield of Virtual Machine Operation Directive

25th – PutStatic of the virtual machine object operation instruction

If you have any questions, you can directly review your message or adder WeChat Mazhimazh

Pay attention to the public account, there is a hotspot VM source code analysis series articles!