Mercurial > hgweb > octave
changeset 32273:2779eb2ecb74
VM Fix using WIDE opcode extension for command type calls (bug #64560)
E.g. "pi;" would not work if the identifier 'pi' was the 256:th or later
identifier in the function, due to forgotten wide slot check.
* libinterp/parse-tree/pt-bytecode-vm.cc: Check for slot size, add offset
* test/compile/bytecode_misc.m: Update tests
| author | Petter T. <petter.vilhelm@gmail.com> |
|---|---|
| date | Sat, 19 Aug 2023 11:25:42 +0200 |
| parents | b8d5428ed68b |
| children | a32650514d38 |
| files | libinterp/parse-tree/pt-bytecode-vm.cc test/compile/bytecode_misc.m |
| diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-bytecode-vm.cc +++ b/libinterp/parse-tree/pt-bytecode-vm.cc @@ -1683,7 +1683,9 @@ // Also skip ip to the end of the opcode. int nargout; bool push_classdef_metas = false; - INSTR opcode = static_cast<INSTR> (*(ip - 2)); + int wide_opcode_offset = slot < 256 ? 0 : -1; // If WIDE is used, we need to look further back + + INSTR opcode = static_cast<INSTR> (*(ip - 2 + wide_opcode_offset)); if (opcode == INSTR::PUSH_SLOT_NARGOUT1 || opcode == INSTR::PUSH_PI) nargout = 1;
--- a/test/compile/bytecode_misc.m +++ b/test/compile/bytecode_misc.m @@ -111,6 +111,20 @@ assert (s.s == 2); s.w.s = 3; assert (s.w.s == 3); + + % Test command function calling + pi; % WIDE PUSH_PI + assert (round (100 * pi) == 314) + + suby1; + assert (suby1 == 1); + suby2; + [a, b] = suby2; + assert (a == 1) + assert (b == 2) + [a, b] = suby2 (); + assert (a == 1) + assert (b == 2) end @@ -119,3 +133,11 @@ eval (sprintf ("assert (a%03d == %d);", i, i)); end end + +function ret = suby1 + ret = 1; +end + +function [a, b] = suby2 + a = 1; b = 2; +end \ No newline at end of file
