History

Merged in dev/macBuild (pull request #1)

Fix some issues when building on mac

Aaron R Robinson committed 9 years ago

Commit bf34adb2 parents db76c0c 0217bda13 files · +53 −50Browse files

Unified · Split

13 files
  1. src/asm/type_signature.cpp +6 −6
  2. src/compiler_settings.gypi +2 −1
  3. src/include/disvm.h +3 −3
  4. src/include/vm_asm.h +4 −4
  5. src/vm/execution_table.cpp +2 −2
  6. src/vm/stack.cpp +1 −1
  7. src/vm/string.cpp +13 −13
  8. src/vm/sys/Sysmod.cpp +3 −3
  9. src/vm/sys/sys_utils.h +1 −1
  10. src/vm/thread.cpp +1 −1
  11. src/vm/tool_dispatch.cpp +1 −0
  12. src/vm/vm.cpp +1 −1
  13. src/vm/vm_memory.cpp +15 −14
src/asm/type_signature.cpp+6−6
@@ -138,11 +138,11 @@ sig_stream_t &disvm::assembly::sigkind::operator<<(sig_stream_t &os, const Tm &m · 137 unmodified lines
138138 return os << m._s;
139139 }
140140
141−const char Ttuple::begin = '(';
142−const char Ttuple::end = ')';
141+template<> const char Ttuple::begin = '(';
142+template<> const char Ttuple::end = ')';
143143
144−const char Tmodule::begin = '{';
145−const char Tmodule::end = '}';
144+template<> const char Tmodule::begin = '{';
145+template<> const char Tmodule::end = '}';
146146
147147 sig_stream_t &disvm::assembly::sigkind::operator<<(sig_stream_t &os, const Ttuple &t)
148148 {
@@ -180,8 +180,8 @@ sig_stream_t &disvm::assembly::sigkind::operator<<(sig_stream_t &os, const Tadt_ · 31 unmodified lines
180180 return os << t._s;
181181 }
182182
183−const char Tnested_aggregate_type<type_id_t::adt>::begin = '(';
184−const char Tnested_aggregate_type<type_id_t::adt>::end = ')';
183+template<> const char Tnested_aggregate_type<type_id_t::adt>::begin = '(';
184+template<> const char Tnested_aggregate_type<type_id_t::adt>::end = ')';
185185
186186 sig_stream_t &disvm::assembly::sigkind::operator<<(sig_stream_t &os, const Tnested_aggregate_type<type_id_t::adt> &a)
187187 {
src/compiler_settings.gypi+2−1
@@ -5,7 +5,8 @@ · 4 unmodified lines
55 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
66 'OTHER_CPLUSPLUSFLAGS' : ['-std=c++1y','-stdlib=libc++'],
77 'OTHER_LDFLAGS': ['-stdlib=libc++'],
8− 'MACOSX_DEPLOYMENT_TARGET': '10.10'
8+ 'MACOSX_DEPLOYMENT_TARGET': '10.10',
9+ 'ARCHS': '$(ARCHS_STANDARD_32_BIT)'
910 }
1011 }],
1112 ['OS=="win"', {
src/include/disvm.h+3−3
@@ -55,12 +55,12 @@ namespace disvm · 54 unmodified lines
5555 class vm_t final
5656 {
5757 public: // static
58− static const auto root_vm_thread_id = uint32_t{ 0 };
58+ static const uint32_t root_vm_thread_id = 0;
5959
60− static const auto default_system_thread_count = uint32_t{ 1 };
60+ static const uint32_t default_system_thread_count = 1;
6161
6262 // The Inferno implementation defined the thread quanta as 2048 (include/interp.h)
63− static const auto default_thread_quanta = uint32_t{ 2048 };
63+ static const uint32_t default_thread_quanta = 2048;
6464
6565 public:
6666 explicit vm_t(
src/include/vm_asm.h+4−4
@@ -137,7 +137,7 @@ namespace disvm · 136 unmodified lines
137137 static Tbasic_aggregate_type create(const U &type)
138138 {
139139 sig_stream_t ss;
140− ss << Tbasic_type::id << type;
140+ ss << Tbasic_type<ID>::id << type;
141141
142142 return Tbasic_aggregate_type{ ss };
143143 }
@@ -209,7 +209,7 @@ namespace disvm · 65 unmodified lines
209209 template<typename T1, typename T2, typename ...S>
210210 void nested_type(sig_stream_t &ss, const T1 &t1, const T2 &t2, const S&...s)
211211 {
212− ss << t1 << sig_stream_t::type_delim;
212+ ss << t1 << sig_stream_t::delim;
213213 nested_type(ss, t2, s...);
214214 }
215215
@@ -225,7 +225,7 @@ namespace disvm · 9 unmodified lines
225225 static Tnested_aggregate_type create(const NT&... nestedTypes)
226226 {
227227 sig_stream_t ss;
228− ss << Tbasic_type::id << Tnested_aggregate_type::begin;
228+ ss << Tbasic_type<ID>::id << Tnested_aggregate_type::begin;
229229
230230 nested_type(ss, nestedTypes...);
231231
@@ -314,7 +314,7 @@ namespace disvm · 82 unmodified lines
314314 }
315315
316316 private:
317− Tadt(sig_stream_t &s) : Tnested_aggregate_type{ std::move(s) } { }
317+ Tadt(sig_stream_t &s) : Tnested_aggregate_type{ s } { }
318318 };
319319
320320 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tnested_aggregate_type<type_id_t::adt> &);
src/vm/execution_table.cpp+2−2
@@ -708,7 +708,7 @@ namespace · 707 unmodified lines
708708 const auto index = vt_ref<word_t>(r.mid);
709709 const auto rune = str->get_rune(index);
710710
711− vt_ref<rune_t>(r.dest) = rune;
711+ vt_ref<runtime::rune_t>(r.dest) = rune;
712712 }
713713
714714 // [SPEC] 'Insert Character' op code
@@ -721,7 +721,7 @@ namespace · 6 unmodified lines
721721 // dst[src2] = src1
722722 EXEC_DECL(insc)
723723 {
724− auto rune = vt_ref<rune_t>(r.src);
724+ auto rune = vt_ref<runtime::rune_t>(r.src);
725725 auto index = vt_ref<word_t>(r.mid);
726726 auto str = at_val<vm_string_t>(r.dest);
727727 if (str == nullptr)
src/vm/stack.cpp+1−1
@@ -180,7 +180,7 @@ pointer_t vm_frame_t::fixed_point_register_2() const · 179 unmodified lines
180180 vm_stack_t::vm_stack_t(std::size_t stack_extent)
181181 : _mem{ std::make_unique<vm_stack_layout>(stack_extent) }
182182 {
183− assert(stack_extent != 0);
183+ assert(0 < stack_extent && stack_extent < static_cast<std::size_t>(std::numeric_limits<word_t>::max()));
184184 debug::log_msg(debug::component_trace_t::memory, debug::log_level_t::debug, "init: vm stack\n");
185185 }
186186
src/vm/string.cpp+13−13
@@ -43,12 +43,12 @@ namespace · 42 unmodified lines
4343
4444 // Compare function for character types.
4545 template <typename CharacterType1, typename CharacterType2>
46− int _compare(word_t len, CharacterType1 *s1, CharacterType2 *s2)
46+ int _compare(word_t len, const CharacterType1 *s1, const CharacterType2 *s2)
4747 {
4848 for (auto i = word_t{ 0 }; i < len; ++i)
4949 {
50− const auto sc1 = static_cast<rune_t>(s1[i]);
51− const auto sc2 = static_cast<rune_t>(s2[i]);
50+ const auto sc1 = static_cast<runtime::rune_t>(s1[i]);
51+ const auto sc2 = static_cast<runtime::rune_t>(s2[i]);
5252
5353 if (sc1 != sc2)
5454 return (sc1 < sc2) ? (-1) : 1;
@@ -62,7 +62,7 @@ int vm_string_t::compare(const vm_string_t *s1, const vm_string_t *s2) · 7 unmodified lines
6262 {
6363 auto len_1 = word_t{ 0 };
6464 auto scen_1 = ascii_idx;
65− void *str_mem_1 = "";
65+ const void *str_mem_1 = "";
6666 if (s1 != nullptr)
6767 {
6868 len_1 = s1->_length;
@@ -72,7 +72,7 @@ int vm_string_t::compare(const vm_string_t *s1, const vm_string_t *s2) · 3 unmodified lines
7272
7373 auto len_2 = word_t{ 0 };
7474 auto scen_2 = ascii_idx;
75− void *str_mem_2 = "";
75+ const void *str_mem_2 = "";
7676 if (s2 != nullptr)
7777 {
7878 len_2 = s2->_length;
@@ -97,10 +97,10 @@ int vm_string_t::compare(const vm_string_t *s1, const vm_string_t *s2) · 18 unmodified lines
9797 result = std::memcmp(str_mem_1, str_mem_2, min_length);
9898 break;
9999 case compare_case_t::ascii_rune:
100− result = _compare(min_length, reinterpret_cast<char *>(str_mem_1), reinterpret_cast<rune_t *>(str_mem_2));
100+ result = _compare(min_length, reinterpret_cast<const char *>(str_mem_1), reinterpret_cast<const runtime::rune_t *>(str_mem_2));
101101 break;
102102 case compare_case_t::rune_ascii:
103− result = _compare(min_length, reinterpret_cast<rune_t *>(str_mem_1), reinterpret_cast<char *>(str_mem_2));
103+ result = _compare(min_length, reinterpret_cast<const runtime::rune_t *>(str_mem_1), reinterpret_cast<const char *>(str_mem_2));
104104 break;
105105 }
106106
@@ -128,10 +128,10 @@ namespace · 21 unmodified lines
128128 }
129129
130130 template<>
131− void copy_characters_to(rune_t *dest, word_t dest_start, const rune_t *source, word_t source_length)
131+ void copy_characters_to(runtime::rune_t *dest, word_t dest_start, const runtime::rune_t *source, word_t source_length)
132132 {
133133 assert(dest != nullptr && source != nullptr);
134− std::memcpy((dest + dest_start), source, (source_length * sizeof(rune_t)));
134+ std::memcpy((dest + dest_start), source, (source_length * sizeof(runtime::rune_t)));
135135 }
136136
137137 void combine(
@@ -146,14 +146,14 @@ namespace · 8 unmodified lines
146146 {
147147 if (dest_is_rune)
148148 {
149− auto dest_rune = reinterpret_cast<rune_t *>(dest);
149+ auto dest_rune = reinterpret_cast<runtime::rune_t *>(dest);
150150 if (source1_is_rune)
151− copy_characters_to(dest_rune, 0, reinterpret_cast<const rune_t *>(source1), source1_length);
151+ copy_characters_to(dest_rune, 0, reinterpret_cast<const runtime::rune_t *>(source1), source1_length);
152152 else
153153 copy_characters_to(dest_rune, 0, source1, source1_length);
154154
155155 if (source2_is_rune)
156− copy_characters_to(dest_rune, source1_length, reinterpret_cast<const rune_t *>(source2), source2_length);
156+ copy_characters_to(dest_rune, source1_length, reinterpret_cast<const runtime::rune_t *>(source2), source2_length);
157157 else
158158 copy_characters_to(dest_rune, source1_length, source2, source2_length);
159159 }
@@ -381,7 +381,7 @@ word_t vm_string_t::get_length() const · 221 unmodified lines
381381 return _length;
382382 }
383383
384−rune_t vm_string_t::get_rune(word_t index) const
384+runtime::rune_t vm_string_t::get_rune(word_t index) const
385385 {
386386 if (index < 0 && _length <= index)
387387 throw index_out_of_range_memory{ 0, _length - 1, index };
src/vm/sys/Sysmod.cpp+3−3
@@ -293,7 +293,7 @@ Sys_byte2char(vm_registers_t &r, vm_t &vm) · 292 unmodified lines
293293 fp.ret->t2 = 0;
294294
295295 auto state = utf8::decode_state_t::accept;
296− auto result = rune_t{};
296+ auto result = runtime::rune_t{};
297297 const auto buffer_len = buffer->get_length();
298298 for (auto i = n; i < buffer_len; ++i)
299299 {
@@ -326,7 +326,7 @@ Sys_char2byte(vm_registers_t &r, vm_t &vm) · 26 unmodified lines
326326 if (buffer == nullptr || n >= buffer->get_length())
327327 throw out_of_range_memory{};
328328
329− const auto rune = static_cast<rune_t>(fp.c);
329+ const auto rune = static_cast<runtime::rune_t>(fp.c);
330330
331331 static_assert(Sys_UTFmax == sizeof(rune), "UTF max should be same size as rune");
332332 uint8_t buffer_local[Sys_UTFmax];
@@ -689,7 +689,7 @@ Sys_stream(vm_registers_t &r, vm_t &vm) · 356 unmodified lines
689689
690690 namespace
691691 {
692− bool is_delim(const rune_t c, const vm_string_t &delim)
692+ bool is_delim(const runtime::rune_t c, const vm_string_t &delim)
693693 {
694694 const auto max = delim.get_length();
695695 assert(max > 0);
src/vm/sys/sys_utils.h+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 #define _DISVM_SRC_VM_SYS_SYS_UTILS_H_
99
1010 #include <vector>
11−#include <iosfwd>
11+#include <ios>
1212 #include <memory>
1313 #include <disvm.h>
1414 #include <utils.h>
src/vm/thread.cpp+1−1
@@ -59,7 +59,7 @@ vm_registers_t::vm_registers_t( · 58 unmodified lines
5959 , mp_base{ entry.mp_base }
6060 , thread{ thread }
6161 , pc{ entry.module->header.entry_pc }
62− , stack{ entry.module->header.stack_extent }
62+ , stack{ static_cast<std::size_t>(entry.module->header.stack_extent) }
6363 , tool_dispatch{ nullptr }
6464 , src{ nullptr }
6565 , mid{ nullptr }
src/vm/tool_dispatch.cpp+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 //
66
77 #include <cassert>
8+#include <thread>
89 #include <vector>
910 #include <debug.h>
1011 #include <disvm.h>
src/vm/vm.cpp+1−1
@@ -70,7 +70,7 @@ namespace · 69 unmodified lines
7070 {
7171 std::unique_ptr<runtime::vm_thread_t> _create_thread_safe(std::unique_ptr<runtime::vm_module_ref_t> &entry_module_ref)
7272 {
73− auto thread = std::make_unique<vm_thread_t>(*entry_module_ref, vm_t::root_vm_thread_id);
73+ auto thread = std::make_unique<vm_thread_t>(*entry_module_ref, disvm::vm_t::root_vm_thread_id);
7474
7575 // Now that the thread has been created and has inherited ownership of the pointer, relinquish the smart pointer's ownership.
7676 entry_module_ref->release(); // decrement the vm alloc ref count
src/vm/vm_memory.cpp+15−14
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #include <memory>
88 #include <atomic>
99 #include <bitset>
10+#include <cstdlib>
1011 #include <mutex>
1112 #include <limits>
1213 #include <vector>
@@ -355,98 +356,98 @@ namespace · 342 unmodified lines
355356 }
356357
357358 template<>
358−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<byte_t>()
359+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<byte_t>()
359360 {
360361 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::byte, hidden_type_desc::deleter };
361362 return t;
362363 }
363364
364365 template<>
365−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<short_word_t>()
366+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<short_word_t>()
366367 {
367368 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::short_word, hidden_type_desc::deleter };
368369 return t;
369370 }
370371
371372 template<>
372−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<word_t>()
373+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<word_t>()
373374 {
374375 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::word, hidden_type_desc::deleter };
375376 return t;
376377 }
377378
378379 template<>
379−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<short_real_t>()
380+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<short_real_t>()
380381 {
381382 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::short_real, hidden_type_desc::deleter };
382383 return t;
383384 }
384385
385386 template<>
386−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<real_t>()
387+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<real_t>()
387388 {
388389 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::real, hidden_type_desc::deleter };
389390 return t;
390391 }
391392
392393 template<>
393−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<big_t>()
394+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<big_t>()
394395 {
395396 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::big, hidden_type_desc::deleter };
396397 return t;
397398 }
398399
399400 template<>
400−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<pointer_t>()
401+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<pointer_t>()
401402 {
402403 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::pointer, hidden_type_desc::deleter };
403404 return t;
404405 }
405406
406407 template<>
407−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_array_t>()
408+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_array_t>()
408409 {
409410 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_array, hidden_type_desc::deleter };
410411 return t;
411412 }
412413
413414 template<>
414−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_list_t>()
415+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_list_t>()
415416 {
416417 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_list, hidden_type_desc::deleter };
417418 return t;
418419 }
419420
420421 template<>
421−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_channel_t>()
422+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_channel_t>()
422423 {
423424 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_channel, hidden_type_desc::deleter };
424425 return t;
425426 }
426427
427428 template<>
428−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_string_t>()
429+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_string_t>()
429430 {
430431 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_string, hidden_type_desc::deleter };
431432 return t;
432433 }
433434
434435 template<>
435−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_module_ref_t>()
436+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_module_ref_t>()
436437 {
437438 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_module_ref, hidden_type_desc::deleter };
438439 return t;
439440 }
440441
441442 template<>
442−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_stack_t>()
443+std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_stack_t>()
443444 {
444445 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_stack, hidden_type_desc::deleter };
445446 return t;
446447 }
447448
448449 template<>
449−static std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_thread_t>()
450+ std::shared_ptr<const type_descriptor_t> intrinsic_type_desc::type<vm_thread_t>()
450451 {
451452 static std::shared_ptr<const type_descriptor_t> t = { &hidden_type_desc::vm_thread, hidden_type_desc::deleter };
452453 return t;