aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <[email protected]>2017-08-18 20:15:48 +0900
committerMITSUNARI Shigeo <[email protected]>2017-08-18 20:15:58 +0900
commitd512551e914737300ba35f3c049d1b40effbe76d (patch)
treeb23b1f4e3284726c50520f6ab42e5bfdfaec4996
parentb633c68b53654154699e2780449c47d3049c4420 (diff)
downloadxbyak-d512551e914737300ba35f3c049d1b40effbe76d.tar.gz
xbyak-d512551e914737300ba35f3c049d1b40effbe76d.zip
fix wrong align()v5.52
-rw-r--r--readme.md3
-rw-r--r--readme.txt3
-rw-r--r--test/Makefile1
-rw-r--r--test/misc.cpp22
-rw-r--r--xbyak/xbyak.h22
-rw-r--r--xbyak/xbyak_mnemonic.h2
6 files changed, 42 insertions, 11 deletions
diff --git a/readme.md b/readme.md
index e954d61..4f5adf0 100644
--- a/readme.md
+++ b/readme.md
@@ -1,5 +1,5 @@
-Xbyak 5.51 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
+Xbyak 5.52 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
=============
Abstract
@@ -333,6 +333,7 @@ The header files under xbyak/ are independent of cybozulib.
History
-------------
+* 2017/Aug/18 ver 5.52 fix align (thanks to MerryMage)
* 2017/Aug/17 ver 5.51 add multi-byte nop and align() uses it(thanks to inolen)
* 2017/Aug/08 ver 5.50 add mpx(thanks to magurosan)
* 2017/Aug/08 ver 5.45 add sha(thanks to magurosan)
diff --git a/readme.txt b/readme.txt
index 0c72fe7..2bc20f8 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,5 +1,5 @@
- C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.51
+ C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.52
-----------------------------------------------------------------------------
◎概要
@@ -343,6 +343,7 @@ cybozulibは単体テストでのみ利用されていて、xbyak/ディレク�
-----------------------------------------------------------------------------
◎履歴
+2017/08/18 ver 5.52 align修正(thanks to MerryMage)
2017/08/17 ver 5.51 multi-byte nop追加 align()はそれを使用する(thanks to inolen)
2017/08/08 ver 5.50 mpx追加(thanks to magurosan)
2017/08/08 ver 5.45 sha追加(thanks to magurosan)
diff --git a/test/Makefile b/test/Makefile
index a13e688..bcd63b6 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -42,6 +42,7 @@ test: normalize_prefix jmp bad_address
./test_address.sh
./jmp
./bad_address
+ ./misc
ifeq ($(BIT),64)
./test_address.sh 64
./test_nm.sh 64
diff --git a/test/misc.cpp b/test/misc.cpp
index 5d1ba24..4747f81 100644
--- a/test/misc.cpp
+++ b/test/misc.cpp
@@ -81,3 +81,25 @@ CYBOZU_TEST_AUTO(mov_const)
}
} code;
}
+
+CYBOZU_TEST_AUTO(align)
+{
+ struct Code : Xbyak::CodeGenerator {
+ Code()
+ {
+ const size_t alignSize = 16;
+ for (int padding = 0; padding < 20; padding++) {
+ for (int i = 0; i < padding; i++) {
+ db(1);
+ }
+ align(alignSize);
+ CYBOZU_TEST_EQUAL(size_t(getCurr()) % alignSize, 0u);
+ }
+ align(alignSize);
+ const uint8 *p = getCurr();
+ // do nothing if aligned
+ align(alignSize);
+ CYBOZU_TEST_EQUAL(p, getCurr());
+ }
+ } c;
+}
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h
index f056a5e..1f8e96c 100644
--- a/xbyak/xbyak.h
+++ b/xbyak/xbyak.h
@@ -105,7 +105,7 @@ namespace Xbyak {
enum {
DEFAULT_MAX_CODE_SIZE = 4096,
- VERSION = 0x5510 /* 0xABCD = A.BC(D) */
+ VERSION = 0x5520 /* 0xABCD = A.BC(D) */
};
#ifndef MIE_INTEGER_TYPE_DEFINED
@@ -2391,8 +2391,17 @@ public:
#undef jnl
#endif
- void nop(size_t size = 1)
+ /*
+ use single byte nop if useMultiByteNop = false
+ */
+ void nop(size_t size = 1, bool useMultiByteNop = true)
{
+ if (!useMultiByteNop) {
+ for (size_t i = 0; i < size; i++) {
+ db(0x90);
+ }
+ return;
+ }
/*
Intel Architectures Software Developer's Manual Volume 2
recommended multi-byte sequence of NOP instruction
@@ -2431,12 +2440,9 @@ public:
if (x == 1) return;
if (x < 1 || (x & (x - 1))) throw Error(ERR_BAD_ALIGN);
if (isAutoGrow() && x > inner::ALIGN_PAGE_SIZE) fprintf(stderr, "warning:autoGrow mode does not support %d align\n", (int)x);
- if (useMultiByteNop) {
- nop(size_t(getCurr()) % x);
- return;
- }
- while (size_t(getCurr()) % x > 0) {
- nop();
+ size_t remain = size_t(getCurr()) % x;
+ if (remain) {
+ nop(x - remain, useMultiByteNop);
}
}
#endif
diff --git a/xbyak/xbyak_mnemonic.h b/xbyak/xbyak_mnemonic.h
index 72f7c78..4dbadb6 100644
--- a/xbyak/xbyak_mnemonic.h
+++ b/xbyak/xbyak_mnemonic.h
@@ -1,4 +1,4 @@
-const char *getVersionString() const { return "5.51"; }
+const char *getVersionString() const { return "5.52"; }
void adc(const Operand& op, uint32 imm) { opRM_I(op, imm, 0x10, 2); }
void adc(const Operand& op1, const Operand& op2) { opRM_RM(op1, op2, 0x10); }
void adcx(const Reg32e& reg, const Operand& op) { opGen(reg, op, 0xF6, 0x66, isREG32_REG32orMEM, NONE, 0x38); }