[kaffe] CVS kaffe (robilad): Warning fix for jit3
Kaffe CVS
cvs-commits at kaffe.org
Wed Aug 10 04:08:38 PDT 2005
PatchSet 6799
Date: 2005/08/10 11:03:14
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Warning fix for jit3
2005-08-10 Dalibor Topic <robilad at kaffe.org>
* kaffe/kaffevm/jit3/global-regs.c,
kaffe/kaffevm/jit3/global-regs.h:
New files. Spilt out global register handling code
from machine.c.
* config/i386/common.h: Include gtypes.h.
* kaffe/kaffevm/code-analyse.h: Include classMethod.h
* kaffe/kaffevm/jit3/Makefile.am:
Added global-regs.c and global-regs.h.
* kaffe/kaffevm/jit3/icode.c: Include global-regs.h.
Only call setupGlobalRegisters if NR_GLOBALS is defined.
* kaffe/kaffevm/jit3/machine.c (sortSlots, bindSlotToGlobal,
setupGlobalRegisters): Moved over to global-regs.c.
* kaffe/kaffevm/jit3/machine.h: Include gtypes.h.
Removed setupGlobalRegisters prototype.
* kaffe/kaffevm/jit3/registers.h: Include slots.h.
Reported by: Andreas Tobler <toa at pop.agri.ch>
Members:
ChangeLog:1.4324->1.4325
config/i386/common.h:1.21->1.22
kaffe/kaffevm/code-analyse.h:INITIAL->1.20
kaffe/kaffevm/jit3/Makefile.am:1.15->1.16
kaffe/kaffevm/jit3/Makefile.in:1.117->1.118
kaffe/kaffevm/jit3/global-regs.c:INITIAL->1.1
kaffe/kaffevm/jit3/global-regs.h:INITIAL->1.1
kaffe/kaffevm/jit3/icode.c:1.59->1.60
kaffe/kaffevm/jit3/machine.c:1.77->1.78
kaffe/kaffevm/jit3/machine.h:1.25->1.26
kaffe/kaffevm/jit3/registers.h:INITIAL->1.11
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4324 kaffe/ChangeLog:1.4325
--- kaffe/ChangeLog:1.4324 Tue Aug 9 22:48:32 2005
+++ kaffe/ChangeLog Wed Aug 10 11:03:14 2005
@@ -1,5 +1,32 @@
2005-08-10 Dalibor Topic <robilad at kaffe.org>
+ * kaffe/kaffevm/jit3/global-regs.c,
+ kaffe/kaffevm/jit3/global-regs.h:
+ New files. Spilt out global register handling code
+ from machine.c.
+
+ * config/i386/common.h: Include gtypes.h.
+
+ * kaffe/kaffevm/code-analyse.h: Include classMethod.h
+
+ * kaffe/kaffevm/jit3/Makefile.am:
+ Added global-regs.c and global-regs.h.
+
+ * kaffe/kaffevm/jit3/icode.c: Include global-regs.h.
+ Only call setupGlobalRegisters if NR_GLOBALS is defined.
+
+ * kaffe/kaffevm/jit3/machine.c (sortSlots, bindSlotToGlobal,
+ setupGlobalRegisters): Moved over to global-regs.c.
+
+ * kaffe/kaffevm/jit3/machine.h: Include gtypes.h.
+ Removed setupGlobalRegisters prototype.
+
+ * kaffe/kaffevm/jit3/registers.h: Include slots.h.
+
+ Reported by: Andreas Tobler <toa at pop.agri.ch>
+
+2005-08-10 Dalibor Topic <robilad at kaffe.org>
+
Resynced with GNU Classpath.
2005-08-08 Casey Marshall <csm at gnu.org>
@@ -75,11 +102,11 @@
Reflect recent changes in GNU Classpath. Change gnu.classpath.RawData
to gnu.classpath.Pointer.
-2005-08-08 Andreas Tobler <toa at pop.agri.ch>
+2005-08-08 Andreas Tobler <a.tobler at schweiz.ch>
- * kaffe/kaffe/main.c (setKaffeAWT): Only define if using Kaffe's AWT.
+ * kaffe/kaffevm/jit3/icode.c (cvt_double_int): Remove unused variable.
- * kaffe/kaffevm/jit3/icode.c (cvt_double_int): Removed unused variable i.
+ * kaffe/kaffe/main.c (setKaffeAWT): Silence unused function warnings.
2005-08-08 Wolfgang Baer <WBaer at gmx.de>
Index: kaffe/config/i386/common.h
diff -u kaffe/config/i386/common.h:1.21 kaffe/config/i386/common.h:1.22
--- kaffe/config/i386/common.h:1.21 Sun Apr 17 20:36:40 2005
+++ kaffe/config/i386/common.h Wed Aug 10 11:03:17 2005
@@ -16,6 +16,7 @@
#define __i386_h
#include "generic/gentypes.h"
+#include "gtypes.h"
#if defined(NEED_sysdepCallMethod)
#include "sysdepCallMethod.h"
===================================================================
Checking out kaffe/kaffe/kaffevm/code-analyse.h
RCS: /home/cvs/kaffe/kaffe/kaffe/kaffevm/code-analyse.h,v
VERS: 1.20
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/code-analyse.h Wed Aug 10 11:08:37 2005
@@ -0,0 +1,262 @@
+/* code-analyse.h
+ * Analyse a method's bytecodes.
+ *
+ * Copyright (c) 1996, 1997
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __code_analyse_h
+#define __code_analyse_h
+
+#include "classMethod.h"
+
+typedef struct {
+ Hjava_lang_Class* type;
+ uint8 used;
+ uint8 modified;
+} frameElement;
+
+typedef struct perPCInfo {
+ uint16 stackPointer;
+ uint16 flags;
+#if defined(TRANSLATOR)
+ uintp nativePC;
+#endif
+ struct perPCInfo* nextBB;
+ frameElement* frame;
+} perPCInfo;
+
+typedef struct _localUse {
+ int32 use;
+ int32 first;
+ int32 last;
+ int32 write;
+ Hjava_lang_Class* type;
+} localUse;
+
+typedef struct codeinfo {
+ uint16 codelen;
+ uint16 stacksz;
+ uint16 localsz;
+ localUse* localuse;
+ perPCInfo perPC[1];
+} codeinfo;
+
+#define TUNASSIGNED ((Hjava_lang_Class*)0)
+#define TUNSTABLE ((Hjava_lang_Class*)1)
+#define TADDR ((Hjava_lang_Class*)2)
+#define TOBJ ((Hjava_lang_Class*)3)
+#define TVOID (voidClass)
+#define TINT (intClass)
+#define TLONG (longClass)
+#define TFLOAT (floatClass)
+#define TDOUBLE (doubleClass)
+
+#define CONSTANTTYPE(VAL, LCL) \
+ switch (CLASS_CONST_TAG(meth->class, (LCL))) { \
+ case CONSTANT_Integer: \
+ VAL = TINT; \
+ break; \
+ case CONSTANT_Long: \
+ VAL = TLONG; \
+ break; \
+ case CONSTANT_Float: \
+ VAL = TFLOAT; \
+ break; \
+ case CONSTANT_Double: \
+ VAL = TDOUBLE; \
+ break; \
+ case CONSTANT_String: \
+ case CONSTANT_ResolvedString: \
+ VAL = TOBJ; \
+ break; \
+ default: \
+ VAL = TUNSTABLE; \
+ break; \
+ }
+
+#define FLAG_STARTOFBASICBLOCK 0x0001
+#define FLAG_STARTOFEXCEPTION 0x0002
+#define FLAG_STACKPOINTERSET 0x0004
+#define FLAG_NORMALFLOW 0x0008
+#define FLAG_JUMPFLOW 0x0010
+#define FLAG_JUMP 0x0020
+#define FLAG_NEEDVERIFY 0x0040
+#define FLAG_DONEVERIFY 0x0080
+#define FLAG_STARTOFINSTRUCTION 0x0100
+
+#define FLAGS(_pc) codeInfo->perPC[_pc].flags
+#define STACKPOINTER(_pc) codeInfo->perPC[_pc].stackPointer
+#define FRAME(_pc) codeInfo->perPC[_pc].frame
+#define INSN(pc) meth->c.bcode.code[(pc)]
+#define INSNLEN(pc) insnLen[INSN(pc)]
+#define BYTE(pc) (int8)(meth->c.bcode.code[(pc)+0])
+#define WORD(pc) (int16)( \
+ (meth->c.bcode.code[(pc)+0] << 8) + \
+ (meth->c.bcode.code[(pc)+1]))
+#define DWORD(pc) (int32)( \
+ (meth->c.bcode.code[(pc)+0] << 24) + \
+ (meth->c.bcode.code[(pc)+1] << 16) + \
+ (meth->c.bcode.code[(pc)+2] << 8) + \
+ (meth->c.bcode.code[(pc)+3]))
+#define INCPC(V) pc += (V)
+
+#define SET_STARTOFBASICBLOCK(PC) ATTACH_NEW_BASICBLOCK(PC); \
+ SET_NEWFRAME(PC); \
+ FLAGS(PC) |= FLAG_STARTOFBASICBLOCK
+
+#define SET_STACKPOINTER(PC, SP) do { \
+ if ((FLAGS(PC) & FLAG_STACKPOINTERSET) && STACKPOINTER(PC) != (SP)) { \
+ failed = true; \
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError), "sp size change at pc %d: %d != %d\n", (PC), STACKPOINTER(PC), (SP)); \
+ } \
+ STACKPOINTER(PC) = (SP); \
+ FLAGS(PC) |= FLAG_STACKPOINTERSET; \
+} while(0)
+
+#if defined(TRANSLATOR)
+#define SET_INSNPC(P, V) codeInfo->perPC[(P)].nativePC = (V)
+#define INSNPC(P) codeInfo->perPC[(P)].nativePC
+#else
+#define SET_INSNPC(P, V)
+#endif
+
+#if defined(INTERPRETER)
+#define SET_INSN(PC, V) INSN(PC) = (V)
+#else
+#define SET_INSN(PC, V)
+#endif
+#define SET_NORMALFLOW(pc) FLAGS(pc) |= FLAG_NORMALFLOW
+#define SET_JUMPFLOW(from, to) FLAGS(to) |= FLAG_JUMPFLOW; \
+ FLAGS(from) |= FLAG_JUMP
+#define SET_STARTOFEXCEPTION(pc) FLAGS(pc) |= FLAG_STARTOFEXCEPTION
+#define SET_NEEDVERIFY(pc) FLAGS(pc) |= FLAG_NEEDVERIFY
+#define SET_DONEVERIFY(pc) FLAGS(pc) &= ~FLAG_NEEDVERIFY; \
+ FLAGS(pc) |= FLAG_DONEVERIFY
+#define SET_STARTOFINSTRUCTION(pc) FLAGS(pc) |= FLAG_STARTOFINSTRUCTION
+
+#define IS_STARTOFBASICBLOCK(pc) (FLAGS(pc) & FLAG_STARTOFBASICBLOCK)
+#define IS_STACKPOINTERSET(pc) (FLAGS(pc) & FLAG_STACKPOINTERSET)
+#define IS_NORMALFLOW(pc) (FLAGS(pc) & FLAG_NORMALFLOW)
+#define IS_STARTOFEXCEPTION(pc) (FLAGS(pc) & FLAG_STARTOFEXCEPTION)
+#define IS_NEEDVERIFY(pc) (FLAGS(pc) & FLAG_NEEDVERIFY)
+#define IS_DONEVERIFY(pc) (FLAGS(pc) & FLAG_DONEVERIFY)
+#define IS_STARTOFINSTRUCTION(pc) (FLAGS(pc) & FLAG_STARTOFINSTRUCTION)
+#define IS_UNREACHABLE(pc) ((IS_STARTOFBASICBLOCK(pc) || \
+ IS_STARTOFEXCEPTION(pc)) && \
+ !IS_DONEVERIFY(pc))
+
+#define ALLOCFRAME() gc_malloc((codeInfo->stacksz+codeInfo->localsz+1) * sizeof(frameElement), KGC_ALLOC_CODEANALYSE)
+
+#define ATTACH_NEW_BASICBLOCK(DPC) \
+ if ((DPC) != 0 && !IS_STARTOFBASICBLOCK(DPC) && \
+ !IS_STARTOFEXCEPTION(DPC)) { \
+ btail->nextBB = &codeInfo->perPC[DPC]; \
+ btail = btail->nextBB; \
+ }
+
+#define SET_NEWFRAME(pc) \
+ if (FRAME(pc) == 0) { \
+ FRAME(pc) = ALLOCFRAME(); \
+ if (!FRAME(pc)) { \
+ meth->accflags &= ~ACC_VERIFIED; \
+ tidyAnalyzeMethod(&codeInfo); \
+ postOutOfMemory(einfo); \
+ return false; \
+ } \
+ }
+
+#define FRAMEMERGE(PC, SP) \
+ SET_STACKPOINTER(PC, SP); \
+ mergeFrame(codeInfo, PC, SP, activeFrame, meth); \
+ if (!IS_DONEVERIFY(PC)) { \
+ SET_NEEDVERIFY(PC); \
+ }
+
+#define FRAMEMERGE_LOCALS(PC) \
+ mergeFrame(codeInfo, PC, meth->localsz+meth->stacksz, activeFrame, meth); \
+ if (!IS_DONEVERIFY(PC)) { \
+ SET_NEEDVERIFY(PC); \
+ }
+
+#define FRAMELOAD(_pc) \
+ { \
+ int m; \
+ for (m = codeInfo->stacksz+codeInfo->localsz; m >= 0; m--) { \
+ activeFrame[m] = FRAME(_pc)[m]; \
+ } \
+ }
+
+#define STKPUSH(L) sp -= (L)
+#define STKPOP(L) sp += (L)
+
+#define STACKINIT(S, T) FRAME(pc)[sp+(S)].type = (T)
+
+#ifdef notyet
+#define STACK_CHECKRANGE(S) if ((S)+sp < meth->localsz || (S)+sp > meth->localsz+meth->stacksz) { \
+ failed = true; \
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError), "sp out of range: %d <%d> %d\n", meth->localsz, (S)+sp, meth->localsz + meth->stacksz); \
+ }
+
+#define STACK_CHECKTYPE(S, T) if ((T) != SF(S).type) { \
+ failed = true; \
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError), "pc %d: stk %d (is %d, want %d)\n", pc, sp+(S), SF(S).type, T); \
+ }
+
+#define LOCAL_CHECKRANGE(L) if ((L) < 0 || (L) >= meth->localsz) { \
+ failed = true; \
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError), "lcl out of range: <%d> %d\n", L, meth->localsz); \
+ }
+#define LOCAL_CHECKTYPE(L, T) if ((T) != LCL(L).type) { \
+ failed = true; \
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError), "pc %d: lcl %d (is %d, want %d)\n", pc, (L), LCL(L).type, T); \
+ }
+#else
+#define STACK_CHECKRANGE(S)
+#define STACK_CHECKTYPE(S, T)
+#define LOCAL_CHECKRANGE(L)
+#define LOCAL_CHECKTYPE(L, T)
+#endif
+
+#define SF(S) activeFrame[sp+(S)]
+#define LCL(L) activeFrame[(L)]
+
+#define STACKIN(S, T) STACK_CHECKRANGE(S); \
+ STACK_CHECKTYPE(S, T)
+#define STACKOUT(S, T) SF(S).type = (T)
+#define STACKOUT_CONST(S, T, V) SF(S).type = (T)
+#define STACKOUT_LOCAL(S, T, L) SF(S) = LCL(L); \
+ LCL(L).used = 1
+
+#define LOCALOUT(L, T) LCL(L).type = (T); \
+ LCL(L).used = 1; \
+ LCL(L).modified = 1
+#define LOCALOUT_STACK(L, T, S) LCL(L) = SF(S); \
+ LCL(L).used = 1; \
+ LCL(L).modified = 1
+#define LOCALINOUT(L, T) LCL(L).used = 1; \
+ LCL(L).modified = 1
+#define STACKCOPY(F, T) SF(T) = SF(F)
+#define STACKOUT_STACK(T, X, F) STACKCOPY(F, T)
+#define STACKSWAP(F, T) { \
+ frameElement tmp; \
+ tmp = SF(T); \
+ SF(T) = SF(F); \
+ SF(F) = tmp; \
+ }
+
+#define LOCALINIT(L, T); FRAME(pc)[(L)].type = (T); \
+ FRAME(pc)[(L)].used = 1
+#define LOCALIN(L, T) LOCAL_CHECKTYPE(L, T); \
+ LCL(L).used = 1
+
+struct _methods;
+bool analyzeMethod(struct _methods*, codeinfo**, errorInfo*);
+void tidyAnalyzeMethod(codeinfo**);
+
+extern const uint8 insnLen[];
+
+#endif
Index: kaffe/kaffe/kaffevm/jit3/Makefile.am
diff -u kaffe/kaffe/kaffevm/jit3/Makefile.am:1.15 kaffe/kaffe/kaffevm/jit3/Makefile.am:1.16
--- kaffe/kaffe/kaffevm/jit3/Makefile.am:1.15 Wed Jun 29 17:23:40 2005
+++ kaffe/kaffe/kaffevm/jit3/Makefile.am Wed Aug 10 11:03:18 2005
@@ -39,6 +39,8 @@
constpool.h \
funcs.c \
funcs.h \
+ global-regs.c \
+ global-regs.h \
icode.c \
labels.c \
labels.h \
Index: kaffe/kaffe/kaffevm/jit3/Makefile.in
diff -u kaffe/kaffe/kaffevm/jit3/Makefile.in:1.117 kaffe/kaffe/kaffevm/jit3/Makefile.in:1.118
--- kaffe/kaffe/kaffevm/jit3/Makefile.in:1.117 Tue Jul 19 01:16:13 2005
+++ kaffe/kaffe/kaffevm/jit3/Makefile.in Wed Aug 10 11:03:18 2005
@@ -77,9 +77,9 @@
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libengine_la_LIBADD =
-am_libengine_la_OBJECTS = basecode.lo constpool.lo funcs.lo icode.lo \
- labels.lo machine.lo registers.lo seq.lo slots.lo \
- native-wrapper.lo methodcalls.lo
+am_libengine_la_OBJECTS = basecode.lo constpool.lo funcs.lo \
+ global-regs.lo icode.lo labels.lo machine.lo registers.lo \
+ seq.lo slots.lo native-wrapper.lo methodcalls.lo
nodist_libengine_la_OBJECTS = trampolines.lo
libengine_la_OBJECTS = $(am_libengine_la_OBJECTS) \
$(nodist_libengine_la_OBJECTS)
@@ -408,6 +408,8 @@
constpool.h \
funcs.c \
funcs.h \
+ global-regs.c \
+ global-regs.h \
icode.c \
labels.c \
labels.h \
@@ -490,6 +492,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/basecode.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/constpool.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/funcs.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/global-regs.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/icode.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/labels.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/machine.Plo at am__quote@
===================================================================
Checking out kaffe/kaffe/kaffevm/jit3/global-regs.c
RCS: /home/cvs/kaffe/kaffe/kaffe/kaffevm/jit3/global-regs.c,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jit3/global-regs.c Wed Aug 10 11:08:37 2005
@@ -0,0 +1,145 @@
+/* global-regs.c
+ * Setup global registers.
+ *
+ * Copyright (c) 1996-1999
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * Copyright (c) 2003, 2004, 2005
+ * Kaffe.org contributors. See ChangeLog for details. All rights reserved.
+ *
+ * Cross-language profiling changes contributed by
+ * the Flux Research Group, Department of Computer Science,
+ * University of Utah, http://www.cs.utah.edu/flux/
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "code-analyse.h"
+#include "gc.h"
+#include "global-regs.h"
+#include "itypes.h"
+#include "machine.h"
+#include "md.h"
+#include "registers.h"
+#include "slots.h"
+
+#if defined(NR_GLOBALS)
+
+static
+void
+bindSlotToGlobal(int lcl, int r, int type)
+{
+ kregs* reg;
+ SlotData* dslot;
+ int gtype;
+
+ reg = ®info[r];
+ dslot = localinfo[lcl].slot;
+
+ reg->ctype = type;
+ reg->type |= Rglobal;
+ reg->refs++;
+ reg->slot = dslot;
+ dslot->regno = r;
+
+ gtype = GL_ISGLOBAL;
+
+ /* If this is an argument then pre-load */
+ if (lcl < maxArgs) {
+ gtype |= GL_PRELOAD;
+ }
+ /* If this slot is never written note that the global is
+ * read only.
+ */
+ if (codeInfo->localuse[lcl].write == -1) {
+ gtype |= GL_RONLY;
+ }
+ setGlobal(dslot, gtype);
+}
+
+static
+int
+sortSlots(const void* s1, const void* s2)
+{
+ localUse* lcluse1;
+ localUse* lcluse2;
+
+ lcluse1 = &codeInfo->localuse[*((SlotInfo* const*)s1) - localinfo];
+ lcluse2 = &codeInfo->localuse[*((SlotInfo* const*)s2) - localinfo];
+
+ if (lcluse1->use == lcluse2->use) {
+ return (0);
+ }
+ else if (lcluse1->use > lcluse2->use) {
+ return (-1);
+ }
+ else {
+ return (1);
+ }
+}
+
+/*
+ * Setup global registers
+ */
+void
+setupGlobalRegisters(void)
+{
+ SlotInfo** slots;
+ int j;
+ int max;
+
+ /* If we don't have any code info we can't do any global
+ * optimization
+ */
+ if ((codeInfo == 0) || (codeInfo->localuse == 0)) {
+ return;
+ }
+
+ /* Allocate an array for the slot pointers and copy them in */
+ slots = gc_malloc((1+maxLocal) * sizeof(SlotInfo*), KGC_ALLOC_JIT_SLOTS);
+ for (j = 0; j < maxLocal; j++) {
+ slots[j] = &localinfo[j];
+ }
+
+ /* Sort the slots to the most used is first */
+ qsort(slots, maxLocal, sizeof(SlotInfo*), sortSlots);
+
+ /* Allocate the slots to globals */
+ max = NR_GLOBALS;
+ for (j = 0; j < maxLocal && max > 0; j++) {
+ int k;
+ int i;
+ localUse* lcl;
+
+ i = slots[j] - localinfo;
+ lcl = &codeInfo->localuse[i];
+
+ for (k = 0; k < MAXREG; k++) {
+ kregs* reg;
+
+ reg = ®info[k];
+ if ((reg->flags & Rglobal) == 0) {
+ /* Not a global */
+ }
+ else if ((reg->type & Rglobal) != 0) {
+ /* Already used */
+ }
+ else if (lcl->type == TINT && (reg->type & Rint) != 0) {
+ bindSlotToGlobal(i, k, Rint);
+ max--;
+ break;
+ }
+ else if (lcl->type == TOBJ && (reg->type & Rref) != 0) {
+ bindSlotToGlobal(i, k, Rref);
+ max--;
+ break;
+ }
+ }
+ }
+
+ gc_free(slots);
+}
+
+#endif
===================================================================
Checking out kaffe/kaffe/kaffevm/jit3/global-regs.h
RCS: /home/cvs/kaffe/kaffe/kaffe/kaffevm/jit3/global-regs.h,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jit3/global-regs.h Wed Aug 10 11:08:37 2005
@@ -0,0 +1,20 @@
+/* global-regs.h
+ *
+ * Copyright (c) 1996, 1997
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * Copyright (c) 2004, 2005
+ * Kaffe.org contributors. See ChangeLog for details. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __global_regs_h
+#define __global_regs_h
+
+#if defined(NR_GLOBALS)
+void setupGlobalRegisters(void);
+#endif
+
+#endif
Index: kaffe/kaffe/kaffevm/jit3/icode.c
diff -u kaffe/kaffe/kaffevm/jit3/icode.c:1.59 kaffe/kaffe/kaffevm/jit3/icode.c:1.60
--- kaffe/kaffe/kaffevm/jit3/icode.c:1.59 Mon Aug 8 23:30:55 2005
+++ kaffe/kaffe/kaffevm/jit3/icode.c Wed Aug 10 11:03:18 2005
@@ -37,6 +37,7 @@
#include "funcs.h"
#include "kaffe_jni.h"
#include "fp.h"
+#include "global-regs.h"
#if defined(HAVE_branch_and_link)
#define blink 0x8000000
@@ -225,7 +226,9 @@
l->from = 0;
setupSlotsForBasicBlock();
+#if defined(NR_GLOBALS)
setupGlobalRegisters();
+#endif
setupArgumentRegisters();
/* Emit prologue code */
Index: kaffe/kaffe/kaffevm/jit3/machine.c
diff -u kaffe/kaffe/kaffevm/jit3/machine.c:1.77 kaffe/kaffe/kaffevm/jit3/machine.c:1.78
--- kaffe/kaffe/kaffevm/jit3/machine.c:1.77 Tue Jul 19 16:27:37 2005
+++ kaffe/kaffe/kaffevm/jit3/machine.c Wed Aug 10 11:03:20 2005
@@ -1139,123 +1139,6 @@
SCHK( sanityCheck(); )
}
-static
-int
-sortSlots(const void* s1, const void* s2)
-{
- localUse* lcluse1;
- localUse* lcluse2;
-
- lcluse1 = &codeInfo->localuse[*((SlotInfo* const*)s1) - localinfo];
- lcluse2 = &codeInfo->localuse[*((SlotInfo* const*)s2) - localinfo];
-
- if (lcluse1->use == lcluse2->use) {
- return (0);
- }
- else if (lcluse1->use > lcluse2->use) {
- return (-1);
- }
- else {
- return (1);
- }
-}
-
-static
-void
-bindSlotToGlobal(int lcl, int r, int type)
-{
- kregs* reg;
- SlotData* dslot;
- int gtype;
-
- reg = ®info[r];
- dslot = localinfo[lcl].slot;
-
- reg->ctype = type;
- reg->type |= Rglobal;
- reg->refs++;
- reg->slot = dslot;
- dslot->regno = r;
-
- gtype = GL_ISGLOBAL;
-
- /* If this is an argument then pre-load */
- if (lcl < maxArgs) {
- gtype |= GL_PRELOAD;
- }
- /* If this slot is never written note that the global is
- * read only.
- */
- if (codeInfo->localuse[lcl].write == -1) {
- gtype |= GL_RONLY;
- }
- setGlobal(dslot, gtype);
-}
-
-/*
- * Setup global registers
- */
-void
-setupGlobalRegisters(void)
-{
-#if defined(NR_GLOBALS)
- SlotInfo** slots;
- int j;
- int max;
-
- /* If we don't have any code info we can't do any global
- * optimization
- */
- if ((codeInfo == 0) || (codeInfo->localuse == 0)) {
- return;
- }
-
- /* Allocate an array for the slot pointers and copy them in */
- slots = gc_malloc((1+maxLocal) * sizeof(SlotInfo*), KGC_ALLOC_JIT_SLOTS);
- for (j = 0; j < maxLocal; j++) {
- slots[j] = &localinfo[j];
- }
-
- /* Sort the slots to the most used is first */
- qsort(slots, maxLocal, sizeof(SlotInfo*), sortSlots);
-
- /* Allocate the slots to globals */
- max = NR_GLOBALS;
- for (j = 0; j < maxLocal && max > 0; j++) {
- int k;
- int i;
- localUse* lcl;
-
- i = slots[j] - localinfo;
- lcl = &codeInfo->localuse[i];
-
- for (k = 0; k < MAXREG; k++) {
- kregs* reg;
-
- reg = ®info[k];
- if ((reg->flags & Rglobal) == 0) {
- /* Not a global */
- }
- else if ((reg->type & Rglobal) != 0) {
- /* Already used */
- }
- else if (lcl->type == TINT && (reg->type & Rint) != 0) {
- bindSlotToGlobal(i, k, Rint);
- max--;
- break;
- }
- else if (lcl->type == TOBJ && (reg->type & Rref) != 0) {
- bindSlotToGlobal(i, k, Rref);
- max--;
- break;
- }
- }
- }
-
- gc_free(slots);
-#endif
-}
-
void
setupArgumentRegisters(void)
{
Index: kaffe/kaffe/kaffevm/jit3/machine.h
diff -u kaffe/kaffe/kaffevm/jit3/machine.h:1.25 kaffe/kaffe/kaffevm/jit3/machine.h:1.26
--- kaffe/kaffe/kaffevm/jit3/machine.h:1.25 Sat May 7 16:20:11 2005
+++ kaffe/kaffe/kaffevm/jit3/machine.h Wed Aug 10 11:03:20 2005
@@ -13,6 +13,8 @@
#ifndef __machine_h
#define __machine_h
+#include "gtypes.h"
+
/* -------------------------------------------------------------------- */
#define KJIT(funcName) KaffeJIT3_ ## funcName
@@ -175,7 +177,6 @@
#define willCatch(FLAG) willcatch. FLAG = true
#define canCatch(FLAG) willcatch. FLAG
-void setupGlobalRegisters(void);
void setupArgumentRegisters(void);
/* Desktop edition */
===================================================================
Checking out kaffe/kaffe/kaffevm/jit3/registers.h
RCS: /home/cvs/kaffe/kaffe/kaffe/kaffevm/jit3/registers.h,v
VERS: 1.11
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jit3/registers.h Wed Aug 10 11:08:38 2005
@@ -0,0 +1,215 @@
+/* registers.h
+ * Instruction macros to extract information.
+ *
+ * Copyright (c) 1996, 1997
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __registers_h
+#define __registers_h
+
+#include "slots.h"
+
+/* Register types */
+#define Reserved 0x80
+#define Rglobal 0x40
+#define Rint 0x01
+#define Rlong 0x02
+#define Rfloat 0x04
+#define Rdouble 0x08
+#define Rref 0x10
+#define Rsubint 0x20
+
+/* Register flags */
+#define Rreadonce 0x01
+#define Rnosaveoncall 0x02
+
+/**
+ * Information about the state of a particular register.
+ *
+ * slot - head of the list of slots whose values are in this register
+ * ctype - value type this register currently contains
+ * type - all value types this register can contain
+ * flags - flags of the register
+ * used - the last time this register was assigned to a slot
+ * regno - backend id of this register (whatever the backend wants it to be)
+ * refs - number of slots whose values are in this register
+ */
+typedef struct _kregs {
+ SlotData* slot;
+ uint8 ctype;
+ uint8 type;
+ uint8 flags;
+ uint32 used;
+ uint8 regno;
+ uint8 refs;
+} kregs;
+
+extern kregs reginfo[];
+extern int enable_readonce;
+
+#define MAXREG NR_REGISTERS
+#define NOREG MAXREG
+
+/*
+ * If we have stack limit support use the STACK_LIMIT macro to get
+ * the slot offset. If we don't we just return the value 0 since
+ * we don't be using stack_limit anyway.
+ */
+#if defined(STACK_LIMIT)
+#define STACK_LIMIT_OFFSET() STACK_LIMIT()
+#else
+#define STACK_LIMIT_OFFSET() 0
+#endif
+
+#define SLOT2FRAMEOFFSET(_s) \
+ ( \
+ ((_s) == stack_limit) ? \
+ STACK_LIMIT_OFFSET() : \
+ ((_s) - slotinfo < maxArgs) ? \
+ SLOT2ARGOFFSET((_s) - slotinfo) : \
+ SLOT2LOCALOFFSET((_s) - slotinfo) \
+ )
+
+void initRegisters(void);
+int slotRegister(SlotData*, int, int, int);
+void clobberRegister(int);
+void forceRegister(SlotData*, int, int);
+int slotOffsetNoSpill(SlotData*, int);
+int slotOffset(SlotData*, int, int);
+void slot_invalidate(SlotData*);
+void spillAndUpdate(SlotData*, jboolean);
+void preloadRegister(SlotData*, int, int);
+
+#define rreload 0
+#define rread 1
+#define rwrite 2
+
+/* JIT2 compatibility */
+#define _slowSlotRegister(A,B,C) slotRegister(A,B,C,NOREG)
+#define _slotInRegister(S,T) _inRegister(S,T)
+#define slotInRegister(I,T) inRegister(I,T)
+#define slowSlotOffset(S,T,U) slotOffset(S,T,U)
+#define _slowSlotOffset(S,T,U) slotOffset(S,T,U)
+
+/**
+ * Macros to deal with slots of type jint.
+ *
+ */
+#define rreg_int(i) slotRegister(seq_slot(s, i), Rint, rread, NOREG)
+#define wreg_int(i) slotRegister(seq_slot(s, i), Rint, rwrite, NOREG)
+#define rwreg_int(i) slotRegister(seq_slot(s, i), Rint, rread|rwrite, NOREG)
+#define rslot_int(i) slotOffset(seq_slot(s, i), Rint, rread)
+#define wslot_int(i) slotOffset(seq_slot(s, i), Rint, rwrite)
+#define rreg_ideal_int(i,r) slotRegister(seq_slot(s, i), Rint, rread, r)
+
+/**
+ * Macros to deal with slots of type ref.
+ *
+ */
+#define rreg_ref(i) slotRegister(seq_slot(s, i), Rref, rread, NOREG)
+#define wreg_ref(i) slotRegister(seq_slot(s, i), Rref, rwrite, NOREG)
+#define rwreg_ref(i) slotRegister(seq_slot(s, i), Rref, rread|rwrite, NOREG)
+#define rslot_ref(i) slotOffset(seq_slot(s, i), Rref, rread)
+#define wslot_ref(i) slotOffset(seq_slot(s, i), Rref, rwrite)
+
+/**
+ * Macros to deal with slots of type long.
+ *
+ */
+#define rreg_long(i) slotRegister(seq_slot(s, i), Rlong, rread, NOREG)
+#define wreg_long(i) slotRegister(seq_slot(s, i), Rlong, rwrite, NOREG)
+#define rwreg_long(i) slotRegister(seq_slot(s, i), Rlong, rread|rwrite, NOREG)
+#define rslot_long(i) slotOffset(seq_slot(s, i), Rlong, rread)
+#define wslot_long(i) slotOffset(seq_slot(s, i), Rlong, rwrite)
+#define rreg_ideal_long(i,r) slotRegister(seq_slot(s, i), Rlong, rread, r)
+
+/**
+ * Macros to deal with slots of type float.
+ *
+ */
+#define rreg_float(i) slotRegister(seq_slot(s, i), Rfloat, rread, NOREG)
+#define wreg_float(i) slotRegister(seq_slot(s, i), Rfloat, rwrite, NOREG)
+#define rwreg_float(i) slotRegister(seq_slot(s, i), Rfloat, rread|rwrite, NOREG)
+#define rslot_float(i) slotOffset(seq_slot(s, i), Rfloat, rread)
+#define wslot_float(i) slotOffset(seq_slot(s, i), Rfloat, rwrite)
+#define rreg_ideal_float(i,r) slotRegister(seq_slot(s, i), Rfloat, rread, r)
+
+/**
+ * Macros to deal with slots of type double.
+ *
+ */
+#define rreg_double(i) slotRegister(seq_slot(s, i), Rdouble, rread, NOREG)
+#define wreg_double(i) slotRegister(seq_slot(s, i), Rdouble, rwrite, NOREG)
+#define rwreg_double(i) slotRegister(seq_slot(s, i), Rdouble, rread|rwrite, NOREG)
+#define rslot_double(i) slotOffset(seq_slot(s, i), Rdouble, rread)
+#define wslot_double(i) slotOffset(seq_slot(s, i), Rdouble, rwrite)
+#define rreg_ideal_double(i,r) slotRegister(seq_slot(s, i), Rdouble, rread, r)
+
+/**
+ * Macros to deal with slots of type subint.
+ *
+ */
+#define rreg_subint(i) slotRegister(seq_slot(s, i), Rsubint, rread, NOREG)
+#define wreg_subint(i) slotRegister(seq_slot(s, i), Rsubint, rwrite, NOREG)
+#define rwreg_subint(i) slotRegister(seq_slot(s, i), Rsubint, rread|rwrite, NOREG)
+#define rslot_subint(i) slotOffset(seq_slot(s, i), Rsubint, rread)
+#define wslot_subint(i) slotOffset(seq_slot(s, i), Rsubint, rwrite)
+#define rreg_ideal_subint(i,r) slotRegister(seq_slot(s, i), Rsubint, rread, r)
+
+#define sreg(I) reginfo[(seq_slot(s,I)->regno)].regno
+#define sreg_int(i) sreg(i)
+#define sreg_ref(i) sreg(i)
+#define sreg_long(i) sreg(i)
+#define sreg_float(i) sreg(i)
+#define sreg_double(i) sreg(i)
+
+#if 0
+#define lreg_int(i) wreg_int(i)
+#define lreg_ref(i) wreg_ref(i)
+#define lreg_long(i) wreg_long(i)
+#define lreg_float(i) wreg_float(i)
+#define lreg_double(i) wreg_double(i)
+#endif
+#define lreg_int(i) slotRegister(seq_slot(s, i), Rint, rreload, NOREG)
+#define lreg_ref(i) slotRegister(seq_slot(s, i), Rref, rreload, NOREG)
+#define lreg_long(i) slotRegister(seq_slot(s, i), Rlong, rreload, NOREG)
+#define lreg_float(i) slotRegister(seq_slot(s, i), Rfloat, rreload, NOREG)
+#define lreg_double(i) slotRegister(seq_slot(s, i), Rdouble, rreload, NOREG)
+
+#define const_int(I) s->u[I].value.i
+#define const_long(I) s->u[I].value.l
+#define const_label(I) s->u[I].labconst
+#define const_method(I) s->u[I].methconst
+#define const_float(I) s->u[I].value.f
+#define const_double(I) s->u[I].value.d
+
+/* Reserve a register */
+#define register_reserve(r) (reginfo[r].type |= Reserved)
+#define register_unreserve(r) (reginfo[r].type &= ~Reserved)
+
+#define calleeSave(R) (reginfo[R].flags & Rnosaveoncall)
+
+/* Is a slot already in a register? */
+#define _inRegister(S,T) ((reginfo[(S)->regno].ctype & (T)) != (0))
+#define inRegister(I,T) (_inRegister(seq_slot(s,I), T))
+
+/* Is a register global? */
+#define isRegisterGlobal(R) ((reginfo[(R)].type & Rglobal) != 0)
+
+extern void initGlobalRegisters(int);
+extern void setGlobalRegister(int);
+
+extern void sanityCheck(void);
+extern void reload(SlotData*);
+
+extern void slot_kill_readonce(SlotData*);
+
+#if defined(HAVE_kill_readonce_register)
*** Patch too long, truncated ***
More information about the kaffe
mailing list