不一样的CPU都可以表述的程序设计语言的管理体系

不一样的CPU都可以表述的程序设计语言的管理体系称之为指令系统构架(ISA,Instruction Set Architecture),还可以称之为指令系统(instruction set)。Intel将x86系列产品CPU当中的32位CPU指令系统构架称之为IA-32,IA是“Intel Architecture”的通称,还可以称之为i386、x86-32。AMD相当于Intell明确提出了x86系列产品的64位拓展,因此由AMD设计方案的x86系列产品的64位指令系统构架称之为AMD64。之后Intel在自身的CPU中添加和AMD64基本上同样的指令系统,称之为Intel 64的指令系统。AMD64和Intel 64可以简称为x86-64。

x86-64的全部存储器全是与设备字长(系统总线位宽)同样,即64位的,x86-64将x86的8个32位通用寄存器拓展为64位(eax、ebx、ecx、edx、eci、edi、ebp、esp),而且提升了8个新的64位存储器(r8-r15),在取名方法上,也从”exx”变成”rxx”,但仍保存”exx”开展32位操作,下表叙述了各存储器的取名和功效。

叙述 32 64
通用寄存器组 eax rax
ecx rcx
edx rdx
ebx rbx
esp rsp
ebp rbp
esi rsi
edi rdi
r8~r15
浮点数存储器组 st0~st7 st0~st7
XMM存储器组 XMM0~XMM7 XMM0~XMM15

在其中的%esp与�p有特殊的主要用途,用于储存偏向程序流程栈中特殊部位的表针。

此外也有eflags存储器,根据位来表明特殊的含意,如下图所显示。

%title插图%num

在HotSpot VM中,表明存储器的类都承继自AbstractRegisterImpl类,这一类的界定如下所示:

源码部位:hotspot/src/share/vm/asm/register.hppclass AbstractRegisterImpl;typedef AbstractRegisterImpl* AbstractRegister;class AbstractRegisterImpl { protected:  int value() const  { return (int)(intx)this; }};

AbstractRegisterImpl类的承继管理体系如下图所显示。

%title插图%num

此外也有个ConcreteRegisterImpl类也传承了AbstractRegisterImpl,这一灰与C2c语言编译器的完成相关,这儿不做太多解读。

1、RegisterImpl类

RegisterImpl类用于表明通用寄存器,类的界定如下所示:

源码部位:cpu/x86/vm/register_x86.hpp// 应用Register作为RegisterImpl的通称class RegisterImpl;typedef RegisterImpl* Register;class RegisterImpl: public AbstractRegisterImpl { public:  enum {    number_of_registers      = 16,    number_of_byte_registers = 16  };  // ...};

针对64位而言,通用寄存器的位宽为64位,还可以将eax、ebx、ecx和edx的一部分作为8位存储器来应用,因此可以储存字节数的存储器总数为4。

在HotSpot VM中界定存储器,如下所示:

源码部位:hotspot/src/cpu/x86/vm/register_x86.hppCONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); // noreg_RegisterEnumValue = ((-1))CONSTANT_REGISTER_DECLARATION(Register, rax,    (0)); // rax_RegisterEnumValue = ((0))CONSTANT_REGISTER_DECLARATION(Register, rcx,    (1)); // rcx_RegisterEnumValue = ((1))CONSTANT_REGISTER_DECLARATION(Register, rdx,    (2)); // rdx_RegisterEnumValue = ((2))CONSTANT_REGISTER_DECLARATION(Register, rbx,    (3)); // rbx_RegisterEnumValue = ((3))CONSTANT_REGISTER_DECLARATION(Register, rsp,    (4)); // rsp_RegisterEnumValue = ((4))CONSTANT_REGISTER_DECLARATION(Register, rbp,    (5)); // rbp_RegisterEnumValue = ((5))CONSTANT_REGISTER_DECLARATION(Register, rsi,    (6)); // rsi_RegisterEnumValue = ((6))CONSTANT_REGISTER_DECLARATION(Register, rdi,    (7)); // rdi_RegisterEnumValue = ((7))CONSTANT_REGISTER_DECLARATION(Register, r8,     (8)); // r8_RegisterEnumValue = ((8))CONSTANT_REGISTER_DECLARATION(Register, r9,     (9)); // r9_RegisterEnumValue = ((9))CONSTANT_REGISTER_DECLARATION(Register, r10,   (10)); // r10_RegisterEnumValue = ((10))CONSTANT_REGISTER_DECLARATION(Register, r11,   (11)); // r11_RegisterEnumValue = ((11))CONSTANT_REGISTER_DECLARATION(Register, r12,   (12)); // r12_RegisterEnumValue = ((12))CONSTANT_REGISTER_DECLARATION(Register, r13,   (13)); // r13_RegisterEnumValue = ((13))CONSTANT_REGISTER_DECLARATION(Register, r14,   (14)); // r14_RegisterEnumValue = ((14))CONSTANT_REGISTER_DECLARATION(Register, r15,   (15)); // r15_RegisterEnumValue = ((15))

