Hi everybody,
I'm trying to fully understand how Inline Cache misses and hits work on v8, 
but I'm having trouble to understand the outputs of the --trace_ic, 
--trace_opt and --trace_deopt flags. I'm a newbie in this area, but I've 
used the searcher and I haven't found anything. I found one person that 
asked something similar, but it was not quite the same.
I have read about Inline Caches, and how the site calls change from status, 
however, it's not clear to me how transitions from Uninitialized to 
Monomorphic, and from None to Smi work for instance. I don't know if I make 
myself clear with this. Here is the code, which I think will make things 
easier to understand.

http://paste.ubuntu.com/12514554/

That's the code with some output with grep. The goal of the code is to 
measure an IC miss. According to what I understand, I think that there are 
two optimizations performed, the first one is optimizing the newadd() 
function for two Smi (small integers), and the second one is to optimize 
the same function but for a String and a Smi (which in this place appears 
to be Generic). At the beginning this site call is monomorphic (receiving 
always the same type), and then it should turn to polymorphic of level 2.

Here is the output for the same function, but without the grep:

$ d8 --trace_ic --code_comments weirdadd.js

[LoadIC in ~+106 at native harmony-object.js:5 (0->.) 0x3cffdd234ac1 
<String[6]: Object>]

[LoadIC in ~+142 at native harmony-object.js:7 (0->.) 0x3cffdd262c09 
<String[6]: Import>]

[StoreIC in ~Import+46 at native prologue.js:13 (0->.) 0x3cffdd235301 
<String[4]: next>]

[LoadIC in ~+226 at native harmony-object.js:32 (0->.) 0x3cffdd263099 
<String[16]: InstallFunctions>]

[LoadIC in ~InstallFunctions+79 at native prologue.js:43 (0->.) 
0x3cffdd234c19 <String[6]: length>]

[BinaryOpIC(SAR:None*None->None) => (SAR:Smi*Smi->Smi) @ 0x11962362c7a1 <- 
~InstallFunctions+96 at native prologue.js:43]

[LoadIC in ~InstallFunctions+497 at native prologue.js:44 (0->.) 
0x3cffdd234c19 <String[6]: length>]

[CompareIC in ~InstallFunctions+528 at native prologue.js:44 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#LT @ 
0x11962360ed61]

[  patching ic at 0x119623636e6c, test=0x119623636e70, delta=21

[KeyedLoadIC in ~InstallFunctions+163 at native prologue.js:45 (0->1) 0]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~InstallFunctions+202 at native prologue.js:46]

[  patching ic at 0x119623636d26, test=0x119623636d2a, delta=10

[KeyedLoadIC in ~InstallFunctions+237 at native prologue.js:46 (0->1) 1]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~InstallFunctions+397 at native prologue.js:44]

