Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mprotect_test.cpp
Go to the documentation of this file.
1#define XBYAK_NO_OP_NAMES
2#include "xbyak/xbyak.h"
3#include <string.h>
4#include <vector>
5
7 Code(int x)
8 {
9 mov(eax, x);
10 ret();
11 }
12};
13
14int main()
15 try
16{
17#ifdef XBYAK_USE_MMAP_ALLOCATOR
18 puts("use Allocator with mmap");
19#else
20 puts("use Allocator with posix_memalign");
21#endif
22 const int N = 70000;
23 std::vector<Code*> v(N);
24 for (int i = 0; i < N; i++) {
25 v[i] = new Code(i);
26 }
27 long long sum = 0;
28 for (int i = 0; i < N; i++) {
29 sum += v[i]->getCode<int (*)()>()();
30 }
31 for (int i = 0; i < N; i++) {
32 delete v[i];
33 }
34 printf("sum=%lld\n", sum);
35} catch (std::exception& e) {
36 printf("ERR %s\n", e.what());
37}
const Reg32 eax
Definition xbyak.h:2087
void mov(const Operand &reg1, const Operand &reg2)
Definition xbyak.h:2210
int main()
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
const int N
Definition quantize.cpp:54
Definition bench.cpp:18
Code(int x)
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.
CK_RV ret