aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-01-02 12:19:54 +0100
committerMattias EngdegÄrd2022-01-24 11:41:47 +0100
commit11e1abd5cc76c9adc72746c25688cf23365a9eb0 (patch)
treed33a2457222b61710505dbf40fe66333773da135 /src/bytecode.c
parent721357b86856505324b5f32584d5eae0ba9ab4ac (diff)
downloademacs-11e1abd5cc76c9adc72746c25688cf23365a9eb0.tar.gz
emacs-11e1abd5cc76c9adc72746c25688cf23365a9eb0.zip
Open-code aref and aset in bytecode interpreter
* src/bytecode.c (exec_byte_code): Inline aref and aset for vectors and records, since this is important for code that makes heavy use of arrays and/or objects.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index b2e8f4a9166..76ef2fb661c 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -948,15 +948,39 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
948 948
949 CASE (Baref): 949 CASE (Baref):
950 { 950 {
951 Lisp_Object v1 = POP; 951 Lisp_Object idxval = POP;
952 TOP = Faref (TOP, v1); 952 Lisp_Object arrayval = TOP;
953 ptrdiff_t size;
954 ptrdiff_t idx;
955 if (((VECTORP (arrayval) && (size = ASIZE (arrayval), true))
956 || (RECORDP (arrayval) && (size = PVSIZE (arrayval), true)))
957 && FIXNUMP (idxval)
958 && (idx = XFIXNUM (idxval),
959 idx >= 0 && idx < size))
960 TOP = AREF (arrayval, idx);
961 else
962 TOP = Faref (arrayval, idxval);
953 NEXT; 963 NEXT;
954 } 964 }
955 965
956 CASE (Baset): 966 CASE (Baset):
957 { 967 {
958 Lisp_Object v2 = POP, v1 = POP; 968 Lisp_Object newelt = POP;
959 TOP = Faset (TOP, v1, v2); 969 Lisp_Object idxval = POP;
970 Lisp_Object arrayval = TOP;
971 ptrdiff_t size;
972 ptrdiff_t idx;
973 if (((VECTORP (arrayval) && (size = ASIZE (arrayval), true))
974 || (RECORDP (arrayval) && (size = PVSIZE (arrayval), true)))
975 && FIXNUMP (idxval)
976 && (idx = XFIXNUM (idxval),
977 idx >= 0 && idx < size))
978 {
979 ASET (arrayval, idx, newelt);
980 TOP = newelt;
981 }
982 else
983 TOP = Faset (arrayval, idxval, newelt);
960 NEXT; 984 NEXT;
961 } 985 }
962 986