aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-01-02 12:19:54 +0100
committerMattias EngdegÄrd2022-01-11 15:22:48 +0100
commit1e439fe19aee2b3729d22a00ee416293c4e9c171 (patch)
treeaf8bbad170b342079245dede2dafbb6a86dc06d9 /src/bytecode.c
parent1eacfb3c888764908d2ee421e16c020e7343b5a1 (diff)
downloademacs-1e439fe19aee2b3729d22a00ee416293c4e9c171.tar.gz
emacs-1e439fe19aee2b3729d22a00ee416293c4e9c171.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 97d47a3d9c1..41455629cb9 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