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

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 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
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/scanner.cc » ('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/native_entry.h" 5 #include "vm/native_entry.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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 // Write out the class and tags information. 2074 // Write out the class and tags information.
2075 writer->WriteIndexedObject(kBigintCid); 2075 writer->WriteIndexedObject(kBigintCid);
2076 writer->WriteTags(writer->GetObjectTags(this)); 2076 writer->WriteTags(writer->GetObjectTags(this));
2077 2077
2078 // Write out all the object pointer fields. 2078 // Write out all the object pointer fields.
2079 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); 2079 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
2080 visitor.VisitPointers(from(), to()); 2080 visitor.VisitPointers(from(), to());
2081 } 2081 }
2082 2082
2083 2083
2084 RawFraction* Fraction::ReadFrom(SnapshotReader* reader,
2085 intptr_t object_id,
2086 intptr_t tags,
2087 Snapshot::Kind kind,
2088 bool as_reference) {
2089 ASSERT(reader != NULL);
2090
2091 // Allocate fraction object.
2092 Fraction& obj = Fraction::ZoneHandle(reader->zone(), NEW_OBJECT(Fraction));
2093 reader->AddBackRef(object_id, &obj, kIsDeserialized);
2094
2095 // Set all the object fields.
2096 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject);
2097
2098 // If it is a canonical constant make it one.
2099 // When reading a full snapshot we don't need to canonicalize the object
2100 // as it would already be a canonical object.
2101 // When reading a script snapshot or a message snapshot we always have
2102 // to canonicalize the object.
2103 if (RawObject::IsCanonical(tags)) {
2104 if (Snapshot::IsFull(kind)) {
2105 // Set the canonical bit.
2106 obj.SetCanonical();
2107 } else {
2108 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL);
2109 ASSERT(!obj.IsNull());
2110 ASSERT(obj.IsCanonical());
2111 }
2112 }
2113 return obj.raw();
2114 }
2115
2116
2117 void RawFraction::WriteTo(SnapshotWriter* writer,
2118 intptr_t object_id,
2119 Snapshot::Kind kind,
2120 bool as_reference) {
2121 ASSERT(writer != NULL);
2122
2123 // Write out the serialization header value for this object.
2124 writer->WriteInlinedObjectHeader(object_id);
2125
2126 // Write out the class and tags information.
2127 writer->WriteIndexedObject(kFractionCid);
2128 writer->WriteTags(writer->GetObjectTags(this));
2129
2130 // Write out all the object pointer fields.
2131 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
2132 visitor.VisitPointers(from(), to());
2133 }
2134
2135
2084 RawDouble* Double::ReadFrom(SnapshotReader* reader, 2136 RawDouble* Double::ReadFrom(SnapshotReader* reader,
2085 intptr_t object_id, 2137 intptr_t object_id,
2086 intptr_t tags, 2138 intptr_t tags,
2087 Snapshot::Kind kind, 2139 Snapshot::Kind kind,
2088 bool as_reference) { 2140 bool as_reference) {
2089 ASSERT(reader != NULL); 2141 ASSERT(reader != NULL);
2090 ASSERT(kind != Snapshot::kMessage); 2142 ASSERT(kind != Snapshot::kMessage);
2091 // Read the double value for the object. 2143 // Read the double value for the object.
2092 double value = reader->ReadDouble(); 2144 double value = reader->ReadDouble();
2093 2145
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 // We do not allow objects with native fields in an isolate message. 3371 // We do not allow objects with native fields in an isolate message.
3320 writer->SetWriteException(Exceptions::kArgument, 3372 writer->SetWriteException(Exceptions::kArgument,
3321 "Illegal argument in isolate message" 3373 "Illegal argument in isolate message"
3322 " : (object is a UserTag)"); 3374 " : (object is a UserTag)");
3323 } else { 3375 } else {
3324 UNREACHABLE(); 3376 UNREACHABLE();
3325 } 3377 }
3326 } 3378 }
3327 3379
3328 } // namespace dart 3380 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698