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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/visitor.h" 9 #include "vm/visitor.h"
10 10
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 intptr_t len = reader->ReadSmiValue(); 596 intptr_t len = reader->ReadSmiValue();
597 597
598 // Create the token stream object. 598 // Create the token stream object.
599 TokenStream& token_stream = TokenStream::ZoneHandle( 599 TokenStream& token_stream = TokenStream::ZoneHandle(
600 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 600 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len));
601 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); 601 reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
602 602
603 // Set the object tags. 603 // Set the object tags.
604 token_stream.set_tags(tags); 604 token_stream.set_tags(tags);
605 605
606 // Read the token stream into the TokenStream. 606 // Read the stream of tokens into the TokenStream object.
607 for (intptr_t i = 0; i < len; i++) { 607 {
608 *reader->ObjectHandle() = reader->ReadObjectImpl(); 608 NoGCScope no_gc;
609 token_stream.SetTokenAt(i, *reader->ObjectHandle()); 609 reader->ReadBytes(reinterpret_cast<uint8_t*>(token_stream.EntryAddr(0)),
610 len);
610 } 611 }
612
613 // Read in the literal/identifier token array.
614 *(reader->TokensHandle()) ^= reader->ReadObjectImpl();
615 token_stream.SetTokenObjects(*(reader->TokensHandle()));
616
611 return token_stream.raw(); 617 return token_stream.raw();
612 } 618 }
613 619
614 620
615 void RawTokenStream::WriteTo(SnapshotWriter* writer, 621 void RawTokenStream::WriteTo(SnapshotWriter* writer,
616 intptr_t object_id, 622 intptr_t object_id,
617 Snapshot::Kind kind) { 623 Snapshot::Kind kind) {
618 ASSERT(writer != NULL); 624 ASSERT(writer != NULL);
619 ASSERT(kind != Snapshot::kMessage && 625 ASSERT(kind != Snapshot::kMessage &&
620 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 626 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
621 627
622 // Write out the serialization header value for this object. 628 // Write out the serialization header value for this object.
623 writer->WriteSerializationMarker(kInlined, object_id); 629 writer->WriteSerializationMarker(kInlined, object_id);
624 630
625 // Write out the class and tags information. 631 // Write out the class and tags information.
626 writer->WriteObjectHeader(Object::kTokenStreamClass, 632 writer->WriteObjectHeader(Object::kTokenStreamClass,
627 writer->GetObjectTags(this)); 633 writer->GetObjectTags(this));
628 634
629 // Write out the length field. 635 // Write out the length field and the token stream.
636 intptr_t len = Smi::Value(ptr()->length_);
630 writer->Write<RawObject*>(ptr()->length_); 637 writer->Write<RawObject*>(ptr()->length_);
638 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len);
631 639
632 // Write out the token stream (token kind and literal). 640 // Write out the literal/identifier token array.
633 intptr_t len = Smi::Value(ptr()->length_); 641 writer->WriteObjectImpl(ptr()->token_objects_);
634 for (intptr_t i = 0; i < TokenStream::StreamLength(len); i++) {
635 writer->WriteObjectImpl(ptr()->data_[i]);
636 }
637 } 642 }
638 643
639 644
640 RawScript* Script::ReadFrom(SnapshotReader* reader, 645 RawScript* Script::ReadFrom(SnapshotReader* reader,
641 intptr_t object_id, 646 intptr_t object_id,
642 intptr_t tags, 647 intptr_t tags,
643 Snapshot::Kind kind) { 648 Snapshot::Kind kind) {
644 ASSERT(reader != NULL); 649 ASSERT(reader != NULL);
645 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 650 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags));
646 651
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1986 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1982 writer->WriteObjectImpl(ptr()->pattern_); 1987 writer->WriteObjectImpl(ptr()->pattern_);
1983 writer->WriteIntptrValue(ptr()->type_); 1988 writer->WriteIntptrValue(ptr()->type_);
1984 writer->WriteIntptrValue(ptr()->flags_); 1989 writer->WriteIntptrValue(ptr()->flags_);
1985 1990
1986 // Do not write out the data part which is native. 1991 // Do not write out the data part which is native.
1987 } 1992 }
1988 1993
1989 1994
1990 } // namespace dart 1995 } // namespace dart
OLDNEW
« 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