[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-hotspot-runtime-dev
Subject:    Re: Question about MarkOop
From:       Viacheslav Kovalevskyi <viacheslav () b0noi ! com>
Date:       2014-12-28 21:44:03
Message-ID: 1553A5DB-3341-4D1B-8198-08C4C867AD24 () b0noi ! com
[Download RAW message or body]

Hi Filipp,

Thank you VERY MUCH! This make things very clear for me.

---
Viacheslav Kovalevskyi
viacheslav@b0noi.com



> On 28 Dec 2014, at 16:24, Filipp Zhinkin <filipp.zhinkin@oracle.com> wrote:
> 
> Hi Viacheslav!
> 
> Object header's bit-format has a big-endian layout, but x86 CPU is little-endian.
> JOL reads header byte per byte and don't perform any reordering.
> 
> If you'll reorder it yourself (or will just read header as int/long),
> then you'll see that everything is ok: your header's value is 0x0d.
> 
> It's a biased lock pattern + age 1 (0000 ... 0000 1101b).
> 
> Regards,
> Filipp.
> 
> ----- Original Message -----
> From: viacheslav@b0noi.com <mailto:viacheslav@b0noi.com>
> To: hotspot-runtime-dev@openjdk.java.net \
>                 <mailto:hotspot-runtime-dev@openjdk.java.net>
> Sent: Saturday, December 27, 2014 12:14:21 AM GMT +03:00 Iraq
> Subject: Question about MarkOop
> 
> Hi!
> 
> My name is Viacheslav, I'm making presentation about Java synchronization to my \
> friends and I realized that I have some gaps in understanding of MarkOop object \
> nature. I was not able to figure out all answers on my own from source code and \
> documentation. If someone can help or at least point the right direction it would \
> be awesome! 
> Here is link to markOop.hpp file that is representing revision of JDK (8b132) that \
> I'm using: [1] 
> I'm executing stupid and simple program that shows Java object layout on screen: \
> [2] before and during synchronization. I'm using Java Object Layout tool for \
> this([3]). 
> Here are results of first 2 outputs that I see in console:
> 
> com.b0noi.java.analyzer.AnalyzerTest.Test1 object internals:
> OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
> 0     4       (object header)                0d 00 00 00 (0000 1101 0000 0000 0000 \
> 0000 0000 0000) 4     4       (object header)                00 00 00 00 (0000 0000 \
> 0000 0000 0000 0000 0000 0000) 8     4       (object header)                32 62 \
> 01 f8 (0011 0010 0110 0010 0000 0001 1111 1000) …
> 
> com.b0noi.java.analyzerAnalyzerTest.Test1 object internals:
> OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
> 0     4       (object header)                0d 70 00 1a (0000 1101 0111 0000 0000 \
> 0000 0001 1010) 4     4       (object header)                9b 7f 00 00 (1001 1011 \
> 0111 1111 0000 0000 0000 0000) 8     4       (object header)                32 62 \
> 01 f8 (0011 0010 0110 0010 0000 0001 1111 1000) …
> 
> My hardware:
> CPU: i5 x64
> RAM: 16GB
> 
> OS:
> Mac OS 10.10
> 
> From what I can understand COOPS is switched of on my system. And according to the \
> documentation in markOop file ([1]) my layout should be one from this: //  \
> unused:25 hash:31 -->| unused:1   age:4    biased_lock:1 lock:2 (normal object) //  \
> JavaThread*:54 epoch:2 unused:1   age:4    biased_lock:1 lock:2 (biased object) 
> first output of my program should represent this line (object normal, without \
> baised): //  unused:25 hash:31 -->| unused:1   age:4    biased_lock:1 lock:2 \
> (normal object) 
> second output of my program should represent this line (object inside \
> synchronization block, should be baised): //  JavaThread*:54 epoch:2 unused:1   \
> age:4    biased_lock:1 lock:2 (biased object) 
> However in both case real life values looks not as they should according to layout \
> documentation.  
> In first case (before synchronization), real life:
> OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
> 0     4       (object header)                0d 00 00 00 (0000 1101 0000 0000 0000 \
> 0000 0000 0000) 4     4       (object header)                00 00 00 00 (0000 0000 \
> 0000 0000 0000 0000 0000 0000) …
> according to dict this is: 
> //  unused:25 hash:31 -->| unused:1   age:4    biased_lock:1 lock:2 (normal object)
> 
> question: why we have this strange first byte (0000 1101)? According to layout doc \
> it should be unused, and I assume field with zeros? 
> Second case is even funnier, real life:
> OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
> 0     4       (object header)                0d 70 00 1a (0000 1101 0111 0000 0000 \
> 0000 0001 1010) 4     4       (object header)                9b 7f 00 00 (1001 1011 \
> 0111 1111 0000 0000 0000 0000) …
> according to dict this is: 
> //  JavaThread*:54 epoch:2 unused:1   age:4    biased_lock:1 lock:2 (biased object)
> 
> question: why first byte remains the same, looks like Thread pointer was written to \
> the different offset then it should (according to the doc). Also the first byte \
> remains the same. Layout is totally inconsistent with documentation. 
> Can someone give me a hint or a direction where to dig. 
> 
> Sorry if this is a wrong mail list to ask this type of question. If this is the \
> case, can someone point me to the right one. Thank you in advance. 
> Links:
> [1] http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/oops/markOop.hpp \
> <http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/oops/markOop.hpp \
> ><http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/oops/markOop.hpp \
> > <http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/oops/markOop.hpp>>
> > 
> [2] https://github.com/b0noI/JavaAnalyzer/blob/master/src/test/java/com/b0noi/java/analyzer/AnalyzerTest.java \
> <https://github.com/b0noI/JavaAnalyzer/blob/master/src/test/java/com/b0noi/java/anal \
> yzer/AnalyzerTest.java><https://github.com/b0noI/JavaAnalyzer/blob/master/src/test/java/com/b0noi/java/analyzer/AnalyzerTest.java \
> <https://github.com/b0noI/JavaAnalyzer/blob/master/src/test/java/com/b0noi/java/analyzer/AnalyzerTest.java>>
>  [3] http://openjdk.java.net/projects/code-tools/jol/ \
> <http://openjdk.java.net/projects/code-tools/jol/> \
> <http://openjdk.java.net/projects/code-tools/jol/ \
> <http://openjdk.java.net/projects/code-tools/jol/>> 
> ---
> Viacheslav Kovalevskyi
> viacheslav@b0noi.com <mailto:viacheslav@b0noi.com>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic