@@ -82,20 +82,20 @@ public:
82
82
static std::uniform_int_distribution<int32_t > distr (INT24_MIN, INT24_MAX);
83
83
84
84
// The operation currently being executed
85
- instruction instr = m_program_holder. at (m_ip);
85
+ instruction instr = m_program_holder-> at (m_ip);
86
86
operation op = instr.get_op ();
87
87
88
88
// The web interface needs every thread to send debug info. The CLI expects only active threads to do so.
89
89
#ifdef __EMSCRIPTEN__
90
90
if (m_flags.debug ) {
91
- pair<size_t , size_t > coords = m_program_holder. get_coords (m_ip);
91
+ pair<size_t , size_t > coords = m_program_holder-> get_coords (m_ip);
92
92
send_debug_info (
93
93
m_number,
94
94
m_flags.show_stack ? m_stack.data () : nullptr ,
95
95
m_stack.size (),
96
96
coords.first ,
97
97
coords.second ,
98
- m_program_holder. raw_at (m_ip).c_str ()
98
+ m_program_holder-> raw_at (m_ip).c_str ()
99
99
);
100
100
}
101
101
#endif
@@ -117,14 +117,14 @@ public:
117
117
#ifndef __EMSCRIPTEN__
118
118
// Print the requisite information in debug mode.
119
119
if (m_flags.debug ) {
120
- pair<size_t , size_t > coords = m_program_holder. get_coords (m_ip);
120
+ pair<size_t , size_t > coords = m_program_holder-> get_coords (m_ip);
121
121
send_debug_info (
122
122
m_number,
123
123
m_flags.show_stack ? m_stack.data () : nullptr ,
124
124
m_stack.size (),
125
125
coords.first ,
126
126
coords.second ,
127
- m_program_holder. raw_at (m_ip).c_str ()
127
+ m_program_holder-> raw_at (m_ip).c_str ()
128
128
);
129
129
}
130
130
#endif
@@ -133,6 +133,7 @@ public:
133
133
switch (op) {
134
134
case operation::BNG:
135
135
case operation::NOP:
136
+ case operation::JMP:
136
137
break ;
137
138
case operation::ADD: {
138
139
SIZE_CHECK (" add from" , 2 );
@@ -464,7 +465,7 @@ public:
464
465
default : {
465
466
cerr << " Unrecognized opcode '" ;
466
467
print_unichar (static_cast <int24_t >(op), cerr);
467
- pair<size_t , size_t > coords = m_program_holder. get_coords (m_ip);
468
+ pair<size_t , size_t > coords = m_program_holder-> get_coords (m_ip);
468
469
cerr << " ' (at (" << coords.first << " , " << coords.second << " ))\n " ;
469
470
thread<ProgramHolder>::flush_and_exit (EXIT_FAILURE);
470
471
}
@@ -478,19 +479,18 @@ public:
478
479
479
480
#undef SIZE_CHECK
480
481
protected:
481
- inline thread (const ProgramHolder& ph, flags f) noexcept :
482
+ inline thread (ProgramHolder* ph, flags f) noexcept :
482
483
m_program_holder(ph), m_stack(), m_ip(), m_status(status::active), m_flags(f), m_number(thread_count++) {}
483
484
484
485
constexpr void advance () noexcept {
485
- // FIXME: Segfaults when spawning a new thread with an empty stack
486
- m_program_holder.advance (m_ip, [&]() NOEXCEPT_T {
486
+ m_program_holder->advance (m_ip, [&]() NOEXCEPT_T {
487
487
EMPTY_PROTECT (" branch on" ) {}
488
488
return m_stack.back () < INT24_C (0 );
489
489
});
490
490
}
491
491
#undef EMPTY_PROTECT
492
492
493
- ProgramHolder m_program_holder;
493
+ ProgramHolder* m_program_holder;
494
494
std::vector<int24_t > m_stack;
495
495
NO_UNIQUE_ADDRESS typename ProgramHolder::IP m_ip;
496
496
status m_status;
0 commit comments