term_print(): assume we’re not at the right margin #403

Manually merged
dnkl merged 1 commits from term-print-assume-col-can-be-incremented into master 9 months ago
dnkl commented 9 months ago
Owner

That is, assume we can, and should, increment the cursor column.

This changes the emitted assembly from:

   518fb:       8b 8b f8 05 00 00       mov    0x5f8(%rbx),%ecx
   51901:       ff c9                   dec    %ecx
   51903:       39 d1                   cmp    %edx,%ecx
   51905:       7e 11                   jle    51918 <term_print.constprop.0+0x78>
   51907:       ff c2                   inc    %edx
   51909:       89 50 10                mov    %edx,0x10(%rax)
   5190c:       5b                      pop    %rbx
   5190d:       5d                      pop    %rbp
   5190e:       41 5c                   pop    %r12
   51910:       c3                      ret
   51911:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)
   51918:       c6 40 18 01             movb   $0x1,0x18(%rax)
   5191c:       5b                      pop    %rbx
   5191d:       5d                      pop    %rbp
   5191e:       41 5c                   pop    %r12
   51920:       c3                      ret

To:

   5191c:       41 8d 50 01             lea    0x1(%r8),%edx
   51920:       89 50 10                mov    %edx,0x10(%rax)
   51923:       3b 93 f8 05 00 00       cmp    0x5f8(%rbx),%edx
   51929:       0f 8d 21 01 00 00       jge    51a50 <term_print.constprop.0+0x190>
   5192f:       5b                      pop    %rbx
   51930:       5d                      pop    %rbp
   51931:       41 5c                   pop    %r12
   51933:       c3                      ret
   ...
   51a50:       c6 40 18 01             movb   $0x1,0x18(%rax)
   51a54:       44 89 40 10             mov    %r8d,0x10(%rax)
   51a58:       5b                      pop    %rbx
   51a59:       5d                      pop    %rbp
   51a5a:       41 5c                   pop    %r12
   51a5c:       c3                      ret

I.e. it cuts the normal path from 10 instructions down to 8. It increases the "bad" path with one extra instruction.

That is, assume we can, and should, increment the cursor column. This changes the emitted assembly from: ``` 518fb: 8b 8b f8 05 00 00 mov 0x5f8(%rbx),%ecx 51901: ff c9 dec %ecx 51903: 39 d1 cmp %edx,%ecx 51905: 7e 11 jle 51918 <term_print.constprop.0+0x78> 51907: ff c2 inc %edx 51909: 89 50 10 mov %edx,0x10(%rax) 5190c: 5b pop %rbx 5190d: 5d pop %rbp 5190e: 41 5c pop %r12 51910: c3 ret 51911: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 51918: c6 40 18 01 movb $0x1,0x18(%rax) 5191c: 5b pop %rbx 5191d: 5d pop %rbp 5191e: 41 5c pop %r12 51920: c3 ret ``` To: ``` 5191c: 41 8d 50 01 lea 0x1(%r8),%edx 51920: 89 50 10 mov %edx,0x10(%rax) 51923: 3b 93 f8 05 00 00 cmp 0x5f8(%rbx),%edx 51929: 0f 8d 21 01 00 00 jge 51a50 <term_print.constprop.0+0x190> 5192f: 5b pop %rbx 51930: 5d pop %rbp 51931: 41 5c pop %r12 51933: c3 ret ... 51a50: c6 40 18 01 movb $0x1,0x18(%rax) 51a54: 44 89 40 10 mov %r8d,0x10(%rax) 51a58: 5b pop %rbx 51a59: 5d pop %rbp 51a5a: 41 5c pop %r12 51a5c: c3 ret ``` I.e. it cuts the normal path from **10** instructions down to **8**. It increases the "bad" path with one extra instruction.
dnkl added the
performance
label 9 months ago
dnkl added 1 commit 9 months ago
2451699c35
term: term_print(): assume we’re *not* at the right margin
dnkl merged commit d8f0e701b5 into master manually 9 months ago
The pull request has been manually merged as d8f0e701b5.
Sign in to join this conversation.
Loading…
There is no content yet.