Skip to content

Instantly share code, notes, and snippets.

@YujiSoftware
Last active December 11, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YujiSoftware/4648197 to your computer and use it in GitHub Desktop.
Save YujiSoftware/4648197 to your computer and use it in GitHub Desktop.
Effective Java の「項目66 共有された可変データへのアクセスを同期する」で、活性エラーについて記載があります。 この現象が起こった時の x86 アセンブリコードを見てみました。 http://d.hatena.ne.jp/chiheisen/20130127/1359290291
{method}
VM option '+PrintOptoAssembly'
- klass: {other class}
- this oop: 0x10251ed8
- method holder: 'StopThread'
- constants: 0x10251b00 constant pool [53] for 'StopThread' cache=0x10252108
- access: 0x81001008 static synthetic
- name: 'access$0'
- signature: '()Z'
- max stack: 1
- max locals: 0
- size of params: 0
- method size: 24
- vtable index: -2
- i2i entry: 0x00b0b700
- adapter: 0x00a8f118
- compiled entry 0x00baaa84
- code size: 4
- code start: 0x10251ed0
- code end (excl): 0x10251ed4
- method data: 0x10254b68
- checked ex length: 0
- linenumber start: 0x10251ed4
- localvar length: 0
#
# bool ( )
#
# -- 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 <- B1 Freq: 1
abababab
000 B1: # N1 <- BLOCK HEAD IS JUNK Freq: 1
000 PUSHL EBP
SUB ESP,8 # Create frame
007 MOV EBX,#336
00c MOVZX8 EAX,[EBX + precise klass StopThread: 0x00a7dfa8:Constant:exact *] # ubyte -> int ! Field StopThread.stopRequested
013 ADD ESP,8 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
01d RET
01d
{method}
- klass: {other class}
- this oop: 0x102528a8
- method holder: 'StopThread$1'
- constants: 0x10252648 constant pool [33] for 'StopThread$1' cache=0x10252ae0
- access: 0xc1000001 public
- name: 'run'
- signature: '()V'
- max stack: 1
- max locals: 2
- size of params: 1
- method size: 24
- vtable index: 5
- i2i entry: 0x00b0b700
- adapter: 0x00a8f0ec
- compiled entry 0x00baab87
- code size: 15
- code start: 0x10252870
- code end (excl): 0x1025287f
- method data: 0x102549d0
- checked ex length: 0
- linenumber start: 0x1025287f
- localvar length: 2
- localvar start: 0x1025288e
#
# 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 N51: # B1 <- BLOCK HEAD IS JUNK Freq: 1
000 INT3
NOP # 3 bytes pad for loops and calls
004 B1: # B3 B2 <- BLOCK HEAD IS JUNK Freq: 1
004 PUSHL EBP
SUB ESP,24 # Create frame
00b MOV EBX,#2
010 ADD EBX,[ECX]
012 MOV [ESP + #0],ECX
015 CALL_LEAF,runtime OSR_migration_end
No JVM State Info
#
01a MOV ECX,#336
01f MOVZX8 EAX,[ECX + precise klass StopThread: 0x041b9f08:Constant:exact *] # ubyte -> int ! Field StopThread.stopRequested
026 TEST EAX,EAX
028 Jne,s B3 P=0.000000 C=111794.000000
028
02a B2: # B2 <- B1 B2 top-of-loop Freq: 1e-035
02a TSTL #polladdr,EAX ! Safepoint: poll for GC # StopThread$1::run @ bci:11 L[0]=_ L[1]=EBX STK[0]=EAX
# OopMap{off=42}
030 INC EBX
031 JMP,s B2
031
033 B3: # N51 <- B1 Freq: 4.76837e-007
033 ADD ESP,24 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
03d RET
03d
{method}
VM option '+PrintOptoAssembly'
- klass: {other class}
- this oop: 0x10251ed8
- method holder: 'StopThread'
- constants: 0x10251b00 constant pool [53] for 'StopThread' cache=0x10252108
- access: 0x81001008 static synthetic
- name: 'access$0'
- signature: '()Z'
- max stack: 1
- max locals: 0
- size of params: 0
- method size: 24
- vtable index: -2
- i2i entry: 0x00b0b700
- adapter: 0x00a8f118
- compiled entry 0x00baaa84
- code size: 4
- code start: 0x10251ed0
- code end (excl): 0x10251ed4
- method data: 0x10255fc0
- checked ex length: 0
- linenumber start: 0x10251ed4
- localvar length: 0
#
# bool ( )
#
# -- 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 <- B1 Freq: 1
abababab
000 B1: # N1 <- BLOCK HEAD IS JUNK Freq: 1
000 PUSHL EBP
SUB ESP,8 # Create frame
007 MOV EBX,#336
00c MOVZX8 EAX,[EBX + precise klass StopThread: 0x00a21710:Constant:exact *] # ubyte -> int ! Field StopThread.stopRequested
013 ADD ESP,8 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
01d RET
01d
{method}
- klass: {other class}
- this oop: 0x102528c0
- method holder: 'StopThread$1'
- constants: 0x10252648 constant pool [37] for 'StopThread$1' cache=0x10252af8
- access: 0xc1000001 public
- name: 'run'
- signature: '()V'
- max stack: 1
- max locals: 2
- size of params: 1
- method size: 24
- vtable index: 5
- i2i entry: 0x00b0b700
- adapter: 0x00a8f0ec
- compiled entry 0x00baab87
- code size: 17
- code start: 0x10252888
- code end (excl): 0x10252899
- method data: 0x10255ed8
- checked ex length: 0
- linenumber start: 0x10252899
- localvar length: 2
- localvar start: 0x102528a6
#
# 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 N170: # B1 <- BLOCK HEAD IS JUNK Freq: 1
000 INT3
NOP # 3 bytes pad for loops and calls
004 B1: # B14 B2 <- BLOCK HEAD IS JUNK Freq: 1
004 # stack bang
PUSHL EBP
SUB ESP,24 # Create frame
012 MOV EBP,[ECX + #4]
015 MOV [ESP + #0],ECX
018 CALL_LEAF,runtime OSR_migration_end
No JVM State Info
#
01d MOV EBX,[EBP + #4]
020 NullCheck EBP
020
020 B2: # B13 B3 <- B1 Freq: 0.999999
020 CMPu EBX,precise klass StopThread$1: 0x041bd520:Constant:exact *
026 Jne,u B13 P=0.000001 C=-1.000000
026
02c B3: # B5 B4 <- B2 Freq: 0.999998
02c #checkcastPP of EBP
02c MOV EBX,[EBP] # int
02f MOV ECX,EBX
031 AND ECX,#7
034 CMP ECX,#1
037 Jne,s B5 P=0.001000 C=-1.000000
037
039 B4: # B8 B5 <- B3 Freq: 0.998998
039 SHR EBX,#7
03c TEST EBX,EBX
03e Jne,s B8 P=0.999000 C=-1.000000
03e
040 B5: # B15 B6 <- B3 B4 Freq: 0.00199898
040 MOV ECX,EBP
042 NOP # 1 bytes pad for loops and calls
043 CALL,static java.lang.Object::hashCode
# StopThread$1::run @ bci:6 L[0]=EBP L[1]=_
# OopMap{ebp=Oop off=72}
048
048 B6: # B8 <- B5 Freq: 0.00199894
# Block is sole successor of call
048 JMP,s B8
048
04a B7: # B16 B8 <- B9 B11 top-of-loop Freq: 1998.98
04a MOV ECX,EBP
04c NOP # 3 bytes pad for loops and calls
04f CALL,static java.lang.Object::hashCode
# StopThread$1::run @ bci:6 L[0]=EBP L[1]=_
# OopMap{ebp=Oop off=84}
054
054 B8: # B12 B9 <- B6 B4 B7 B10 Loop: B8-B7 inner Freq: 999998
054 MOV ECX,#336
059 MOVZX8 EBX,[ECX + precise klass StopThread: 0x041be830:Constant:exact *] # ubyte -> int ! Field StopThread.stopRequested
060 TSTL #polladdr,EAX ! Safepoint: poll for GC # StopThread$1::run @ bci:13 L[0]=EBP L[1]=_ STK[0]=EBX
# OopMap{ebp=Oop off=96}
066 TEST EBX,EBX
068 Jne,s B12 P=0.000000 C=91248.000000
068
06a B9: # B7 B10 <- B8 Freq: 999998
06a MOV ECX,[EBP] # int
06d MOV EDI,ECX
06f AND EDI,#7
072 CMP EDI,#1
075 Jne,s B7 P=0.001000 C=-1.000000
075
077 B10: # B8 B11 <- B9 Freq: 998998
077 SHR ECX,#7
07a TEST ECX,ECX
07c Jne,s B8 P=0.999000 C=-1.000000
07c
07e B11: # B7 <- B10 Freq: 998.985
07e JMP,s B7
07e
080 B12: # N170 <- B8 Freq: 0.959763
080 ADD ESP,24 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
08a RET
08a
08b B13: # N170 <- B2 Freq: 9.99999e-007
08b MOV ECX,#-83
090 NOP # 3 bytes pad for loops and calls
093 CALL,static wrapper for: uncommon_trap(reason='unreached' action='reinterpret')
# StopThread$1::run @ bci:5 L[0]=EBP L[1]=_
# OopMap{ebp=Oop off=152}
098 INT3 ; ShouldNotReachHere
098
099 B14: # N170 <- B1 Freq: 1.01328e-006
099 MOV ECX,#-10
09e NOP # 1 bytes pad for loops and calls
09f CALL,static wrapper for: uncommon_trap(reason='null_check' action='maybe_recompile')
# StopThread$1::run @ bci:6 L[0]=_ L[1]=_ STK[0]=#NULL
# OopMap{off=164}
0a4 INT3 ; ShouldNotReachHere
0a4
0a5 B15: # B17 <- B5 Freq: 1.99898e-008
0a5 # exception oop is in EAX; no code emitted
0a5 MOV ECX,EAX
0a7 JMP,s B17
0a7
0a9 B16: # B17 <- B7 Freq: 0.040235
0a9 # exception oop is in EAX; no code emitted
0a9 MOV ECX,EAX
0a9
0ab B17: # N170 <- B15 B16 Freq: 0.040235
0ab ADD ESP,24 # Destroy frame
POPL EBP
0af JMP rethrow_stub
0af
{method}
VM option '+PrintOptoAssembly'
- klass: {other class}
- this oop: 0x10251ed8
- method holder: 'StopThread'
- constants: 0x10251b00 constant pool [53] for 'StopThread' cache=0x10252108
- access: 0x81001008 static synthetic
- name: 'access$0'
- signature: '()Z'
- max stack: 1
- max locals: 0
- size of params: 0
- method size: 24
- vtable index: -2
- i2i entry: 0x00b0b700
- adapter: 0x00a8f118
- compiled entry 0x00baaa84
- code size: 4
- code start: 0x10251ed0
- code end (excl): 0x10251ed4
- method data: 0x10255300
- checked ex length: 0
- linenumber start: 0x10251ed4
- localvar length: 0
#
# bool ( )
#
# -- 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 <- B1 Freq: 1
abababab
000 B1: # N1 <- BLOCK HEAD IS JUNK Freq: 1
000 PUSHL EBP
SUB ESP,8 # Create frame
007 MOV EBX,#336
00c MOVZX8 EAX,[EBX + precise klass StopThread: 0x00a21710:Constant:exact *] # ubyte -> int ! Field VolatileStopThread.stopRequested
013 MEMBAR-acquire ! (empty encoding)
013 ADD ESP,8 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
01d RET
01d
{method}
- klass: {other class}
- this oop: 0x102528a8
- method holder: 'StopThread$1'
- constants: 0x10252648 constant pool [33] for 'StopThread$1' cache=0x10252ae0
- access: 0xc1000001 public
- name: 'run'
- signature: '()V'
- max stack: 1
- max locals: 2
- size of params: 1
- method size: 24
- vtable index: 5
- i2i entry: 0x00b0b700
- adapter: 0x00a8f0ec
- compiled entry 0x00baab87
- code size: 15
- code start: 0x10252870
- code end (excl): 0x1025287f
- method data: 0x10255198
- checked ex length: 0
- linenumber start: 0x1025287f
- localvar length: 2
- localvar start: 0x1025288e
#
# 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 N47: # B1 <- BLOCK HEAD IS JUNK Freq: 1
000 INT3
NOP # 3 bytes pad for loops and calls
004 B1: # B3 <- BLOCK HEAD IS JUNK Freq: 1
004 PUSHL EBP
SUB ESP,24 # Create frame
00b MOV EBP,#1
010 ADD EBP,[ECX]
012 MOV [ESP + #0],ECX
015 CALL_LEAF,runtime OSR_migration_end
No JVM State Info
#
01a MOV EBX,#336
01f JMP,s B3
NOP # 15 bytes pad for loops and calls
030 B2: # B3 <- B3 top-of-loop Freq: 1e+006
030 INC EBP
031
031 B3: # B2 B4 <- B1 B2 Loop: B3-B2 inner Freq: 1e+006
031 MOVZX8 ECX,[EBX + precise klass StopThread: 0x041b9fa8:Constant:exact *] # ubyte -> int ! Field VolatileStopThread.stopRequested
038 MEMBAR-acquire ! (empty encoding)
038 TSTL #polladdr,EAX ! Safepoint: poll for GC # StopThread$1::run @ bci:11 L[0]=_ L[1]=EBP STK[0]=ECX
# OopMap{off=56}
03e TEST ECX,ECX
040 Je,s B2 P=1.000000 C=124665.000000
040
042 B4: # N47 <- B3 Freq: 1
042 ADD ESP,24 # Destroy frame
POPL EBP
TEST PollPage,EAX ! Poll Safepoint
04c RET
04c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment