Re: please help understanding what's the relationship of hotspot compiler c1 and c2 ?

Krystal Mok rednaxelafx at
Wed Nov 2 08:54:10 UTC 2016


By "HIR" and "LIR", I specifically mean the "High-level IR" and "Low-level
IR" for C1. In C1, the GraphBuilder is what parses Java bytecodes into HIR,
and then the LIRGenerator is what lowers HIR into LIR, and finally the
LIRAssembler is what encodes LIR into actual machine code.

C1 is the "Client Compiler", and C2 is the "Server Compiler".
In a HotSpot Client VM build (which is by default not available on 64-bit
architectures), it only contains C1.
In a JDK7+ HotSpot Server VM, the VM actually contains both C1 and C2
compilers. They can work together in what's called a "tiered compilation
system", where methods can be interpreted first, then compiled by C1, and
then further compiled by C2.
In JDK7, -XX:+TieredCompilation is off by default, where as in JDK8 it's on
by default.

- Kris

On Wed, Nov 2, 2016 at 1:48 AM, 恶灵骑士 <1072213404 at> wrote:

> Thank you ,Krystal !
> i think i need some time to make these things light,
> and
> which part of  code  link HIR and LIR together in openjdk ?
> c1 matches client   mode,
> c2 matches server  mode,
> when some code running, just one of them work or both do?
> ------------------ 原始邮件 ------------------
> *发件人:* "Krystal Mok";<rednaxelafx at>;
> *发送时间:* 2016年11月2日(星期三) 下午4:28
> *收件人:* "恶灵骑士"<1072213404 at>;
> *抄送:* "hotspot-dev"<hotspot-dev at>;
> *主题:* Re: please help understanding what's the function and diffrence
> between hotspot compiler c1 and c2 ?
> Hi,
> I don't think I understand your question, but I'll take a shot.
> Are you trying to ask what the differences are between C1 and C2, with
> regards to how they handle volatile field accesses?
> For C1, yes, all Java fields accesses (load/store) are represented in the
> HIR with LoadField and StoreField instructions. The ciField in these
> instructions would carry the information about whether the field is
> volatile or not.
> When lowering HIR to LIR, the LIRGenerator::do_LoadField() and
> do_StoreField() functions are called. What is it that you're trying to
> learn about these functions?
> For C2, it's a bit complicated, because volatile semantics involve the
> memory graph portion of C2's Sea-of-nodes IR. You may want to refer to [1]
> and [2] for some background information before you dive into the code.
> Hope it helps,
> Kris
> [1]:
> Overview+of+Ideal%2C+C2%27s+high+level+intermediate+representation
> [2]:
> On Wed, Nov 2, 2016 at 1:19 AM, 恶灵骑士 <1072213404 at> wrote:
>> what's the function and diffrence between hotspot compiler c1 and c2 ?
>> about c1,
>> i have found something about ‘voaltile’ and
>> methods  LIRGenerator::do_StoreField(StoreField* x)  and
>> LIRGenerator::do_LoadField(LoadField* x) in
>>  ‘share/vm/c1/c1_LIRGenerator.cpp‘,
>> when operating a  variable with a volatile qualifier,will it finally
>> invoke do_StoreField or do_LoadField method?
>> if true, then method do_LoadField or do_StoreField  by  which method?

More information about the hotspot-dev mailing list