<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 23, 2013 at 12:47 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im">On Dec 17, 2013, at 11:39 PM, Gaël Thomas <<a href="mailto:gael.thomas00@gmail.com" target="_blank">gael.thomas00@gmail.com</a>> wrote:<br>
</div><div><div class="im"><br><blockquote type="cite"><p>Ok I see. Of course, at runtime, it's enough for dynamic linking or for deoptimization. However, wmkit acts both as a jit and as an aot. For the aot, it means that I can not use patchpoint and that I should have two different compilation strategy. It's not so difficult, but in this case, I can not use patchpoints to generate gc's stackmap for the aot (basically, I think that I could use a patchpoint to generate a safepoint where I know the locations of my roots by ysing them as arguments of the patchpoint?)?</p>
<div><br></div></blockquote><div><br></div></div><div><div>Yes that makes sense.</div><div><br></div><div>Note that you can pass a NULL for the callee argument to emit an "inactive" safepoint and have the runtime patch a call in its place later. I suspect that you're not actually interested in patching the code though. You probably just want to find the location of roots at an existing call site. To do this, your runtime needs to be able to reliable unwind the stack restoring callee save registers.</div>
</div><div class="im"><blockquote type="cite"><p>Do you think that using a symbol for my targets is easy to implement? Or maybe that there is a conceptual problem for symbols in this case?</p><div><br></div></blockquote><div>
<br></div></div><div>It would be great if patchpoint supported symbols. I'm not aware of any fundamental problem with doing it. There are a few tricky pieces of code that need to be reworked.</div><div><br></div><div>
e.g.</div><div>SelectionDAGBuilder::visitPatchpoint should allow a Function type operand.</div><div><br></div><div>LowerPATCHPOINT should recognize the symbolic operand and emit the right kind of call (maybe CALL64pcrel32).</div>
<div><br></div><div>I’ll be happy to review patches.</div><div class="im"><div><br></div><blockquote type="cite"><p>By the way, were can I find the metadata at the end of the compilation? They are generated in a special symbol/section?</p>
</blockquote><div><br></div></div><div>Please see the docs here.</div><div><a href="http://llvm-reviews.chandlerc.com/D1981" target="_blank">http://llvm-reviews.chandlerc.com/D1981</a></div></div></div></blockquote><div><br>
</div><div>Andy, commit this already! It has LGTM from all three reviewers (although for some reason Juergen's indicator at the top still shows it unreviewed, but going through the comments he LGTM'd it).</div><div>
<br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br></div><div>I know I should check this in now. There are just a few offline review comments I should to address. In particular:</div>
<div><br></div><div>For a patchpoint with a non-null callee, the runtime must reserve enough space to encode the call under all conditions (on x86 this could result in an extra nop because we can't predict the REX prefix ahead of time).</div>
<div><br></div><div>When the runtime patches the code at a patchpoint, it must patch all reserved bytes. It cannot assume that LLVM emits a particular call sequence or flavor of nops.</div><div><br></div><div>Someone recently suggested emitting the call at the end of the reserved bytes (nops before the call). I think that’s a good idea. If we do that we may allow the runtime to assume the return address is one byte past the end of the reserved bytes.</div>
<div><br></div><div>-Andy</div><div><div class="h5"><blockquote type="cite"><p>Anyway, thank you for your answer,<br>
Gaël </p>
<div class="gmail_quote">Le 18 déc. 2013 02:17, "Filip Pizlo" <<a href="mailto:fpizlo@apple.com" target="_blank">fpizlo@apple.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">patchpoint is intended to be used in VMs that do their own linking, and so you wouldn't expect the function parameter to be resolved by LLVM.<div><br></div><div>Presumably, in VMKit, you could just plant a pointer constant to the function you wish to call initially?</div>
<div><br></div><div>-Filip</div><div><br></div><div><br><div><div>On Dec 17, 2013, at 2:42 PM, Gaël Thomas <<a href="mailto:gael.thomas00@gmail.com" target="_blank">gael.thomas00@gmail.com</a>> wrote:</div><br><blockquote type="cite">
<div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Hi all,<br>
<br>I'm trying to play with patchoint (with MCJIT and VMKit) and I don't<br>understand something. I generate this call for my first patch point.<br>Basically, I want to call f(0).<br><br>%5 = call i64 (i64, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.i64(<br>
i64 42, ;; patch point id is 42<br> i32 0, ;; 0 bytes for the padding<br> i8* bitcast (i32 (i32)* @f to i8*), ;; my function f<br> i32 1, ;; 1 argument<br> i32 0) ;; the argument<br><br>I think that the types are correct (at least, the compiler seems happy<br>
with that:)). But when I'm trying to compile the code (that I generate<br>from C++, it's not a bitcode file), I have this message:<br><br>Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible<br>
type!"), function cast, file<br>/Users/gthomas/research/vmkit4/llvm-src/include/llvm/Support/Casting.h,<br>line 232.<br><br>With this stack (I only give the relevant part):<br><br> frame #5: 0x000000010092ed44<br>
libjvm.dylib`llvm::SelectionDAGBuilder::visitPatchpoint() + 3780 at<br>
SelectionDAGNodes.h:610<br> frame #6: 0x000000010091f511<br>libjvm.dylib`llvm::SelectionDAGBuilder::visitIntrinsicCall(this=0x0000000106ff4d20,<br>I=0x0000000106fea460) + 10961 at SelectionDAGBuilder.cpp:5349<br> frame #7: 0x0000000100904c4a<br>
libjvm.dylib`llvm::SelectionDAGBuilder::visitCall(this=0x0000000106ff4d20,<br>I=0x0000000106fea460) + 234 at SelectionDAGBuilder.cpp:5870<br> frame #8: 0x00000001008fc9ea<br>libjvm.dylib`llvm::SelectionDAGBuilder::visit(this=0x0000000106ff4d20,<br>
I=0x0000000106fea460) + 74 at SelectionDAGBuilder.cpp:971<br> frame #9: 0x0000000100947e98<br>libjvm.dylib`llvm::SelectionDAGISel::SelectBasicBlock(this=0x0000000106ff40d0,<br>HadTailCall=0x00007fff5fbfe31e) + 40 at SelectionDAGISel.cpp:579<br>
frame #10: 0x0000000100947aee<br>libjvm.dylib`llvm::SelectionDAGISel::SelectAllBasicBlocks(this=0x0000000106ff40d0,<br>Fn=0x0000000106fe7020) + 8174 at SelectionDAGISel.cpp:1192<br> frame #11: 0x0000000100944b94<br>
libjvm.dylib`llvm::SelectionDAGISel::runOnMachineFunction(this=0x0000000106ff40d0)<br>
+ 1588 at SelectionDAGISel.cpp:434<br> frame #12: 0x0000000100afefc0<br>libjvm.dylib`llvm::MachineFunctionPass::runOnFunction() + 128 at<br>MachineFunctionPass.cpp:33<br> frame #13: 0x00000001010837fb<br>libjvm.dylib`llvm::FPPassManager::runOnFunction(this=0x0000000106fedf20,<br>
F=0x0000000106fe7020) + 331 at LegacyPassManager.cpp:1538<br> frame #14: 0x0000000101083abb<br>libjvm.dylib`llvm::FPPassManager::runOnModule(this=0x0000000106fedf20)<br>+ 59 at LegacyPassManager.cpp:1558<br> frame #15: 0x000000010108402d<br>
libjvm.dylib`llvm::legacy::PassManagerImpl::run(llvm::Module&)<br>[inlined] llvm::legacy::PassManagerImpl::getContainedManager(N=0,<br>this=0x0000000106feb9f0) + 429 at LegacyPassManager.cpp:1616<br> frame #16: 0x0000000101083e80<br>
libjvm.dylib`llvm::legacy::PassManagerImpl::run(this=0x0000000106feb9f0,<br>M=0x0000000106fe6f30) + 544 at LegacyPassManager.cpp:1711<br> frame #17: 0x000000010108466d<br>libjvm.dylib`llvm::legacy::PassManager::run() + 13 at<br>
LegacyPassManager.cpp:1746<br> frame #18: 0x0000000100eeaf8c<br>libjvm.dylib`llvm::MCJIT::emitObject(this=0x0000000106fa69a0,<br>M=0x0000000106fe6f30) + 236 at MCJIT.cpp:131<br> frame #19: 0x0000000100eeb2d3<br>libjvm.dylib`llvm::MCJIT::generateCodeForModule(this=0x0000000106fa69a0,<br>
M=0x0000000106fe6f30) + 323 at MCJIT.cpp:169<br> frame #20: 0x0000000100eec022<br>libjvm.dylib`llvm::MCJIT::getFunctionAddress(std::string const&)<br>[inlined] llvm::MCJIT::getSymbolAddress(this=0x0000000106fa69a0,<br>
CheckFunctionsOnly=true) + 58 at MCJIT.cpp:279<br> frame #21: 0x0000000100eebfe8<br>libjvm.dylib`llvm::MCJIT::getFunctionAddress(this=0x0000000106fa69a0,<br>Name=0x00007fff5fbfe7b0) + 40 at MCJIT.cpp:295<br>...<br><br>
So, I don't understand where could be my mistake?<br>
<br>Thank you in advance,<br>Gaël<br><br><br><br>--<span> </span><br>-------------------------------------------------------------------<br>Gaël Thomas, Associate Professor, UPMC<br><a href="http://pagesperso-systeme.lip6.fr/Gael.Thomas/" target="_blank">http://pagesperso-systeme.lip6.fr/Gael.Thomas/</a><br>
-------------------------------------------------------------------<br><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a><span> </span> <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></div></blockquote></div><br></div></div></blockquote></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">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></blockquote></div></div></div><br></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></div>