| | @@ -453,10 +453,26 @@ |
| 453 | 453 | |
| 454 | 454 | { Copying } |
| 455 | 455 | |
| 456 | +{ size bytes from [rsi] to [rdi], through rcx; rsi and rdi are left |
| 457 | + as they fall. Up to 64 bytes, as a record or a small array mostly |
| 458 | + is, they go as moves of 8, 4, 2 and 1 bytes: rep movsb takes some |
| 459 | + twenty cycles to start, longer than the few moves take. } |
| 456 | 460 | procedure Copy(size: int64); |
| 461 | +var o, n: int64; |
| 457 | 462 | begin |
| 458 | | - MovRI(RCX, size); |
| 459 | | - RepMovsb; |
| 463 | + if size > 64 then begin |
| 464 | + MovRI(RCX, size); |
| 465 | + RepMovsb; |
| 466 | + exit; |
| 467 | + end; |
| 468 | + o := 0; |
| 469 | + while o < size do begin |
| 470 | + n := 8; |
| 471 | + while n > size - o do n := n div 2; |
| 472 | + Load(RCX, Mem(RSI, o), n, false); |
| 473 | + Store(Mem(RDI, o), RCX, n); |
| 474 | + Inc(o, n); |
| 475 | + end; |
| 460 | 476 | end; |
| 461 | 477 | |
| 462 | 478 | procedure CopyToTemp(var x: TItem); |
| | @@ -495,6 +511,7 @@ |
| 495 | 511 | Lea(RDI, Mem(RBP, tmp)); |
| 496 | 512 | Lea(RSI, MemRip(x.chunk, 0)); |
| 497 | 513 | Copy(x.val); |
| 514 | + Lea(RDI, Mem(RBP, tmp + x.val)); |
| 498 | 515 | MovRI(RCX, t^.len - x.val); |
| 499 | 516 | MovRI(RAX, 0); |
| 500 | 517 | RepStosb; |