[  patching ic at 0x119623636de9, test=0x119623636ded, delta=10

[LoadIC in ~InstallFunctions+497 at native prologue.js:44 (.->1) 
0x3cffdd234c19 <String[6]: length>]

[LoadIC in ~+52 at native harmony-object.js:8 (0->.) 0x3cffdd23a291 
<String[15]: OwnPropertyKeys>]

[LoadIC in ~PostExperimentals+341 at native prologue.js:144 (0->.) 
0x3cffdd235301 <String[4]: next>]

[LoadIC in ~+52 at native v8natives.js:26 (0->.) 0x3cffdd2ba189 
<String[29]: ProxyDelegateCallAndConstruct>]

[LoadIC in ~+141 at native v8natives.js:27 (0->.) 0x3cffdd2ba1c1 
<String[22]: ProxyDerivedHasOwnTrap>]

[LoadIC in ~+230 at native v8natives.js:28 (0->.) 0x3cffdd2ba1f1 
<String[20]: ProxyDerivedKeysTrap>]

[LoadIC in ~PostExperimentals+561 at native prologue.js:148 (0->.) 
0x3cffdd235301 <String[4]: next>]

[StoreIC in ~PostExperimentals+781 at native prologue.js:152 (0->.) 
0x3cffdd263a59 <String[17]: PostExperimentals>]

[StoreIC in ~PostExperimentals+804 at native prologue.js:153 (0->.) 
0x3cffdd262c09 <String[6]: Import>]

[StoreIC in ~PostExperimentals+827 at native prologue.js:154 (0->.) 
0x3cffdd262ab1 <String[6]: Export>]

[StoreIC in ~+107 at native test-extra.js:4 (0->.) 0x3cffdd2ba3e9 
<String[25]: testExtraShouldReturnFive>]

[StoreIC in ~+174 at native test-extra.js:7 (0->.) 0x3cffdd2ba421 
<String[28]: testExtraShouldCallToRuntime>]

[LoadIC in ~+106 at native harmony-object.js:5 (0->.) 0x3cffdd234ac1 
<String[6]: Object>]

[LoadIC in ~+142 at native harmony-object.js:7 (0->.) 0x3cffdd262c09 
<String[6]: Import>]

[StoreIC in ~Import+46 at native prologue.js:13 (.->1) 0x3cffdd235301 
<String[4]: next>]

[LoadIC in ~+226 at native harmony-object.js:32 (0->.) 0x3cffdd263099 
<String[16]: InstallFunctions>]

[LoadIC in ~InstallFunctions+79 at native prologue.js:43 (.->1) 
0x3cffdd234c19 <String[6]: length>]

[LoadIC in ~InstallFunctions+497 at native prologue.js:44 (1->P) 
0x3cffdd234c19 <String[6]: length>]

[KeyedLoadIC in ~InstallFunctions+163 at native prologue.js:45 (1->P) 0]

[KeyedLoadIC in ~InstallFunctions+237 at native prologue.js:46 (1->P) 1]

[CallIC in ~InstallFunctions+277 at native prologue.js:47 (1->G) 
0x3cffdd262859 <String[15]: SetFunctionName>]

[CallIC in ~PostExperimentals+298 at native prologue.js:145 (1->G) 
0x3cffdd204291 <String[0]: >]

[LoadIC in ~+52 at native harmony-object.js:8 (0->.) 0x3cffdd23a291 
<String[15]: OwnPropertyKeys>]

[LoadIC in ~PostExperimentals+341 at native prologue.js:144 (.->1) 
0x3cffdd235301 <String[4]: next>]

[CallIC in ~PostExperimentals+518 at native prologue.js:149 (1->G) 
0x3cffdd204291 <String[0]: >]

[LoadIC in ~+52 at native v8natives.js:26 (.->1) 0x3cffdd2ba189 
<String[29]: ProxyDelegateCallAndConstruct>]

[LoadIC in ~+141 at native v8natives.js:27 (.->1) 0x3cffdd2ba1c1 
<String[22]: ProxyDerivedHasOwnTrap>]

[LoadIC in ~+230 at native v8natives.js:28 (.->1) 0x3cffdd2ba1f1 
<String[20]: ProxyDerivedKeysTrap>]

[LoadIC in ~PostExperimentals+561 at native prologue.js:148 (.->1) 
0x3cffdd235301 <String[4]: next>]

[StoreIC in ~PostExperimentals+781 at native prologue.js:152 (.->1) 
0x3cffdd263a59 <String[17]: PostExperimentals>]

[StoreIC in ~PostExperimentals+804 at native prologue.js:153 (.->1) 
0x3cffdd262c09 <String[6]: Import>]

[StoreIC in ~PostExperimentals+827 at native prologue.js:154 (.->1) 
0x3cffdd262ab1 <String[6]: Export>]

[StoreIC in ~+107 at native test-extra.js:4 (0->.) 0x3cffdd2ba3e9 
<String[25]: testExtraShouldReturnFive>]

[StoreIC in ~+174 at native test-extra.js:7 (0->.) 0x3cffdd2ba421 
<String[28]: testExtraShouldCallToRuntime>]

[StoreIC in ~+101 at weirdadd.js:5 (0->.) 0x3cffdd237ea9 <String[1]: N>]

[StoreIC in ~+134 at weirdadd.js:7 (0->.) 0x3cffdd23f001 <String[1]: i>]

[LoadIC in ~+2132 at weirdadd.js:7 (0->.) 0x3cffdd23f001 <String[1]: i>]

[LoadIC in ~+2162 at weirdadd.js:7 (0->.) 0x3cffdd237ea9 <String[1]: N>]

[CompareIC in ~+2193 at weirdadd.js:7 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#LT @ 
0x11962360ed61]

[  patching ic at 0x11962363a16d, test=0x11962363a171, delta=21

[LoadIC in ~+168 at weirdadd.js:9 (0->.) 0x3cffdd252749 <String[4]: Math>]

[LoadIC in ~+198 at weirdadd.js:9 (0->.) 0x3cffdd251719 <String[5]: floor>]

[LoadIC in ~+235 at weirdadd.js:9 (.->1) 0x3cffdd252749 <String[4]: Math>]

[LoadIC in ~+265 at weirdadd.js:9 (0->.) 0x3cffdd251a51 <String[6]: random>]

[LoadIC in ~random+78 at native math.js:86 (0->.) 0x3cffdd26e1b9 
<String[8]: rngstate>]

[KeyedLoadIC in ~random+108 at native math.js:86 (0->1) 0]

[BinaryOpIC(BIT_AND:None*None->None) => (BIT_AND:Smi*Smi->Smi) @ 
0x119623614581 <- ~random+125 at native math.js:86]

[LoadIC in ~random+184 at native math.js:86 (.->1) 0x3cffdd26e1b9 
<String[8]: rngstate>]

[KeyedLoadIC in ~random+214 at native math.js:86 (0->1) 0]

[BinaryOpIC(SHR:None*None->None) => (SHR:Smi*Smi->Smi) @ 0x11962362ade1 <- 
~random+231 at native math.js:86]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~random+238 at native math.js:86]

[BinaryOpIC(BIT_OR:None*None->None) => (BIT_OR:Smi*Smi->Smi) @ 
0x1196236169e1 <- ~random+256 at native math.js:86]

[KeyedStoreIC in ~random+304 at native math.js:87 (0->1) 0]

[KeyedLoadIC in ~random+385 at native math.js:88 (0->1) 1]

[BinaryOpIC(BIT_AND:None*None->None) => (BIT_AND:Number*Smi->Smi) @ 
0x119623609c41 <- ~random+402 at native math.js:88]

[KeyedLoadIC in ~random+491 at native math.js:88 (0->1) 1]

[BinaryOpIC(SHR:None*None->None) => (SHR:Number*Smi->Smi) @ 0x11962362dda1 
<- ~random+508 at native math.js:88]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~random+515 at native math.js:88]

