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

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

Issue 1873143003: - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list a… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review Created 4 years, 8 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
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 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 obj = reader->NewInstance(); 2286 obj = reader->NewInstance();
2287 // Set the canonical bit. 2287 // Set the canonical bit.
2288 if (RawObject::IsCanonical(tags)) { 2288 if (RawObject::IsCanonical(tags)) {
2289 obj.SetCanonical(); 2289 obj.SetCanonical();
2290 } 2290 }
2291 } else { 2291 } else {
2292 obj ^= Object::Allocate(kInstanceCid, 2292 obj ^= Object::Allocate(kInstanceCid,
2293 Instance::InstanceSize(), 2293 Instance::InstanceSize(),
2294 HEAP_SPACE(kind)); 2294 HEAP_SPACE(kind));
2295 if (RawObject::IsCanonical(tags)) { 2295 if (RawObject::IsCanonical(tags)) {
2296 obj = obj.CheckAndCanonicalize(NULL); 2296 obj = obj.CheckAndCanonicalize(reader->thread(), NULL);
2297 } 2297 }
2298 } 2298 }
2299 reader->AddBackRef(object_id, &obj, kIsDeserialized); 2299 reader->AddBackRef(object_id, &obj, kIsDeserialized);
2300 2300
2301 return obj.raw(); 2301 return obj.raw();
2302 } 2302 }
2303 2303
2304 2304
2305 void RawInstance::WriteTo(SnapshotWriter* writer, 2305 void RawInstance::WriteTo(SnapshotWriter* writer,
2306 intptr_t object_id, 2306 intptr_t object_id,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 // If it is a canonical constant make it one. 2397 // If it is a canonical constant make it one.
2398 // When reading a full snapshot we don't need to canonicalize the object 2398 // When reading a full snapshot we don't need to canonicalize the object
2399 // as it would already be a canonical object. 2399 // as it would already be a canonical object.
2400 // When reading a script snapshot or a message snapshot we always have 2400 // When reading a script snapshot or a message snapshot we always have
2401 // to canonicalize the object. 2401 // to canonicalize the object.
2402 if (RawObject::IsCanonical(tags)) { 2402 if (RawObject::IsCanonical(tags)) {
2403 if (kind == Snapshot::kFull) { 2403 if (kind == Snapshot::kFull) {
2404 // Set the canonical bit. 2404 // Set the canonical bit.
2405 obj.SetCanonical(); 2405 obj.SetCanonical();
2406 } else { 2406 } else {
2407 obj ^= obj.CheckAndCanonicalize(NULL); 2407 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL);
2408 ASSERT(!obj.IsNull()); 2408 ASSERT(!obj.IsNull());
2409 ASSERT(obj.IsCanonical()); 2409 ASSERT(obj.IsCanonical());
2410 } 2410 }
2411 } 2411 }
2412 return obj.raw(); 2412 return obj.raw();
2413 } 2413 }
2414 2414
2415 2415
2416 void RawBigint::WriteTo(SnapshotWriter* writer, 2416 void RawBigint::WriteTo(SnapshotWriter* writer,
2417 intptr_t object_id, 2417 intptr_t object_id,
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); 2824 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind)));
2825 reader->AddBackRef(object_id, array, state); 2825 reader->AddBackRef(object_id, array, state);
2826 } 2826 }
2827 if (!as_reference) { 2827 if (!as_reference) {
2828 // Read all the individual elements for inlined objects. 2828 // Read all the individual elements for inlined objects.
2829 reader->ArrayReadFrom(object_id, *array, len, tags); 2829 reader->ArrayReadFrom(object_id, *array, len, tags);
2830 if (RawObject::IsCanonical(tags)) { 2830 if (RawObject::IsCanonical(tags)) {
2831 if (kind == Snapshot::kFull) { 2831 if (kind == Snapshot::kFull) {
2832 array->SetCanonical(); 2832 array->SetCanonical();
2833 } else { 2833 } else {
2834 *array ^= array->CheckAndCanonicalize(NULL); 2834 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL);
2835 } 2835 }
2836 } 2836 }
2837 } 2837 }
2838 return raw(*array); 2838 return raw(*array);
2839 } 2839 }
2840 2840
2841 2841
2842 void RawArray::WriteTo(SnapshotWriter* writer, 2842 void RawArray::WriteTo(SnapshotWriter* writer,
2843 intptr_t object_id, 2843 intptr_t object_id,
2844 Snapshot::Kind kind, 2844 Snapshot::Kind kind,
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 // If it is a canonical constant make it one. 3240 // If it is a canonical constant make it one.
3241 // When reading a full snapshot we don't need to canonicalize the object 3241 // When reading a full snapshot we don't need to canonicalize the object
3242 // as it would already be a canonical object. 3242 // as it would already be a canonical object.
3243 // When reading a script snapshot or a message snapshot we always have 3243 // When reading a script snapshot or a message snapshot we always have
3244 // to canonicalize the object. 3244 // to canonicalize the object.
3245 if (RawObject::IsCanonical(tags)) { 3245 if (RawObject::IsCanonical(tags)) {
3246 if (kind == Snapshot::kFull) { 3246 if (kind == Snapshot::kFull) {
3247 // Set the canonical bit. 3247 // Set the canonical bit.
3248 result.SetCanonical(); 3248 result.SetCanonical();
3249 } else { 3249 } else {
3250 result ^= result.CheckAndCanonicalize(NULL); 3250 result ^= result.CheckAndCanonicalize(reader->thread(), NULL);
3251 ASSERT(!result.IsNull()); 3251 ASSERT(!result.IsNull());
3252 ASSERT(result.IsCanonical()); 3252 ASSERT(result.IsCanonical());
3253 } 3253 }
3254 } 3254 }
3255 return result.raw(); 3255 return result.raw();
3256 } 3256 }
3257 #undef TYPED_DATA_READ 3257 #undef TYPED_DATA_READ
3258 3258
3259 3259
3260 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, 3260 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader,
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 // We do not allow objects with native fields in an isolate message. 3700 // We do not allow objects with native fields in an isolate message.
3701 writer->SetWriteException(Exceptions::kArgument, 3701 writer->SetWriteException(Exceptions::kArgument,
3702 "Illegal argument in isolate message" 3702 "Illegal argument in isolate message"
3703 " : (object is a UserTag)"); 3703 " : (object is a UserTag)");
3704 } else { 3704 } else {
3705 UNREACHABLE(); 3705 UNREACHABLE();
3706 } 3706 }
3707 } 3707 }
3708 3708
3709 } // namespace dart 3709 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/parser.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698