diff options
| Commit | 1296644f97fa06c3c3f655f71c796c32cce4a865 (patch) | |
|---|---|---|
| Author | 2019-01-13 15:15:04 +0200 | |
| Committer | 2019-01-13 15:15:04 +0200 | |
| Files | c4c98e72a0cd6cea12bb3004aab5be4c26f01f42 | |
| IPL-1296644f97fa06c3c3f655f71c796c32cce4a865.tar IPL-1296644f97fa06c3c3f655f71c796c32cce4a865.tar.gz IPL-1296644f97fa06c3c3f655f71c796c32cce4a865.zip | ||
| Parent | a52ca3270679a04c55a8e30f41161d7b0c791e48 (diff) | |
Add slides for jit
1 files changed, 74 insertions, 0 deletions
| -rw-r--r-- | website/content/slides/11_jit/_index.md | 74 |
diff --git a/website/content/slides/11_jit/_index.md b/website/content/slides/11_jit/_index.md new file mode 100644 index 0000000..5300c6e --- /dev/null +++ b/website/content/slides/11_jit/_index.md @@ -0,0 +1,74 @@ +--- +title: "Just-in-time compilation" +date: 2018-12-05T17:45:53+03:00 +draft: false +outputs: ["Reveal"] +--- +# Just-in-time compilation + +--- + +### Why + +- Interpreter are slow +- Flexibility +- Optimization + +--- + +### What we need + +- Executable memory +- Generate code +- Execute code + +--- + +### Executable memory +- Why +- Security concerns + +### Create executable memory Linux + +virtualCodeAddress = mmap( + NULL, + codeBytes, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_ANONYMOUS | MAP_PRIVATE, + 0, + 0); + +--- +### Create executable memory Windows + + auto const buffer = VirtualAlloc(nullptr, page_size, MEM_COMMIT, PAGE_READWRITE); + VirtualProtect(buffer, code.size(), PAGE_EXECUTE_READ, &dummy); + +--- +### Create executable memory other platforms + +- Consolse +- Mobile +- Pic + +--- + +### How to create and execute code + typedef unsigned (*asmFunc)(void); + .... + unsigned char * memory = (unsigned char *) (virtualCodeAddress); + // mov %rdi, %rax + memory[i++] = 0x48; // REX.W prefix + memory[i++] = 0x8b; // MOV opcode, register/register + memory[i++] = 0xc7; // MOD/RM byte for %rdi -> %rax + // ret + memory[i++] = 0xc3; // RET opcode + ((asmFunc) (virtualCodeAddress))(); +--- + +### Calling convention + +- Standart +- Custom + +# ? |
