Skip to content

Instantly share code, notes, and snippets.

@ytoshima
Created November 18, 2011 16:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytoshima/1376858 to your computer and use it in GitHub Desktop.
Save ytoshima/1376858 to your computer and use it in GitHub Desktop.
PrintOptoAssembly output example
// -XX::CompileOnly=sum::doit would narrow down the method to compile, but it
// is not used here.
$ ~/jdk1.7.0-b147/fastdebug/bin/java -XX:+PrintOptoAssembly sum
VM option '+PrintOptoAssembly'
{method}
- klass: {other class}
- this oop: 0x911f8110
- method holder: 'sum'
- constants: 0x911f7e10 constant pool [32] for 'sum' cache=0x911f86b0
- access: 0xc1000008 static
- name: 'doit'
- signature: '()I'
- max stack: 2
- max locals: 2
- size of params: 0
- method size: 24
- vtable index: -2
- i2i entry: 0xb470be20
- adapter: 0x091c0598
- compiled entry 0xb47aada5
- code size: 22
- code start: 0x911f80f0
- code end (excl): 0x911f8106
- method data: 0x911f8c40
- checked ex length: 0
- linenumber start: 0x911f8106
- localvar length: 0
#
# int ( )
#
# -- Old esp -- Framesize: 16 --
#r045 esp+12: return address
#r044 esp+ 8: pad2, in_preserve
#r043 esp+ 4: pad2, in_preserve
#r042 esp+ 0: Fixed slot 0
#
abababab N1: # B1 <- B5 Freq: 1
abababab
000 B1: # B2 <- BLOCK HEAD IS JUNK Freq: 1
000 PUSHL EBP
SUB ESP,8 # Create frame
007 XOR EAX,EAX
009 MOV EBX,#1
NOP # 2 bytes pad for loops and calls
010 B2: # B2 B3 <- B1 B2 Loop: B2-B2 inner main of N14 Freq: 100.967
010 ADD EAX,EBX
012 ADD EAX,EBX
014 ADD EAX,EBX
016 ADD EAX,EBX
018 ADD EAX,EBX
01a ADD EAX,EBX
01c ADD EAX,EBX
01e ADD EAX,EBX
020 ADD EBX,#8
023 ADD EAX,#28
026 CMP EBX,#97
029 Jl,s B2 # Loop end P=0.990096 C=205333.000000
029
02b B3: # B5 B4 <- B2 Freq: 1
02b CMP EBX,#100
02e Jge,s B5 P=0.500000 C=-1.000000
02e
030 B4: # B4 B5 <- B3 B4 Loop: B4-B4 inner post of N90 Freq: 1
030 ADD EAX,EBX
032 INC EBX
033 CMP EBX,#100
036 Jl,s B4 # Loop end P=0.500000 C=205333.000000
036
038 B5: # N1 <- B4 B3 Freq: 1
038 ADD ESP,8 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
042 RET
042
{method}
- klass: {other class}
- this oop: 0x911f8048
- method holder: 'sum'
- constants: 0x911f7e10 constant pool [32] for 'sum' cache=0x911f86b0
- access: 0xc1000009 public static
- name: 'main'
- signature: '([Ljava/lang/String;)V'
- max stack: 4
- max locals: 4
- size of params: 1
- method size: 24
- vtable index: -2
- i2i entry: 0xb470be20
- adapter: 0x091c056c
- compiled entry 0xb47aaee8
- code size: 34
- code start: 0x911f8018
- code end (excl): 0x911f803a
- method data: 0x911f8cd0
- checked ex length: 0
- linenumber start: 0x911f803a
- localvar length: 0
#
# void ( rawptr:BotPTR )
#
#r000 ecx : parm 0: rawptr:BotPTR
# -- Old esp -- Framesize: 32 --
#r045 esp+28: return address
#r044 esp+24: pad2, in_preserve
#r043 esp+20: pad2, in_preserve
#r042 esp+16: Fixed slot 0
#r049 esp+12: spill
#r048 esp+ 8: spill
#r047 esp+ 4: spill
#r046 esp+ 0: outgoing argument
#
000 N28: # B1 <- BLOCK HEAD IS JUNK Freq: 1
000 INT3
NOP # 3 bytes pad for loops and calls
008 B1: # N28 <- BLOCK HEAD IS JUNK Freq: 1
008 # stack bang
PUSHL EBP
SUB ESP,24 # Create frame
016 MOV [ESP + #0],ECX
019 CALL_LEAF,runtime OSR_migration_end
No JVM State Info
#
01e MOV ECX,#24
023 CALL,static wrapper for: uncommon_trap(reason='unloaded' action='reinterpret' index='24')
# sum::main @ bci:26 L[0]=_ L[1]=_ L[2]=_ L[3]=_ STK[0]=#10000 STK[1]=_
# OopMap{off=40}
028 INT3 ; ShouldNotReachHere
028
public class sum {
public static void main(String[] args) {
long r = 0L;
for (int i = 0; i < 100000; i++) {
r += doit();
}
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
}
static int doit() {
int sm = 0;
for (int i = 0; i < 100; i++) sm += i;
return sm;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment