@@ -568,6 +568,7 @@ recording::context::context (context *parent_ctxt)
568
568
m_last_error_str (NULL ),
569
569
m_owns_last_error_str (false ),
570
570
m_mementos (),
571
+ m_type_mementos (),
571
572
m_compound_types (),
572
573
m_globals (),
573
574
m_functions (),
@@ -617,6 +618,10 @@ recording::context::~context ()
617
618
{
618
619
delete m;
619
620
}
621
+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
622
+ {
623
+ delete m;
624
+ }
620
625
621
626
for (i = 0 ; i < GCC_JIT_NUM_STR_OPTIONS; ++i)
622
627
free (m_str_options[i]);
@@ -650,6 +655,14 @@ recording::context::record (memento *m)
650
655
m_mementos.safe_push (m);
651
656
}
652
657
658
+ void
659
+ recording::context::record_type (memento *m)
660
+ {
661
+ gcc_assert (m);
662
+
663
+ m_type_mementos.safe_push (m);
664
+ }
665
+
653
666
/* Replay this context (and any parents) into the given replayer. */
654
667
655
668
void
@@ -681,6 +694,25 @@ recording::context::replay_into (replayer *r)
681
694
return ;
682
695
683
696
/* Replay this context's saved operations into r. */
697
+
698
+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
699
+ {
700
+ /* Disabled low-level debugging, here if we need it: print what
701
+ we're replaying.
702
+ Note that the calls to get_debug_string might lead to more
703
+ mementos being created for the strings.
704
+ This can also be used to exercise the debug_string
705
+ machinery. */
706
+ if (0 )
707
+ printf (" context %p replaying (%p): %s\n " ,
708
+ (void *)this , (void *)m, m->get_debug_string ());
709
+
710
+ m->replay_into (r);
711
+
712
+ if (r->errors_occurred ())
713
+ return ;
714
+ }
715
+
684
716
FOR_EACH_VEC_ELT (m_mementos, i, m)
685
717
{
686
718
/* Disabled low-level debugging, here if we need it: print what
@@ -720,6 +752,11 @@ recording::context::disassociate_from_playback ()
720
752
if (m_parent_ctxt)
721
753
m_parent_ctxt->disassociate_from_playback ();
722
754
755
+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
756
+ {
757
+ m->set_playback_obj (NULL );
758
+ }
759
+
723
760
FOR_EACH_VEC_ELT (m_mementos, i, m)
724
761
{
725
762
m->set_playback_obj (NULL );
@@ -785,7 +822,7 @@ recording::context::get_type (enum gcc_jit_types kind)
785
822
else
786
823
{
787
824
recording::type *result = new memento_of_get_type (this , kind);
788
- record (result);
825
+ record_type (result);
789
826
m_basic_types[kind] = result;
790
827
}
791
828
}
@@ -863,7 +900,7 @@ recording::context::new_array_type (recording::location *loc,
863
900
}
864
901
recording::type *result =
865
902
new recording::array_type (this , loc, element_type, num_elements);
866
- record (result);
903
+ record_type (result);
867
904
return result;
868
905
}
869
906
@@ -880,7 +917,7 @@ recording::context::new_field (recording::location *loc,
880
917
{
881
918
recording::field *result =
882
919
new recording::field (this , loc, type, new_string (name));
883
- record (result);
920
+ record_type (result);
884
921
return result;
885
922
}
886
923
@@ -913,7 +950,7 @@ recording::context::new_struct_type (recording::location *loc,
913
950
const char *name)
914
951
{
915
952
recording::struct_ *result = new struct_ (this , loc, new_string (name));
916
- record (result);
953
+ record_type (result);
917
954
m_compound_types.safe_push (result);
918
955
return result;
919
956
}
@@ -929,7 +966,7 @@ recording::context::new_union_type (recording::location *loc,
929
966
const char *name)
930
967
{
931
968
recording::union_ *result = new union_ (this , loc, new_string (name));
932
- record (result);
969
+ record_type (result);
933
970
m_compound_types.safe_push (result);
934
971
return result;
935
972
}
@@ -953,7 +990,7 @@ recording::context::new_function_type (recording::type *return_type,
953
990
param_types,
954
991
is_variadic,
955
992
is_target_builtin);
956
- record (fn_type);
993
+ record_type (fn_type);
957
994
return fn_type;
958
995
}
959
996
@@ -2181,6 +2218,8 @@ recording::context::dump_reproducer_to_file (const char *path)
2181
2218
2182
2219
r.write (" /* Replay of API calls for %s. */\n " ,
2183
2220
r.get_identifier (contexts[ctxt_idx]));
2221
+ FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_type_mementos , i, m)
2222
+ m->write_reproducer (r);
2184
2223
FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_mementos , i, m)
2185
2224
m->write_reproducer (r);
2186
2225
}
@@ -2485,7 +2524,7 @@ recording::type::get_pointer ()
2485
2524
if (!m_pointer_to_this_type)
2486
2525
{
2487
2526
m_pointer_to_this_type = new memento_of_get_pointer (this );
2488
- m_ctxt->record (m_pointer_to_this_type);
2527
+ m_ctxt->record_type (m_pointer_to_this_type);
2489
2528
}
2490
2529
return m_pointer_to_this_type;
2491
2530
}
@@ -2499,7 +2538,7 @@ recording::type *
2499
2538
recording::type::get_const ()
2500
2539
{
2501
2540
recording::type *result = new memento_of_get_const (this );
2502
- m_ctxt->record (result);
2541
+ m_ctxt->record_type (result);
2503
2542
return result;
2504
2543
}
2505
2544
@@ -2512,7 +2551,7 @@ recording::type *
2512
2551
recording::type::get_restrict ()
2513
2552
{
2514
2553
recording::type *result = new memento_of_get_restrict (this );
2515
- m_ctxt->record (result);
2554
+ m_ctxt->record_type (result);
2516
2555
return result;
2517
2556
}
2518
2557
@@ -2525,7 +2564,7 @@ recording::type *
2525
2564
recording::type::get_volatile ()
2526
2565
{
2527
2566
recording::type *result = new memento_of_get_volatile (this );
2528
- m_ctxt->record (result);
2567
+ m_ctxt->record_type (result);
2529
2568
return result;
2530
2569
}
2531
2570
@@ -2539,7 +2578,7 @@ recording::type::get_aligned (size_t alignment_in_bytes)
2539
2578
{
2540
2579
recording::type *result
2541
2580
= new memento_of_get_aligned (this , alignment_in_bytes);
2542
- m_ctxt->record (result);
2581
+ m_ctxt->record_type (result);
2543
2582
return result;
2544
2583
}
2545
2584
@@ -2559,7 +2598,7 @@ recording::type::get_vector (size_t num_units)
2559
2598
{
2560
2599
recording::type *result
2561
2600
= new vector_type (this , num_units);
2562
- m_ctxt->record (result);
2601
+ m_ctxt->record_type (result);
2563
2602
return result;
2564
2603
}
2565
2604
@@ -3824,7 +3863,7 @@ recording::compound_type::set_fields (location *loc,
3824
3863
gcc_assert (m_fields == NULL );
3825
3864
3826
3865
m_fields = new fields (this , num_fields, field_array);
3827
- m_ctxt->record (m_fields);
3866
+ m_ctxt->record_type (m_fields);
3828
3867
}
3829
3868
3830
3869
/* Implementation of pure virtual hook recording::type::dereference for
@@ -4071,6 +4110,13 @@ recording::rvalue::access_field (recording::location *loc,
4071
4110
return result;
4072
4111
}
4073
4112
4113
+ void
4114
+ recording::rvalue::set_type (type *new_type)
4115
+ {
4116
+ gcc_assert (new_type);
4117
+ m_type = new_type;
4118
+ }
4119
+
4074
4120
/* Create a recording::dereference_field_rvalue instance and add it to
4075
4121
the rvalue's context's list of mementos.
4076
4122
0 commit comments