mirror of
https://github.com/wownero/RandomX.git
synced 2026-12-01 20:44:18 +01:00
Random accesses - JIT compiler
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
;# unroll VM stack
|
||||
mov rsp, rbp
|
||||
mov rsp, rdi
|
||||
|
||||
;# save VM register values
|
||||
pop rcx
|
||||
pop rcx
|
||||
mov qword ptr [rcx+0], r8
|
||||
mov qword ptr [rcx+8], r9
|
||||
mov qword ptr [rcx+16], r10
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
push r15
|
||||
|
||||
;# function arguments
|
||||
push rdi ;# RegisterFile& registerFile
|
||||
mov rbx, rsi ;# MemoryRegisters& memory
|
||||
mov rsi, rdx ;# convertible_t* scratchpad
|
||||
push rdi ;# RegisterFile& registerFile
|
||||
mov rbp, qword ptr [rsi] ;# "mx", "ma"
|
||||
mov rax, qword ptr [rsi+8] ;# uint8_t* dataset
|
||||
push rax
|
||||
mov rsi, rdx ;# convertible_t* scratchpad
|
||||
mov rcx, rdi
|
||||
|
||||
#include "program_prologue_load.inc"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mov rbp, rsp ;# beginning of VM stack
|
||||
mov rdi, 1048577 ;# number of VM instructions to execute + 1
|
||||
mov rdi, rsp ;# beginning of VM stack
|
||||
mov ebx, 1048577 ;# number of VM instructions to execute + 1
|
||||
|
||||
xorps xmm10, xmm10
|
||||
cmpeqpd xmm10, xmm10
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
movdqu xmmword ptr [rsp+0], xmm10
|
||||
|
||||
;# function arguments
|
||||
push rcx ;# RegisterFile& registerFile
|
||||
mov rbx, rdx ;# MemoryRegisters& memory
|
||||
mov rsi, r8 ;# convertible_t* scratchpad
|
||||
push rcx ;# RegisterFile& registerFile
|
||||
mov rbp, qword ptr [rdx] ;# "mx", "ma"
|
||||
mov rax, qword ptr [rdx+8] ;# uint8_t* dataset
|
||||
push rax
|
||||
mov rsi, r8 ;# convertible_t* scratchpad
|
||||
|
||||
include program_prologue_load.inc
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
push rcx ;# preserve ecx
|
||||
db 0, 0, 0, 0 ;# TransformAddress placeholder
|
||||
mov rax, qword ptr [rdi] ;# load the dataset address
|
||||
xor rbp, rcx ;# modify "mx"
|
||||
;# prefetch cacheline "mx"
|
||||
and rbp, -64 ;# align "mx" to the start of a cache line
|
||||
mov edx, ebp ;# edx = mx
|
||||
prefetchnta byte ptr [rax+rdx]
|
||||
;# read cacheline "ma"
|
||||
ror rbp, 32 ;# swap "ma" and "mx"
|
||||
mov edx, ebp ;# edx = ma
|
||||
scratchpad_mask ;# limit address to the specified scratchpad size aligned to multiple of 8
|
||||
lea rcx, [rsi+rcx*8] ;# scratchpad cache line
|
||||
lea rax, [rax+rdx] ;# dataset cache line
|
||||
mov rdx, qword ptr [rax+0] ;# load first dataset quadword (prefetched into the cache by now)
|
||||
xor qword ptr [rcx+0], rdx ;# XOR the dataset item with a scratchpad item, repeat for the rest of the cacheline
|
||||
mov rdx, qword ptr [rax+8]
|
||||
xor qword ptr [rcx+8], rdx
|
||||
mov rdx, qword ptr [rax+16]
|
||||
xor qword ptr [rcx+16], rdx
|
||||
mov rdx, qword ptr [rax+24]
|
||||
xor qword ptr [rcx+24], rdx
|
||||
mov rdx, qword ptr [rax+32]
|
||||
xor qword ptr [rcx+32], rdx
|
||||
mov rdx, qword ptr [rax+40]
|
||||
xor qword ptr [rcx+40], rdx
|
||||
mov rdx, qword ptr [rax+48]
|
||||
xor qword ptr [rcx+48], rdx
|
||||
mov rdx, qword ptr [rax+56]
|
||||
xor qword ptr [rcx+56], rdx
|
||||
pop rcx ;# restore ecx
|
||||
ret
|
||||
@@ -1,13 +0,0 @@
|
||||
mov edx, dword ptr [rbx] ;# ma
|
||||
mov rax, qword ptr [rbx+8] ;# dataset
|
||||
cvtdq2pd xmm0, qword ptr [rax+rdx]
|
||||
add dword ptr [rbx], 8
|
||||
xor ecx, dword ptr [rbx+4] ;# mx
|
||||
mov dword ptr [rbx+4], ecx
|
||||
test ecx, 65528
|
||||
jne short rx_read_dataset_f_ret
|
||||
and ecx, -8
|
||||
mov dword ptr [rbx], ecx
|
||||
prefetcht0 byte ptr [rax+rcx]
|
||||
rx_read_dataset_f_ret:
|
||||
ret 0
|
||||
@@ -1,13 +0,0 @@
|
||||
mov eax, dword ptr [rbx] ;# ma
|
||||
mov rdx, qword ptr [rbx+8] ;# dataset
|
||||
mov rax, qword ptr [rdx+rax]
|
||||
add dword ptr [rbx], 8
|
||||
xor ecx, dword ptr [rbx+4] ;# mx
|
||||
mov dword ptr [rbx+4], ecx
|
||||
test ecx, 65528
|
||||
jne short rx_read_dataset_r_ret
|
||||
and ecx, -8
|
||||
mov dword ptr [rbx], ecx
|
||||
prefetcht0 byte ptr [rdx+rcx]
|
||||
rx_read_dataset_r_ret:
|
||||
ret 0
|
||||
Reference in New Issue
Block a user