Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1927)

Unified Diff: vm/raw_object_snapshot.cc

Issue 10697055: Represent tokens as a compressed stream instead of an array. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/raw_object_snapshot.cc
===================================================================
--- vm/raw_object_snapshot.cc (revision 9536)
+++ vm/raw_object_snapshot.cc (working copy)
@@ -603,11 +603,17 @@
// Set the object tags.
token_stream.set_tags(tags);
- // Read the token stream into the TokenStream.
- for (intptr_t i = 0; i < len; i++) {
- *reader->ObjectHandle() = reader->ReadObjectImpl();
- token_stream.SetTokenAt(i, *reader->ObjectHandle());
+ // Read the stream of tokens into the TokenStream object.
+ {
+ NoGCScope no_gc;
+ reader->ReadBytes(reinterpret_cast<uint8_t*>(token_stream.EntryAddr(0)),
+ len);
}
+
+ // Read in the literal/identifier token array.
+ *(reader->TokensHandle()) ^= reader->ReadObjectImpl();
+ token_stream.SetTokenObjects(*(reader->TokensHandle()));
+
return token_stream.raw();
}
@@ -626,14 +632,13 @@
writer->WriteObjectHeader(Object::kTokenStreamClass,
writer->GetObjectTags(this));
- // Write out the length field.
+ // Write out the length field and the token stream.
+ intptr_t len = Smi::Value(ptr()->length_);
writer->Write<RawObject*>(ptr()->length_);
+ writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len);
- // Write out the token stream (token kind and literal).
- intptr_t len = Smi::Value(ptr()->length_);
- for (intptr_t i = 0; i < TokenStream::StreamLength(len); i++) {
- writer->WriteObjectImpl(ptr()->data_[i]);
- }
+ // Write out the literal/identifier token array.
+ writer->WriteObjectImpl(ptr()->token_objects_);
}
« no previous file with comments | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698