宏CONSTANT_REGISTER_DECLARATION界定如下所示:

源码部位:hotspot/src/share/vm/asm/register.hpp#define CONSTANT_REGISTER_DECLARATION(type, name, value)   \\  extern const type name;                                  \\  enum { name##_##type##EnumValue = (value) }

通过宏拓展后如下所示:

extern const Register  rax;enum { rax_RegisterEnumValue = ((0)) }extern const Register  rcx;enum { rcx_RegisterEnumValue = ((1)) }extern const Register  rdx;enum { rdx_RegisterEnumValue = ((2)) }extern const Register  rbx;enum { rbx_RegisterEnumValue = ((3)) }extern const Register  rsp;enum { rsp_RegisterEnumValue = ((4)) }extern const Register  rbp;enum { rbp_RegisterEnumValue = ((5)) }extern const Register  rsi;enum { rsi_RegisterEnumValue = ((6)) }extern const Register  rsi;enum { rdi_RegisterEnumValue = ((7)) }extern const Register  r8;enum { r8_RegisterEnumValue = ((8)) }extern const Register  r9;enum { r9_RegisterEnumValue = ((9)) }extern const Register  r10;enum { r10_RegisterEnumValue = ((10)) }extern const Register  r11;enum { r11_RegisterEnumValue = ((11)) }extern const Register  r12;enum { r12_RegisterEnumValue = ((12)) }extern const Register  r13;enum { r13_RegisterEnumValue = ((13)) }extern const Register  r14;enum { r14_RegisterEnumValue = ((14)) }extern const Register  r15;enum { r15_RegisterEnumValue = ((15)) }

以上的枚举类给存储器特定了一个变量定义值。

在cpu/x86/vm/register_definitions_x86.cpp文件中界定的存储器如下所示:

const Register  noreg = ((Register)noreg_RegisterEnumValue)const Register  rax =   ((Register)rax_RegisterEnumValue)const Register  rcx =   ((Register)rcx_RegisterEnumValue)const Register  rdx =   ((Register)rdx_RegisterEnumValue)const Register  rbx =   ((Register)rbx_RegisterEnumValue)const Register  rsp =   ((Register)rsp_RegisterEnumValue)const Register  rbp =   ((Register)rbp_RegisterEnumValue)const Register  rsi =   ((Register)rsi_RegisterEnumValue)const Register  rdi =   ((Register)rdi_RegisterEnumValue)const Register  r8 =  ((Register)r8_RegisterEnumValue)const Register  r9 =  ((Register)r9_RegisterEnumValue)const Register  r10 = ((Register)r10_RegisterEnumValue)const Register  r11 = ((Register)r11_RegisterEnumValue)const Register  r12 = ((Register)r12_RegisterEnumValue)const Register  r13 = ((Register)r13_RegisterEnumValue)const Register  r14 = ((Register)r14_RegisterEnumValue)const Register  r15 = ((Register)r15_RegisterEnumValue)

在我们必须应用通用寄存器时,根据rax、rcx等自变量引入就可以了。

2、FloatRegisterImpl

在HotSpot VM中,应用FloatRegisterImpl来表明浮点数存储器,该类的界定如下所示:

源码部位:hotspot/src/cpu/x86/vm/register_x86.hpp// 应用FloatRegister作为通称class FloatRegisterImpl;typedef FloatRegisterImpl* FloatRegister;class FloatRegisterImpl: public AbstractRegisterImpl { public:  enum {    number_of_registers = 8  };  // ...}

浮点数存储器有8个,分别是st0~st7,这也是8个80位存储器。

这儿必须特别注意的是,也有一种存储器MMX,MMX并不是一种新的存储器,反而是使用了80位浮点数存储器的低64位,换句话说,应用MMX指令系统,会危害浮点运算!

3、MMXRegisterImpl

MMX 为一种 SIMD 技术性,就可以根据一条命令实行好几个数据信息计算,一共有8个64位存储器(使用了80位浮点数存储器的低64位),各自为mm0 – mm7,他与别的一般64位存储器的区分取决于根据它的命令开展计算,可以与此同时测算2个32位数据信息,或是4个16位数据信息这些,可以运用为图象处理全过程中图型 色调的测算。

