├── android
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── themes.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ ├── layout
│ │ │ │ │ └── activity_main.xml
│ │ │ │ ├── values-night
│ │ │ │ │ └── themes.xml
│ │ │ │ └── drawable-v24
│ │ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── swift
│ │ │ │ │ └── openrosseta
│ │ │ │ │ └── MainActivity.java
│ │ │ └── AndroidManifest.xml
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── swift
│ │ │ │ └── openrosseta
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── swift
│ │ │ └── openrosseta
│ │ │ └── ExampleInstrumentedTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradle.properties
└── gradlew.bat
├── source
├── backend
│ ├── arm64
│ │ ├── x64
│ │ │ └── ir_translate_x64.cc
│ │ ├── svm_context.cc
│ │ ├── ir_translate_simd.cc
│ │ ├── block_linker.h
│ │ ├── constants.h
│ │ ├── host_callbacks.h
│ │ ├── label_manager.cc
│ │ ├── ir_translate_system.cc
│ │ ├── block_linker.cc
│ │ ├── label_manager.h
│ │ ├── ir_translate_status.cc
│ │ ├── ir_translate_memory.cc
│ │ ├── ir_translate_context.cc
│ │ ├── ir_translator.h
│ │ └── trampolines.cc
│ ├── register_manager.cc
│ ├── label_manager.cc
│ ├── register_manager.h
│ ├── label_manager.h
│ ├── trampolines.h
│ └── cpu.h
├── ir
│ ├── operand.cc
│ ├── instruction.cc
│ ├── instr_table.ir
│ ├── assembler.h
│ ├── assembler.cc
│ └── instruction.h
├── README.md
├── main.h
├── asm
│ └── x86
│ │ ├── 64
│ │ ├── registers_x86_64.h
│ │ ├── managed_register_x86_64.cc
│ │ └── constants_x86_64.h
│ │ ├── value_object.h
│ │ ├── memory_region.cc
│ │ ├── enums.h
│ │ ├── managed_register.h
│ │ ├── offsets.h
│ │ ├── assembler.cc
│ │ └── label.h
├── frontend
│ ├── x64
│ │ ├── jit_visitor.cc
│ │ ├── jit_visitor.h
│ │ └── cpu.h
│ ├── decoder.h
│ ├── visitor.h
│ └── arm32
│ │ ├── decoder.h
│ │ └── decoder.cc
├── ir_opt
│ ├── ir_opt_manager.h
│ ├── instruction_id_clear.cc
│ ├── instruction_id_pass.cc
│ ├── context_promotion_pass.h
│ ├── instruction_id_pass.h
│ ├── instruction_id_clear.h
│ ├── register_alloc_pass.h
│ ├── flags_set_elimination.h
│ ├── context_promotion_pass.cc
│ ├── flags_get_set_sync.h
│ ├── value_expr_fold.h
│ ├── optimize.h
│ ├── dead_code_remove.h
│ ├── dead_code_remove.cc
│ ├── const_memory_read_pass.h
│ ├── const_folding_pass.cc
│ ├── ir_opt_manager.cc
│ ├── ctx_get_set_elimination.h
│ ├── register_alloc_pass.cc
│ ├── const_folding_pass.h
│ ├── value_expr_fold.cc
│ ├── ir_opt_result.cc
│ ├── const_memory_read_pass.cc
│ ├── flags_get_set_sync.cc
│ ├── flags_set_elimination.cc
│ └── ir_opt_result.h
├── externals
│ ├── distorm
│ │ ├── CMakeLists.txt
│ │ ├── operands.h
│ │ ├── wstring.c
│ │ ├── decoder.h
│ │ ├── wstring.h
│ │ ├── textdefs.h
│ │ ├── insts.h
│ │ ├── x86defs.h
│ │ └── prefix.h
│ └── vixl
│ │ ├── CMakeLists.txt
│ │ ├── platform-vixl.h
│ │ ├── macro-assembler-interface.h
│ │ ├── assembler-base-vixl.h
│ │ └── aarch64
│ │ └── instrument-aarch64.h
├── runtime
│ ├── block_translator.h
│ ├── instance.cc
│ ├── jit_thread.h
│ ├── jit_thread.cc
│ ├── module_disk_cache.h
│ ├── block_translator.cc
│ ├── module_disk_cache.cc
│ └── vcpu.cc
├── function
│ ├── block.cc
│ ├── functions.h
│ └── block.h
├── cache
│ ├── cache_pool.h
│ ├── cache_pool.cc
│ ├── code_buffer.h
│ ├── cache_module.h
│ └── dispatcher_table.h
├── platform
│ ├── memory.h
│ ├── unix_file.h
│ ├── unix_file.cc
│ └── memory.cc
├── base
│ ├── slab_alloc.cc
│ ├── file.h
│ ├── marco.cc
│ ├── lru_container.h
│ ├── cow_vector.h
│ ├── blocking_queue.h
│ └── object_pool.h
├── include
│ ├── configs.h
│ ├── svm_instance.h
│ ├── page_entry.h
│ ├── svm_cpu.h
│ ├── memory_interface.h
│ └── types.h
├── CMakeLists.txt
└── android_entry.cc
├── README.md
└── .gitignore
/android/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "OpenRosseta"
--------------------------------------------------------------------------------
/source/backend/arm64/x64/ir_translate_x64.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 2021/5/29.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/source/ir/operand.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2021/1/2.
3 | //
4 |
5 | #include "operand.h"
6 |
--------------------------------------------------------------------------------
/source/backend/register_manager.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/8/21.
3 | //
4 |
5 | #include "register_manager.h"
6 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OpenRosseta
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Open source cross-platform software virtual cpu in userspace
2 |
3 | * AOT
4 | * Interpreter
5 | * JIT
6 |
7 | Just beginning
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/source/README.md:
--------------------------------------------------------------------------------
1 | # X86 TSO
2 | x86 使用的是 TSO (Total Store Ordering), 而 ARM 是 weak memory ordering 。
3 | 苹果在 Apple Silicon (M1/A12Z)中内置了一个状态寄存器来模拟 TSO
--------------------------------------------------------------------------------
/source/main.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2020/12/27.
3 | //
4 |
5 | #pragma once
6 |
7 | namespace Svm {
8 |
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/source/backend/arm64/svm_context.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 2021/5/26.
3 | //
4 |
5 | #include
6 |
7 | namespace Svm::A64 {
8 |
9 | }
--------------------------------------------------------------------------------
/source/backend/label_manager.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/8/21.
3 | //
4 |
5 | #include "label_manager.h"
6 |
7 | namespace Svm {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/source/backend/register_manager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/8/21.
3 | //
4 |
5 | #pragma once
6 |
7 | namespace Svm::Backend {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/source/asm/x86/value_object.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | namespace Svm::X86 {
6 |
7 | class ValueObject {
8 | };
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ganyao114/VirtualCPU/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/source/frontend/x64/jit_visitor.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2021/1/1.
3 | //
4 |
5 | #include "jit_visitor.h"
6 |
7 | namespace Svm::Decoder {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/source/backend/arm64/ir_translate_simd.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 2021/6/25.
3 | //
4 |
5 | #include "ir_translator.h"
6 |
7 | #define __ context->Masm().
8 |
9 | namespace Svm::A64 {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/source/ir_opt/ir_opt_manager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/8/21.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 | #include "ir_opt_result.h"
9 |
10 | namespace Svm::IR {
11 |
12 | void OptimizeIR(IRBlock *block, OptResult *result);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Dec 27 10:36:25 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/source/ir_opt/instruction_id_clear.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/1/10.
3 | //
4 |
5 | #include "instruction_id_clear.h"
6 |
7 | namespace Svm::IR {
8 |
9 | void InstrIdClear::Optimize(IRBlock *block, OptResult *result) {
10 | block->IndexInstructions();
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/source/ir_opt/instruction_id_pass.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/1/10.
3 | //
4 |
5 | #include "instruction_id_pass.h"
6 |
7 | namespace Svm::IR {
8 |
9 |
10 | void InstrIdPass::Optimize(IRBlock *block, OptResult *result) {
11 | block->IndexInstructions();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/source/externals/distorm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(.)
2 |
3 | add_library(distorm STATIC
4 | decoder.c
5 | distorm.c
6 | instructions.c
7 | insts.c
8 | mnemonics.c
9 | operands.c
10 | prefix.c
11 | textdefs.c
12 | wstring.c)
13 |
--------------------------------------------------------------------------------
/source/frontend/x64/jit_visitor.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2021/1/1.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 | #include
9 |
10 | namespace Svm::Decoder {
11 |
12 | class X64JitVisitor : public Visitor, public IR::Assembler {
13 | public:
14 | };
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/source/ir_opt/context_promotion_pass.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/3/17.
3 | //
4 | #pragma once
5 |
6 | #include "optimize.h"
7 |
8 | namespace Svm::IR {
9 |
10 | class CtxPromotionPass : public IROptimize {
11 | public:
12 | void Optimize(IRBlock *block, OptResult *result) override;
13 | };
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/source/ir_opt/instruction_id_pass.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/1/10.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 |
9 | namespace Svm::IR {
10 |
11 | class InstrIdPass : public IROptimize {
12 | public:
13 |
14 | void Optimize(IRBlock *block, OptResult *result) override;
15 |
16 | };
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/source/ir_opt/instruction_id_clear.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/1/10.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 |
9 | namespace Svm::IR {
10 |
11 | class InstrIdClear : public IROptimize {
12 | public:
13 |
14 | void Optimize(IRBlock *block, OptResult *result) override;
15 |
16 | };
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/source/ir_opt/register_alloc_pass.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/9/21.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 |
9 | namespace Svm::IR {
10 |
11 | class RegAllocatePass : public IROptimize {
12 | public:
13 |
14 | void Optimize(IRBlock *block, OptResult *result) override;
15 |
16 | };
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/source/ir_opt/flags_set_elimination.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 2021/8/30.
3 | //
4 |
5 | #include "optimize.h"
6 | #include "ir_opt_result.h"
7 |
8 | namespace Svm::IR {
9 |
10 | class FlagsSetOpt : public IROptimize {
11 | public:
12 |
13 | void Optimize(IRBlock *block, OptResult *result) override;
14 |
15 | };
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/source/backend/arm64/block_linker.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/1/27.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "include/types.h"
8 | #include "aarch64/macro-assembler-aarch64.h"
9 |
10 | namespace Svm {
11 |
12 | using namespace vixl::aarch64;
13 |
14 | bool LinkBlock(PAddr source, PAddr target, u8 *source_rw, bool pic = true);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/source/ir_opt/context_promotion_pass.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Created by 甘尧 on 2022/3/17.
3 | //
4 |
5 | #include "context_promotion_pass.h"
6 |
7 | namespace Svm::IR {
8 |
9 | void CtxPromotionPass::Optimize(IRBlock *block, OptResult *result) {
10 | auto &instr_seq = block->Sequence();
11 | for (auto &instr : instr_seq) {
12 |
13 | }
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/source/ir_opt/flags_get_set_sync.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/11/21.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 | #include "ir_opt_result.h"
9 |
10 | namespace Svm::IR {
11 |
12 | class FlagsSyncOpt : public IROptimize {
13 | public:
14 |
15 | void Optimize(IRBlock *block, OptResult *result) override;
16 |
17 | };
18 |
19 | }
--------------------------------------------------------------------------------
/source/ir_opt/value_expr_fold.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/7/21.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 | #include "ir_opt_result.h"
9 |
10 | namespace Svm::IR {
11 |
12 | class ValueExprFoldOpt : public IROptimize {
13 | public:
14 |
15 | void Optimize(IRBlock *block, OptResult *result) override;
16 |
17 | };
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/source/ir_opt/optimize.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2021/1/4.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 | #include "ir_opt_result.h"
9 |
10 | namespace Svm::IR {
11 |
12 | class IROptimize : public BaseObject, CopyDisable {
13 | public:
14 |
15 | virtual void Optimize(IRBlock *block, OptResult *result) = 0;
16 |
17 | };
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/source/frontend/decoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2020/12/29.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 | #include "visitor.h"
9 | #include
10 |
11 | namespace Svm::Decoder {
12 |
13 | class BaseDecoder : public BaseObject, CopyDisable {
14 | public:
15 |
16 | virtual void Decode() = 0;
17 |
18 | };
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/source/ir_opt/dead_code_remove.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by SwiftGan on 2021/1/4.
3 | //
4 |
5 | #pragma once
6 |
7 | #include "optimize.h"
8 |
9 | namespace Svm::IR {
10 |
11 | class DeadCodeRemoveOpt : public IROptimize {
12 | public:
13 |
14 | void Optimize(IRBlock *block, OptResult *result) override;
15 |
16 | private:
17 |
18 | bool HasSideEffect(Instruction *instr, OptResult *result);
19 |
20 | };
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/source/asm/x86/memory_region.cc:
--------------------------------------------------------------------------------
1 | #include "memory_region.h"
2 |
3 | namespace Svm::X86 {
4 |
5 | void MemoryRegion::CopyFrom(size_t offset, const MemoryRegion &from) const {
6 | CHECK(from.pointer() != nullptr);
7 | CHECK_GT(from.size(), 0U);
8 | CHECK_GE(this->size(), from.size());
9 | CHECK_LE(offset, this->size() - from.size());
10 | memmove(reinterpret_cast(begin() + offset), from.pointer(), from.size());
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/source/runtime/block_translator.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 2021/5/20.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 | #include "jit_runtime.h"
9 |
10 | namespace Svm {
11 |
12 | std::shared_ptr GenerateBlock(JitRuntime *runtime, VAddr block_pc, CpuArch arch);
13 |
14 | std::shared_ptr GenerateBlockX64(JitRuntime *runtime, VAddr block_pc);
15 |
16 | bool TranslateBlock(JitRuntime *runtime, IR::IRBlock *block);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/source/backend/label_manager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by swift on 1/8/21.
3 | //
4 |
5 | #pragma once
6 |
7 | #include
8 |
9 | namespace Svm {
10 |
11 | template
12 | class BaseLabelManager : public CopyDisable {
13 | public:
14 |
15 | Label *AllocLabel() {
16 | auto res = &labels.emplace_back();
17 | return res;
18 | }
19 |
20 | private:
21 | List