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

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, 9 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/scanner.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 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 return literal_token.raw();
599 }
600
601
602 void RawLiteralToken::WriteTo(SnapshotWriter* writer,
603 intptr_t object_id,
604 Snapshot::Kind kind) {
605 ASSERT(writer != NULL);
606 ASSERT(kind != Snapshot::kMessage);
607
608 // Write out the serialization header value for this object.
609 writer->WriteSerializationMarker(kInlined, object_id);
610
611 // Write out the class and tags information.
612 writer->WriteObjectHeader(Object::kLiteralTokenClass, ptr()->tags_);
613
614 // Write out the kind field.
615 writer->Write<intptr_t>(ptr()->kind_);
616
617 // Write out literal and value fields.
618 writer->WriteObject(ptr()->literal_);
619 writer->WriteObject(ptr()->value_);
620 }
621
622
575 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 623 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
576 intptr_t object_id, 624 intptr_t object_id,
577 intptr_t tags, 625 intptr_t tags,
578 Snapshot::Kind kind) { 626 Snapshot::Kind kind) {
579 ASSERT(reader != NULL); 627 ASSERT(reader != NULL);
580 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 628 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags));
581 629
582 // Read the length so that we can determine number of tokens to read. 630 // Read the length so that we can determine number of tokens to read.
583 intptr_t len = reader->ReadSmiValue(); 631 intptr_t len = reader->ReadSmiValue();
584 632
585 // Create the token stream object. 633 // Create the token stream object.
586 TokenStream& token_stream = TokenStream::ZoneHandle( 634 TokenStream& token_stream = TokenStream::ZoneHandle(
587 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 635 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len));
588 reader->AddBackwardReference(object_id, &token_stream); 636 reader->AddBackwardReference(object_id, &token_stream);
589 637
590 // Set the object tags. 638 // Set the object tags.
591 token_stream.set_tags(tags); 639 token_stream.set_tags(tags);
592 640
593 // Read the token stream into the TokenStream. 641 // Read the token stream into the TokenStream.
594 for (intptr_t i = 0; i < len; i++) { 642 for (intptr_t i = 0; i < len; i++) {
595 Token::Kind kind = static_cast<Token::Kind>(reader->ReadSmiValue()); 643 *reader->ObjectHandle() = reader->ReadObject();
596 *reader->StringHandle() ^= reader->ReadObject(); 644 token_stream.SetTokenAt(i, *reader->ObjectHandle());
597 token_stream.SetTokenAt(i, kind, *reader->StringHandle());
598 } 645 }
599 return token_stream.raw(); 646 return token_stream.raw();
600 } 647 }
601 648
602 649
603 void RawTokenStream::WriteTo(SnapshotWriter* writer, 650 void RawTokenStream::WriteTo(SnapshotWriter* writer,
604 intptr_t object_id, 651 intptr_t object_id,
605 Snapshot::Kind kind) { 652 Snapshot::Kind kind) {
606 ASSERT(writer != NULL); 653 ASSERT(writer != NULL);
607 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); 654 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot());
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1915
1869 1916
1870 void RawICData::WriteTo(SnapshotWriter* writer, 1917 void RawICData::WriteTo(SnapshotWriter* writer,
1871 intptr_t object_id, 1918 intptr_t object_id,
1872 Snapshot::Kind kind) { 1919 Snapshot::Kind kind) {
1873 UNIMPLEMENTED(); 1920 UNIMPLEMENTED();
1874 } 1921 }
1875 1922
1876 1923
1877 } // namespace dart 1924 } // namespace dart
OLDNEW
« no previous file with comments | « vm/raw_object.cc ('k') | vm/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698