diff options
| author | Andrea Corallo | 2019-09-22 20:58:26 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:37:53 +0100 |
| commit | 59d53e1fde516b911c29cedf338779df29f59dff (patch) | |
| tree | e84e2067dae2db49589af3628c8901b136979be8 | |
| parent | 84caa1a404cb89a6f02aa1cb517f5251e7e0e022 (diff) | |
| download | emacs-59d53e1fde516b911c29cedf338779df29f59dff.tar.gz emacs-59d53e1fde516b911c29cedf338779df29f59dff.zip | |
fix push handler propagation
| -rw-r--r-- | lisp/emacs-lisp/comp.el | 10 | ||||
| -rw-r--r-- | src/comp.c | 20 |
2 files changed, 19 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 24548242c37..34aafe401d4 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el | |||
| @@ -644,7 +644,9 @@ If NEGATED non nil negate the tested condition." | |||
| 644 | (let ((guarded-bb (comp-new-block-sym))) | 644 | (let ((guarded-bb (comp-new-block-sym))) |
| 645 | (comp-block-maybe-add :name guarded-bb :sp (comp-sp)) | 645 | (comp-block-maybe-add :name guarded-bb :sp (comp-sp)) |
| 646 | (let ((handler-bb (comp-lap-to-limple-bb guarded-label))) | 646 | (let ((handler-bb (comp-lap-to-limple-bb guarded-label))) |
| 647 | (comp-emit (list 'push-handler (comp-slot+1) | 647 | (comp-emit (list 'push-handler |
| 648 | (comp-slot+1) | ||
| 649 | (comp-slot+1) | ||
| 648 | handler-type | 650 | handler-type |
| 649 | handler-bb | 651 | handler-bb |
| 650 | guarded-bb)) | 652 | guarded-bb)) |
| @@ -1022,7 +1024,7 @@ Top level forms for the current context are rendered too." | |||
| 1022 | (cl-loop with blocks = (comp-func-blocks comp-func) | 1024 | (cl-loop with blocks = (comp-func-blocks comp-func) |
| 1023 | for bb being each hash-value of blocks | 1025 | for bb being each hash-value of blocks |
| 1024 | for last-insn = (car (last (comp-block-insns bb))) | 1026 | for last-insn = (car (last (comp-block-insns bb))) |
| 1025 | for (op first second third forth) = last-insn | 1027 | for (op first second third forth fifth) = last-insn |
| 1026 | do (cl-case op | 1028 | do (cl-case op |
| 1027 | (jump | 1029 | (jump |
| 1028 | (edge-add :src bb :dst (gethash first blocks))) | 1030 | (edge-add :src bb :dst (gethash first blocks))) |
| @@ -1033,8 +1035,8 @@ Top level forms for the current context are rendered too." | |||
| 1033 | (edge-add :src bb :dst (gethash second blocks)) | 1035 | (edge-add :src bb :dst (gethash second blocks)) |
| 1034 | (edge-add :src bb :dst (gethash third blocks))) | 1036 | (edge-add :src bb :dst (gethash third blocks))) |
| 1035 | (push-handler | 1037 | (push-handler |
| 1036 | (edge-add :src bb :dst (gethash third blocks)) | 1038 | (edge-add :src bb :dst (gethash forth blocks)) |
| 1037 | (edge-add :src bb :dst (gethash forth blocks))) | 1039 | (edge-add :src bb :dst (gethash fifth blocks))) |
| 1038 | (return) | 1040 | (return) |
| 1039 | (otherwise | 1041 | (otherwise |
| 1040 | (error "Block %s does not end with a branch in func %s" | 1042 | (error "Block %s does not end with a branch in func %s" |
diff --git a/src/comp.c b/src/comp.c index afc7a3b1873..4905dbfdcaf 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -62,6 +62,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 62 | XCAR (XCDR (XCDR (x))) | 62 | XCAR (XCDR (XCDR (x))) |
| 63 | #define FORTH(x) \ | 63 | #define FORTH(x) \ |
| 64 | XCAR (XCDR (XCDR (XCDR (x)))) | 64 | XCAR (XCDR (XCDR (XCDR (x)))) |
| 65 | #define FIFTH(x) \ | ||
| 66 | XCAR (XCDR (XCDR (XCDR (XCDR (x))))) | ||
| 65 | 67 | ||
| 66 | #define FUNCALL1(fun, arg) \ | 68 | #define FUNCALL1(fun, arg) \ |
| 67 | CALLN (Ffuncall, intern_c_string (STR(fun)), arg) | 69 | CALLN (Ffuncall, intern_c_string (STR(fun)), arg) |
| @@ -1149,7 +1151,11 @@ emit_limple_push_handler (gcc_jit_rvalue *handler, gcc_jit_rvalue *handler_type, | |||
| 1149 | gcc_jit_block *handler_bb, gcc_jit_block *guarded_bb, | 1151 | gcc_jit_block *handler_bb, gcc_jit_block *guarded_bb, |
| 1150 | Lisp_Object clobbered_mvar) | 1152 | Lisp_Object clobbered_mvar) |
| 1151 | { | 1153 | { |
| 1152 | /* Ex: (push-handler #s(comp-mvar 6 0 t (arith-error) nil) 1 bb_3 bb_2). */ | 1154 | /* |
| 1155 | Ex: (push-handler #s(comp-mvar 1 8 nil nil nil nil) | ||
| 1156 | #s(comp-mvar 1 7 t done symbol nil) | ||
| 1157 | catcher bb_2 bb_1). | ||
| 1158 | */ | ||
| 1153 | 1159 | ||
| 1154 | static unsigned pushhandler_n; /* FIXME move at ctxt or func level. */ | 1160 | static unsigned pushhandler_n; /* FIXME move at ctxt or func level. */ |
| 1155 | 1161 | ||
| @@ -1158,8 +1164,7 @@ emit_limple_push_handler (gcc_jit_rvalue *handler, gcc_jit_rvalue *handler_type, | |||
| 1158 | gcc_jit_function_new_local (comp.func, | 1164 | gcc_jit_function_new_local (comp.func, |
| 1159 | NULL, | 1165 | NULL, |
| 1160 | comp.handler_ptr_type, | 1166 | comp.handler_ptr_type, |
| 1161 | format_string ("c_%u", | 1167 | format_string ("c_%u", pushhandler_n)); |
| 1162 | pushhandler_n)); | ||
| 1163 | 1168 | ||
| 1164 | gcc_jit_rvalue *args[] = { handler, handler_type }; | 1169 | gcc_jit_rvalue *args[] = { handler, handler_type }; |
| 1165 | gcc_jit_block_add_assignment ( | 1170 | gcc_jit_block_add_assignment ( |
| @@ -1263,9 +1268,10 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1263 | { | 1268 | { |
| 1264 | gcc_jit_rvalue *handler = emit_mvar_val (arg0); | 1269 | gcc_jit_rvalue *handler = emit_mvar_val (arg0); |
| 1265 | int h_num UNINIT; | 1270 | int h_num UNINIT; |
| 1266 | if (EQ (SECOND (args), Qcatcher)) | 1271 | Lisp_Object handler_spec = THIRD (args); |
| 1272 | if (EQ (handler_spec, Qcatcher)) | ||
| 1267 | h_num = CATCHER; | 1273 | h_num = CATCHER; |
| 1268 | else if (EQ (SECOND (args), Qcondition_case)) | 1274 | else if (EQ (handler_spec, Qcondition_case)) |
| 1269 | h_num = CONDITION_CASE; | 1275 | h_num = CONDITION_CASE; |
| 1270 | else | 1276 | else |
| 1271 | ice ("incoherent insn"); | 1277 | ice ("incoherent insn"); |
| @@ -1273,8 +1279,8 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1273 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1279 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1274 | comp.int_type, | 1280 | comp.int_type, |
| 1275 | h_num); | 1281 | h_num); |
| 1276 | gcc_jit_block *handler_bb = retrive_block (THIRD (args)); | 1282 | gcc_jit_block *handler_bb = retrive_block (FORTH (args)); |
| 1277 | gcc_jit_block *guarded_bb = retrive_block (FORTH (args)); | 1283 | gcc_jit_block *guarded_bb = retrive_block (FIFTH (args)); |
| 1278 | emit_limple_push_handler (handler, handler_type, handler_bb, guarded_bb, | 1284 | emit_limple_push_handler (handler, handler_type, handler_bb, guarded_bb, |
| 1279 | arg0); | 1285 | arg0); |
| 1280 | } | 1286 | } |