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

Unified Diff: runtime/vm/clustered_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/clustered_snapshot.cc
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 6f958fd5cb3693e34ccef21399d6f54f3788b0c4..6a6bd11634061b1e453aad7ef8d2983a13ae5cfe 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -3278,6 +3278,84 @@ class BigintDeserializationCluster : public DeserializationCluster {
};
+class FractionSerializationCluster : public SerializationCluster {
+ public:
+ FractionSerializationCluster() { }
+ virtual ~FractionSerializationCluster() { }
+
+ void Trace(Serializer* s, RawObject* object) {
+ RawFraction* fraction = Fraction::RawCast(object);
+ objects_.Add(fraction);
+
+ RawObject** from = fraction->from();
+ RawObject** to = fraction->to();
+ for (RawObject** p = from; p <= to; p++) {
+ s->Push(*p);
+ }
+ }
+
+ void WriteAlloc(Serializer* s) {
+ s->WriteCid(kFractionCid);
+ intptr_t count = objects_.length();
+ s->Write<intptr_t>(count);
+ for (intptr_t i = 0; i < count; i++) {
+ RawFraction* fraction = objects_[i];
+ s->AssignRef(fraction);
+ }
+ }
+
+ void WriteFill(Serializer* s) {
+ intptr_t count = objects_.length();
+ for (intptr_t i = 0; i < count; i++) {
+ RawFraction* fraction = objects_[i];
+ s->Write<bool>(fraction->IsCanonical());
+ RawObject** from = fraction->from();
+ RawObject** to = fraction->to();
+ for (RawObject** p = from; p <= to; p++) {
+ s->WriteRef(*p);
+ }
+ }
+ }
+
+ private:
+ GrowableArray<RawFraction*> objects_;
+};
+
+
+class FractionDeserializationCluster : public DeserializationCluster {
+ public:
+ FractionDeserializationCluster() { }
+ virtual ~FractionDeserializationCluster() { }
+
+ void ReadAlloc(Deserializer* d) {
+ start_index_ = d->next_index();
+ PageSpace* old_space = d->heap()->old_space();
+ intptr_t count = d->Read<intptr_t>();
+ for (intptr_t i = 0; i < count; i++) {
+ d->AssignRef(AllocateUninitialized(old_space, Fraction::InstanceSize()));
+ }
+ stop_index_ = d->next_index();
+ }
+
+ void ReadFill(Deserializer* d) {
+ bool is_vm_object = d->isolate() == Dart::vm_isolate();
+
+ for (intptr_t id = start_index_; id < stop_index_; id++) {
+ RawFraction* fraction = reinterpret_cast<RawFraction*>(d->Ref(id));
+ bool is_canonical = d->Read<bool>();
+ Deserializer::InitializeHeader(fraction, kFractionCid,
+ Fraction::InstanceSize(),
+ is_vm_object, is_canonical);
+ RawObject** from = fraction->from();
+ RawObject** to = fraction->to();
+ for (RawObject** p = from; p <= to; p++) {
+ *p = d->ReadRef();
+ }
+ }
+ }
+};
+
+
class DoubleSerializationCluster : public SerializationCluster {
public:
DoubleSerializationCluster() { }
@@ -4198,6 +4276,7 @@ SerializationCluster* Serializer::NewClusterForClass(intptr_t cid) {
case kClosureCid: return new (Z) ClosureSerializationCluster();
case kMintCid: return new (Z) MintSerializationCluster();
case kBigintCid: return new (Z) BigintSerializationCluster();
+ case kFractionCid: return new (Z) FractionSerializationCluster();
case kDoubleCid: return new (Z) DoubleSerializationCluster();
case kGrowableObjectArrayCid:
return new (Z) GrowableObjectArraySerializationCluster();
@@ -4521,6 +4600,7 @@ DeserializationCluster* Deserializer::ReadCluster() {
case kClosureCid: return new (Z) ClosureDeserializationCluster();
case kMintCid: return new (Z) MintDeserializationCluster();
case kBigintCid: return new (Z) BigintDeserializationCluster();
+ case kFractionCid: return new (Z) FractionDeserializationCluster();
case kDoubleCid: return new (Z) DoubleDeserializationCluster();
case kGrowableObjectArrayCid:
return new (Z) GrowableObjectArrayDeserializationCluster();
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698