@@ -400,7 +400,7 @@ LEAF_ENTRY RhpAssignRef, _TEXT
400400
401401 JustAssign:
402402ALTERNATE_ENTRY RhpAssignRefAVLocationNotHeap
403- mov [ rdi ], rsi // no card marking , src is not a heap object
403+ mov [ rdi ], rsi // no card marking , src is not a heap object
404404 // set rdi , rsi per contract with JIT_ByRefWriteBarrier
405405 add rdi , 8
406406 mov rsi , r10
@@ -515,9 +515,17 @@ ALTERNATE_ENTRY RhpAssignRefAVLocation
515515 push rdx
516516 push r10
517517
518+ // also save xmm0 , in case it is used for stack clearing , as JIT_ByRefWriteBarrier should not trash xmm0
519+ // Hopefully EscapeFn cannot corrupt other xmm regs , since there is no float math or vectorizable code in there.
520+ sub rsp , 16
521+ movdqu [ rsp ], xmm0
522+
518523 // void SatoriRegion::EscapeFn(SatoriObject ** dst , SatoriObject * src , SatoriRegion * region)
519524 call qword ptr [ rdx + 8 ]
520525
526+ movdqu xmm0 , [ rsp ]
527+ add rsp , 16
528+
521529 pop r10
522530 pop rdx
523531 pop rsi
@@ -529,31 +537,48 @@ LEAF_END RhpAssignRef, _TEXT
529537//
530538// RhpByRefAssignRef simulates movs instruction for object references.
531539//
532- // On entry:
533- // rdi : address of ref - field (assigned to)
534- // rsi : address of the data (source)
535- //
536- // On exit:
537- // rdi , rsi are incremented by 8 ,
538- // rdi , rdx , r9 , r10 , r11 : trashed
539- //
540+ // Entry:
541+ // RDI - address of ref - field (assigned to)
542+ // RSI - address of the data (source)
543+ // Exit:
544+ // RCX is trashed
545+ // RAX is trashed
546+ // RDI , RSI are incremented by SIZEOF(LPVOID)
540547LEAF_ENTRY RhpByRefAssignRef , _TEXT
541- lea r10 , [ rsi + 8 ]
542- ALTERNATE_ENTRY RhpByRefAssignRefAVLocation1
543- mov rsi , [ rsi ]
544-
545- // See if dst is in GCHeap
548+ // See if dst is in GCHeap
546549 mov rax , [ C_VAR(g_card_bundle_table) ] // fetch the page byte map
547- mov r8 , rdi
548- shr r8 , 30 // dst page index
549- cmp byte ptr [ rax + r8 ], 0
550- jne C_FUNC(CheckedEntry)
550+ mov rcx , rdi
551+ shr rcx , 30 // dst page index
552+ cmp byte ptr [ rax + rcx ], 0
553+ jne InHeap
551554
552- NotInHeap_RhpByRefAssignRef:
555+ ALTERNATE_ENTRY RhpByRefAssignRefAVLocation1
556+ mov rcx , [ rsi ]
553557ALTERNATE_ENTRY RhpByRefAssignRefAVLocation2
554- mov [ rdi ], rsi
558+ mov [ rdi ], rcx
555559 add rdi , 8
556- mov rsi , r10
560+ add rsi , 8
561+ ret
562+
563+ InHeap:
564+ // JIT_WriteBarrier may trash these registers
565+ push rdx
566+ push r8
567+ push r9
568+ push r10
569+ push r11
570+
571+ // save preadjusted rsi
572+ lea r10 , [ rsi + 8 ]
573+ mov rsi , [ rsi ]
574+
575+ call CheckedEntry
576+
577+ pop r11
578+ pop r10
579+ pop r9
580+ pop r8
581+ pop rdx
557582 ret
558583LEAF_END RhpByRefAssignRef , _TEXT
559584
0 commit comments