[BinaryOpIC(BIT_OR:None*None->None) => (BIT_OR:Smi*Smi->Smi) @ 
0x1196236169e1 <- ~random+533 at native math.js:88]

[KeyedStoreIC in ~random+591 at native math.js:89 (0->1) 1]

[BinaryOpIC(SHL:None*None->None) => (SHL:Smi*Smi->Smi) @ 0x11962362dcc1 <- 
~random+610 at native math.js:90]

[BinaryOpIC(BIT_AND:None*None->None) => (BIT_AND:Smi*Smi->Smi) @ 
0x119623614581 <- ~random+631 at native math.js:90]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~random+638 at native math.js:90]

[BinaryOpIC(BIT_OR:None*None->None) => (BIT_OR:Smi*Smi->Smi) @ 
0x1196236169e1 <- ~random+656 at native math.js:90]

[CompareIC in ~random+680 at native math.js:91 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#LT @ 
0x11962360ed61]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Number->Number) @ 
0x119623627ea1 <- ~random+726 at native math.js:91]

[BinaryOpIC(MUL:None*None->None) => (MUL:Number*Number->Number) @ 
0x11962362f001 <- ~random+752 at native math.js:91]

[BinaryOpIC(MUL:None*None->None) => (MUL:Number*Smi->Number) @ 
0x11962362ce41 <- ~+330 at weirdadd.js:9]

