Thank you for using AsmJit and welcome to the mailing list!
On Mon, Mar 12, 2012 at 8:49 PM, Eugene <eabat...@gmail.com> wrote:
> Hi all,
>
> Thank you for your library. This semester we used it in our
> virtualization classes.
> Repository is here: http://code.google.com/p/mathvm/
I just checked and I like that the project uses static typing, not so
usual when it comes to VMs.
> I am student. My implementation of virtual machine is here:
> http://code.google.com/p/mathvm/source/browse/#svn%2Ftrunk%2Fstudents%2F2011%2FEvgeny.Batalov%2Fvm
>
> This vm can generate a lot of code so it can help you in testing your
> library.
> I can help you with testing using this vm because if we have a bug in
> particular test it can be hard to understand who introduced it - vm or
> compiler.
I'm interested about any bugs generated by AsmJit, don't hasitate to
report them!
> I've used compiler to generate optimized code and I think that I have
> found some bugs or documentation inaccuracy in it. I could make
> library usage mistakes too.
>
> Here they are:
> 1. idiv_lo_hi
>
> Definition from docs:
> void AsmJit::CompilerIntrinsics::idiv_lo_hi
> (const GPVar & dst_lo, const GPVar & dst_hi, const GPVar & src )
>
> This instruction divides (signed) the value in the AL, AX, or EAX
> register by the source operand and stores the result in the AX, DX:AX,
> or EDX:EAX registers.
>
> Definition from intel manual:
> Signed divide RDX:RAX by r/m64, with result stored in RAX ← Quotient,
> RDX ←Remainder.
Okay, I think that dst_lo and dst_hi should be renamed to dst_rem and
dst_quot, do you agree?
> So I thought that I can use it in following way (code from vm jit):
> case BC_IDIV: { AnyVar _tos1 = ssaStack.back();
> ssaStack.pop_back();
> AnyVar _tos2 = ssaStack.back();
> ssaStack.pop_back();
> GPVar _tmp(cc.newGP());
> cc.mov(_tmp, imm(0));
> cc.idiv_lo_hi(*_tos1.gp, _tmp, *_tos2.gp);
> ssaStack.push_back(_tos1);
> cc.unuse(*_tos2.gp); cc.unuse(_tmp);
> } break;
I will check this out, I think that maybe the problem is wrong
argument position generated by AsmJit.
It's hard to me to check for error only using this log, I think that
the best is to create small example which uses only AsmJit::Compiler
and generates the exception.
Agreed, I filled issue #48.
> 3. Also there are problems with labels. But my current understanding
> of asmjit code doesn't allow to localize source of errors or context
> where they are possible.
I think that you should make sure you created a label using
newLabel(). Labels contain ID which is used by assembler/compiler and
this ID is only generated by calling newLabel(). I hope there is no
other problem here. But anyway, if you encounter an issue here, don't
hesitate to report it. You can also put asserts into AsmJit and send
me patch if you think that there is something wrong.
I will look at the issues tonight.
Thanks
Petr
I fixed issue #48, but there is some SVN problem at code.google.com,
so I will try to do a commit tomorrow.
I also reviewed the idiv issue and it seems that you are using
AsmJit-1.0-beta3. There is newer version in SVN however. I'm going to
make a new beta4 release with all fixes applied this weekend.
Best regards
Petr Kobalicek
16 марта 2012 г. 3:31 пользователь Petr Kobalíček
<kobalic...@gmail.com> написал:
On Mon, Apr 16, 2012 at 10:33 PM, Eugene <eabat...@gmail.com> wrote:
> Hi all once again and sorry for my delay.
> Thank you Petr for new release.
No problem and thanks:)
Thanks, this should be fixed now by #402.
> 2. It seems like you added management of exported symbols onto asmjit. So my
> types which include AsmJit types were had to be fixed with pragma (one of
> some ways to do it).
> #pragma GCC visibility push(hidden)
> typedef union {
> AsmJit::GPVar *gp;
> AsmJit::XMMVar *xmm;
> } AnyVar;
> typedef std::vector<AnyVar> SSAStack;
> #pragma GCC visibility pop
I think this have been added a whole time ago, however, I'm planning
to remove that feature, because source code is usually compiled with
hidden visibility. It was critical some time ago.
But on the other hand, I don't like the union. If you need union-like
type, you can use "AsmJit::BaseVar"
AsmJit::BaseVar var = c.newGP();
var.isGP();
var.isXMM();
But the casting is a bit verbose:
static_cast<AsmJit::GPVar&>(var);
static_cast<AsmJit::XMMVar&>(var);
IF your union works then there is no problem, but I wonder about your
memory management to manage the pointers.
> 3. About the bug with idiv_lo_hi. As I see it was removed in beta4 and there
> is no method for division with register allocation feature now?
Please use plain div/idiv, it's the same:
inline void idiv(const GPVar& dst_rem, const GPVar& dst_quot, const
GPVar& src)
inline void idiv(const GPVar& dst_rem, const GPVar& dst_quot, const Mem& src)
> 4. About issue #48. Yes it is fixed. Error isn't reproducible now.
OK, thanks:)
I will look into this issue, thanks for this code.
> 6. I tested my VM with test set which was passed with beta3.
> Test set is quite big and good news! Beta4 passes VM test set too! :)
Thanks, good to know.
I'm going to reply here after I found solutions to fix those problems.
To fix visibility issue you can use -DASMJIT_HIDDEN compiler option
(AsmJit won't redeclare it if defined).
I filled issues #55 and #56.
Best regards
Petr Kobalicek
On Mon, Apr 16, 2012 at 11:00 PM, Petr Kobalíček