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

Unified Diff: runtime/vm/clustered_snapshot.cc

Issue 2035453002: Pixels class prototype and test (not to be committed). 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/flow_graph_compiler.cc » ('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..dbb780f29a1f0d455d185200e6a4fbb1adf25174 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -3278,6 +3278,84 @@ class BigintDeserializationCluster : public DeserializationCluster {
};
+class PixelsSerializationCluster : public SerializationCluster {
+ public:
+ PixelsSerializationCluster() { }
+ virtual ~PixelsSerializationCluster() { }
+
+ void Trace(Serializer* s, RawObject* object) {
+ RawPixels* pixels = Pixels::RawCast(object);
+ objects_.Add(pixels);
+
+ RawObject** from = pixels->from();
+ RawObject** to = pixels->to();
+ for (RawObject** p = from; p <= to; p++) {
+ s->Push(*p);
+ }
+ }
+
+ void WriteAlloc(Serializer* s) {
+ s->WriteCid(kPixelsCid);
+ intptr_t count = objects_.length();
+ s->Write<intptr_t>(count);
+ for (intptr_t i = 0; i < count; i++) {
+ RawPixels* pixels = objects_[i];
+ s->AssignRef(pixels);
+ }
+ }
+
+ void WriteFill(Serializer* s) {
+ intptr_t count = objects_.length();
+ for (intptr_t i = 0; i < count; i++) {
+ RawPixels* pixels = objects_[i];
+ s->Write<bool>(pixels->IsCanonical());
+ RawObject** from = pixels->from();
+ RawObject** to = pixels->to();
+ for (RawObject** p = from; p <= to; p++) {
+ s->WriteRef(*p);
+ }
+ }
+ }
+
+ private:
+ GrowableArray<RawPixels*> objects_;
+};
+
+
+class PixelsDeserializationCluster : public DeserializationCluster {
+ public:
+ PixelsDeserializationCluster() { }
+ virtual ~PixelsDeserializationCluster() { }
+
+ 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, Pixels::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++) {
+ RawPixels* pixels = reinterpret_cast<RawPixels*>(d->Ref(id));
+ bool is_canonical = d->Read<bool>();
+ Deserializer::InitializeHeader(pixels, kPixelsCid,
+ Pixels::InstanceSize(),
+ is_vm_object, is_canonical);
+ RawObject** from = pixels->from();
+ RawObject** to = pixels->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 kPixelsCid: return new (Z) PixelsSerializationCluster();
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 kPixelsCid: return new (Z) PixelsDeserializationCluster();
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/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698