@@ -209,6 +209,18 @@ fn encode_variant_id(ebml_w: &mut Encoder, vid: DefId) {
209209 ebml_w. end_tag ( ) ;
210210}
211211
212+ pub fn write_closure_type ( ecx : & EncodeContext ,
213+ ebml_w : & mut Encoder ,
214+ closure_type : & ty:: ClosureTy ) {
215+ let ty_str_ctxt = & tyencode:: ctxt {
216+ diag : ecx. diag ,
217+ ds : def_to_string,
218+ tcx : ecx. tcx ,
219+ abbrevs : & ecx. type_abbrevs
220+ } ;
221+ tyencode:: enc_closure_ty ( ebml_w. writer , ty_str_ctxt, closure_type) ;
222+ }
223+
212224pub fn write_type ( ecx : & EncodeContext ,
213225 ebml_w : & mut Encoder ,
214226 typ : ty:: t ) {
@@ -1618,6 +1630,26 @@ fn encode_macro_defs(ecx: &EncodeContext,
16181630 ebml_w. end_tag ( ) ;
16191631}
16201632
1633+ fn encode_unboxed_closures < ' a > (
1634+ ecx : & ' a EncodeContext ,
1635+ ebml_w : & ' a mut Encoder ) {
1636+ ebml_w. start_tag ( tag_unboxed_closures) ;
1637+ for ( unboxed_closure_id, unboxed_closure_type) in
1638+ ecx. tcx . unboxed_closure_types . borrow ( ) . iter ( ) {
1639+ if unboxed_closure_id. krate != LOCAL_CRATE {
1640+ continue
1641+ }
1642+
1643+ ebml_w. start_tag ( tag_unboxed_closure) ;
1644+ encode_def_id ( ebml_w, * unboxed_closure_id) ;
1645+ ebml_w. start_tag ( tag_unboxed_closure_type) ;
1646+ write_closure_type ( ecx, ebml_w, unboxed_closure_type) ;
1647+ ebml_w. end_tag ( ) ;
1648+ ebml_w. end_tag ( ) ;
1649+ }
1650+ ebml_w. end_tag ( ) ;
1651+ }
1652+
16211653struct ImplVisitor < ' a , ' b , ' c > {
16221654 ecx : & ' a EncodeContext < ' b > ,
16231655 ebml_w : & ' a mut Encoder < ' c > ,
@@ -1787,6 +1819,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
17871819 native_lib_bytes : u64 ,
17881820 plugin_registrar_fn_bytes : u64 ,
17891821 macro_defs_bytes : u64 ,
1822+ unboxed_closure_bytes : u64 ,
17901823 impl_bytes : u64 ,
17911824 misc_bytes : u64 ,
17921825 item_bytes : u64 ,
@@ -1801,6 +1834,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
18011834 native_lib_bytes : 0 ,
18021835 plugin_registrar_fn_bytes : 0 ,
18031836 macro_defs_bytes : 0 ,
1837+ unboxed_closure_bytes : 0 ,
18041838 impl_bytes : 0 ,
18051839 misc_bytes : 0 ,
18061840 item_bytes : 0 ,
@@ -1873,6 +1907,11 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
18731907 encode_macro_defs ( & ecx, krate, & mut ebml_w) ;
18741908 stats. macro_defs_bytes = ebml_w. writer . tell ( ) . unwrap ( ) - i;
18751909
1910+ // Encode the types of all unboxed closures in this crate.
1911+ i = ebml_w. writer . tell ( ) . unwrap ( ) ;
1912+ encode_unboxed_closures ( & ecx, & mut ebml_w) ;
1913+ stats. unboxed_closure_bytes = ebml_w. writer . tell ( ) . unwrap ( ) - i;
1914+
18761915 // Encode the def IDs of impls, for coherence checking.
18771916 i = ebml_w. writer . tell ( ) . unwrap ( ) ;
18781917 encode_impls ( & ecx, krate, & mut ebml_w) ;
@@ -1911,6 +1950,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
19111950 println ! ( " native bytes: {}" , stats. native_lib_bytes) ;
19121951 println ! ( "plugin registrar bytes: {}" , stats. plugin_registrar_fn_bytes) ;
19131952 println ! ( " macro def bytes: {}" , stats. macro_defs_bytes) ;
1953+ println ! ( " unboxed closure bytes: {}" , stats. unboxed_closure_bytes) ;
19141954 println ! ( " impl bytes: {}" , stats. impl_bytes) ;
19151955 println ! ( " misc bytes: {}" , stats. misc_bytes) ;
19161956 println ! ( " item bytes: {}" , stats. item_bytes) ;
0 commit comments