<div dir="ltr">Hi Cheng,<div><br></div>It sounds like the either (1) 0x7fe4801fa1f8 is part of the environment, and it's not being configured the same way the 2nd time around, or (2) The JIT is handling on-disk objects differently from in-memory ones. The first option is more likely.<div><br></div><div>It would be helpful if you could attach the object that was stored in your cache.<br><div><br></div><div>Cheers,</div><div>Lang.</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 11, 2014 at 10:58 AM, Cheng Zhu <span dir="ltr"><<a href="mailto:chengzhu@gmail.com" target="_blank">chengzhu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi, All</div><div> </div><div>I have a problem to reuse mcjit jitted code loaded from ObjectCache from a file. In the first run, I use MCJIT generate function JittedOpExpr object code as following and it runs OK. 0x7fe4801fa1f8 at instruction 0x00007fe4cc6c2014 points to 0x69382E which is the beginning of ExecEvalVar function. Then I save the object code into a file after implementing notifyObjectCompiled method. </div><div> </div><div><br> IrExprGetValue:<br>0x00007fe4cc6c2000: push %rbp<br>0x00007fe4cc6c2001: mov %rsp,%rbp<br>0x00007fe4cc6c2004: mov 0x10(%rdi),%rax<br>0x00007fe4cc6c2008: pop %rbp<br>0x00007fe4cc6c2009: jmpq *%rax<br>0x00007fe4cc6c200b: nopl 0x0(%rax,%rax,1)<br> JittedOpExpr:<br>0x00007fe4cc6c2010: push %rbp<br>0x00007fe4cc6c2011: mov %rsp,%rbp<br><strong>0x00007fe4cc6c2014: movabs $0x7fe4801fa1f8,%rax</strong><br>0x00007fe4cc6c201e: movabs $0x7fe4801fa1e8,%rdi<br>0x00007fe4cc6c2028: callq *(%rax)<br>0x00007fe4cc6c202a: add $0x5,%rax<br>0x00007fe4cc6c202e: pop %rbp<br>0x00007fe4cc6c202f: retq <br>0x00007fe4cc6c2030: adc $0x0,%al<br>0x00007fe4cc6c2032: add %al,(%rax)<br>0x00007fe4cc6c2034: add %al,(%rax)</div><div> </div><div><strong>0x7fe4801fa1f8 -> 0x69382E</strong></div><div><strong> ExecEvalVar</strong>(ExprState*, ExprContext*, bool*, ExprDoneCond*):<br>0x000000000069382e: push %rbp<br>0x000000000069382f: mov %rsp,%rbp<br>0x0000000000693832: push %r12<br><br clear="all"></div><div>In the next run, I buildedunction of JittedOpExpr again and loaded compiled object from that saved binary file using getObject and went through getPointertoFunction from MCJIT execution engine, I got the following object code in memory. But this time 0x7fe4801fa1f8 points to 0x0, so when callq *(%rax) it couldn't find the ExecEvalVar anymore. I followed the blog "Object Caching with the Kaleidoscope Example Problem" written by Andy Kaylor by implementing my own MCJITObjectCache class. Did I miss anything here? Thank you very much. </div><div> </div><div> IrExprGetValue:<br>0x00007fe4cc6c2000: push %rbp<br>0x00007fe4cc6c2001: mov %rsp,%rbp<br>0x00007fe4cc6c2004: mov 0x10(%rdi),%rax<br>0x00007fe4cc6c2008: pop %rbp<br>0x00007fe4cc6c2009: jmpq *%rax<br>0x00007fe4cc6c200b: nopl 0x0(%rax,%rax,1)<br> JittedOpExpr:<br>0x00007fe4cc6c2010: push %rbp<br>0x00007fe4cc6c2011: mov %rsp,%rbp<br><strong>0x00007fe4cc6c2014: movabs $0x7fe4801fa1f8,%rax</strong><br>0x00007fe4cc6c201e: movabs $0x7fe4801fa1e8,%rdi<br>0x00007fe4cc6c2028: callq *(%rax)<br>0x00007fe4cc6c202a: add $0x5,%rax<br>0x00007fe4cc6c202e: pop %rbp<br>0x00007fe4cc6c202f: retq </div><div> </div><div><strong>but 0x7fe4801fa1f8 -> 000000000</strong><span class="HOEnZb"><font color="#888888"><br><br>-- <br>Best regards<br><br>Cheng
</font></span></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>