diff options
author | bde <bde@FreeBSD.org> | 1995-07-11 17:59:22 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-07-11 17:59:22 +0000 |
commit | 5312a5c2187ffb0fb972b9c4d221a0cb228b34d2 (patch) | |
tree | eb18f83b13329d9bbc72e3d9c0acaeddf26c2f7c | |
parent | 7654eb453854f4d047720e71b5c0a34b53ab74cb (diff) | |
download | FreeBSD-src-5312a5c2187ffb0fb972b9c4d221a0cb228b34d2.zip FreeBSD-src-5312a5c2187ffb0fb972b9c4d221a0cb228b34d2.tar.gz |
Speed up the inner loop of ansi_put() by a few percent.
syscons' output is now only about 4-5 times slower than I want.
It loses a factor of 2 for scrolling output by unnecessarily copying
the screen buffer, a factor of 4/3 for dumb OPOST processing, and
a factor of 3/2 for clist processing.
-rw-r--r-- | sys/dev/syscons/syscons.c | 12 | ||||
-rw-r--r-- | sys/i386/isa/syscons.c | 12 | ||||
-rw-r--r-- | sys/isa/syscons.c | 12 |
3 files changed, 30 insertions, 6 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 9591c71..28e5433 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.117 1995/05/30 08:03:13 rgrimes Exp $ + * $Id: syscons.c,v 1.118 1995/06/14 05:16:12 bde Exp $ */ #include "sc.h" @@ -1860,7 +1860,15 @@ outloop: u_short cur_attr = scp->term.cur_attr; u_short *cursor_pos = scp->cursor_pos; do { - *cursor_pos++ = (scr_map[*ptr++] | cur_attr); + /* + * gcc-2.6.3 generates poor (un)sign extension code. Casting the + * pointers in the following to volatile should have no effect, + * but in fact speeds up this inner loop from 26 to 18 cycles + * (+ cache misses) on i486's. + */ +#define UCVP(ucp) ((u_char volatile *)(ucp)) + *cursor_pos++ = UCVP(scr_map)[*UCVP(ptr)] | cur_attr; + ptr++; cnt--; } while (cnt && PRINTABLE(*ptr)); len -= (cursor_pos - scp->cursor_pos); diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index 9591c71..28e5433 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.117 1995/05/30 08:03:13 rgrimes Exp $ + * $Id: syscons.c,v 1.118 1995/06/14 05:16:12 bde Exp $ */ #include "sc.h" @@ -1860,7 +1860,15 @@ outloop: u_short cur_attr = scp->term.cur_attr; u_short *cursor_pos = scp->cursor_pos; do { - *cursor_pos++ = (scr_map[*ptr++] | cur_attr); + /* + * gcc-2.6.3 generates poor (un)sign extension code. Casting the + * pointers in the following to volatile should have no effect, + * but in fact speeds up this inner loop from 26 to 18 cycles + * (+ cache misses) on i486's. + */ +#define UCVP(ucp) ((u_char volatile *)(ucp)) + *cursor_pos++ = UCVP(scr_map)[*UCVP(ptr)] | cur_attr; + ptr++; cnt--; } while (cnt && PRINTABLE(*ptr)); len -= (cursor_pos - scp->cursor_pos); diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index 9591c71..28e5433 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.117 1995/05/30 08:03:13 rgrimes Exp $ + * $Id: syscons.c,v 1.118 1995/06/14 05:16:12 bde Exp $ */ #include "sc.h" @@ -1860,7 +1860,15 @@ outloop: u_short cur_attr = scp->term.cur_attr; u_short *cursor_pos = scp->cursor_pos; do { - *cursor_pos++ = (scr_map[*ptr++] | cur_attr); + /* + * gcc-2.6.3 generates poor (un)sign extension code. Casting the + * pointers in the following to volatile should have no effect, + * but in fact speeds up this inner loop from 26 to 18 cycles + * (+ cache misses) on i486's. + */ +#define UCVP(ucp) ((u_char volatile *)(ucp)) + *cursor_pos++ = UCVP(scr_map)[*UCVP(ptr)] | cur_attr; + ptr++; cnt--; } while (cnt && PRINTABLE(*ptr)); len -= (cursor_pos - scp->cursor_pos); |