PERFORCE change 49613 for review
Marcel Moolenaar
marcel at FreeBSD.org
Tue Mar 23 23:21:57 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=49613
Change 49613 by marcel at marcel_nfs on 2004/03/23 23:21:00
Implement run-length encoding. For platforms with a large amount
of register data (like ia64), this can be a major booster. On
ia64 it will be, because the high FP registers (96 registers, each
16 bytes) are most of the time zeroes. Instead of pumping 3072
characters over the link, we can compress that to 96 characters in
case they are all zero.
Affected files ...
.. //depot/projects/gdb/sys/gdb/gdb_packet.c#5 edit
Differences ...
==== //depot/projects/gdb/sys/gdb/gdb_packet.c#5 (text+ko) ====
@@ -158,6 +158,7 @@
gdb_tx_end(void)
{
const char *p;
+ int runlen;
unsigned char c, cksum;
do {
@@ -166,8 +167,51 @@
cksum = 0;
p = gdb_txbuf;
while (p < gdb_txp) {
- gdb_cur->gdb_putc(*p);
- cksum += *p++;
+ /* Send a character and start run-length encoding. */
+ c = *p++;
+ gdb_cur->gdb_putc(c);
+ cksum += c;
+ runlen = 0;
+ /* Determine run-length and update checksum. */
+ while (p < gdb_txp && *p == c) {
+ runlen++;
+ p++;
+ }
+ /* Emit the run-length encoded string. */
+ while (runlen >= 97) {
+ gdb_cur->gdb_putc('*');
+ cksum += '*';
+ gdb_cur->gdb_putc(97+29);
+ cksum += 97+29;
+ runlen -= 97;
+ if (runlen > 0) {
+ gdb_cur->gdb_putc(c);
+ cksum += c;
+ runlen--;
+ }
+ }
+ if (runlen == 1) {
+ gdb_cur->gdb_putc(c);
+ cksum += c;
+ runlen--;
+ }
+ if (runlen == 0)
+ continue;
+ /* Don't emit '$', '#', '+' or '-'. */
+ if (runlen == 7) {
+ gdb_cur->gdb_putc(c);
+ cksum += c;
+ runlen--;
+ }
+ if (runlen == 6 || runlen == 14 || runlen == 16) {
+ gdb_cur->gdb_putc(c);
+ cksum += c;
+ runlen--;
+ }
+ gdb_cur->gdb_putc('*');
+ cksum += '*';
+ gdb_cur->gdb_putc(runlen+29);
+ cksum += runlen+29;
}
gdb_cur->gdb_putc('#');
More information about the p4-projects
mailing list