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

Side by Side Diff: vm/raw_object_snapshot.cc

Issue 9462003: Changes to shrink the token stream representation from two words to one word. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 10 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
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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 writer->Write<bool>(ptr()->is_static_); 565 writer->Write<bool>(ptr()->is_static_);
566 writer->Write<bool>(ptr()->is_final_); 566 writer->Write<bool>(ptr()->is_final_);
567 writer->Write<bool>(ptr()->has_initializer_); 567 writer->Write<bool>(ptr()->has_initializer_);
568 568
569 // Write out all the object pointer fields. 569 // Write out all the object pointer fields.
570 SnapshotWriterVisitor visitor(writer); 570 SnapshotWriterVisitor visitor(writer);
571 visitor.VisitPointers(from(), to()); 571 visitor.VisitPointers(from(), to());
572 } 572 }
573 573
574 574
575 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
576 intptr_t object_id,
577 intptr_t tags,
578 Snapshot::Kind kind) {
579 ASSERT(reader != NULL);
580 ASSERT(kind != Snapshot::kMessage);
581
582 // Create the literal token object.
583 LiteralToken& literal_token = LiteralToken::ZoneHandle(
584 reader->isolate(), NEW_OBJECT(LiteralToken));
585 reader->AddBackwardReference(object_id, &literal_token);
586
587 // Set the object tags.
588 literal_token.set_tags(tags);
589
590 // Read the token attributes.
591 Token::Kind token_kind = static_cast<Token::Kind>(reader->ReadIntptrValue());
592 literal_token.set_kind(token_kind);
593 *reader->StringHandle() ^= reader->ReadObject();
594 literal_token.set_literal(*reader->StringHandle());
595 *reader->ObjectHandle() = reader->ReadObject();
596 literal_token.set_value(*reader->ObjectHandle());
597
598 // If object needs to be a canonical object, Canonicalize it.
599 if ((kind != Snapshot::kFull) && literal_token.IsCanonical()) {
600 literal_token ^= literal_token.Canonicalize();
601 }
602 return literal_token.raw();
603 }
604
605
606 void RawLiteralToken::WriteTo(SnapshotWriter* writer,
607 intptr_t object_id,
608 Snapshot::Kind kind) {
609 ASSERT(writer != NULL);
610 ASSERT(kind != Snapshot::kMessage);
611
612 // Write out the serialization header value for this object.
613 writer->WriteSerializationMarker(kInlined, object_id);
614
615 // Write out the class and tags information.
616 writer->WriteObjectHeader(Object::kLiteralTokenClass, ptr()->tags_);
617
618 // Write out the kind field.
619 writer->Write<intptr_t>(ptr()->kind_);
620
621 // Write out literal and value fields.
622 writer->WriteObject(ptr()->literal_);
623 writer->WriteObject(ptr()->value_);
624 }
625
626
575 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 627 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
576 intptr_t object_id, 628 intptr_t object_id,
577 intptr_t tags, 629 intptr_t tags,
578 Snapshot::Kind kind) { 630 Snapshot::Kind kind) {
579 ASSERT(reader != NULL); 631 ASSERT(reader != NULL);
580 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 632 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags));
581 633
582 // Read the length so that we can determine number of tokens to read. 634 // Read the length so that we can determine number of tokens to read.
583 intptr_t len = reader->ReadSmiValue(); 635 intptr_t len = reader->ReadSmiValue();
584 636
585 // Create the token stream object. 637 // Create the token stream object.
586 TokenStream& token_stream = TokenStream::ZoneHandle( 638 TokenStream& token_stream = TokenStream::ZoneHandle(
587 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 639 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len));
588 reader->AddBackwardReference(object_id, &token_stream); 640 reader->AddBackwardReference(object_id, &token_stream);
589 641
590 // Set the object tags. 642 // Set the object tags.
591 token_stream.set_tags(tags); 643 token_stream.set_tags(tags);
592 644
593 // Read the token stream into the TokenStream. 645 // Read the token stream into the TokenStream.
594 for (intptr_t i = 0; i < len; i++) { 646 for (intptr_t i = 0; i < len; i++) {
595 Token::Kind kind = static_cast<Token::Kind>(reader->ReadSmiValue()); 647 *reader->ObjectHandle() = reader->ReadObject();
596 *reader->StringHandle() ^= reader->ReadObject(); 648 token_stream.SetTokenAt(i, *reader->ObjectHandle());
597 token_stream.SetTokenAt(i, kind, *reader->StringHandle());
598 } 649 }
599 return token_stream.raw(); 650 return token_stream.raw();
600 } 651 }
601 652
602 653
603 void RawTokenStream::WriteTo(SnapshotWriter* writer, 654 void RawTokenStream::WriteTo(SnapshotWriter* writer,
604 intptr_t object_id, 655 intptr_t object_id,
605 Snapshot::Kind kind) { 656 Snapshot::Kind kind) {
606 ASSERT(writer != NULL); 657 ASSERT(writer != NULL);
607 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); 658 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot());
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 1909
1859 1910
1860 void RawICData::WriteTo(SnapshotWriter* writer, 1911 void RawICData::WriteTo(SnapshotWriter* writer,
1861 intptr_t object_id, 1912 intptr_t object_id,
1862 Snapshot::Kind kind) { 1913 Snapshot::Kind kind) {
1863 UNIMPLEMENTED(); 1914 UNIMPLEMENTED();
1864 } 1915 }
1865 1916
1866 1917
1867 } // namespace dart 1918 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698