• R/O
  • HTTP
  • SSH
  • HTTPS

HeavyOSECPU: Commit


Commit MetaInfo

Revision68641107f50bb728bf8d32d5048c5647bb526c29 (tree)
Time2014-03-24 15:17:36
Authorhikarupsp <hikarupsp@user...>
Commiterhikarupsp

Log Message

PRegCopyのmemcpyによる実装への変更。

Change Summary

Incremental Difference

--- a/jitc.c
+++ b/jitc.c
@@ -1,82 +1,76 @@
1-#include "osecpu.h"
2-#include "jitc.h"
3-
4-//
5-// JITC common functions (architecture not dependent)
6-//
7-
8-void errorHandler(HOSECPU_RuntimeEnvironment *r)
9-{
10- puts("security error! abort...");
11- printf("debugInfo0=%d, debugInfo1=%d\n", r->debugInfo0, r->debugInfo1);
12-#if (USE_DEBUGGER != 0)
13- dbgrMain(r);
14-#endif
15- exit(1);
16-}
17-
18-int jitCompCmdLen(const unsigned char *src)
19-{
20- //BCode命令長を取得する
21- int i = 1;
22-
23- if (0x01 <= *src && *src < 0x04){
24- // LB, LIMM, PLIMM
25- i = 6;
26- } else if (*src == 0x04){
27- // CND
28- i = 2;
29- } else if (0x08 <= *src && *src < 0x0d){
30- // LMEM, SMEM, ??, ??, ??
31- i = 8 + src[7] * 4;
32- } else if (0x0e <= *src && *src < 0x10){
33- // PADD, PDIF
34- i = 8;
35- } else if (0x10 <= *src && *src < 0x1c){
36- // CP/OR, XOR, AND, ADD, SUB, MUL, SHL, SAR, DIV, MOD,
37- i = 4;
38- } else if (0x1c <= *src && *src < 0x1f){
39- // ??, ??, PCP
40- i = 3;
41- } else if (*src == 0x1f){
42- // ??
43- i = 11;
44- } else if(0x20 <= *src && *src < 0x2e){
45- // CMPE, CMPNE, CMPL, CMPGE, CMPLE, CMPG, TSTZ, TSTNZ,
46- // PCMPE, PCMPNE, PCMPL, PCMPGE, PCMPLE, PCMPG,
47- i = 4;
48- } else if (*src == 0x2f){
49- // ??
50- i = 4 + src[1];
51- } else if (0x30 <= *src && *src < 0x34){
52- // ??, ??, MALLOC, ??
53- i = 4;
54- } else if (0x3c <= *src && *src < 0x3e){
55- // ??, ??
56- i = 7;
57- } else if (*src == 0xfe){
58- // REMARK
59- i = 2 + src[1];
60- }
61-
62- return i;
63-}
64-
65-void PRegCopy(HOSECPU_PointerRegisterEntry *dst, HOSECPU_PointerRegisterEntry *src)
66-{
67- // なんか直接代入するとMacではアライメントエラーで落ちるのです...
68- // *dst = *src;
69-
70- dst->p = src->p;
71- dst->typ = src->typ;
72- dst->p0 = src->p0;
73- dst->p1 = src->p1;
74- dst->liveSign = src->liveSign;
75- dst->pls = src->pls;
76- dst->flags = src->flags;
77- dst->dummy = src->dummy;
78-}
79-
80-
81-
82-
1+#include "osecpu.h"
2+#include "jitc.h"
3+
4+//
5+// JITC common functions (architecture not dependent)
6+//
7+
8+void errorHandler(HOSECPU_RuntimeEnvironment *r)
9+{
10+ puts("security error! abort...");
11+ printf("debugInfo0=%d, debugInfo1=%d\n", r->debugInfo0, r->debugInfo1);
12+#if (USE_DEBUGGER != 0)
13+ dbgrMain(r);
14+#endif
15+ exit(1);
16+}
17+
18+int jitCompCmdLen(const unsigned char *src)
19+{
20+ //BCode命令長を取得する
21+ int i = 1;
22+
23+ if (0x01 <= *src && *src < 0x04){
24+ // LB, LIMM, PLIMM
25+ i = 6;
26+ } else if (*src == 0x04){
27+ // CND
28+ i = 2;
29+ } else if (0x08 <= *src && *src < 0x0d){
30+ // LMEM, SMEM, ??, ??, ??
31+ i = 8 + src[7] * 4;
32+ } else if (0x0e <= *src && *src < 0x10){
33+ // PADD, PDIF
34+ i = 8;
35+ } else if (0x10 <= *src && *src < 0x1c){
36+ // CP/OR, XOR, AND, ADD, SUB, MUL, SHL, SAR, DIV, MOD,
37+ i = 4;
38+ } else if (0x1c <= *src && *src < 0x1f){
39+ // ??, ??, PCP
40+ i = 3;
41+ } else if (*src == 0x1f){
42+ // ??
43+ i = 11;
44+ } else if(0x20 <= *src && *src < 0x2e){
45+ // CMPE, CMPNE, CMPL, CMPGE, CMPLE, CMPG, TSTZ, TSTNZ,
46+ // PCMPE, PCMPNE, PCMPL, PCMPGE, PCMPLE, PCMPG,
47+ i = 4;
48+ } else if (*src == 0x2f){
49+ // ??
50+ i = 4 + src[1];
51+ } else if (0x30 <= *src && *src < 0x34){
52+ // ??, ??, MALLOC, ??
53+ i = 4;
54+ } else if (0x3c <= *src && *src < 0x3e){
55+ // ??, ??
56+ i = 7;
57+ } else if (*src == 0xfe){
58+ // REMARK
59+ i = 2 + src[1];
60+ }
61+
62+ return i;
63+}
64+
65+void PRegCopy(HOSECPU_PointerRegisterEntry *dst, HOSECPU_PointerRegisterEntry *src)
66+{
67+ // 以下の方法で代入するとMacではアライメントエラーで落ちるのです...
68+ // *dst = *src;
69+ // ということで、memcpyによる実装に変更しました。
70+
71+ memcpy(dst, src, sizeof(HOSECPU_PointerRegisterEntry));
72+}
73+
74+
75+
76+
--- a/jitcx86.c
+++ b/jitcx86.c
@@ -1483,6 +1483,7 @@ void jitcRunBinary(void (*bin)(char *), HOSECPU_RuntimeEnvironment *env)
14831483
14841484 void func3c(char *ebp, int opt, int r1, int p1, int lenR, int lenP, int r0, int p0)
14851485 {
1486+ // ENTER
14861487 HOSECPU_RuntimeEnvironment *r = (HOSECPU_RuntimeEnvironment *) (ebp - jitCompA0001_EBP128);
14871488 int i, *pi;
14881489 HOSECPU_PointerRegisterEntry *pp;
Show on old repository browser