aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-21 12:19:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-21 12:19:47 -0300
commit3df5624ff432b340fe122988fe6d025ad3217946 (patch)
tree2abdd6d7de1245a2dcaf887c9ca28d3f259e7a49
parentbe78aeae4c429d7d68af3a3e1b0cf8e52fcff160 (diff)
downloadlua-3df5624ff432b340fe122988fe6d025ad3217946.tar.gz
lua-3df5624ff432b340fe122988fe6d025ad3217946.tar.bz2
lua-3df5624ff432b340fe122988fe6d025ad3217946.zip
Fixed bug when yiedling inside OP_ADDK opcode
The family of opcodes OP_ADDK (arithmetic operators with K constant) were not being handled in 'luaV_finishOp', which completes their task after an yield.
-rw-r--r--lvm.c3
-rw-r--r--testes/coroutine.lua11
2 files changed, 14 insertions, 0 deletions
diff --git a/lvm.c b/lvm.c
index 1cfc1035..303954f0 100644
--- a/lvm.c
+++ b/lvm.c
@@ -720,6 +720,9 @@ void luaV_finishOp (lua_State *L) {
720 case OP_ADDI: case OP_SUBI: 720 case OP_ADDI: case OP_SUBI:
721 case OP_MULI: case OP_DIVI: case OP_IDIVI: 721 case OP_MULI: case OP_DIVI: case OP_IDIVI:
722 case OP_MODI: case OP_POWI: 722 case OP_MODI: case OP_POWI:
723 case OP_ADDK: case OP_SUBK:
724 case OP_MULK: case OP_DIVK: case OP_IDIVK:
725 case OP_MODK: case OP_POWK:
723 case OP_ADD: case OP_SUB: 726 case OP_ADD: case OP_SUB:
724 case OP_MUL: case OP_DIV: case OP_IDIV: 727 case OP_MUL: case OP_DIV: case OP_IDIV:
725 case OP_BANDK: case OP_BORK: case OP_BXORK: 728 case OP_BANDK: case OP_BORK: case OP_BXORK:
diff --git a/testes/coroutine.lua b/testes/coroutine.lua
index 79bbf2ea..26ed1f6a 100644
--- a/testes/coroutine.lua
+++ b/testes/coroutine.lua
@@ -724,6 +724,17 @@ assert(run(function () return a / b end, {"div"}) == 10/12)
724assert(run(function () return a % b end, {"mod"}) == 10) 724assert(run(function () return a % b end, {"mod"}) == 10)
725assert(run(function () return a // b end, {"idiv"}) == 0) 725assert(run(function () return a // b end, {"idiv"}) == 0)
726 726
727-- repeat tests with larger constants (to use 'K' opcodes)
728local a1000 = new(1000)
729
730assert(run(function () return a1000 + 1000 end, {"add"}) == 2000)
731assert(run(function () return a1000 - 25000 end, {"sub"}) == -24000)
732assert(run(function () return 2000 * a end, {"mul"}) == 20000)
733assert(run(function () return a1000 / 1000 end, {"div"}) == 1)
734assert(run(function () return a1000 % 600 end, {"mod"}) == 400)
735assert(run(function () return a1000 // 500 end, {"idiv"}) == 2)
736
737
727 738
728assert(run(function () return a % b end, {"mod"}) == 10) 739assert(run(function () return a % b end, {"mod"}) == 10)
729 740