about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-04-05 18:37:51 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-04-06 12:42:47 -0400
commitf2051212c2ac670bf20f8467bac7898e72d4d34d (patch)
treed48971f7f69129cf65e05614419c0d199c72194d
parente9ec282df8fb658cca1a0a3acb2cb6cf62fd1f84 (diff)
downloadrust-f2051212c2ac670bf20f8467bac7898e72d4d34d.tar.gz
rust-f2051212c2ac670bf20f8467bac7898e72d4d34d.zip
remove use of rbml and just use opaque encoder
-rw-r--r--src/librustc_incremental/persist/load.rs34
-rw-r--r--src/librustc_incremental/persist/save.rs19
-rw-r--r--src/librustc_incremental/persist/util.rs4
3 files changed, 16 insertions, 41 deletions
diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs
index 30923f6826e..a86d1c3c13b 100644
--- a/src/librustc_incremental/persist/load.rs
+++ b/src/librustc_incremental/persist/load.rs
@@ -11,8 +11,8 @@
 //! Code to save/load the dep-graph from files.
 
 use calculate_svh::SvhCalculate;
-use rbml::{self, Doc};
-use rbml::reader::{self, DecodeResult, Decoder};
+use rbml::Error;
+use rbml::opaque::Decoder;
 use rustc::dep_graph::DepNode;
 use rustc::middle::def_id::DefId;
 use rustc::ty;
@@ -66,7 +66,7 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
         }
     }
 
-    match decode_dep_graph(tcx, Doc::new(&data)) {
+    match decode_dep_graph(tcx, &data) {
         Ok(dirty) => dirty,
         Err(err) => {
             bug!("decoding error in dep-graph from `{}`: {}", path.display(), err);
@@ -74,34 +74,22 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
     }
 }
 
-pub fn decode_dep_graph<'tcx, 'doc>(tcx: &ty::TyCtxt<'tcx>, doc: rbml::Doc<'doc>)
-                                    -> DecodeResult<()>
+pub fn decode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>, data: &[u8])
+                              -> Result<(), Error>
 {
-    // First load the directory, which maps the def-ids found
-    // elsewhere into `DefPath`. We can then refresh the `DefPath` to
-    // obtain updated def-ids.
-    let directory = {
-        let directory_doc = reader::get_doc(doc, DIRECTORY_TAG);
-        let mut decoder = Decoder::new(directory_doc);
-        try!(DefIdDirectory::decode(&mut decoder))
-    };
+    // Deserialize the directory and dep-graph.
+    let mut decoder = Decoder::new(data, 0);
+    let directory = try!(DefIdDirectory::decode(&mut decoder));
+    let serialized_dep_graph = try!(SerializedDepGraph::decode(&mut decoder));
 
     debug!("decode_dep_graph: directory = {:#?}", directory);
+    debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
 
-    // Retrace those paths to find their current location (if any).
+    // Retrace the paths in the directory to find their current location (if any).
     let retraced = directory.retrace(tcx);
 
     debug!("decode_dep_graph: retraced = {:#?}", retraced);
 
-    // Deserialize the dep-graph (which will include DefPathIndex entries)
-    let serialized_dep_graph = {
-        let dep_graph_doc = reader::get_doc(doc, DEP_GRAPH_TAG);
-        let mut decoder = Decoder::new(dep_graph_doc);
-        try!(SerializedDepGraph::decode(&mut decoder))
-    };
-
-    debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
-
     // Compute the set of Hir nodes whose data has changed.
     let mut dirty_nodes =
         initial_dirty_nodes(tcx, &serialized_dep_graph.hashes, &retraced);
diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs
index 1db129ca700..d88f9e42b08 100644
--- a/src/librustc_incremental/persist/save.rs
+++ b/src/librustc_incremental/persist/save.rs
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use calculate_svh::SvhCalculate;
-use rbml::writer::{EncodeResult, Encoder};
+use rbml::opaque::Encoder;
 use rustc::dep_graph::DepNode;
 use rustc::ty;
 use rustc_serialize::{Encodable as RustcEncodable};
-use std::io::{Cursor, Write};
+use std::io::{self, Cursor, Write};
 use std::fs::{self, File};
 
 use super::data::*;
@@ -70,7 +70,7 @@ pub fn save_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>) {
 
 pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
                               encoder: &mut Encoder)
-                              -> EncodeResult
+                              -> io::Result<()>
 {
     // Here we take advantage of how RBML allows us to skip around
     // and encode the depgraph as a two-part structure:
@@ -126,19 +126,10 @@ pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
 
     debug!("graph = {:#?}", graph);
 
-    // Encode the graph data into RBML.
-    try!(encoder.start_tag(DEP_GRAPH_TAG));
-    try!(graph.encode(encoder));
-    try!(encoder.end_tag());
-
-    // Now encode the directory.
+    // Encode the directory and then the graph data.
     let directory = builder.into_directory();
-
-    debug!("directory = {:#?}", directory);
-
-    try!(encoder.start_tag(DIRECTORY_TAG));
     try!(directory.encode(encoder));
-    try!(encoder.end_tag());
+    try!(graph.encode(encoder));
 
     Ok(())
 }
diff --git a/src/librustc_incremental/persist/util.rs b/src/librustc_incremental/persist/util.rs
index 11cc55950ca..9b4e5997efe 100644
--- a/src/librustc_incremental/persist/util.rs
+++ b/src/librustc_incremental/persist/util.rs
@@ -12,10 +12,6 @@ use rustc::ty;
 use std::fs;
 use std::path::PathBuf;
 
-pub const DEP_GRAPH_TAG: usize = 0x100;
-
-pub const DIRECTORY_TAG: usize = DEP_GRAPH_TAG + 1;
-
 pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
     // For now, just save/load dep-graph from
     // directory/dep_graph.rbml