MMXRegisterImpl类的界定如下所示:

class MMXRegisterImpl;typedef MMXRegisterImpl* MMXRegister;

MMX存储器的界定如下所示:

CONSTANT_REGISTER_DECLARATION(MMXRegister, mnoreg , (-1));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx0 , ( 0));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx1 , ( 1));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx2 , ( 2));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx3 , ( 3));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx4 , ( 4));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx5 , ( 5));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx6 , ( 6));CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx7 , ( 7));

宏拓展后如下所示:

extern const MMXRegister  mnoreg;enum { mnoreg_MMXRegisterEnumValue = ((-1)) }extern const MMXRegister  mmx0;enum { mmx0_MMXRegisterEnumValue = (( 0)) }extern const MMXRegister  mmx1;enum { mmx1_MMXRegisterEnumValue = (( 1)) }extern const MMXRegister  mmx2;enum { mmx2_MMXRegisterEnumValue = (( 2)) }extern const MMXRegister  mmx3;enum { mmx3_MMXRegisterEnumValue = (( 3)) }extern const MMXRegister  mmx4;enum { mmx4_MMXRegisterEnumValue = (( 4)) }extern const MMXRegister  mmx5;enum { mmx5_MMXRegisterEnumValue = (( 5)) }extern const MMXRegister  mmx6;enum { mmx6_MMXRegisterEnumValue = (( 6)) }extern const MMXRegister  mmx7;enum { mmx7_MMXRegisterEnumValue = (( 7)) }

MMX Pentium及其Pentium II以后的CPU中有从mm0到mm7共8个64位存储器。但事实上MMX存储器和浮点型存储器是同用的,即没法与此同时应用浮点型存储器和MMX存储器。

cpu/x86/vm/register_definitions_x86.cpp文件中界定的寄存器变量如下所示:

const MMXRegister  mnoreg = ((MMXRegister)mnoreg_MMXRegisterEnumValue)const MMXRegister  mmx0 =   ((MMXRegister)mmx0_MMXRegisterEnumValue)const MMXRegister  mmx1 =   ((MMXRegister)mmx1_MMXRegisterEnumValue)const MMXRegister  mmx2 =   ((MMXRegister)mmx2_MMXRegisterEnumValue)const MMXRegister  mmx3 =   ((MMXRegister)mmx3_MMXRegisterEnumValue)const MMXRegister  mmx4 =   ((MMXRegister)mmx4_MMXRegisterEnumValue)const MMXRegister  mmx5 =   ((MMXRegister)mmx5_MMXRegisterEnumValue)const MMXRegister  mmx6 =   ((MMXRegister)mmx6_MMXRegisterEnumValue)const MMXRegister  mmx7 =   ((MMXRegister)mmx7_MMXRegisterEnumValue)

在我们必须应用MMX存储器时,根据mmx0、mmx1等自变量引入就可以了。

4、XMMRegisterImpl类

XMM存储器是SSE命令用的存储器。Pentium iii及其以后的CPU中给予了xmm0到xmm7共8个128位宽的XMM存储器。此外也有个mxcsr存储器,这一存储器用于表明SSE命令的计算情况的存储器。在HotSpot VM中,根据XMMRegisterImpl类来表明存储器。这一类的界定如下所示:

源码部位:hotspot/src/share/x86/cpu/vm/register_x86.hpp// 应用XMMRegister存储器作为通称class XMMRegisterImpl;typedef XMMRegisterImpl* XMMRegister;class XMMRegisterImpl: public AbstractRegisterImpl { public:  enum {    number_of_registers = 16  };  ...}

XMM存储器的界定如下所示:

CONSTANT_REGISTER_DECLARATION(XMMRegister, xnoreg , (-1));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm0 ,   ( 0));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm1 ,   ( 1));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm2 ,   ( 2));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm3 ,   ( 3));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm4 ,   ( 4));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm5 ,   ( 5));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm6 ,   ( 6));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm7 ,   ( 7));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm8,      (8));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm9,      (9));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm10,    (10));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm11,    (11));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm12,    (12));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm13,    (13));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm14,    (14));CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm15,    (15));

通过宏拓展后为:

