substitute
substitute
CC#
Created by Yasaki Kondo on 8/5/2024 in #help
How to click on link?
(they could also just reimplement the LinkText locator for p, which is basically the above^)
9 replies
CC#
Created by Yasaki Kondo on 8/5/2024 in #help
How to click on link?
or by using the FindElements on p and grabbing the one with the exact text.
9 replies
CC#
Created by Yasaki Kondo on 8/5/2024 in #help
How to click on link?
/html/body/div/div/div[1]/div[2]/div/div[2]/div[1]/div[1]/button/p
/html/body/div/div/div[1]/div[2]/div/div[2]/div[1]/div[1]/button/p
9 replies
CC#
Created by Yasaki Kondo on 8/5/2024 in #help
How to click on link?
xpath is probably best here
9 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
I may be able to avoid a copy for already big endian systems if I am able to add extension methods for COM imports (it’s a COM class)
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
further cleanup can still happen once I've tested it.
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
still need to test it but should work.
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
otherwise I just pipe it directly in
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
so I create a copy if I need to reverse the endianness and send that in as byte[] (to avoid another copy)
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
public void WriteFloats(uint address, Span<float> values)
{
if (BitConverter.IsLittleEndian)
{
var memory = new byte[values.Length * sizeof(float)];
BinaryPrimitives.ReverseEndianness(
MemoryMarshal.Cast<float, int>(values),
MemoryMarshal.Cast<byte, int>(memory));
SetMemory(address, memory, out _);
return;
}
SetMemory(address, MemoryMarshal.Cast<float, byte>(values), out _);
}
public void WriteFloats(uint address, Span<float> values)
{
if (BitConverter.IsLittleEndian)
{
var memory = new byte[values.Length * sizeof(float)];
BinaryPrimitives.ReverseEndianness(
MemoryMarshal.Cast<float, int>(values),
MemoryMarshal.Cast<byte, int>(memory));
SetMemory(address, memory, out _);
return;
}
SetMemory(address, MemoryMarshal.Cast<float, byte>(values), out _);
}
There is a method to reverse the endianness of N values from a span.
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
for many values I ended up adding an overload for taking a byte[] directly
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
probably
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
from Godbolt on .Net 8, interesting.
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
stackalloc
Program:<<Main>$>g__WriteFloat2|0_2(uint,float) (FullOpts):
G_M4409_IG01: ;; offset=0x0000
sub rsp, 24
vzeroupper
xor eax, eax
mov qword ptr [rsp+0x08], rax
mov qword ptr [rsp+0x10], 0xCBAE90
G_M4409_IG02: ;; offset=0x0017
lea rax, [rsp+0x08]
vmovd ecx, xmm0
bswap ecx
mov dword ptr [rax], ecx
cmp qword ptr [rsp+0x10], 0xCBAE90
je SHORT G_M4409_IG03
call CORINFO_HELP_FAIL_FAST
G_M4409_IG03: ;; offset=0x0034
nop
G_M4409_IG04: ;; offset=0x0035
add rsp, 24
ret
Program:<<Main>$>g__WriteFloat2|0_2(uint,float) (FullOpts):
G_M4409_IG01: ;; offset=0x0000
sub rsp, 24
vzeroupper
xor eax, eax
mov qword ptr [rsp+0x08], rax
mov qword ptr [rsp+0x10], 0xCBAE90
G_M4409_IG02: ;; offset=0x0017
lea rax, [rsp+0x08]
vmovd ecx, xmm0
bswap ecx
mov dword ptr [rax], ecx
cmp qword ptr [rsp+0x10], 0xCBAE90
je SHORT G_M4409_IG03
call CORINFO_HELP_FAIL_FAST
G_M4409_IG03: ;; offset=0x0034
nop
G_M4409_IG04: ;; offset=0x0035
add rsp, 24
ret
re-use existing heap
Program:<<Main>$>g__WriteFloat|0_1(uint,float) (FullOpts):
G_M5640_IG01: ;; offset=0x0000
push rbp
sub rsp, 16
vzeroupper
lea rbp, [rsp+0x10]
vmovss dword ptr [rbp-0x04], xmm0
G_M5640_IG02: ;; offset=0x0012
lea rdi, bword ptr [rbp-0x04]
mov eax, 4
vmovss xmm0, dword ptr [rbp-0x04]
vmovd ecx, xmm0
bswap ecx
cmp eax, 4
jb SHORT G_M5640_IG05
mov dword ptr [rdi], ecx
G_M5640_IG03: ;; offset=0x002D
add rsp, 16
pop rbp
ret
G_M5640_IG04: ;; offset=0x0033
call CORINFO_HELP_OVERFLOW
G_M5640_IG05: ;; offset=0x0038
mov edi, 40
call [System.ThrowHelper:ThrowArgumentOutOfRangeException(int)]
int3
Program:<<Main>$>g__WriteFloat|0_1(uint,float) (FullOpts):
G_M5640_IG01: ;; offset=0x0000
push rbp
sub rsp, 16
vzeroupper
lea rbp, [rsp+0x10]
vmovss dword ptr [rbp-0x04], xmm0
G_M5640_IG02: ;; offset=0x0012
lea rdi, bword ptr [rbp-0x04]
mov eax, 4
vmovss xmm0, dword ptr [rbp-0x04]
vmovd ecx, xmm0
bswap ecx
cmp eax, 4
jb SHORT G_M5640_IG05
mov dword ptr [rdi], ecx
G_M5640_IG03: ;; offset=0x002D
add rsp, 16
pop rbp
ret
G_M5640_IG04: ;; offset=0x0033
call CORINFO_HELP_OVERFLOW
G_M5640_IG05: ;; offset=0x0038
mov edi, 40
call [System.ThrowHelper:ThrowArgumentOutOfRangeException(int)]
int3
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
I use them for C++ stuff
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
Huh, I didn’t know gb supported C#
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
(One just reuses the arg while the other uses new stack)
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
It is additionally interesting as they’re doing the same thing (writing to some stack memory); Time to dive into the rabbit hole.
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
Interesting results
76 replies
CC#
Created by substitute on 7/31/2024 in #help
new Span vs stackalloc
@Kouhai Compiled both on sharplabs, the reinterpret cast is fewer instructions in the JIT assembly in debug, but the stack alloc is fewer instructions in release
76 replies