Showing the changes to src/vm/execution_table.cpp (1 of 6 files). Show all
Unified · Split
| @@ -548,33 +548,33 @@ namespace · 547 unmodified lines | ||
| 548 | 548 | // Compare and Branch operations |
| 549 | 549 | // |
| 550 | 550 | |
| 551 | − EXEC_DECL(bltb) { if (vt_ref<byte_t>(r.src) < vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 552 | − EXEC_DECL(bgtb) { if (vt_ref<byte_t>(r.src) > vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 553 | − EXEC_DECL(bleb) { if (vt_ref<byte_t>(r.src) <= vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 554 | − EXEC_DECL(bgeb) { if (vt_ref<byte_t>(r.src) >= vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 555 | − EXEC_DECL(beqb) { if (vt_ref<byte_t>(r.src) == vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 556 | − EXEC_DECL(bneb) { if (vt_ref<byte_t>(r.src) != vt_ref<byte_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 557 | − | |
| 558 | − EXEC_DECL(bltw) { if (vt_ref<word_t>(r.src) < vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 559 | − EXEC_DECL(bgtw) { if (vt_ref<word_t>(r.src) > vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 560 | − EXEC_DECL(blew) { if (vt_ref<word_t>(r.src) <= vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 561 | − EXEC_DECL(bgew) { if (vt_ref<word_t>(r.src) >= vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 562 | − EXEC_DECL(beqw) { if (vt_ref<word_t>(r.src) == vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 563 | − EXEC_DECL(bnew) { if (vt_ref<word_t>(r.src) != vt_ref<word_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 564 | − | |
| 565 | − EXEC_DECL(bltf) { if (vt_ref<real_t>(r.src) < vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 566 | − EXEC_DECL(bgtf) { if (vt_ref<real_t>(r.src) > vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 567 | − EXEC_DECL(blef) { if (vt_ref<real_t>(r.src) <= vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 568 | − EXEC_DECL(bgef) { if (vt_ref<real_t>(r.src) >= vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 569 | − EXEC_DECL(beqf) { if (vt_ref<real_t>(r.src) == vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 570 | − EXEC_DECL(bnef) { if (vt_ref<real_t>(r.src) != vt_ref<real_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 571 | − | |
| 572 | − EXEC_DECL(bltl) { if (vt_ref<big_t>(r.src) < vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 573 | − EXEC_DECL(bgtl) { if (vt_ref<big_t>(r.src) > vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 574 | − EXEC_DECL(blel) { if (vt_ref<big_t>(r.src) <= vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 575 | − EXEC_DECL(bgel) { if (vt_ref<big_t>(r.src) >= vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 576 | − EXEC_DECL(beql) { if (vt_ref<big_t>(r.src) == vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 577 | − EXEC_DECL(bnel) { if (vt_ref<big_t>(r.src) != vt_ref<big_t>(r.mid)) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 551 | + EXEC_DECL(bltb) { if (vt_ref<byte_t>(r.src) < vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 552 | + EXEC_DECL(bgtb) { if (vt_ref<byte_t>(r.src) > vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 553 | + EXEC_DECL(bleb) { if (vt_ref<byte_t>(r.src) <= vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 554 | + EXEC_DECL(bgeb) { if (vt_ref<byte_t>(r.src) >= vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 555 | + EXEC_DECL(beqb) { if (vt_ref<byte_t>(r.src) == vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 556 | + EXEC_DECL(bneb) { if (vt_ref<byte_t>(r.src) != vt_ref<byte_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 557 | + | |
| 558 | + EXEC_DECL(bltw) { if (vt_ref<word_t>(r.src) < vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 559 | + EXEC_DECL(bgtw) { if (vt_ref<word_t>(r.src) > vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 560 | + EXEC_DECL(blew) { if (vt_ref<word_t>(r.src) <= vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 561 | + EXEC_DECL(bgew) { if (vt_ref<word_t>(r.src) >= vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 562 | + EXEC_DECL(beqw) { if (vt_ref<word_t>(r.src) == vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 563 | + EXEC_DECL(bnew) { if (vt_ref<word_t>(r.src) != vt_ref<word_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 564 | + | |
| 565 | + EXEC_DECL(bltf) { if (vt_ref<real_t>(r.src) < vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 566 | + EXEC_DECL(bgtf) { if (vt_ref<real_t>(r.src) > vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 567 | + EXEC_DECL(blef) { if (vt_ref<real_t>(r.src) <= vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 568 | + EXEC_DECL(bgef) { if (vt_ref<real_t>(r.src) >= vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 569 | + EXEC_DECL(beqf) { if (vt_ref<real_t>(r.src) == vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 570 | + EXEC_DECL(bnef) { if (vt_ref<real_t>(r.src) != vt_ref<real_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 571 | + | |
| 572 | + EXEC_DECL(bltl) { if (vt_ref<big_t>(r.src) < vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 573 | + EXEC_DECL(bgtl) { if (vt_ref<big_t>(r.src) > vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 574 | + EXEC_DECL(blel) { if (vt_ref<big_t>(r.src) <= vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 575 | + EXEC_DECL(bgel) { if (vt_ref<big_t>(r.src) >= vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 576 | + EXEC_DECL(beql) { if (vt_ref<big_t>(r.src) == vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 577 | + EXEC_DECL(bnel) { if (vt_ref<big_t>(r.src) != vt_ref<big_t>(r.mid)) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 578 | 578 | |
| 579 | 579 | // Define case table constants |
| 580 | 580 | // [SPEC]Table format is partially defined in Dis VM specification |
| @@ -621,7 +621,7 @@ namespace · 40 unmodified lines | ||
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | assert(0 <= static_cast<std::size_t>(target_pc) && static_cast<std::size_t>(target_pc) < r.module_ref->code_section.size()); |
| 624 | − r.pc = static_cast<vm_pc_t>(target_pc); | |
| 624 | + r.next_pc = static_cast<vm_pc_t>(target_pc); | |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | EXEC_DECL(casew) { _case<word_t>(r); } |
| @@ -675,19 +675,19 @@ namespace · 47 unmodified lines | ||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | assert(0 <= static_cast<std::size_t>(target_pc) && static_cast<std::size_t>(target_pc) < r.module_ref->code_section.size()); |
| 678 | − r.pc = target_pc; | |
| 678 | + r.next_pc = target_pc; | |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | // |
| 682 | 682 | // String operations |
| 683 | 683 | // |
| 684 | 684 | |
| 685 | − EXEC_DECL(bltc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) < 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 686 | − EXEC_DECL(bgtc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) > 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 687 | − EXEC_DECL(blec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) <= 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 688 | − EXEC_DECL(bgec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) >= 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 689 | − EXEC_DECL(beqc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) == 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 690 | − EXEC_DECL(bnec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) != 0) r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 685 | + EXEC_DECL(bltc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) < 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 686 | + EXEC_DECL(bgtc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) > 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 687 | + EXEC_DECL(blec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) <= 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 688 | + EXEC_DECL(bgec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) >= 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 689 | + EXEC_DECL(beqc) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) == 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 690 | + EXEC_DECL(bnec) { if (vm_string_t::compare(at_val<vm_string_t>(r.src), at_val<vm_string_t>(r.mid)) != 0) r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 691 | 691 | |
| 692 | 692 | EXEC_DECL(lenc) |
| 693 | 693 | { |
| @@ -1454,7 +1454,7 @@ namespace · 760 unmodified lines | ||
| 1454 | 1454 | { |
| 1455 | 1455 | const auto current_top_frame = r.stack.peek_frame(); |
| 1456 | 1456 | assert(current_top_frame != nullptr); |
| 1457 | − r.pc = current_top_frame->prev_pc(); | |
| 1457 | + r.next_pc = current_top_frame->prev_pc(); | |
| 1458 | 1458 | |
| 1459 | 1459 | if (current_top_frame->prev_module_ref() != nullptr) |
| 1460 | 1460 | { |
| @@ -1477,7 +1477,7 @@ namespace · 16 unmodified lines | ||
| 1477 | 1477 | EXEC_DECL(call) |
| 1478 | 1478 | { |
| 1479 | 1479 | auto top_frame = r.stack.push_frame(); |
| 1480 | − top_frame->prev_pc() = r.pc; | |
| 1480 | + top_frame->prev_pc() = r.next_pc; | |
| 1481 | 1481 | |
| 1482 | 1482 | #ifndef NDEBUG |
| 1483 | 1483 | // Validate the stack state |
| @@ -1486,7 +1486,7 @@ namespace · 2 unmodified lines | ||
| 1486 | 1486 | assert(top_frame->base() == frame_base_pointer); |
| 1487 | 1487 | #endif |
| 1488 | 1488 | |
| 1489 | − r.pc = vt_ref<vm_pc_t>(r.dest); | |
| 1489 | + r.next_pc = vt_ref<vm_pc_t>(r.dest); | |
| 1490 | 1490 | |
| 1491 | 1491 | debug::log_msg(debug::component_trace_t::stack, debug::log_level_t::debug, "enter: function"); |
| 1492 | 1492 | } |
| @@ -1514,7 +1514,7 @@ namespace · 21 unmodified lines | ||
| 1514 | 1514 | #endif |
| 1515 | 1515 | |
| 1516 | 1516 | // Store current state |
| 1517 | − top_frame->prev_pc() = r.pc; | |
| 1517 | + top_frame->prev_pc() = r.next_pc; | |
| 1518 | 1518 | top_frame->prev_module_ref() = r.module_ref; |
| 1519 | 1519 | |
| 1520 | 1520 | if (debug::is_component_tracing_enabled<debug::component_trace_t::stack>()) |
| @@ -1533,7 +1533,7 @@ namespace · 12 unmodified lines | ||
| 1533 | 1533 | r.module_ref = target_module; |
| 1534 | 1534 | r.module_ref->add_ref(); |
| 1535 | 1535 | r.mp_base = r.module_ref->mp_base; |
| 1536 | − r.pc = function_pc; | |
| 1536 | + r.next_pc = function_pc; | |
| 1537 | 1537 | |
| 1538 | 1538 | if (r.module_ref->is_builtin_module()) |
| 1539 | 1539 | { |
| @@ -1554,7 +1554,7 @@ namespace · 14 unmodified lines | ||
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | − EXEC_DECL(jmp) { r.pc = vt_ref<vm_pc_t>(r.dest); } | |
| 1557 | + EXEC_DECL(jmp) { r.next_pc = vt_ref<vm_pc_t>(r.dest); } | |
| 1558 | 1558 | |
| 1559 | 1559 | EXEC_DECL(goto_) |
| 1560 | 1560 | { |
| @@ -1563,7 +1563,7 @@ namespace · 2 unmodified lines | ||
| 1563 | 1563 | assert(r.dest != nullptr); |
| 1564 | 1564 | const auto pc_table = reinterpret_cast<vm_pc_t *>(r.dest); |
| 1565 | 1565 | |
| 1566 | − r.pc = pc_table[pc_index]; | |
| 1566 | + r.next_pc = pc_table[pc_index]; | |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | // |
| @@ -1673,8 +1673,7 @@ namespace · 103 unmodified lines | ||
| 1673 | 1673 | vm_frame_t *target_frame; |
| 1674 | 1674 | vm_pc_t handler_pc; |
| 1675 | 1675 | |
| 1676 | − // The faulting pc is minus one since the VM has already incremented the counter. | |
| 1677 | − const auto faulting_pc = r.pc - 1; | |
| 1676 | + const auto faulting_pc = r.pc; | |
| 1678 | 1677 | |
| 1679 | 1678 | assert(r.module_ref != nullptr); |
| 1680 | 1679 | std::tie(handler, target_frame, handler_pc) = find_exception_handler(r.stack, *r.module_ref, faulting_pc, *exception_id); |
| @@ -1718,7 +1717,7 @@ namespace · 37 unmodified lines | ||
| 1718 | 1717 | // Set the exception destination. |
| 1719 | 1718 | pt_ref(exception_destination) = e->get_allocation(); |
| 1720 | 1719 | |
| 1721 | − r.pc = handler_pc; | |
| 1720 | + r.next_pc = handler_pc; | |
| 1722 | 1721 | } |
| 1723 | 1722 | |
| 1724 | 1723 | // [SPEC] Added to support debugger. |