extern const XMMRegister  xnoreg;enum { xnoreg_XMMRegisterEnumValue = ((-1)) }extern const XMMRegister  xmm0;enum { xmm0_XMMRegisterEnumValue = (( 0)) }extern const XMMRegister  xmm1;enum { xmm1_XMMRegisterEnumValue = (( 1)) }extern const XMMRegister  xmm2;enum { xmm2_XMMRegisterEnumValue = (( 2)) }extern const XMMRegister  xmm3;enum { xmm3_XMMRegisterEnumValue = (( 3)) }extern const XMMRegister  xmm4;enum { xmm4_XMMRegisterEnumValue = (( 4)) }extern const XMMRegister  xmm5;enum { xmm5_XMMRegisterEnumValue = (( 5)) }extern const XMMRegister  xmm6;enum { xmm6_XMMRegisterEnumValue = (( 6)) }extern const XMMRegister  xmm7;enum { xmm7_XMMRegisterEnumValue = (( 7)) }extern const XMMRegister  xmm8;enum { xmm8_XMMRegisterEnumValue = ((8)) }extern const XMMRegister  xmm9;enum { xmm9_XMMRegisterEnumValue = ((9)) }extern const XMMRegister  xmm10;enum { xmm10_XMMRegisterEnumValue = ((10)) }extern const XMMRegister  xmm11;enum { xmm11_XMMRegisterEnumValue = ((11)) }extern const XMMRegister  xmm12;enum { xmm12_XMMRegisterEnumValue = ((12)) }extern const XMMRegister  xmm13;enum { xmm13_XMMRegisterEnumValue = ((13)) }extern const XMMRegister  xmm14;enum { xmm14_XMMRegisterEnumValue = ((14)) }extern const XMMRegister  xmm15;enum { xmm15_XMMRegisterEnumValue = ((15)) }

在cpu/x86/vm/register_definitions_x86.cpp文件中界定的寄存器变量如下所示:

const XMMRegister  xnoreg = ((XMMRegister)xnoreg_XMMRegisterEnumValue)const XMMRegister  xmm0 =   ((XMMRegister)xmm0_XMMRegisterEnumValue)const XMMRegister  xmm1 =   ((XMMRegister)xmm1_XMMRegisterEnumValue)const XMMRegister  xmm2 =   ((XMMRegister)xmm2_XMMRegisterEnumValue)const XMMRegister  xmm3 =   ((XMMRegister)xmm3_XMMRegisterEnumValue)const XMMRegister  xmm4 =   ((XMMRegister)xmm4_XMMRegisterEnumValue)const XMMRegister  xmm5 =   ((XMMRegister)xmm5_XMMRegisterEnumValue)const XMMRegister  xmm6 =   ((XMMRegister)xmm6_XMMRegisterEnumValue)const XMMRegister  xmm7 =   ((XMMRegister)xmm7_XMMRegisterEnumValue)const XMMRegister  xmm8 =   ((XMMRegister)xmm8_XMMRegisterEnumValue)const XMMRegister  xmm9 =   ((XMMRegister)xmm9_XMMRegisterEnumValue)const XMMRegister  xmm10 =  ((XMMRegister)xmm10_XMMRegisterEnumValue)const XMMRegister  xmm11 =  ((XMMRegister)xmm11_XMMRegisterEnumValue)const XMMRegister  xmm12 =  ((XMMRegister)xmm12_XMMRegisterEnumValue)const XMMRegister  xmm13 =  ((XMMRegister)xmm13_XMMRegisterEnumValue)const XMMRegister  xmm14 =  ((XMMRegister)xmm14_XMMRegisterEnumValue)const XMMRegister  xmm15 =  ((XMMRegister)xmm15_XMMRegisterEnumValue)

在我们必须应用XMM存储器时,立即根据xmm0、xmm1等自变量引入就可以了。

 

阅读推荐:

第1篇-有关JVM运作时,开场说的简易些

第2篇-JVMvm虚拟机那样来启用Java主类的main()方式

第3篇-CallStub新栈帧的建立

第4篇-JVM总算逐渐启用Java主类的main()方式啦

第5篇-启用Java方式后弹出来栈帧及解决回到結果

第6篇-Java方式新栈帧的建立

第7篇-为Java方式建立栈帧

第8篇-dispatch_next()涵数分配字节码

第9篇-字节码命令的界定

第10篇-复位模版表

第11篇-了解Stub与StubQueue

第12篇-了解CodeletMark

第13篇-根据InterpreterCodelet储存计算机指令精彩片段

第14篇-转化成关键的方法

第15章-编译器及编译器制作器

第16章-vm虚拟机中的汇编器

假如有什么问题可立即评价留言板留言或加创作者微信mazhimazh

扫码关注,有HotSpot VM源代码分析系列产品文章内容!