History

Add new Exec module - similar to Command module but no UI context Update all current limbo modules to implement Exec instead of Command module Add new type signature building API to asm library Include the official RFC1321 (MD5) reference implementation only for use in type signature generation - NOTE: The MD5 implementation in the asm library should NOT be used for any other purpose

arr committed 10 years ago

Commit 77ee7d81 parent 8549d3410 files · +923 −28Browse files

Showing the changes to src/exec/main.cpp (1 of 10 files). Show all

Unified · Split

src/exec/main.cpp+20−22
@@ -11,10 +11,12 @@ · 10 unmodified lines
1111 #include <builtin_module.h>
1212 #include <debug.h>
1313 #include <exceptions.h>
14+#include <vm_asm.h>
1415 #include "exec.h"
1516
1617 using namespace disvm;
1718 using namespace disvm::runtime;
19+using namespace disvm::assembly::sigkind;
1820
1921 namespace
2022 {
@@ -88,20 +90,16 @@ namespace · 67 unmodified lines
8890 };
8991
9092 // Initialize the module base register
91− const auto mp_type = type_descriptor_t::create(12, { 0xe0 });
93+ const auto mp_type = type_descriptor_t::create(8, { 0xc0 });
9294 e.original_mp.reset(vm_alloc_t::allocate(mp_type, vm_alloc_t::zero_memory));
9395 auto mp_base = e.original_mp->get_allocation<pointer_t>();
9496 mp_base[0] = command_module_path->get_allocation();
9597
96− // [TODO] Implement the UI context for the command
97− mp_base[1] = nullptr;
98−
9998 if (args != nullptr)
100− mp_base[2] = args->get_allocation();
99+ mp_base[1] = args->get_allocation();
101100
102101 // Define the frame offsets for the two arguments
103102 const auto first_arg_offset = vm_frame_constants::limbo_first_arg_register_offset;
104− const auto second_arg_offset = first_arg_offset + vm_frame_constants::register_size_in_bytes;
105103
106104 e.code_section =
107105 {
@@ -124,17 +122,9 @@ namespace · 16 unmodified lines
124122 { vm_exec_op_t
125123 {
126124 opcode_t::movp,
127− { address_mode_t::offset_indirect_mp, 4, 0 }, // UI context
128− { address_mode_middle_t::none },
129− { address_mode_t::offset_double_indirect_fp, 24, first_arg_offset } // module call frame -> UI context offset
130− }
131− },
132− { vm_exec_op_t
133− {
134− opcode_t::movp,
135− { address_mode_t::offset_indirect_mp, 8, 0 }, // Argument list
125+ { address_mode_t::offset_indirect_mp, 4, 0 }, // Argument list
136126 { address_mode_middle_t::none },
137− { address_mode_t::offset_double_indirect_fp, 24, second_arg_offset } // module call frame -> argument list offset
127+ { address_mode_t::offset_double_indirect_fp, 24, first_arg_offset } // module call frame -> argument list offset
138128 }
139129 },
140130 { vm_exec_op_t
@@ -148,13 +138,21 @@ namespace · 7 unmodified lines
148138 { vm_exec_op_t{ opcode_t::ret,{ address_mode_t::none },{ address_mode_middle_t::none },{ address_mode_t::none } } },
149139 };
150140
151− // Create import section for Command
152− // See limbo/Command.m for type details
141+ // Create import section for Exec
142+ // See limbo/Exec.m for type details
153143 {
154− import_function_t func{};
155−
156− // [TODO] Create mechanism to generated type signatures
157− func.sig = 0x4244b354;
144+ import_function_t func;
145+
146+ const auto exec_init_sig = 0x2e01144a;
147+
148+ // Validate the hard-coded type signature on debug builds.
149+#if !defined(NDEBUG)
150+ sig_stream_t m;
151+ m << Tfunction::create(Tlist::create(Tstring::id)).returns(Tnone::id);
152+ assert(exec_init_sig == m.get_signature_hash());
153+ assert(exec_init_sig == sig_stream_t::compute_signature_hash("f(Ls)n"));
154+#endif
155+ func.sig = exec_init_sig;
158156
159157 std::array<uint8_t, 5> func_name = { "init" };
160158 func.name = std::make_unique<vm_string_t>(func_name.size() - 1, func_name.data());