From 222540d6f4b5adadf0992d4ce97ed44d6875a720 Mon Sep 17 00:00:00 2001 From: hikarupsp Date: Sat, 15 Mar 2014 14:22:08 +0900 Subject: [PATCH] =?utf8?q?jitCompPutImm32=E7=AD=89=E3=82=92define=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- jitc.h | 10 ++++-- jitcx86.c | 114 ++++++++++++++++++++++++++++---------------------------------- 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/jitc.h b/jitc.h index 7e49a4a..1ddcae8 100644 --- a/jitc.h +++ b/jitc.h @@ -1,4 +1,4 @@ - + #ifndef HeavyOSECPU_jitc_h #define HeavyOSECPU_jitc_h @@ -51,7 +51,12 @@ int jitCompCmdLen(const unsigned char *src); #define envOffset_DBGINFO0 (2304 + 0) #define envOffset_DBGINFO1 (2304 + 4) // -#define jitCompPutOp_PUSHAD(p) jitCompPutByte1(p, 0x60); +#define jitCompPutImm32(p, i) jitCompPutByte4(p, ((i) & 0xff), (((i) >> 8) & 0xff), (((i) >> 16) & 0xff), (((i) >> 24) & 0xff)) +#define jitCompPutOp_PUSHAD(p) jitCompPutByte1(p, 0x60); +#define jitCompPutOp_POPAD(p) jitCompPutByte1(p, 0x61); +#define jitCompPutOp_PUSH_GReg(p, reg) jitCompPutByte1(p, 0x50 | (reg)); +#define jitCompPutOp_POP_GReg(p, reg) jitCompPutByte1(p, 0x58 | (reg)); +#define jitCompPutOp_CALL_Relative(p, diff) jitCompPutByte1(w.dst, 0xe8); jitCompPutImm32(&w, j); // Optimization settings @@ -76,7 +81,6 @@ struct JitCompWork { char prefix; //CND命令の値を記録(初期値=0) }; -void jitCompPutImm32(struct JitCompWork *w, int i); int jitCompGetImm32(const unsigned char *src); int jitCompGetLabelNum(struct JitCompWork *w, const unsigned char *src); void jitCompA0001_85DispN(struct JitCompWork *w, int disp, int n); diff --git a/jitcx86.c b/jitcx86.c index 18743ab..5c849af 100644 --- a/jitcx86.c +++ b/jitcx86.c @@ -5,16 +5,6 @@ // // for x86-32bit // - -void jitCompPutImm32(struct JitCompWork *w, int i) -{ - jitCompPutByte1(w->dst, i & 0xff); - jitCompPutByte1(w->dst, (i >> 8) & 0xff); - jitCompPutByte1(w->dst, (i >> 16) & 0xff); - jitCompPutByte1(w->dst, (i >> 24) & 0xff); - return; -} - int jitCompGetImm32(const unsigned char *src) { return (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; @@ -38,7 +28,7 @@ void jitCompA0001_85DispN(struct JitCompWork *w, int disp, int n) } else { // 10 + reg + 101 + disp jitCompPutByte1(w->dst, 0x85 | (n << 3)); - jitCompPutImm32(w, disp); + jitCompPutImm32(w->dst, disp); } return; } @@ -64,7 +54,7 @@ void jitCompA0001_movEaxRxx(struct JitCompWork *w, int rxx) #if (jitCompA0001_USE_R3F_IMM32 != 0) if (rxx == 0x3f) { jitCompPutByte1(w->dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(w, w->r3f); + jitCompPutImm32(w->dst, w->r3f); return; } #endif @@ -242,7 +232,7 @@ void jitCompA0001_checkType0(struct JitCompWork *w, int pxx, int typ, int ac) jitCompA0001_movReg32EbpDisp(w, 0 /* EAX */, 256 + pxx * 32 + 4); /* MOV(EAX, [EBP+?]); */ /* typ */ jitCompPutByte3(w->dst, 0x83, 0xf8, typ & 0x7f); /* CMP(EAX, ?); */ jitCompPutByte2(w->dst, 0x0f, 0x85); /* JNE */ - jitCompPutImm32(w, errfnc - (w->dst + 4)); + jitCompPutImm32(w->dst, errfnc - (w->dst + 4)); return; } @@ -259,11 +249,11 @@ void jitCompA0001_checkLimit(struct JitCompWork *w, int reg, int pxx) jitCompPutByte1(w->dst, 0x3b); /* CMP(reg, [EBP+?]); */ jitCompA0001_85DispN(w, 256 + pxx * 32 + 8, reg); /* p0 */ jitCompPutByte2(w->dst, 0x0f, 0x82); /* JB */ - jitCompPutImm32(w, errfnc - (w->dst + 4)); + jitCompPutImm32(w->dst, errfnc - (w->dst + 4)); jitCompPutByte1(w->dst, 0x3b); /* CMP(reg, [EBP+?]); */ jitCompA0001_85DispN(w, 256 + pxx * 32 + 12, reg); /* p1 */ jitCompPutByte2(w->dst, 0x0f, 0x83); /* JAE */ - jitCompPutImm32(w, errfnc - (w->dst + 4)); + jitCompPutImm32(w->dst, errfnc - (w->dst + 4)); return; } @@ -301,7 +291,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompA0001_movEbpDispReg32(&w, envOffset_DBGINFO0, IA32_REG0_EAX); // MOV(EAX, ?); jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, imm32); */ - jitCompPutImm32(&w, debugInfo1); + jitCompPutImm32(w.dst, debugInfo1); jitCompA0001_movEbpDispReg32(&w, envOffset_DBGINFO1, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */ } while (src < src1) { @@ -337,7 +327,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr // LB命令の後に0x3C命令・・・beginFunc() jitCompPutByte1(w.dst, 0xe9); // (x86) JMP rel32 : 次の命令との相対オフセットだけ相対ニアジャンプする enter0 = w.dst; - jitCompPutImm32(&w, 0); // 飛び相対座標が0 ・・・パイプラインのフラッシュ?? + jitCompPutImm32(w.dst, 0); // 飛び相対座標が0 ・・・パイプラインのフラッシュ?? } if (src[6] == 0x34) { // LBの次の命令がDATA ・・・DAT_SA0(label, typ32, length) ・・・メモリ確保命令 tmp_ucp = w.dst; @@ -353,7 +343,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr } j *= jitCompGetImm32(&src[11]); if (j <= 0) w.err = JITC_ERR_BADTYPE; - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); #if (jitCompA0001_OPTIMIZE_JMP != 0) if (j <= 127 - jitCompA0001_OPTIMIZE_ALIGN) { w.dst -= 5; @@ -370,9 +360,9 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (i == 2) { jitCompPutByte2(w.dst, 0x89, 0xc0); j += i; } /* MOV(EAX, EAX); */ if (i == 3) { jitCompPutByte3(w.dst, 0x8d, 0x76, 0x00); j += i; } /* LEA(ESI, [ESI+0]); */ if (i == 4) { jitCompPutByte4(w.dst, 0x8d, 0x74, 0x26, 0x00); j += i; } /* LEA(ESI, [ESI*1+0]); */ - if (i == 5) { jitCompPutByte1(w.dst, 0x0d); jitCompPutImm32(&w, 0); j += i; } /* OR(EAX, 0); */ - if (i == 6) { jitCompPutByte2(w.dst, 0x8d, 0xb6); jitCompPutImm32(&w, 0); j += i; } /* LEA(ESI, [ESI+0]); */ - if (i >= 7) { jitCompPutByte3(w.dst, 0x8d, 0xb4, 0x26); jitCompPutImm32(&w, 0); j += 7; } /* LEA(ESI, [ESI*1+0]); */ + if (i == 5) { jitCompPutByte1(w.dst, 0x0d); jitCompPutImm32(w.dst, 0); j += i; } /* OR(EAX, 0); */ + if (i == 6) { jitCompPutByte2(w.dst, 0x8d, 0xb6); jitCompPutImm32(w.dst, 0); j += i; } /* LEA(ESI, [ESI+0]); */ + if (i >= 7) { jitCompPutByte3(w.dst, 0x8d, 0xb4, 0x26); jitCompPutImm32(w.dst, 0); j += 7; } /* LEA(ESI, [ESI*1+0]); */ } #endif if (src[6] == 0x34) { @@ -433,7 +423,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr /* reg0 のレジスタに対応したMOV命令を発行 */ jitCompPutByte1(w.dst, 0xb8 | reg0); /* MOV(reg0, ?); == 10111000b+wr imm32 */ - jitCompPutImm32(&w, i); + jitCompPutImm32(w.dst, i); if (reg0 == 0) // R03以降の、レジスタの内容をメモリ上に格納してエミュレートする場合 @@ -482,7 +472,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr j = 0; if ((flags & JITC_PHASE1) != 0 || (((flags & JITC_PHASE1) == 0) && label[i].opt != 0)) // label番号iが確保されていれば (このif文は意味をなさない) j = label[i].p - (w.dst + 4); // j はとび先の相対番地 - jitCompPutImm32(&w, j); // JMP もしくは JZ 命令のアドレス部を記述 + jitCompPutImm32(w.dst, j); // JMP もしくは JZ 命令のアドレス部を記述 #if (jitCompA0001_OPTIMIZE_JMP != 0) if (-128 - 3 <= j && j < 0) { if (w.dst[-5] == 0xe9) { @@ -504,7 +494,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr // 代入先が P01, P02なら ESI, EDI,それ以外ならEAXを指定 reg0 = jitCompA000_selectPRegCache(src[1], IA32_REG0_EAX); jitCompPutByte1(w.dst, 0xb8 | reg0); /* MOV(reg0, ?); */ - jitCompPutImm32(&w, (int)label[i].p); // ラベルのパスを各レジスタに代入 + jitCompPutImm32(w.dst, (int)label[i].p); // ラベルのパスを各レジスタに代入 // レジスタへの代入をメモリでエミュレーションする場合は、スタックに積む。 if (reg0 == 0) @@ -513,10 +503,10 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (level < JITC_LV_FASTEST) { jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 8, reg0); /* MOV([EBP+?], reg0); */ /* p0 */ jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, label[i].typ); + jitCompPutImm32(w.dst, label[i].typ); jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 4, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* typ */ jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, (int)label[i].p1); + jitCompPutImm32(w.dst, (int)label[i].p1); jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 12, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* p1 */ jitCompPutByte2(w.dst, 0x31, 0xc0); /* XOR(EAX, EAX); */ jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 16, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ /* liveSign */ @@ -546,7 +536,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr else { jitCompPutByte2(w.dst, 0xf7, 0xc0 | reg0); /* TEST(reg0,1); */ } - jitCompPutImm32(&w, 1); + jitCompPutImm32(w.dst, 1); /* JZ命令を発行 */ jitCompPutByte2(w.dst, 0x74, 0x00); /* JZ($+2) */ @@ -745,7 +735,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr else { jitCompPutByte2(w.dst, 0x81, 0xc0 | reg0); /* ADD(reg0, ?); */ } - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); goto padd1; } #endif @@ -823,7 +813,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (reg2 >= 0) jitCompA000_storeRegCacheAll(&w); jitCompPutByte1(w.dst, 0xb8 | reg0); /* MOV(reg0, ?); */ - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); jitCompPutByte1(w.dst, 0x2b); jitCompA0001_85DispN(&w, src[3] * 4, reg0); if (reg0 == 0) @@ -897,7 +887,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompPutByte2(w.dst, 0x69, 0xc0 | reg0 << 3 | reg0); } } - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); if (reg0 == 0) jitCompA0001_movRxxEax(&w, src[1]); break; @@ -960,7 +950,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr #if (jitCompA0001_USE_R3F_IMM32 != 0) if (src[2] == 0x3f) { jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); } else { jitCompA0001_movEaxRxx(&w, src[2]); @@ -985,14 +975,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr #if (jitCompA0001_USE_R3F_IMM32 != 0) if (src[3] == 0x3f) { jitCompPutByte1(w.dst, 0xb8 | 1); /* MOV(ECX, ?); */ - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); } else { jitCompA0001_movReg32EbpDisp(&w, IA32_REG1_ECX, src[3] * 4); /* MOV(ECX, [EBP+?]); */ } if (src[2] == 0x3f) { jitCompPutByte1(w.dst, 0xb8 | 0); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); } else { jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, src[2] * 4); /* MOV(EAX, [EBP+?]); */ @@ -1042,7 +1032,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompA0001_movReg32EbpDisp(&w, 0 /* EAX */, 256 + src[2] * 32 + 4); /* MOV(EAX, [EBP+?]); */ /* typ */ jitCompPutByte3(w.dst, 0x83, 0xf8, 0); /* CMP(EAX, 0); */ jitCompPutByte2(w.dst, 0x0f, 0x85); /* JNE */ - jitCompPutImm32(&w, errfnc - (w.dst + 4)); + jitCompPutImm32(w.dst, errfnc - (w.dst + 4)); /* セキュリティチェックが足りてない!(aliveとか) */ } reg0 = IA32_REG0_EAX; @@ -1052,7 +1042,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompPutByte1(w.dst, 0x3b); /* CMP(reg0, [EBP+?]); */ jitCompA0001_85DispN(&w, 256 + src[2] * 32 + 8, reg0); /* p0 */ jitCompPutByte2(w.dst, 0x0f, 0x85); /* JNE */ - jitCompPutImm32(&w, errfnc - (w.dst + 4)); + jitCompPutImm32(w.dst, errfnc - (w.dst + 4)); } jitCompPutByte2(w.dst, 0xff, 0xe0); /* JMP(EAX); */ } @@ -1067,12 +1057,12 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + src[6] * 32 + i); /* MOV(EAX, [EBP+?]); */ if (i == 4) { jitCompPutByte1(w.dst, 0x0d); /* OR(EAX, ?); */ - jitCompPutImm32(&w, 0x80000000); + jitCompPutImm32(w.dst, 0x80000000); } jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + i, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ } jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, debugInfo1); + jitCompPutImm32(w.dst, debugInfo1); jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 28, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ jitCompA000_loadPRegCacheAll(&w); // 手抜き. cmp0reg = -1; @@ -1084,14 +1074,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompA0001_movReg32EbpDisp(&w, 0 /* EAX */, 256 + src[6] * 32 + i); /* MOV(EAX, [EBP+?]); */ if (i == 4) { jitCompPutByte1(w.dst, 0x25); /* AND(EAX, ?); */ - jitCompPutImm32(&w, 0x7fffffff); + jitCompPutImm32(w.dst, 0x7fffffff); } jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + i, IA32_REG0_EAX); /* MOV([EBP+?], EAX); */ } if (level < JITC_LV_FASTER) { jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + src[6] * 32 + 28); /* MOV(EAX, [EBP+?]); */ jitCompPutByte1(w.dst, 0x3d); /* CMP(EAX, ?); */ - jitCompPutImm32(&w, debugInfo1); + jitCompPutImm32(w.dst, debugInfo1); jitCompPutByte2(w.dst, 0x74, 8); /* JE */ jitCompPutByte2(w.dst, 0x31, 0xc0); /* XOR(EAX, EAX); (2) */ jitCompA0001_movEbpDispReg32(&w, 256 + src[1] * 32 + 0, IA32_REG0_EAX); /* MOV([EBP+?], EAX); (1+1+4) */ @@ -1155,7 +1145,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (*src <= 0x25) { jitCompPutByte2(w.dst, 0x81, 0xf8 | reg0); } if (*src >= 0x26) { jitCompPutByte2(w.dst, 0xf7, 0xc0 | reg0); } } - jitCompPutImm32(&w, w.r3f); + jitCompPutImm32(w.dst, w.r3f); goto cmpcc1; } #endif @@ -1188,7 +1178,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr j = 0; if ((flags & JITC_PHASE1) != 0 || (((flags & JITC_PHASE1) == 0) && label[i].opt != 0)) j = label[i].p - (w.dst + 4); - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); #if (jitCompA0001_OPTIMIZE_JMP != 0) if (-128 - 4 <= j && j < 0) { j += 4; @@ -1256,7 +1246,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (*src == 0x31) j = ((unsigned char *)&funcf5) - (w.dst + 4); if (*src == 0x32) j = ((unsigned char *)&funcf6) - (w.dst + 4); if (*src == 0x33) j = ((unsigned char *)&funcf7) - (w.dst + 4); - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); jitCompPutByte3(w.dst, 0x83, 0xc4, 0x10); /* ADD(ESP,16); */ jitCompA000_loadRegCacheAll(&w); // 手抜き. jitCompA000_loadPRegCacheAll(&w); // 手抜き. @@ -1308,14 +1298,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if ((flags & JITC_PHASE1) != 0 && w.err == 0) { if (label[i].opt == 0) { w.err = JITC_ERR_LABELNODEF; goto err_w; } } - jitCompPutImm32(&w, (int)label[i].p); - jitCompPutImm32(&w, label[i].typ); - jitCompPutImm32(&w, (int)label[i].p); - jitCompPutImm32(&w, (int)label[i].p1); - jitCompPutImm32(&w, 0); /* liveSign */ - jitCompPutImm32(&w, 2320); /* pls */ - jitCompPutImm32(&w, 0); - jitCompPutImm32(&w, 0); + jitCompPutImm32(w.dst, (int)label[i].p); + jitCompPutImm32(w.dst, label[i].typ); + jitCompPutImm32(w.dst, (int)label[i].p); + jitCompPutImm32(w.dst, (int)label[i].p1); + jitCompPutImm32(w.dst, 0); /* liveSign */ + jitCompPutImm32(w.dst, 2320); /* pls */ + jitCompPutImm32(w.dst, 0); + jitCompPutImm32(w.dst, 0); j--; } } @@ -1336,7 +1326,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompPutByte1(w.dst, 0x55); /* PUSH(EBP); */ jitCompPutByte1(w.dst, 0xe8); j = ((unsigned char *)&func3c) - (w.dst + 4); - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); jitCompPutByte3(w.dst, 0x83, 0xc4, 0x20); /* ADD(ESP,32); */ jitCompA000_loadRegCacheAll(&w); // 手抜き. jitCompA000_loadPRegCacheAll(&w); // 手抜き. @@ -1356,7 +1346,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr jitCompPutByte1(w.dst, 0x55); /* PUSH(EBP); */ jitCompPutByte1(w.dst, 0xe8); j = ((unsigned char *)&func3d) - (w.dst + 4); - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); jitCompPutByte3(w.dst, 0x83, 0xc4, 0x20); /* ADD(ESP,32); */ jitCompA000_loadRegCacheAll(&w); // 手抜き. jitCompA000_loadPRegCacheAll(&w); // 手抜き. @@ -1367,14 +1357,14 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr if (src[1] == 0x01 && src[2] == 0x00) { // DBGINFO1 if (level <= JITC_LV_SLOWER) { jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, debugInfo1); + jitCompPutImm32(w.dst, debugInfo1); jitCompA0001_movEbpDispReg32(&w, 2304 + 4, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */ } } if (src[1] == 0x01 && src[2] == 0x03) { // DBGINFO1CLR if (level <= JITC_LV_SLOWER) { jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, -1); + jitCompPutImm32(w.dst, -1); jitCompA0001_movEbpDispReg32(&w, 2304 + 4, IA32_REG0_EAX); /* MOV(debugInfo1, EAX); */ } } @@ -1384,7 +1374,7 @@ int jitCompiler(unsigned char *dst, unsigned char *dst1, const unsigned char *sr // jitCompPutByte1(w.dst, 0xbf); /* MOV(EDI, ?); */ // jitCompPutImm32(&w, debugInfo0); jitCompPutByte1(w.dst, 0xb8); /* MOV(EAX, ?); */ - jitCompPutImm32(&w, debugInfo0); + jitCompPutImm32(w.dst, debugInfo0); jitCompA0001_movEbpDispReg32(&w, 2304 + 0, IA32_REG0_EAX); /* MOV(debugInfo0, EAX); */ } } @@ -1458,18 +1448,18 @@ unsigned char *jitCompCallFunc(unsigned char *dst, void *func) w.dst = dst; jitCompA000_storeRegCacheAll(&w); jitCompA000_storePRegCacheAll(&w); - jitCompPutByte1(w.dst, 0x60); /* PUSHAD(); */ - jitCompPutByte1(w.dst, 0x50); /* PUSH(EAX); */ /* for 16byte-align(win32では不要なのだけど、MacOSには必要らしい) */ - jitCompPutByte1(w.dst, 0x55); /* PUSH(EBP); */ + jitCompPutOp_PUSHAD(w.dst); + jitCompPutOp_PUSH_GReg(w.dst, IA32_REG0_EAX); /* for 16Byte-align(Mac OSX) */ + jitCompPutOp_PUSH_GReg(w.dst, IA32_REG5_EBP); /* PUSH(EBP); */ jitCompPutByte1(w.dst, 0xe8); /* CALL(func); */ int j = ((unsigned char *)func) - (w.dst + 4); //この関数の中では結局w->dstしか参照していない - jitCompPutImm32(&w, j); + jitCompPutImm32(w.dst, j); - jitCompPutByte1(w.dst, 0x58); /* POP(EAX); */ /* (win32では不要なのだけど、MacOSには必要らしい) */ - jitCompPutByte1(w.dst, 0x58); /* POP(EAX); */ - jitCompPutByte1(w.dst, 0x61); /* POPAD(); */ + jitCompPutOp_POP_GReg(w.dst, IA32_REG0_EAX); /* for 16Byte-align (Mac OSX) */ + jitCompPutOp_POP_GReg(w.dst, IA32_REG0_EAX); + jitCompPutOp_POPAD(w.dst); jitCompA000_loadRegCacheAll(&w); jitCompA000_loadPRegCacheAll(&w); jitCompA0001_movReg32EbpDisp(&w, IA32_REG0_EAX, 256 + 0x30 * 32 + 0); /* MOV(EAX, [EBP+?]); */ -- 2.11.0