aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/comp.c107
1 files changed, 56 insertions, 51 deletions
diff --git a/src/comp.c b/src/comp.c
index 1e06f83dcbd..162716279b2 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -468,7 +468,7 @@ load_gccjit_if_necessary (bool mandatory)
468 468
469 469
470/* Increase this number to force a new Vcomp_abi_hash to be generated. */ 470/* Increase this number to force a new Vcomp_abi_hash to be generated. */
471#define ABI_VERSION "11" 471#define ABI_VERSION "12"
472 472
473/* Length of the hashes used for eln file naming. */ 473/* Length of the hashes used for eln file naming. */
474#define HASH_LENGTH 8 474#define HASH_LENGTH 8
@@ -630,6 +630,7 @@ typedef struct {
630 gcc_jit_function *add1; 630 gcc_jit_function *add1;
631 gcc_jit_function *sub1; 631 gcc_jit_function *sub1;
632 gcc_jit_function *negate; 632 gcc_jit_function *negate;
633 gcc_jit_function *eq;
633 gcc_jit_function *car; 634 gcc_jit_function *car;
634 gcc_jit_function *cdr; 635 gcc_jit_function *cdr;
635 gcc_jit_function *setcar; 636 gcc_jit_function *setcar;
@@ -693,6 +694,7 @@ static void *helper_link_table[] =
693 helper_unbind_n, 694 helper_unbind_n,
694 helper_save_restriction, 695 helper_save_restriction,
695 helper_GET_SYMBOL_WITH_POSITION, 696 helper_GET_SYMBOL_WITH_POSITION,
697 slow_eq,
696 helper_sanitizer_assert, 698 helper_sanitizer_assert,
697 record_unwind_current_buffer, 699 record_unwind_current_buffer,
698 set_internal, 700 set_internal,
@@ -1481,17 +1483,6 @@ emit_CONSP (gcc_jit_rvalue *obj)
1481} 1483}
1482 1484
1483static gcc_jit_rvalue * 1485static gcc_jit_rvalue *
1484emit_BARE_SYMBOL_P (gcc_jit_rvalue *obj)
1485{
1486 emit_comment ("BARE_SYMBOL_P");
1487
1488 return gcc_jit_context_new_cast (comp.ctxt,
1489 NULL,
1490 emit_TAGGEDP (obj, Lisp_Symbol),
1491 comp.bool_type);
1492}
1493
1494static gcc_jit_rvalue *
1495emit_SYMBOL_WITH_POS_P (gcc_jit_rvalue *obj) 1486emit_SYMBOL_WITH_POS_P (gcc_jit_rvalue *obj)
1496{ 1487{
1497 emit_comment ("SYMBOL_WITH_POS_P"); 1488 emit_comment ("SYMBOL_WITH_POS_P");
@@ -1511,52 +1502,46 @@ emit_SYMBOL_WITH_POS_P (gcc_jit_rvalue *obj)
1511} 1502}
1512 1503
1513static gcc_jit_rvalue * 1504static gcc_jit_rvalue *
1514emit_SYMBOL_WITH_POS_SYM (gcc_jit_rvalue *obj) 1505emit_slow_eq (gcc_jit_rvalue *x, gcc_jit_rvalue *y)
1515{ 1506{
1516 emit_comment ("SYMBOL_WITH_POS_SYM"); 1507 gcc_jit_rvalue *args[] =
1508 { emit_coerce (comp.lisp_obj_type, x),
1509 emit_coerce (comp.lisp_obj_type, y) };
1517 1510
1518 gcc_jit_rvalue *arg [] = { obj }; 1511 return emit_call (intern_c_string ("slow_eq"),
1519 return gcc_jit_context_new_call (comp.ctxt, 1512 comp.bool_type,
1520 NULL, 1513 ARRAYELTS (args),
1521 comp.symbol_with_pos_sym, 1514 args,
1522 1, 1515 false);
1523 arg);
1524} 1516}
1525 1517
1526static gcc_jit_rvalue * 1518static gcc_jit_rvalue *
1527emit_EQ (gcc_jit_rvalue *x, gcc_jit_rvalue *y) 1519emit_EQ (gcc_jit_rvalue *x, gcc_jit_rvalue *y)
1528{ 1520{
1529 return 1521 gcc_jit_rvalue *base_eq = emit_BASE_EQ (x, y);
1530 emit_OR ( 1522 gcc_jit_rvalue *symbols_with_pos_enabled_rval = gcc_jit_lvalue_as_rvalue (
1531 gcc_jit_context_new_comparison ( 1523 gcc_jit_rvalue_dereference (comp.f_symbols_with_pos_enabled_ref,
1532 comp.ctxt, NULL, 1524 NULL));
1533 GCC_JIT_COMPARISON_EQ, 1525
1534 emit_XLI (x), emit_XLI (y)), 1526 gcc_jit_rvalue *expect_args[] =
1535 emit_AND ( 1527 { emit_coerce (comp.long_type, symbols_with_pos_enabled_rval),
1536 gcc_jit_lvalue_as_rvalue ( 1528 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1537 gcc_jit_rvalue_dereference (comp.f_symbols_with_pos_enabled_ref, 1529 comp.long_type,
1538 NULL)), 1530 0) };
1539 emit_OR ( 1531
1540 emit_AND ( 1532 gcc_jit_rvalue *likely_symbols_with_pos_enabled = emit_coerce (
1541 emit_SYMBOL_WITH_POS_P (x), 1533 comp.bool_type,
1542 emit_OR ( 1534 gcc_jit_context_new_call (
1543 emit_AND ( 1535 comp.ctxt,
1544 emit_SYMBOL_WITH_POS_P (y), 1536 NULL,
1545 emit_BASE_EQ ( 1537 gcc_jit_context_get_builtin_function (comp.ctxt,
1546 emit_XLI (emit_SYMBOL_WITH_POS_SYM (x)), 1538 "__builtin_expect"),
1547 emit_XLI (emit_SYMBOL_WITH_POS_SYM (y)))), 1539 2,
1548 emit_AND ( 1540 expect_args));
1549 emit_BARE_SYMBOL_P (y), 1541
1550 emit_BASE_EQ ( 1542 return emit_OR (
1551 emit_XLI (emit_SYMBOL_WITH_POS_SYM (x)), 1543 base_eq,
1552 emit_XLI (y))))), 1544 emit_AND (likely_symbols_with_pos_enabled, emit_slow_eq (x, y)));
1553 emit_AND (
1554 emit_BARE_SYMBOL_P (x),
1555 emit_AND (
1556 emit_SYMBOL_WITH_POS_P (y),
1557 emit_BASE_EQ (
1558 emit_XLI (x),
1559 emit_XLI (emit_SYMBOL_WITH_POS_SYM (y))))))));
1560} 1545}
1561 1546
1562static gcc_jit_rvalue * 1547static gcc_jit_rvalue *
@@ -2599,6 +2584,21 @@ emit_consp (Lisp_Object insn)
2599} 2584}
2600 2585
2601static gcc_jit_rvalue * 2586static gcc_jit_rvalue *
2587emit_eq (Lisp_Object insn)
2588{
2589 gcc_jit_rvalue *x = emit_mvar_rval (SECOND (insn));
2590 gcc_jit_rvalue *y = emit_mvar_rval (THIRD (insn));
2591 gcc_jit_rvalue *res = emit_EQ (x, y);
2592 res = emit_coerce (comp.bool_type, res);
2593 return gcc_jit_context_new_call (comp.ctxt,
2594 NULL,
2595 comp.bool_to_lisp_obj,
2596 1,
2597 &res);
2598}
2599
2600
2601static gcc_jit_rvalue *
2602emit_car (Lisp_Object insn) 2602emit_car (Lisp_Object insn)
2603{ 2603{
2604 return emit_call_with_type_hint (comp.car, insn, Qcons); 2604 return emit_call_with_type_hint (comp.car, insn, Qcons);
@@ -2932,6 +2932,10 @@ declare_runtime_imported_funcs (void)
2932 2932
2933 args[0] = comp.lisp_obj_type; 2933 args[0] = comp.lisp_obj_type;
2934 args[1] = comp.lisp_obj_type; 2934 args[1] = comp.lisp_obj_type;
2935 ADD_IMPORTED (slow_eq, comp.bool_type, 2, args);
2936
2937 args[0] = comp.lisp_obj_type;
2938 args[1] = comp.lisp_obj_type;
2935 ADD_IMPORTED (helper_sanitizer_assert, comp.lisp_obj_type, 2, args); 2939 ADD_IMPORTED (helper_sanitizer_assert, comp.lisp_obj_type, 2, args);
2936 2940
2937 ADD_IMPORTED (record_unwind_current_buffer, comp.void_type, 0, NULL); 2941 ADD_IMPORTED (record_unwind_current_buffer, comp.void_type, 0, NULL);
@@ -4515,6 +4519,7 @@ Return t on success. */)
4515 register_emitter (Qadd1, emit_add1); 4519 register_emitter (Qadd1, emit_add1);
4516 register_emitter (Qsub1, emit_sub1); 4520 register_emitter (Qsub1, emit_sub1);
4517 register_emitter (Qconsp, emit_consp); 4521 register_emitter (Qconsp, emit_consp);
4522 register_emitter (Qeq, emit_eq);
4518 register_emitter (Qcar, emit_car); 4523 register_emitter (Qcar, emit_car);
4519 register_emitter (Qcdr, emit_cdr); 4524 register_emitter (Qcdr, emit_cdr);
4520 register_emitter (Qsetcar, emit_setcar); 4525 register_emitter (Qsetcar, emit_setcar);