JIT on NetBSD/sparc

Michael Eriksson T/D Michael.Eriksson at era-t.ericsson.se
Tue Mar 4 04:00:20 PST 1997


Kaffe, including 0.8.2, does not enable JIT for NetBSD/sparc (there's
simply no config/sparc/netbsd1/jit-md.h file). I think (correct me if
I'm wrong) that the reason for this is that you get a compile error
for kaffe/kaffevm/jit/machine.c:

gcc -O  -I. -I. -I./../../config -I../../config -I../../include -DTRANSLATOR -I./jit -DKVER=\"0.82\" -c -fpic ./jit/machine.c
/tmp/cc015343.s: Assembler messages:
/tmp/cc015343.s:7664: Error: Illegal operands
*** Error code 1

What's causing this is that the NetBSD assembler as(1) can't assemble
the iflush instruction (which flushes the cache) with some operands
(specificially, just a register without offset). By a simple fix to
config/sparc/jit.h, as(1) can get a syntax it recognizes:

*** config/sparc/jit.h.orig	Fri Feb 28 10:31:21 1997
--- config/sparc/jit.h	Tue Mar  4 10:41:20 1997
***************
*** 223,229 ****
  	do {								\
  		int *_p = (int *)(beg), *_e = (int *)(end);		\
  		while (_p < _e) {					\
! 			asm volatile("iflush %0" : : "r"(_p++));	\
  		} 							\
  	} while (0)
  
--- 223,229 ----
  	do {								\
  		int *_p = (int *)(beg), *_e = (int *)(end);		\
  		while (_p < _e) {					\
! 			asm volatile("iflush %0+0" : : "r"(_p++));	\
  		} 							\
  	} while (0)
  

For people who wants to do The Right Thing(tm), there's a patch below
for NetBSD's as, so it does recognize the register-only operand (if
you apply this patch, you obviously don't have to patch
config/sparc/jit.h). This patch has been send-pr'd, so hopefully it
will show up in future releases of NetBSD.

*** gnu/usr.bin/gas/opcode/sparc.h.orig	Fri Feb  4 00:30:09 1994
--- gnu/usr.bin/gas/opcode/sparc.h	Tue Mar  4 11:41:31 1997
***************
*** 777,782 ****
--- 777,783 ----
  { "unimp",	F2(0x0, 0x0), 0xffc00000, "n", 0, v6 },
  
  { "iflush",	F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI(~0),	"1+2", 0, v6 },
+ { "iflush",	F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|SIMM13(~0),	"1", 0, v6 },
  { "iflush",	F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1),		"1+i", 0, v6 },
  { "iflush",	F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1),		"i+1", 0, v6 },
  { "iflush",	F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|RS1_G0,	"i", 0, v6 },


Independently on how one solves the iflush problem, one needs a
config/sparc/netbsd1/jit-md.h:

- Cut here - o - o - o - o - o - o - o - o - o - o - o - o - o - o - o - o -
/*
 * sparc/netbsd/jit-md.h
 * NetBSD sparc JIT configuration information.
 *
 * Copyright (c) 1997 T. J. Wilkinson & Associates, London, UK.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * Written by Michael Eriksson <eramer at era-t.ericsson.se>, 1997.
 */

#ifndef __sparc_netbsd_jit_md_h
#define __sparc_netbsd_jit_md_h

/**/
/* Include common information. */
/**/
#include "sparc/jit.h"

/**/
/* Extra exception handling information. */
/**/

/* Function prototype for signal handlers */
#define	EXCEPTIONPROTO							\
	int sig, int code, struct sigcontext* ctx

/* Get the first exception frame from a signal handler */
#define	EXCEPTIONFRAME(f, c)						\
	(f).retbp = (c)->sc_sp;						\
	(f).retpc = (c)->sc_pc

#endif
- Cut here - o - o - o - o - o - o - o - o - o - o - o - o - o - o - o - o -

After this, you should only have to run configure again (be sure it
says "checking execution engine... jit") and recompile.

I've made some simple tests with JIT on NetBSD/sparc, and it seems to
work (if it doesn't, be sure to tell Tim :-)).

Regards,
Michael Eriksson


More information about the kaffe mailing list