-
-
Save anonymous/65db7aa834b5bda36d30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <algorithm> | |
| #include "codegen.hpp" | |
| #include "interpretation.hpp" | |
| #include <iterator> | |
| #include <sys/mman.h> | |
| #include <vector> | |
| int main() { | |
| std::vector<unsigned char> code; | |
| translate(opcode::yield, std::back_inserter(code)); | |
| translate(opcode::yield, std::back_inserter(code)); | |
| translate(opcode::yield, std::back_inserter(code)); | |
| translate(opcode::yield, std::back_inserter(code)); | |
| translate(opcode::yield, std::back_inserter(code)); | |
| auto executable_code = static_cast<char*>( | |
| mmap(nullptr, code.size(), PROT_READ | PROT_WRITE | PROT_EXEC, | |
| MAP_PRIVATE | MAP_ANON, -1, 0)); | |
| std::copy(code.begin(), code.end(), executable_code); | |
| interpreter interpreter(executable_code); | |
| interpreter.resume(); | |
| interpreter.resume(); | |
| interpreter.resume(); | |
| interpreter.resume(); | |
| interpreter.resume(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment