debloatified my virtual machine a little bit, fixed stringmatching bug
This commit is contained in:
parent
f002034867
commit
12a7db912f
@ -36,10 +36,9 @@ namespace regexis024 {
|
||||
FORK_slots += (stat & SLOT_OCCUPIED) ? "O" : "x";
|
||||
}
|
||||
char buf[4096];
|
||||
snprintf(buf, 4096, "READ_slots: %s ; FORK_slots: %s ; READ_stack_new_main: %s ; "
|
||||
"READ_stack_new_second: %s ; READ_stack_old: %s ; FORK_stack: %s",
|
||||
READ_slots.c_str(), FORK_slots.c_str(), stack_to_str(ctx.READ_halted_stack_new_first).c_str(),
|
||||
stack_to_str(ctx.READ_halted_stack_new_second).c_str(),
|
||||
snprintf(buf, 4096, "READ_slots: %s ; FORK_slots: %s ; READ_stack_new: %s ; "
|
||||
"READ_stack_old: %s ; FORK_stack: %s",
|
||||
READ_slots.c_str(), FORK_slots.c_str(), stack_to_str(ctx.READ_halted_stack_new).c_str(),
|
||||
stack_to_str(ctx.READ_halted_stack_old).c_str(), stack_to_str(ctx.FORK_halted_stack).c_str());
|
||||
return buf;
|
||||
}
|
||||
|
@ -8,17 +8,13 @@
|
||||
namespace regexis024 {
|
||||
#define nonthrowing_assert(expr) if (!(expr)) {error = -1; return; }
|
||||
void compilation_core(std::vector<uint8_t>& result, FA_Container& fa, explicit_bookmarks& bookmark_manager,
|
||||
size_t& first_read_ns, size_t& second_read_ns, size_t& fork_ss_ns, int& error)
|
||||
size_t& read_ss_ns, size_t& fork_ss_ns, int& error)
|
||||
{
|
||||
bookmark_id_t node_start_bm_offset = bookmark_manager.new_range_of_bookmarks(fa.all.size());
|
||||
std::vector<size_t> not_yet_dedicated_second_read_ns_ssids;
|
||||
first_read_ns = 0;
|
||||
second_read_ns = 0;
|
||||
read_ss_ns = 0;
|
||||
fork_ss_ns = 0;
|
||||
assert(fa.start);
|
||||
std::vector<FA_Node*> todo = {fa.start};
|
||||
// std::vector<bool> promised(fa.all.size(), false);
|
||||
// promised[fa.start->nodeId] = true;
|
||||
|
||||
auto nodesBookmark = [&](FA_Node* node) -> bookmark_id_t {
|
||||
assert(node);
|
||||
@ -29,15 +25,6 @@ namespace regexis024 {
|
||||
todo.push_back(node);
|
||||
};
|
||||
|
||||
auto reading_head = [&](bool is_in_second_ns) {
|
||||
if (is_in_second_ns) {
|
||||
cmd_READ_second_ns(result, not_yet_dedicated_second_read_ns_ssids);
|
||||
second_read_ns++;
|
||||
} else {
|
||||
cmd_READ_first_ns(result, first_read_ns++);
|
||||
}
|
||||
};
|
||||
|
||||
while (!todo.empty()) {
|
||||
FA_Node* node = todo.back(); todo.pop_back();
|
||||
if (bookmark_manager.has_landed(nodesBookmark(node))) {
|
||||
@ -55,8 +42,8 @@ namespace regexis024 {
|
||||
break;
|
||||
} else if (node->type == one_char_read) {
|
||||
FA_NodeOfOneCharRead* ocr = dynamic_cast<FA_NodeOfOneCharRead*>(node);
|
||||
nonthrowing_assert(first_read_ns + second_read_ns < UINT32_MAX);
|
||||
reading_head(ocr->second_ns);
|
||||
nonthrowing_assert(read_ss_ns < UINT32_MAX);
|
||||
cmd_READ(result, read_ss_ns++);
|
||||
write_filter(result, bookmark_manager, {ocr->filter},{nodesBookmark(ocr->nxt_node)});
|
||||
node = ocr->nxt_node;
|
||||
} else if (node->type == look_one_behind) {
|
||||
@ -92,10 +79,10 @@ namespace regexis024 {
|
||||
node = tamh->nxt_node;
|
||||
} else if (node->type == det_char_crossroads) {
|
||||
FA_NodeOfDetCharCrossroads* dcc = dynamic_cast<FA_NodeOfDetCharCrossroads*>(node);
|
||||
nonthrowing_assert(first_read_ns + second_read_ns < UINT32_MAX);
|
||||
nonthrowing_assert(read_ss_ns < UINT32_MAX);
|
||||
if (dcc->matching)
|
||||
cmd_MATCH(result);
|
||||
reading_head(dcc->second_ns);
|
||||
cmd_READ(result, read_ss_ns++);
|
||||
std::vector<codeset_t> codesets;
|
||||
std::vector<bookmark_id_t> branches;
|
||||
for (const DFA_CrossroadPath& p: dcc->crossroads) {
|
||||
@ -111,8 +98,5 @@ namespace regexis024 {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
for (size_t j = 0; j < not_yet_dedicated_second_read_ns_ssids.size(); j++) {
|
||||
belated_sslot_id(result, not_yet_dedicated_second_read_ns_ssids[j], j + first_read_ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace regexis024 {
|
||||
void compilation_core(std::vector<uint8_t>& result, FA_Container& fa, explicit_bookmarks& bookmark_manager,
|
||||
size_t& first_read_ns, size_t& second_read_ns, size_t& fork_ss_ns, int& error);
|
||||
size_t& read_ss_ns, size_t& fork_ss_ns, int& error);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -28,15 +28,11 @@ namespace regexis024 {
|
||||
struct belate_initialization_parameters {
|
||||
size_t todo_pos_read_ss_n;
|
||||
size_t todo_pos_fork_ss_n;
|
||||
size_t todo_pos_second_ns_size;
|
||||
|
||||
void complete_it(std::vector<uint8_t>& result,
|
||||
sslot_id_t first_read_ns, sslot_id_t second_read_ns, sslot_id_t fork_ss_ns)
|
||||
void complete_it(std::vector<uint8_t>& result, sslot_id_t read_ss_ns, sslot_id_t fork_ss_ns)
|
||||
{
|
||||
assert((uint64_t)first_read_ns + (uint64_t)second_read_ns <= UINT32_MAX);
|
||||
belated_sslot_id(result, todo_pos_read_ss_n , first_read_ns + second_read_ns);
|
||||
belated_sslot_id(result, todo_pos_read_ss_n , read_ss_ns);
|
||||
belated_sslot_id(result, todo_pos_fork_ss_n, fork_ss_ns);
|
||||
belated_sslot_id(result, todo_pos_second_ns_size, second_read_ns);
|
||||
}
|
||||
};
|
||||
|
||||
@ -59,15 +55,6 @@ namespace regexis024 {
|
||||
write_byte(result, opcodes::PARAM_SELARR_LEN);
|
||||
write_tai(result, selarr_size);
|
||||
|
||||
write_byte(result, opcodes::MSG_MULTISTART_ALLOWED);
|
||||
write_byte(result, 1);
|
||||
|
||||
write_byte(result, opcodes::MSG_FED_INPUT_EXTENDED);
|
||||
write_byte(result, info1.fed_chars_extend_one_left ? 1 : 0);
|
||||
write_byte(result, info1.fed_chars_extend_one_right ? 1 : 0);
|
||||
todo.todo_pos_second_ns_size = result.size();
|
||||
write_sslot_id(result, 0); // Belate
|
||||
|
||||
write_byte(result, opcodes::INIT);
|
||||
return todo;
|
||||
}
|
||||
@ -94,11 +81,11 @@ namespace regexis024 {
|
||||
|
||||
belate_initialization_parameters init_param_todo = write_some_normal_initialization(result, selarr_size, info1);
|
||||
|
||||
size_t first_read_ns, second_read_ns, fork_ss_ns;
|
||||
compilation_core(result, fa, bookmark_manager, first_read_ns, second_read_ns, fork_ss_ns, error);
|
||||
size_t read_ss_ns, fork_ss_ns;
|
||||
compilation_core(result, fa, bookmark_manager, read_ss_ns, fork_ss_ns, error);
|
||||
if (error < 0)
|
||||
return;
|
||||
init_param_todo.complete_it(result, first_read_ns, second_read_ns, fork_ss_ns);
|
||||
init_param_todo.complete_it(result, read_ss_ns, fork_ss_ns);
|
||||
bookmark_manager.finish(result);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace regexis024 {
|
||||
write_byte(result, opcodes::MATCH);
|
||||
}
|
||||
|
||||
void cmd_READ_first_ns(std::vector<uint8_t>& result, size_t slot) {
|
||||
void cmd_READ(std::vector<uint8_t>& result, size_t slot) {
|
||||
assert(slot <= UINT32_MAX);
|
||||
write_byte(result, opcodes::READ);
|
||||
write_sslot_id(result, slot);
|
||||
@ -68,10 +68,4 @@ namespace regexis024 {
|
||||
write_sslot_id(result, slot);
|
||||
bookmark_manager.write_unresolved_reference(result, dest);
|
||||
}
|
||||
|
||||
void cmd_READ_second_ns(std::vector<uint8_t>& result, std::vector<size_t>& belate_second_read_ns_slot_args) {
|
||||
write_byte(result, opcodes::READ);
|
||||
belate_second_read_ns_slot_args.push_back(result.size());
|
||||
write_sslot_id(result, 0);
|
||||
}
|
||||
}
|
@ -14,8 +14,7 @@ namespace regexis024 {
|
||||
void cmd_DIE(std::vector<uint8_t>& result);
|
||||
void cmd_MATCH(std::vector<uint8_t>& result);
|
||||
|
||||
void cmd_READ_first_ns(std::vector<uint8_t>& result, size_t slot);
|
||||
void cmd_READ_second_ns(std::vector<uint8_t>& result, std::vector<size_t>& belate_second_read_ns_slot_args);
|
||||
void cmd_READ(std::vector<uint8_t>& result, size_t slot);
|
||||
void cmd_FORK(std::vector<uint8_t> &result, explicit_bookmarks& bookmark_manager, size_t slot, bookmark_id_t dest);
|
||||
}
|
||||
|
||||
|
@ -21,24 +21,19 @@ void test(const string& input, const string& pattern, const MatchInfo& right_ans
|
||||
}
|
||||
|
||||
int main() {
|
||||
test("11aa", "^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo({}, {}));
|
||||
test("aa11", "^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo({}, {}));
|
||||
test("a111", "^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo());
|
||||
test("aa11", "^!A;\\B!A;\\B!any;\\B!any;$", MatchInfo());
|
||||
test("1a11", "^!A;\\B!A;\\B!any;\\B!any;$", MatchInfo());
|
||||
test("11aa", "!dfa;^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo({}, {}));
|
||||
test("aa11", "!dfa;^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo({}, {}));
|
||||
test("a111", "!dfa;^!A;\\B!A;\\b!any;\\B!any;$", MatchInfo());
|
||||
test("aa11", "!dfa;^!A;\\B!A;\\B!any;\\B!any;$", MatchInfo());
|
||||
test("1a11", "!dfa;^!A;\\B!A;\\B!any;\\B!any;$", MatchInfo());
|
||||
test("bababbaa", "[ab]*", MatchInfo({}, {}));
|
||||
test("bababbaa", "!dfa;[ab]*", MatchInfo({}, {}));
|
||||
test("d3", "[abc]3", MatchInfo());
|
||||
test("a3", "[abc]3", MatchInfo({}, {}));
|
||||
test("", "", MatchInfo({}, {}));
|
||||
test("a", "a", MatchInfo({}, {}));
|
||||
test("abba", "!select{M{max}}a#M(b*)a", MatchInfo({}, {1, 3}));
|
||||
|
||||
test("LINE\r\nFirst:Second\r\nThird:12\r\n\r\n",
|
||||
"!dfa;!select{fieldname{ca}fieldbody{ca}}^^^LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n$$$",
|
||||
"!dfa;!select{fieldname{ca}fieldbody{ca}}LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}, {0, 20}, {1, 25}, {2, 26}, {3, 28}}, {20, 25, 26, 28}));
|
||||
test("LINE\r\nFirst:Second\r\nThird:12\r\n\r\n",
|
||||
"!dfa;!select{fieldname{ca}fieldbody{ca}}^LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+\\>):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}, {0, 20}, {1, 25}, {2, 26}, {3, 28}}, {20, 25, 26, 28}));
|
||||
test("LINE\r\nFirst:Second\r\nThird:12\r\n\r\n",
|
||||
"!dfa;!select{fieldname{ca}fieldbody{ca}}^LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
"!dfa;!select{fieldname{ca}fieldbody{ca}}LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}, {0, 20}, {1, 25}, {2, 26}, {3, 28}}, {20, 25, 26, 28}));
|
||||
test("LINE\r\nFirst:Second\r\n\r\n",
|
||||
"!select{fieldname{ca}}LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
@ -53,12 +48,11 @@ int main() {
|
||||
test("абвввввввгд", "абв*г+д", MatchInfo({}, {}));
|
||||
test("абвввввввд", "абв*г+д", MatchInfo());
|
||||
test("LINE\r\nFirst:Second\r\nThird:12\r\n\r\n",
|
||||
"!dfa;^LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
"!dfa;LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}, {0, 20}, {1, 25}, {2, 26}, {3, 28}}, {}));
|
||||
test("LINE\r\nFirst:Second\r\n\r\n",
|
||||
"LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
|
||||
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}}, {}));
|
||||
test("C111111111111", "C\\>1*", MatchInfo({}, {}));
|
||||
test("GET / HTTP/1.1\r\nHost: example.com\r\nAAAAA: a\rfaafafdf\r\n\r\n",
|
||||
"!dfa;(GET|POST) / HTTP/(1.1|1.0|0.9)\r\n([\\u0021-\\u007E&^:]+:([\\u0000-\\u007F&^\r\n])*\r\n)*\r\n",
|
||||
MatchInfo());
|
||||
@ -66,24 +60,17 @@ int main() {
|
||||
test("\n3432\r\n", "[\\u0000-\\u007F&^\r\n]*\r\n", MatchInfo());
|
||||
test("3:::;;432\r\n", "[\\u0000-\\u007F&^\r\n]*\r\n", MatchInfo({}, {}));
|
||||
test("3:::;;432 \r\n", "[\\u0000-\\u007F&^\r\n]*\r\n", MatchInfo({}, {}));
|
||||
test("GET / HTTP/0.9\r\nHost: bibur at\r\nContent-type: html\r\n\r\n",
|
||||
"^(GET|POST\\>) / HTTP/(1.1|1.0|0.9)\r\n([\\u0021-\\u007E&^:]+:([\\u0000-\\u007F&^\r\n])*\r\n)*\r\n",
|
||||
MatchInfo({}, {}));
|
||||
test("b", "#boba(b)", MatchInfo({{0, 0}, {1, 1}}, {}));
|
||||
test("abc", "!selarr{boba{ca}}^a#boba(b)c$", MatchInfo({{0, 1}, {1, 2}}, {1, 2}));
|
||||
test("abc", "!selarr{boba{ca}}a#boba(b)c", MatchInfo({{0, 1}, {1, 2}}, {1, 2}));
|
||||
for (int i = 0; i < 64; i++) {
|
||||
std::string T;
|
||||
T += ('a' + (i >> 3));
|
||||
T+= ('a' + (i % 8));
|
||||
test(T, "(((a|b)|(c|d))|((e|f)|(g|h)))!r{2}", MatchInfo({}, {}));
|
||||
}
|
||||
test("abba", "!select{M{max}}a#M(b*)a", MatchInfo({}, {1, 3}));
|
||||
test("abba", "!dfa;!select{M{max}}a#M(b*)a", MatchInfo({}, {1, 3}));
|
||||
test("abba", "!select{M{max}}a#M(!any;*)a", MatchInfo({}, {1, 3}));
|
||||
test("abba", "!dfa;!select{M{max}}a#M(!any;*)a", MatchInfo({}, {1, 3}));
|
||||
test("", "", MatchInfo({}, {}));
|
||||
test("a", "a", MatchInfo({}, {}));
|
||||
test("a3", "[abc]3", MatchInfo({}, {}));
|
||||
test("b3", "[abc]3", MatchInfo({}, {}));
|
||||
test("c3", "[abc]3", MatchInfo({}, {}));
|
||||
test("aa", "aa", MatchInfo({}, {}));
|
||||
|
@ -46,22 +46,11 @@ namespace regexis024 {
|
||||
retStatus = "Virtual machine initialization. " + getVMErrString();
|
||||
return -1;
|
||||
}
|
||||
int left_ext_feed = vm.getInputLeftExtensionSize();
|
||||
int right_ext_feed = vm.getInputRightExtensionSize();
|
||||
if (left_ext_feed > 1 || right_ext_feed > 1) {
|
||||
retStatus = "Unnatural extended input request.";
|
||||
return -1;
|
||||
}
|
||||
if (vm.addNewMatchingThread() != error_codes::stable) {
|
||||
retStatus = "Virtual machine first kick. " + getVMErrString();
|
||||
return -1;
|
||||
}
|
||||
if (left_ext_feed) {
|
||||
if (vm.extendedFeedCharacter('\n') != error_codes::stable) {
|
||||
retStatus = "VM left extended input. " + getVMErrString();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
for (size_t cur_text_pos = 0;cur_text_pos < input.size();) {
|
||||
for (size_t cur_text_pos = 0; cur_text_pos < input.size();) {
|
||||
int32_t inp_code;
|
||||
size_t adj;
|
||||
utf8_string_iterat(inp_code, adj, cur_text_pos, input.data(), input.size());
|
||||
@ -75,12 +64,6 @@ namespace regexis024 {
|
||||
}
|
||||
cur_text_pos += adj;
|
||||
}
|
||||
if (right_ext_feed) {
|
||||
if (vm.extendedFeedCharacter('\n') != error_codes::stable) {
|
||||
retStatus = "VM right extended input. " + getVMErrString();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
assert(vm.isUsable());
|
||||
if (vm.isMatched()) {
|
||||
retMatchInfo.have_match = true;
|
||||
@ -107,4 +90,4 @@ namespace regexis024 {
|
||||
MatchInfo::MatchInfo(const std::vector<CAEvent> &ca_history, const std::vector<uint64_t> &sa):
|
||||
ca_history(ca_history), sa(sa), have_match(true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,15 +49,6 @@ ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
#define sift_mode_check() if (!ctx.sifting_with){ \
|
||||
ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
|
||||
/* Can append to both read_halted+new stacks of context */
|
||||
void read_halted_new_type_stacks_append(VMContext &ctx, sslot_id_t ssid){
|
||||
ctx_print_debug(ctx);
|
||||
if (ssid < ctx.portion_of_FIRST_read_halt_ns){
|
||||
ctx.READ_halted_stack_new_first.append(ssid);
|
||||
} else {
|
||||
ctx.READ_halted_stack_new_second.append(ssid);
|
||||
}
|
||||
}
|
||||
|
||||
void do_i_read(VMContext &ctx, sslot_id_t ssid) {
|
||||
ctx_print_debug(ctx);
|
||||
@ -71,13 +62,13 @@ ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
} else {
|
||||
swap_old_settled_and_new_active(ctx, other);
|
||||
/* Even though ssid was registed in stack for elders, now young stack should also track this slot */
|
||||
read_halted_new_type_stacks_append(ctx, ssid);
|
||||
ctx.READ_halted_stack_new.append(ssid);
|
||||
}
|
||||
} else {
|
||||
other = ctx.active_thread;
|
||||
other.slot_occupation_status = SLOT_NEW_val;
|
||||
ctx.active_thread.slot_occupation_status = SLOT_EMPTY_val;
|
||||
read_halted_new_type_stacks_append(ctx, ssid);
|
||||
ctx.READ_halted_stack_new.append(ssid);
|
||||
ctx.try_to_continue_scheduled();
|
||||
}
|
||||
}
|
||||
@ -221,22 +212,6 @@ ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
ctx.have_sift_function = false;
|
||||
}
|
||||
|
||||
void i_MSG_MULTISTART_ALLOWED(VMContext& ctx){
|
||||
ctx_print_debug(ctx);
|
||||
initialization_phase_check()
|
||||
check_available_prg(1)
|
||||
ctx.allows_multistart = (bool)ctx.extract_b();
|
||||
}
|
||||
|
||||
void i_MSG_FED_INPUT_EXTENDED(VMContext& ctx){
|
||||
ctx_print_debug(ctx);
|
||||
initialization_phase_check()
|
||||
check_available_prg(1 + 1 + BYTECODE_SSLOT_ID_SZ)
|
||||
ctx.fed_input_extends_left = ctx.extract_b();
|
||||
ctx.fed_input_extends_right = ctx.extract_b();
|
||||
ctx.portion_of_second_read_halt_ns = ctx.extract_sslot_id();
|
||||
}
|
||||
|
||||
uint64_t get_el_from_selarr(uint64_t* sa, near_ptr_t ind){
|
||||
return sa ? sa[1UL + ind] : 0;
|
||||
}
|
||||
@ -427,14 +402,10 @@ ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
smitsya(read_sslot_count_limit_violation);
|
||||
if (ctx.fork_slots_number > ctx.FORK_SS_LIMIT)
|
||||
smitsya(fork_sslot_count_limit_violation);
|
||||
if (ctx.portion_of_second_read_halt_ns > ctx.read_slots_number)
|
||||
smitsya(fork_sslot_out_of_range);
|
||||
ctx.READ_halted_slots = calloc_slots_array(ctx.read_slots_number);
|
||||
calloc_stack_slots(ctx.READ_halted_stack_old, ctx.read_slots_number);
|
||||
|
||||
ctx.portion_of_FIRST_read_halt_ns = ctx.read_slots_number - ctx.portion_of_second_read_halt_ns;
|
||||
calloc_stack_slots(ctx.READ_halted_stack_new_first, ctx.portion_of_FIRST_read_halt_ns);
|
||||
calloc_stack_slots(ctx.READ_halted_stack_new_second, ctx.portion_of_second_read_halt_ns);
|
||||
calloc_stack_slots(ctx.READ_halted_stack_new, ctx.read_slots_number);
|
||||
|
||||
ctx.FORK_halted_slots = calloc_slots_array(ctx.fork_slots_number);
|
||||
calloc_stack_slots(ctx.FORK_halted_stack, ctx.fork_slots_number);
|
||||
@ -474,8 +445,6 @@ ctx.error = error_codes::instruction_not_for_collision_thread; return; }
|
||||
rcase(PARAM_SELARR_LEN)
|
||||
rcase(PARAM_COLSIFTFUNC_SET)
|
||||
rcase(PARAM_COLSIFTFUNC_WIPE)
|
||||
rcase(MSG_MULTISTART_ALLOWED)
|
||||
rcase(MSG_FED_INPUT_EXTENDED)
|
||||
rcase(DMOV_RABX_SELARR)
|
||||
rcase(DDIST_RABX_SELARR)
|
||||
rcase(SIFTPRIOR_MIN_RABX)
|
||||
|
@ -28,8 +28,6 @@ namespace regexis024 {
|
||||
rcase(PARAM_SELARR_LEN)
|
||||
rcase(PARAM_COLSIFTFUNC_SET)
|
||||
rcase(PARAM_COLSIFTFUNC_WIPE)
|
||||
rcase(MSG_MULTISTART_ALLOWED)
|
||||
rcase(MSG_FED_INPUT_EXTENDED)
|
||||
rcase(DMOV_RABX_SELARR)
|
||||
rcase(DDIST_RABX_SELARR)
|
||||
rcase(SIFTPRIOR_MIN_RABX)
|
||||
|
@ -101,18 +101,13 @@ namespace regexis024 {
|
||||
bool have_sift_function = false;
|
||||
near_ptr_t sift_function;
|
||||
|
||||
bool allows_multistart = false;
|
||||
uint8_t fed_input_extends_left = 0, fed_input_extends_right = 0;
|
||||
sslot_id_t portion_of_second_read_halt_ns = 0, portion_of_FIRST_read_halt_ns = 0;
|
||||
|
||||
bool initialized = false;
|
||||
near_ptr_t unnatural_started_thread_IP = 1337;
|
||||
error_code_t error = error_codes::stable;
|
||||
|
||||
Thread* READ_halted_slots;
|
||||
SSID_Stack READ_halted_stack_old;
|
||||
SSID_Stack READ_halted_stack_new_first;
|
||||
SSID_Stack READ_halted_stack_new_second;
|
||||
SSID_Stack READ_halted_stack_new;
|
||||
Thread* FORK_halted_slots;
|
||||
SSID_Stack FORK_halted_stack;
|
||||
|
||||
|
@ -144,8 +144,7 @@ namespace regexis024 {
|
||||
ctx_print_debug(*this);
|
||||
if (matched_thread.slot_occupation_status & SLOT_OCCUPIED)
|
||||
matched_thread.delete_thread();
|
||||
emptify_one_of_new_read_halted_stacks(*this, READ_halted_stack_new_second);
|
||||
fill_empty_old_read_halted_stack(*this, READ_halted_stack_new_first);
|
||||
fill_empty_old_read_halted_stack(*this, READ_halted_stack_new);
|
||||
INP = input;
|
||||
passed_bytes += corresponding_byte_amount;
|
||||
passed_chars++;
|
||||
@ -154,22 +153,10 @@ namespace regexis024 {
|
||||
return error;
|
||||
}
|
||||
|
||||
error_code_t VMContext::extendedFeedCharacter(uint64_t input) {
|
||||
ctx_print_debug(*this);
|
||||
if (matched_thread.slot_occupation_status & SLOT_OCCUPIED)
|
||||
matched_thread.delete_thread();
|
||||
fill_empty_old_read_halted_stack(*this, READ_halted_stack_new_second);
|
||||
INP = input;
|
||||
try_to_continue_scheduled();
|
||||
kick(*this);
|
||||
return error;
|
||||
}
|
||||
|
||||
VMContext::~VMContext() {
|
||||
ctx_print_debug(*this);
|
||||
if (initialized){
|
||||
emptify_one_of_new_read_halted_stacks(*this, READ_halted_stack_new_first);
|
||||
emptify_one_of_new_read_halted_stacks(*this, READ_halted_stack_new_second);
|
||||
emptify_one_of_new_read_halted_stacks(*this, READ_halted_stack_new);
|
||||
while (!READ_halted_stack_old.empty()){
|
||||
Thread& thread = READ_halted_slots[READ_halted_stack_old.pop()];
|
||||
assert(thread.slot_occupation_status & SLOT_OCCUPIED);
|
||||
|
@ -41,25 +41,13 @@ namespace regexis024 {
|
||||
return isUsable() ? reveal->selection_array_len : 0;
|
||||
}
|
||||
|
||||
bool VirtualMachine::isAllowMultistart() {
|
||||
return isUsable() ? reveal->allows_multistart : false;
|
||||
}
|
||||
|
||||
uint8_t VirtualMachine::getInputLeftExtensionSize() {
|
||||
return isUsable() ? reveal->fed_input_extends_left : 0;
|
||||
}
|
||||
|
||||
uint8_t VirtualMachine::getInputRightExtensionSize() {
|
||||
return isUsable() ? reveal->fed_input_extends_right : 0;
|
||||
}
|
||||
|
||||
error_code_t VirtualMachine::getErrno() {
|
||||
return reveal->error;
|
||||
}
|
||||
|
||||
/* Stupid kinda function. Checks if somebody is ready to continue reading the actual string or extended l-r input */
|
||||
bool VirtualMachine::haveSurvivors() {
|
||||
return isUsable() && (!reveal->READ_halted_stack_new_first.empty() || !reveal->READ_halted_stack_new_second.empty());
|
||||
return isUsable() && (!reveal->READ_halted_stack_new.empty());
|
||||
}
|
||||
|
||||
bool VirtualMachine::isMatched() {
|
||||
@ -92,15 +80,9 @@ namespace regexis024 {
|
||||
return reveal->startThread();
|
||||
}
|
||||
|
||||
error_code_t VirtualMachine::extendedFeedCharacter(uint64_t input) {
|
||||
if (!isUsable())
|
||||
throw std::runtime_error("unusable\n");
|
||||
return reveal->extendedFeedCharacter(input);
|
||||
}
|
||||
|
||||
error_code_t VirtualMachine::feedCharacter(uint64_t input, uint64_t bytesResembled) {
|
||||
if (!isUsable())
|
||||
throw std::runtime_error("unusable\n");
|
||||
return reveal->feedCharacter(input, bytesResembled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,6 @@ namespace regexis024 {
|
||||
bool isUsable();
|
||||
virtual ~VirtualMachine();
|
||||
tai_t getSelectionArrayLength();
|
||||
bool isAllowMultistart();
|
||||
uint8_t getInputLeftExtensionSize();
|
||||
uint8_t getInputRightExtensionSize();
|
||||
error_code_t getErrno();
|
||||
bool haveSurvivors();
|
||||
bool isMatched();
|
||||
@ -35,7 +32,6 @@ namespace regexis024 {
|
||||
uint64_t getMatchedThreadSAValue(uint16_t key);
|
||||
|
||||
error_code_t addNewMatchingThread();
|
||||
error_code_t extendedFeedCharacter(uint64_t input);
|
||||
error_code_t feedCharacter(uint64_t input, uint64_t bytesResembled);
|
||||
|
||||
private:
|
||||
|
@ -6,10 +6,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef __ORDER_LITTLE_ENDIAN__
|
||||
#error "Big endian is currently unsupported"
|
||||
#endif
|
||||
|
||||
namespace regexis024 {
|
||||
int utf8_retrieve_size(char firstByte) {
|
||||
if (!((uint8_t)firstByte & 0b10000000))
|
||||
|
@ -45,10 +45,6 @@ namespace regexis024 {
|
||||
PARAM_COLSIFTFUNC_SET = 21,
|
||||
/* PARAM_COLSIFTFUNC_WIPE */
|
||||
PARAM_COLSIFTFUNC_WIPE = 22,
|
||||
/* MSG_MULTISTART_ALLOWED <1B> */
|
||||
MSG_MULTISTART_ALLOWED = 23,
|
||||
/* MSG_FED_INPUT_EXTENDED <1B> <1B> <Settlement ID (length of suffix)> */
|
||||
MSG_FED_INPUT_EXTENDED = 24,
|
||||
/* DMOVRABXSELARR <Track array index> */
|
||||
DMOV_RABX_SELARR = 25,
|
||||
/* DDISTRABXSELARR <Track array index> <Track array index> */
|
||||
|
Loading…
Reference in New Issue
Block a user