[kaffe] mipsel and jit3
Mikolaj Habryn
dichro at rcpt.to
Thu Oct 14 02:31:25 PDT 2004
On Tue, 2004-10-12 at 10:47, Dalibor Topic wrote:
> Are you in Sydney, by chance?
Indeed so! The city that never sleeps, and occasionally forgets to
bathe.
> Very nice trick, I like it. Makes me wonder how that would work with
> endianness issues.
Not at all, I'm afraid. Here's an alternative that leaves the smarts
regarding endianness, multi-size loads and unaligned accesses up to the
compiler to resolve through the deft application of memcpy, which any
reasonable compiler (ie, gcc) will resolve as a builtin function rather
than a library call.
--- kaffe/kaffe/kaffevm/jit3/funcs.c.~1~ 2004-07-12 05:03:04.000000000 +1000
+++ kaffe/kaffe/kaffevm/jit3/funcs.c 2004-10-14 18:58:47.000000000 +1000
@@ -36,6 +36,12 @@
: CODEPC))
#if defined(KAFFE_VMDEBUG)
+#define _mjh_OUT(v, var, count) do { \
+ var _dummy = (v); \
+ DBGEXPR(JIT,(void)printCodeLabels(),0); \
+ memcpy(codeblock + CODEPC, &_dummy, count); \
+ CODEPC += count; \
+ } while(0)
/*
* Print any labels that refer to the current address.
*/
@@ -49,19 +55,18 @@
kaffe_dprintf("%s:\n", il->name);
}
}
-#undef OUT
-#define OUT(v) do { DBGEXPR(JIT,(void)printCodeLabels(),0),codeblock[CODEPC] = v; CODEPC++; } while (0)
-#define BOUT(v) do { DBGEXPR(JIT,(void)printCodeLabels(),0),*(uint8*)&codeblock[CODEPC] = v; CODEPC++; } while (0)
-#define WOUT(v) do { DBGEXPR(JIT,(void)printCodeLabels(),0),*(uint16*)&codeblock[CODEPC] = v; CODEPC += 2; } while (0)
-#define LOUT(v) do { DBGEXPR(JIT,(void)printCodeLabels(),0),*(uint32*)&codeblock[CODEPC] = v; CODEPC += 4; } while (0)
-#define QOUT(v) do { DBGEXPR(JIT,(void)printCodeLabels(),0),*(uint64*)&codeblock[CODEPC] = v; CODEPC += 8; } while (0)
#else /* ! defined(KAFFE_VMDEBUG) */
-#undef OUT
-#define OUT(v) do { codeblock[CODEPC] = v; CODEPC++; } while (0)
-#define BOUT(v) do { *(uint8*)&codeblock[CODEPC] = v; CODEPC++; } while (0)
-#define WOUT(v) do { *(uint16*)&codeblock[CODEPC] = v; CODEPC += 2; } while (0)
-#define LOUT(v) do { *(uint32*)&codeblock[CODEPC] = v; CODEPC += 4; } while (0)
-#define QOUT(v) do { *(uint64*)&codeblock[CODEPC] = v; CODEPC += 8; } while (0)
+#define _mjh_OUT(v, var, count) do { \
+ var _dummy = (v); \
+ memcpy(codeblock + CODEPC, &_dummy, count); \
+ CODEPC += count; \
+ } while(0)
#endif /* defined(KAFFE_VMDEBUG) */
+#define BOUT(v) _mjh_OUT((v), u_int8_t, 1)
+#define WOUT(v) _mjh_OUT((v), u_int16_t, 2)
+#define LOUT(v) _mjh_OUT((v), u_int32_t, 4)
+#define QOUT(v) _mjh_OUT((v), u_int64_t, 8)
+#undef OUT
+#define OUT BOUT
#include "jit.def"
> Uh. Weird. I've seen stuff like that when I was fixing some mips jit
> breakage, but didn't want to touch it without access to a mips. :(
Hey, I'm working on a US$80 MIPS/Linux box here. What's your postal
address? I'll buy you one :)
I'll come back to the other points I mentioned in my earlier mail, with
patches. I'm still hoping for a flash of inspiration and a one-line fix
that will magically make the whole thing work perfectly.
m.
More information about the kaffe
mailing list