[  patching ic at 0x119623639a26, test=0x119623639a2a, delta=10

[BinaryOpIC(ADD:None*None->None) => (ADD:Number*Smi->Number) @ 
0x1196236217c1 <- ~+398 at weirdadd.js:9]

[  patching ic at 0x119623639a6a, test=0x119623639a6e, delta=10

[BinaryOpIC(MUL:None*None->None) => (MUL:Number*Smi->Number) @ 
0x11962362ce41 <- ~floor+39 at native math.js:33]

[StoreIC in ~+462 at weirdadd.js:9 (0->.) 0x360a9192bf71 <String[4]: val1>]

[LoadIC in ~+521 at weirdadd.js:10 (0->.) 0x3cffdd251719 <String[5]: floor>]

[LoadIC in ~+588 at weirdadd.js:10 (0->.) 0x3cffdd251a51 <String[6]: 
random>]

[BinaryOpIC(MUL:None*None->None) => (MUL:Number*Smi->Number) @ 
0x11962362ce41 <- ~+653 at weirdadd.js:10]

[  patching ic at 0x119623639b69, test=0x119623639b6d, delta=10

[BinaryOpIC(ADD:None*None->None) => (ADD:Number*Smi->Number) @ 
0x1196236217c1 <- ~+721 at weirdadd.js:10]

[  patching ic at 0x119623639bad, test=0x119623639bb1, delta=10

[StoreIC in ~+785 at weirdadd.js:10 (0->.) 0x360a9192bf91 <String[4]: val2>]

[LoadIC in ~+814 at weirdadd.js:13 (.->1) 0x3cffdd23f001 <String[1]: i>]

[CompareIC in ~+869 at weirdadd.js:13 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#GTE @ 
0x119623629041]

[  patching ic at 0x119623639c41, test=0x119623639c45, delta=21

[LoadIC in ~+1040 at weirdadd.js:19 (0->.) 0x3cffdd2b7de9 <String[11]: 
performance>]

[LoadIC in ~+1070 at weirdadd.js:19 (0->.) 0x3cffdd25dc69 <String[3]: now>]

[StoreIC in ~+1125 at weirdadd.js:19 (0->.) 0x360a9192bfb1 <String[2]: t0>]

[LoadIC in ~+1154 at weirdadd.js:20 (0->.) 0x360a9192bf51 <String[6]: 
newadd>]

[LoadIC in ~+1196 at weirdadd.js:20 (0->.) 0x360a9192bf71 <String[4]: val1>]

[LoadIC in ~+1226 at weirdadd.js:20 (0->.) 0x360a9192bf91 <String[4]: val2>]

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~newadd+33 at weirdadd.js:2]

[StoreIC in ~+1274 at weirdadd.js:20 (0->.) 0x360a9192bfd1 <String[6]: 
result>]

[LoadIC in ~+1303 at weirdadd.js:21 (.->1) 0x3cffdd2b7de9 <String[11]: 
performance>]

[LoadIC in ~+1333 at weirdadd.js:21 (0->.) 0x3cffdd25dc69 <String[3]: now>]

[StoreIC in ~+1388 at weirdadd.js:21 (0->.) 0x360a9192bff1 <String[2]: t1>]

[LoadIC in ~+1417 at weirdadd.js:22 (0->.) 0x360a9192bff1 <String[2]: t1>]

[LoadIC in ~+1447 at weirdadd.js:22 (0->.) 0x360a9192bfb1 <String[2]: t0>]

[BinaryOpIC(SUB:None*None->None) => (SUB:Number*Number->Number) @ 
0x11962362d021 <- ~+1466 at weirdadd.js:22]

[  patching ic at 0x119623639e96, test=0x119623639e9a, delta=10

[StoreIC in ~+1501 at weirdadd.js:22 (0->.) 0x3cffdd280379 <String[4]: 
time>]

[CompareIC in ~+1589 at weirdadd.js:24 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#EQ @ 
0x119623620901]

[  patching ic at 0x119623639f11, test=0x119623639f15, delta=21

[CompareIC in ~+1817 at weirdadd.js:25 
((UNINITIALIZED+UNINITIALIZED=UNINITIALIZED)->(SMI+SMI=SMI))#EQ @ 
0x119623620901]

[  patching ic at 0x119623639ff5, test=0x119623639ff9, delta=21

[BinaryOpIC(ADD:None*None->None) => (ADD:Smi*Smi->Smi) @ 0x1196236273a1 <- 
~+2037 at weirdadd.js:7]

[  patching ic at 0x11962363a0d1, test=0x11962363a0d5, delta=45

[StoreIC in ~+2058 at weirdadd.js:7 (0->.) 0x3cffdd23f001 <String[1]: i>]

[LoadIC in ~+2162 at weirdadd.js:7 (.->1) 0x3cffdd237ea9 <String[1]: N>]

[LoadIC in ~+198 at weirdadd.js:9 (.->1) 0x3cffdd251719 <String[5]: floor>]

[LoadIC in ~+265 at weirdadd.js:9 (.->1) 0x3cffdd251a51 <String[6]: random>]

[StoreIC in ~+462 at weirdadd.js:9 (.->1) 0x360a9192bf71 <String[4]: val1>]

[LoadIC in ~+521 at weirdadd.js:10 (.->1) 0x3cffdd251719 <String[5]: floor>]

[LoadIC in ~+588 at weirdadd.js:10 (.->1) 0x3cffdd251a51 <String[6]: 
random>]

[StoreIC in ~+785 at weirdadd.js:10 (.->1) 0x360a9192bf91 <String[4]: val2>]

[LoadIC in ~+1070 at weirdadd.js:19 (.->1) 0x3cffdd25dc69 <String[3]: now>]

[StoreIC in ~+1125 at weirdadd.js:19 (.->1) 0x360a9192bfb1 <String[2]: t0>]

[LoadIC in ~+1154 at weirdadd.js:20 (.->1) 0x360a9192bf51 <String[6]: 
newadd>]

[LoadIC in ~+1196 at weirdadd.js:20 (.->1) 0x360a9192bf71 <String[4]: val1>]

[LoadIC in ~+1226 at weirdadd.js:20 (.->1) 0x360a9192bf91 <String[4]: val2>]

[StoreIC in ~+1274 at weirdadd.js:20 (.->1) 0x360a9192bfd1 <String[6]: 
result>]

[LoadIC in ~+1333 at weirdadd.js:21 (.->1) 0x3cffdd25dc69 <String[3]: now>]

[StoreIC in ~+1388 at weirdadd.js:21 (.->1) 0x360a9192bff1 <String[2]: t1>]

[LoadIC in ~+1417 at weirdadd.js:22 (.->1) 0x360a9192bff1 <String[2]: t1>]

[LoadIC in ~+1447 at weirdadd.js:22 (.->1) 0x360a9192bfb1 <String[2]: t0>]

[StoreIC in ~+1501 at weirdadd.js:22 (.->1) 0x3cffdd280379 <String[4]: 
time>]

[StoreIC in ~+2058 at weirdadd.js:7 (.->1) 0x3cffdd23f001 <String[1]: i>]

[StoreIC in ~+1388 at weirdadd.js:21 (1->1) 0x360a9192bff1 <String[2]: t1>]

[StoreIC in ~+1125 at weirdadd.js:19 (1->1) 0x360a9192bfb1 <String[2]: t0>]

[StoreIC in ~+1501 at weirdadd.js:22 (1->1) 0x3cffdd280379 <String[4]: 
time>]

[LoadIC in *+997 at weirdadd.js:13 (0->.) 0x3cffdd236c61 <String[8]: 
toString>]

[StoreIC in ~+1011 at weirdadd.js:13 (0->.) 0x360a9192bf71 <String[4]: 
val1>]

[LoadIC in ~ADD+389 at native runtime.js:173 (0->.) 0x3cffdd26dfa9 
<String[12]: $toPrimitive>]

[LoadIC in ~ADD+460 at native runtime.js:174 (0->.) 0x3cffdd26dfa9 
<String[12]: $toPrimitive>]

[LoadIC in ~ADD+587 at native runtime.js:176 (0->.) 0x3cffdd26d3c1 
<String[9]: $toString>]

[BinaryOpIC(ADD:Smi*Smi->Smi) => (ADD:Generic*Smi->Generic) @ 
0x119623643661 <- ~newadd+33 at weirdadd.js:2]

[StoreIC in ~+1274 at weirdadd.js:20 (1->1) 0x360a9192bfd1 <String[6]: 
result>]

[LoadIC in ~+1646 at weirdadd.js:24 (0->.) 0x3cffdd2b6aa9 <String[5]: 
print>]

[LoadIC in ~+1700 at weirdadd.js:24 (0->.) 0x3cffdd280379 <String[4]: time>]

newadd() time with first string value:  1.3689999999999998

[LoadIC in ~+956 at weirdadd.js:13 (.->1) 0x3cffdd236c61 <String[8]: 
toString>]

[StoreIC in ~+1011 at weirdadd.js:13 (.->1) 0x360a9192bf71 <String[4]: 
val1>]

[StoreIC in ~+1011 at weirdadd.js:13 (1->1) 0x360a9192bf71 <String[4]: 
val1>]

[LoadIC in ~ADD+389 at native runtime.js:173 (.->1) 0x3cffdd26dfa9 
<String[12]: $toPrimitive>]

[LoadIC in ~ADD+460 at native runtime.js:174 (.->1) 0x3cffdd26dfa9 
<String[12]: $toPrimitive>]

[LoadIC in ~ADD+587 at native runtime.js:176 (.->1) 0x3cffdd26d3c1 
<String[9]: $toString>]

[BinaryOpIC(ADD:None*None->None) => 
(ADD_CreateAllocationMementos:String*Smi->String) @ 0x1196236447a1 <- 
*+1232 at weirdadd.js:2 using allocation site 0x360a91940b41]

newadd() time with string value optimized:  0



My questions would be:
1) Where are the transitions between Uninitialized, and Monomorphic of the 
newadd function, for instance? I read that there are some Uninitialized -> 
Smi, but I can't see the relation in the output to my function newadd().

2) How does the IC technique works here? I've seen in the code, in 
runtime-profiler.cc that here's where the OptimizeNow() function is called, 
but I don't understand how many times or why is it called. Does anyone here 
knows how it works?

3) What does LoadIC, StoreIC, CompareIC and BinaryOpcIC mean?


Thank you in advance if you read the whole post!

Ignacio.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to