Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 22 10:04
    kobalicek commented #346
  • Sep 22 09:58
    kobalicek commented #346
  • Sep 22 02:58
    nmanhong commented #346
  • Sep 22 02:58
    nmanhong commented #346
  • Sep 22 02:57
    nmanhong commented #346
  • Sep 18 03:14
    nmanhong commented #346
  • Sep 17 07:27
    kobalicek commented #346
  • Sep 17 01:52
    nmanhong commented #346
  • Sep 16 13:27
    kobalicek commented #346
  • Sep 16 13:26
    kobalicek commented #346
  • Sep 16 09:30
    nmanhong commented #346
  • Sep 16 09:29
    nmanhong commented #346
  • Sep 15 07:42
    kobalicek labeled #346
  • Sep 15 07:41
    kobalicek commented #346
  • Sep 15 06:58
    nmanhong closed #342
  • Sep 15 06:45
    nmanhong commented #346
  • Sep 15 06:44
    nmanhong opened #346
  • Sep 05 11:25
    kobalicek labeled #341
  • Sep 05 11:25
    kobalicek labeled #342
  • Sep 05 11:25
    kobalicek labeled #345
mdecicco
@mdecicco
I just bind each function's label immediately after addFunc for each function
Petr Kobalicek
@kobalicek
yeah
but bind it before the function
mdecicco
@mdecicco
Before addFunc?
Petr Kobalicek
@kobalicek
yeah
mdecicco
@mdecicco
ah, thank you
Petr Kobalicek
@kobalicek
I'm not sure binding after you call addFunc() is a good idea - if the Compiler adds there some instructions you could get a wrong offset
mdecicco
@mdecicco
I was a bit worried about that, I'm glad it works the other way
Petr Kobalicek
@kobalicek
btw Compiler allows patching of already generated code - it stores nodes, you can basically remember nodes you are interested in, and change their content before calling finalize() - there is a lot of powerful stuff that not everybody uses :)
mdecicco
@mdecicco
That was my first half baked plan
I was keeping a map of InvokeNode* -> script_function* was about to write code to update each InvokeNode* afterward
then I realized finalize() would probably have other plans
mdecicco
@mdecicco
It worked!
Just a few more IR instructions to implement with asmjit and it'll be ready for the real test
Petr Kobalicek
@kobalicek
Cool glad it works
mdecicco
@mdecicco
Sorry for the heavy load of questions, but I've got another one...
Does this line mean conversion between data types is not supported or something else? https://github.com/asmjit/asmjit/blob/master/src/asmjit/x86/x86rapass.cpp#L481
Petr Kobalicek
@kobalicek
Yes, compiler doesn't try to convert between register groups
it's TODO, but I'm not sure it should do that by default as it's tricky
In this case you should just follow your arguments - if there is a float and you have GP reg, just convert to XMM and pass it as argument
Compiler really doesn't try to be smart here - if you have INT32 in XMM and you want FLOAT32 in argument, it won't care about that and won't convert anything
mdecicco
@mdecicco
yeah, I think it's just because I'm not handling the register types safely enough
mdecicco
@mdecicco
I wanted to let you know that with my VM the boids simulation was running at 60-70 fps with 250 agents, with asmjit it's up to 150-200 fps with 1000 agents!
Petr Kobalicek
@kobalicek
cool glad to hear that it works flawlessly :)
mdecicco
@mdecicco
It's not entirely flawlessly, I had to do a slight workaround in the script because of one thing I haven't figured out yet... I'm not sure if it's me or asmjit
mdecicco
@mdecicco

In the asmjit string logger output, it says that this is the output for the related x86 code:

0 | mov rdx, qword ptr [rsp+320]
1 | add rdx, 16
2 | mov rdx, qword ptr [rdx]
3 | mov rcx, r8d
4 | imul rcx, 28
5 | mov rax, rdx
6 | add rax, rcx
7 | mov rdx, rax
8 | mov rax, rax

But when I disassemble it and step through, this is the actual code:

0 | mov         rdx,qword ptr [rsp+140h]  
1 | add         rdx,10h  
2 | mov         rdx,qword ptr [rdx]  
3 | mov         ecx,r8d  
4 | imul        rcx,rcx,1Ch  
5 | mov         rax,rdx  
6 | add         rax,rcx  
7 | mov         rdx,rax  
8 | mov         rax,rax
Which are pretty much the same, as expected, but on line 3 in the log it says mov rcx, r8d, and on line 3 of the actual code it says mov ecx, r8d
the following imul in both uses rcxthough
mdecicco
@mdecicco
This is the code for an array indexing operation with r8d being the index, rsp+320 being the array base pointer (- 16 bytes), and 28 being the element size
I'm not sure why, this works as expected most of the time. The only time it doesn't work is in the main loop, where this code is executed twice separated by a call which backs up r8d to [rsp+328]
it's then loaded back in from that address for the second block of code that needs it, but the imul is treating it as an int64 when it's only int32
mdecicco
@mdecicco
and as it happens, the backed up r8d has the correct value, but when its loaded to ecx there are some bits above the int32 value in ecx that affect the imul
So I've been doing a bunch of research to see what all of this actually means...
mdecicco
@mdecicco
Well, it seems to work when I update the code generator to force array indices to u64s instead of allowing them to be u32s
I'm not sure if the rcx / ecx thing is a bug or not but it works now
Petr Kobalicek
@kobalicek
It's wrong asm, which asmjit gladly accepts
you really have to use the correct register size on both ends
Try something like compiler.addValidationOptions(BaseEmitter::kValidationOptionIntermediate)
Validation is expensive, so it's off by default, but in your debug builds, you can enable it like this
Petr Kobalicek
@kobalicek
BTW, if your virtReg is 32-bit, you can still cast it - like reg.r64() or reg.r16() etc
So you can do something like this to zero extend 32-bit to 64-bit:
compiler.mov(dst.r32(), src.r32());
mdecicco
@mdecicco
Oh I didn't even know about these things, thanks for the tips!
I've got a validation error right off the bat
I'm sure this'll help a lot
Petr Kobalicek
@kobalicek
Yeah I think validation is very useful as it really strictly validates instructions and their operands
genuine_
@blaquee
Hi, @kobalicek was just wondering if you maintain the vcpkg for asmjit. I typically use vcpkg for easy library integration but want to make sure this is officially maintained
Petr Kobalicek
@kobalicek
Nope, I don't maintain these packages, I don't use vcpkg
I'm only planning to maintain Conan recipe in Conan center, but I don't maintain it at the moment
genuine_
@blaquee
ok
thanks