Skip to content

Commit 06cb2e9

Browse files
committed
remove use of rbml and just use opaque encoder
1 parent 670f554 commit 06cb2e9

File tree

3 files changed

+16
-41
lines changed

3 files changed

+16
-41
lines changed

src/librustc_incremental/persist/load.rs

+11-23
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! Code to save/load the dep-graph from files.
1212
1313
use calculate_svh::SvhCalculate;
14-
use rbml::{self, Doc};
15-
use rbml::reader::{self, DecodeResult, Decoder};
14+
use rbml::Error;
15+
use rbml::opaque::Decoder;
1616
use rustc::dep_graph::DepNode;
1717
use rustc::middle::def_id::DefId;
1818
use rustc::ty;
@@ -66,42 +66,30 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
6666
}
6767
}
6868

69-
match decode_dep_graph(tcx, Doc::new(&data)) {
69+
match decode_dep_graph(tcx, &data) {
7070
Ok(dirty) => dirty,
7171
Err(err) => {
7272
bug!("decoding error in dep-graph from `{}`: {}", path.display(), err);
7373
}
7474
}
7575
}
7676

77-
pub fn decode_dep_graph<'tcx, 'doc>(tcx: &ty::TyCtxt<'tcx>, doc: rbml::Doc<'doc>)
78-
-> DecodeResult<()>
77+
pub fn decode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>, data: &[u8])
78+
-> Result<(), Error>
7979
{
80-
// First load the directory, which maps the def-ids found
81-
// elsewhere into `DefPath`. We can then refresh the `DefPath` to
82-
// obtain updated def-ids.
83-
let directory = {
84-
let directory_doc = reader::get_doc(doc, DIRECTORY_TAG);
85-
let mut decoder = Decoder::new(directory_doc);
86-
try!(DefIdDirectory::decode(&mut decoder))
87-
};
80+
// Deserialize the directory and dep-graph.
81+
let mut decoder = Decoder::new(data, 0);
82+
let directory = try!(DefIdDirectory::decode(&mut decoder));
83+
let serialized_dep_graph = try!(SerializedDepGraph::decode(&mut decoder));
8884

8985
debug!("decode_dep_graph: directory = {:#?}", directory);
86+
debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
9087

91-
// Retrace those paths to find their current location (if any).
88+
// Retrace the paths in the directory to find their current location (if any).
9289
let retraced = directory.retrace(tcx);
9390

9491
debug!("decode_dep_graph: retraced = {:#?}", retraced);
9592

96-
// Deserialize the dep-graph (which will include DefPathIndex entries)
97-
let serialized_dep_graph = {
98-
let dep_graph_doc = reader::get_doc(doc, DEP_GRAPH_TAG);
99-
let mut decoder = Decoder::new(dep_graph_doc);
100-
try!(SerializedDepGraph::decode(&mut decoder))
101-
};
102-
103-
debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
104-
10593
// Compute the set of Hir nodes whose data has changed.
10694
let mut dirty_nodes =
10795
initial_dirty_nodes(tcx, &serialized_dep_graph.hashes, &retraced);

src/librustc_incremental/persist/save.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// except according to those terms.
1010

1111
use calculate_svh::SvhCalculate;
12-
use rbml::writer::{EncodeResult, Encoder};
12+
use rbml::opaque::Encoder;
1313
use rustc::dep_graph::DepNode;
1414
use rustc::ty;
1515
use rustc_serialize::{Encodable as RustcEncodable};
16-
use std::io::{Cursor, Write};
16+
use std::io::{self, Cursor, Write};
1717
use std::fs::{self, File};
1818

1919
use super::data::*;
@@ -70,7 +70,7 @@ pub fn save_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>) {
7070

7171
pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
7272
encoder: &mut Encoder)
73-
-> EncodeResult
73+
-> io::Result<()>
7474
{
7575
// Here we take advantage of how RBML allows us to skip around
7676
// and encode the depgraph as a two-part structure:
@@ -126,19 +126,10 @@ pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
126126

127127
debug!("graph = {:#?}", graph);
128128

129-
// Encode the graph data into RBML.
130-
try!(encoder.start_tag(DEP_GRAPH_TAG));
131-
try!(graph.encode(encoder));
132-
try!(encoder.end_tag());
133-
134-
// Now encode the directory.
129+
// Encode the directory and then the graph data.
135130
let directory = builder.into_directory();
136-
137-
debug!("directory = {:#?}", directory);
138-
139-
try!(encoder.start_tag(DIRECTORY_TAG));
140131
try!(directory.encode(encoder));
141-
try!(encoder.end_tag());
132+
try!(graph.encode(encoder));
142133

143134
Ok(())
144135
}

src/librustc_incremental/persist/util.rs

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ use rustc::ty;
1212
use std::fs;
1313
use std::path::PathBuf;
1414

15-
pub const DEP_GRAPH_TAG: usize = 0x100;
16-
17-
pub const DIRECTORY_TAG: usize = DEP_GRAPH_TAG + 1;
18-
1915
pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
2016
// For now, just save/load dep-graph from
2117
// directory/dep_graph.rbml

0 commit comments

Comments
 (0)