@@ -676,28 +676,35 @@ impl<K: DepKind> DepGraph<K> {
676
676
None => { }
677
677
}
678
678
679
- let mut stack =
680
- MarkingStack { stack : vec ! [ prev_index] , sess : qcx. dep_context ( ) . sess ( ) , graph : data } ;
679
+ let mut stack = smallvec ! [ prev_index] ;
680
+ let _backtrace_print =
681
+ MarkingStack { stack : & mut stack, sess : qcx. dep_context ( ) . sess ( ) , graph : data } ;
681
682
682
683
// This DepNode and the corresponding query invocation existed
683
684
// in the previous compilation session too, so we can try to
684
685
// mark it as green by recursively marking all of its
685
686
// dependencies green.
686
- return self
687
- . try_mark_previous_green ( qcx, data, prev_index, & dep_node, & mut stack . stack )
687
+ let ret = self
688
+ . try_mark_previous_green ( qcx, data, prev_index, & dep_node, _backtrace_print . stack )
688
689
. map ( |dep_node_index| ( prev_index, dep_node_index) ) ;
689
690
691
+ // We succeeded, no backtrace.
692
+ std:: mem:: forget ( _backtrace_print) ;
693
+ return ret;
694
+
690
695
/// Remember the stack of queries we are forcing in the event of an incr. comp. panic.
691
- struct MarkingStack < ' a , K : DepKind > {
692
- stack : Vec < SerializedDepNodeIndex > ,
696
+ struct MarkingStack < ' a , ' v , K : DepKind > {
697
+ stack : & ' v mut SmallVec < [ SerializedDepNodeIndex ; 8 ] > ,
693
698
sess : & ' a rustc_session:: Session ,
694
699
graph : & ' a DepGraphData < K > ,
695
700
}
696
701
697
- impl < ' a , K : DepKind > Drop for MarkingStack < ' a , K > {
702
+ impl < ' a , ' v , K : DepKind > Drop for MarkingStack < ' a , ' v , K > {
698
703
/// Print the forcing backtrace.
704
+ #[ inline( never) ]
705
+ #[ cold]
699
706
fn drop ( & mut self ) {
700
- for & frame in self . stack . iter ( ) . skip ( 1 ) . rev ( ) {
707
+ for & frame in self . stack . iter ( ) . rev ( ) {
701
708
let node = self . graph . previous . index_to_node ( frame) ;
702
709
// Do not try to rely on DepNode's Debug implementation,
703
710
// since it may panic.
@@ -721,7 +728,7 @@ impl<K: DepKind> DepGraph<K> {
721
728
data : & DepGraphData < K > ,
722
729
parent_dep_node_index : SerializedDepNodeIndex ,
723
730
dep_node : & DepNode < K > ,
724
- stack : & mut Vec < SerializedDepNodeIndex > ,
731
+ stack : & mut SmallVec < [ SerializedDepNodeIndex ; 8 ] > ,
725
732
) -> Option < ( ) > {
726
733
let dep_dep_node_color = data. colors . get ( parent_dep_node_index) ;
727
734
let dep_dep_node = & data. previous . index_to_node ( parent_dep_node_index) ;
@@ -810,7 +817,7 @@ impl<K: DepKind> DepGraph<K> {
810
817
data : & DepGraphData < K > ,
811
818
prev_dep_node_index : SerializedDepNodeIndex ,
812
819
dep_node : & DepNode < K > ,
813
- stack : & mut Vec < SerializedDepNodeIndex > ,
820
+ stack : & mut SmallVec < [ SerializedDepNodeIndex ; 8 ] > ,
814
821
) -> Option < DepNodeIndex > {
815
822
#[ cfg( not( parallel_compiler) ) ]
816
823
{
0 commit comments