ref: 5545234a412e42871f2c34f0c50fdc32a622e295
parent: e12d463972ec7d574d7a49bd2edf5263e397ae4f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Dec 30 13:08:04 EST 2024
vm: use locally declared value_t temporaries more
--- a/vm.inc
+++ b/vm.inc
@@ -334,7 +334,7 @@
FL(stack)[FL(sp)-1] = fl_neg(FL(stack)[FL(sp)-1]);
}
{
- fixnum_t a, b, c;
+ value_t a, b, c;
a = FL(stack)[FL(sp)-2];
b = FL(stack)[FL(sp)-1];
if(bothfixnums(a, b) && !sadd_overflow(numval(a), numval(b), &c) && fits_fixnum(c)){
@@ -605,30 +605,37 @@
NEXT_OP;
OP(OP_IDIV)
- FL(stack)[ipd] = (uintptr_t)ip;
- v = FL(stack)[FL(sp)-2];
- e = FL(stack)[FL(sp)-1];
- if(bothfixnums(v, e)){
- if(e == 0)
- DivideByZeroError();
- v = fixnum(numval(v) / numval(e));
- }else{
- v = fl_idiv2(v, e);
+ {
+ value_t a = FL(stack)[FL(sp)-2];
+ value_t b = FL(stack)[FL(sp)-1];
+ if(bothfixnums(a, b)){
+ if(b == 0){
+ FL(stack)[ipd] = (uintptr_t)ip;
+ DivideByZeroError();
+ }
+ v = fixnum(numval(a) / numval(b));
+ }else{
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = fl_idiv2(a, b);
+ }
+ POPN(1);
+ FL(stack)[FL(sp)-1] = v;
}
- POPN(1);
- FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_NUMEQ)
- v = FL(stack)[FL(sp)-2]; e = FL(stack)[FL(sp)-1];
- if(bothfixnums(v, e))
- v = v == e ? FL_t : FL_f;
- else{
- FL(stack)[ipd] = (uintptr_t)ip;
- v = numeric_compare(v, e, true, false, true) == 0 ? FL_t : FL_f;
+ {
+ value_t a = FL(stack)[FL(sp)-2];
+ value_t b = FL(stack)[FL(sp)-1];
+ if(bothfixnums(a, b))
+ v = a == b ? FL_t : FL_f;
+ else{
+ FL(stack)[ipd] = (uintptr_t)ip;
+ v = numeric_compare(a, b, true, false, true) == 0 ? FL_t : FL_f;
+ }
+ POPN(1);
+ FL(stack)[FL(sp)-1] = v;
}
- POPN(1);
- FL(stack)[FL(sp)-1] = v;
NEXT_OP;
OP(OP_COMPARE)