mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-18 13:04:36 +03:00
Fixed bug in PodVectorTmp<> implementation and added a test-case for it.
This commit is contained in:
@@ -4,8 +4,9 @@ AsmJit
|
|||||||
Complete x86/x64 JIT and Remote Assembler for C++.
|
Complete x86/x64 JIT and Remote Assembler for C++.
|
||||||
|
|
||||||
* [Official Repository (kobalicek/asmjit)](https://github.com/kobalicek/asmjit)
|
* [Official Repository (kobalicek/asmjit)](https://github.com/kobalicek/asmjit)
|
||||||
* [Official Chat (Gitter)](https://gitter.im/kobalicek/asmjit)
|
* [Official Blog (asmbits)] (https://asmbits.blogspot.com/ncr)
|
||||||
* [Zlib Licensed](http://www.opensource.org/licenses/zlib-license.php)
|
* [Official Chat (gitter)](https://gitter.im/kobalicek/asmjit)
|
||||||
|
* [Permissive ZLIB license](./LICENSE.md)
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ Error PodVectorBase::_reserve(size_t n, size_t sizeOfT) noexcept {
|
|||||||
if (ASMJIT_UNLIKELY(d == nullptr))
|
if (ASMJIT_UNLIKELY(d == nullptr))
|
||||||
return kErrorNoHeapMemory;
|
return kErrorNoHeapMemory;
|
||||||
|
|
||||||
size_t len = d->length;
|
size_t len = oldD->length;
|
||||||
d->length = len;
|
d->length = len;
|
||||||
::memcpy(d, oldD->getData(), len * sizeOfT);
|
::memcpy(d->getData(), oldD->getData(), len * sizeOfT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d = static_cast<Data*>(ASMJIT_REALLOC(d, nBytes));
|
d = static_cast<Data*>(ASMJIT_REALLOC(d, nBytes));
|
||||||
|
|||||||
@@ -216,6 +216,46 @@ struct X86Test_JumpCross : public X86Test {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// [X86Test_JumpMany]
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
struct X86Test_JumpMany : public X86Test {
|
||||||
|
X86Test_JumpMany() : X86Test("[Misc] Jump Many") {}
|
||||||
|
|
||||||
|
static void add(PodVector<X86Test*>& tests) {
|
||||||
|
tests.append(new X86Test_JumpMany());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void compile(X86Compiler& c) {
|
||||||
|
c.addFunc(FuncBuilder0<int>(kCallConvHost));
|
||||||
|
for (uint32_t i = 0; i < 1000; i++) {
|
||||||
|
Label L = c.newLabel();
|
||||||
|
c.jmp(L);
|
||||||
|
c.bind(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
X86GpVar ret = c.newInt32("ret");
|
||||||
|
c.xor_(ret, ret);
|
||||||
|
c.ret(ret);
|
||||||
|
c.endFunc();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool run(void* _func, StringBuilder& result, StringBuilder& expect) {
|
||||||
|
typedef int (*Func)(void);
|
||||||
|
|
||||||
|
Func func = asmjit_cast<Func>(_func);
|
||||||
|
|
||||||
|
int resultRet = func();
|
||||||
|
int expectRet = 0;
|
||||||
|
|
||||||
|
result.setFormat("ret={%d}", resultRet);
|
||||||
|
expect.setFormat("ret={%d}", expectRet);
|
||||||
|
|
||||||
|
return resultRet == expectRet;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// [X86Test_JumpUnreachable1]
|
// [X86Test_JumpUnreachable1]
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -2869,6 +2909,7 @@ X86TestSuite::X86TestSuite() :
|
|||||||
|
|
||||||
// Jump.
|
// Jump.
|
||||||
ADD_TEST(X86Test_JumpCross);
|
ADD_TEST(X86Test_JumpCross);
|
||||||
|
ADD_TEST(X86Test_JumpMany);
|
||||||
ADD_TEST(X86Test_JumpUnreachable1);
|
ADD_TEST(X86Test_JumpUnreachable1);
|
||||||
ADD_TEST(X86Test_JumpUnreachable2);
|
ADD_TEST(X86Test_JumpUnreachable2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user