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

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

Issue 333773006: Removes open arrays (e.g. data[0]) from raw objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/raw_object.cc ('k') | no next file » | 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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 writer->Write<RawObject*>(ptr()->length_); 503 writer->Write<RawObject*>(ptr()->length_);
504 504
505 // Write out the instantiations field, but only in a full snapshot. 505 // Write out the instantiations field, but only in a full snapshot.
506 if (kind == Snapshot::kFull) { 506 if (kind == Snapshot::kFull) {
507 writer->WriteObjectImpl(ptr()->instantiations_); 507 writer->WriteObjectImpl(ptr()->instantiations_);
508 } 508 }
509 509
510 // Write out the individual types. 510 // Write out the individual types.
511 intptr_t len = Smi::Value(ptr()->length_); 511 intptr_t len = Smi::Value(ptr()->length_);
512 for (intptr_t i = 0; i < len; i++) { 512 for (intptr_t i = 0; i < len; i++) {
513 writer->WriteObjectImpl(ptr()->types_[i]); 513 writer->WriteObjectImpl(ptr()->types()[i]);
514 } 514 }
515 } 515 }
516 516
517 517
518 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, 518 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
519 intptr_t object_id, 519 intptr_t object_id,
520 intptr_t tags, 520 intptr_t tags,
521 Snapshot::Kind kind) { 521 Snapshot::Kind kind) {
522 ASSERT(reader != NULL); 522 ASSERT(reader != NULL);
523 ASSERT(((kind == Snapshot::kScript) && 523 ASSERT(((kind == Snapshot::kScript) &&
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 void RawOneByteString::WriteTo(SnapshotWriter* writer, 1970 void RawOneByteString::WriteTo(SnapshotWriter* writer,
1971 intptr_t object_id, 1971 intptr_t object_id,
1972 Snapshot::Kind kind) { 1972 Snapshot::Kind kind) {
1973 StringWriteTo(writer, 1973 StringWriteTo(writer,
1974 object_id, 1974 object_id,
1975 kind, 1975 kind,
1976 kOneByteStringCid, 1976 kOneByteStringCid,
1977 writer->GetObjectTags(this), 1977 writer->GetObjectTags(this),
1978 ptr()->length_, 1978 ptr()->length_,
1979 ptr()->hash_, 1979 ptr()->hash_,
1980 ptr()->data_); 1980 ptr()->data());
1981 } 1981 }
1982 1982
1983 1983
1984 void RawTwoByteString::WriteTo(SnapshotWriter* writer, 1984 void RawTwoByteString::WriteTo(SnapshotWriter* writer,
1985 intptr_t object_id, 1985 intptr_t object_id,
1986 Snapshot::Kind kind) { 1986 Snapshot::Kind kind) {
1987 StringWriteTo(writer, 1987 StringWriteTo(writer,
1988 object_id, 1988 object_id,
1989 kind, 1989 kind,
1990 kTwoByteStringCid, 1990 kTwoByteStringCid,
1991 writer->GetObjectTags(this), 1991 writer->GetObjectTags(this),
1992 ptr()->length_, 1992 ptr()->length_,
1993 ptr()->hash_, 1993 ptr()->hash_,
1994 ptr()->data_); 1994 ptr()->data());
1995 } 1995 }
1996 1996
1997 1997
1998 RawExternalOneByteString* ExternalOneByteString::ReadFrom( 1998 RawExternalOneByteString* ExternalOneByteString::ReadFrom(
1999 SnapshotReader* reader, 1999 SnapshotReader* reader,
2000 intptr_t object_id, 2000 intptr_t object_id,
2001 intptr_t tags, 2001 intptr_t tags,
2002 Snapshot::Kind kind) { 2002 Snapshot::Kind kind) {
2003 UNREACHABLE(); 2003 UNREACHABLE();
2004 return ExternalOneByteString::null(); 2004 return ExternalOneByteString::null();
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 Dart_WeakPersistentHandleFinalizer callback = 2384 Dart_WeakPersistentHandleFinalizer callback =
2385 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( 2385 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>(
2386 reader->ReadRawPointerValue()); 2386 reader->ReadRawPointerValue());
2387 obj.AddFinalizer(peer, callback); 2387 obj.AddFinalizer(peer, callback);
2388 return obj.raw(); 2388 return obj.raw();
2389 } 2389 }
2390 2390
2391 2391
2392 #define TYPED_DATA_WRITE(type) \ 2392 #define TYPED_DATA_WRITE(type) \
2393 { \ 2393 { \
2394 type* data = reinterpret_cast<type*>(ptr()->data_); \ 2394 type* data = reinterpret_cast<type*>(ptr()->data()); \
2395 for (intptr_t i = 0; i < len; i++) { \ 2395 for (intptr_t i = 0; i < len; i++) { \
2396 writer->Write(data[i]); \ 2396 writer->Write(data[i]); \
2397 } \ 2397 } \
2398 } \ 2398 } \
2399 2399
2400 2400
2401 void RawTypedData::WriteTo(SnapshotWriter* writer, 2401 void RawTypedData::WriteTo(SnapshotWriter* writer,
2402 intptr_t object_id, 2402 intptr_t object_id,
2403 Snapshot::Kind kind) { 2403 Snapshot::Kind kind) {
2404 ASSERT(writer != NULL); 2404 ASSERT(writer != NULL);
2405 intptr_t tags = writer->GetObjectTags(this); 2405 intptr_t tags = writer->GetObjectTags(this);
2406 intptr_t cid = ClassIdTag::decode(tags); 2406 intptr_t cid = ClassIdTag::decode(tags);
2407 intptr_t len = Smi::Value(ptr()->length_); 2407 intptr_t len = Smi::Value(ptr()->length_);
2408 2408
2409 // Write out the serialization header value for this object. 2409 // Write out the serialization header value for this object.
2410 writer->WriteInlinedObjectHeader(object_id); 2410 writer->WriteInlinedObjectHeader(object_id);
2411 2411
2412 // Write out the class and tags information. 2412 // Write out the class and tags information.
2413 writer->WriteIndexedObject(cid); 2413 writer->WriteIndexedObject(cid);
2414 writer->WriteIntptrValue(tags); 2414 writer->WriteIntptrValue(tags);
2415 2415
2416 // Write out the length field. 2416 // Write out the length field.
2417 writer->Write<RawObject*>(ptr()->length_); 2417 writer->Write<RawObject*>(ptr()->length_);
2418 2418
2419 // Write out the array elements. 2419 // Write out the array elements.
2420 switch (cid) { 2420 switch (cid) {
2421 case kTypedDataInt8ArrayCid: 2421 case kTypedDataInt8ArrayCid:
2422 case kTypedDataUint8ArrayCid: 2422 case kTypedDataUint8ArrayCid:
2423 case kTypedDataUint8ClampedArrayCid: { 2423 case kTypedDataUint8ClampedArrayCid: {
2424 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data_); 2424 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
2425 writer->WriteBytes(data, len); 2425 writer->WriteBytes(data, len);
2426 break; 2426 break;
2427 } 2427 }
2428 case kTypedDataInt16ArrayCid: 2428 case kTypedDataInt16ArrayCid:
2429 TYPED_DATA_WRITE(int16_t); 2429 TYPED_DATA_WRITE(int16_t);
2430 break; 2430 break;
2431 case kTypedDataUint16ArrayCid: 2431 case kTypedDataUint16ArrayCid:
2432 TYPED_DATA_WRITE(uint16_t); 2432 TYPED_DATA_WRITE(uint16_t);
2433 break; 2433 break;
2434 case kTypedDataInt32ArrayCid: 2434 case kTypedDataInt32ArrayCid:
(...skipping 13 matching lines...) Expand all
2448 break; 2448 break;
2449 case kTypedDataFloat64ArrayCid: 2449 case kTypedDataFloat64ArrayCid:
2450 TYPED_DATA_WRITE(double); // NOLINT. 2450 TYPED_DATA_WRITE(double); // NOLINT.
2451 break; 2451 break;
2452 default: 2452 default:
2453 UNREACHABLE(); 2453 UNREACHABLE();
2454 } 2454 }
2455 } 2455 }
2456 2456
2457 2457
2458 #define TYPED_EXT_DATA_WRITE(type) \
2459 { \
2460 type* data = reinterpret_cast<type*>(ptr()->data_); \
2461 for (intptr_t i = 0; i < len; i++) { \
2462 writer->Write(data[i]); \
2463 } \
2464 } \
2465
2466
2458 #define EXT_TYPED_DATA_WRITE(cid, type) \ 2467 #define EXT_TYPED_DATA_WRITE(cid, type) \
2459 writer->WriteIndexedObject(cid); \ 2468 writer->WriteIndexedObject(cid); \
2460 writer->WriteIntptrValue(RawObject::ClassIdTag::update(cid, tags)); \ 2469 writer->WriteIntptrValue(RawObject::ClassIdTag::update(cid, tags)); \
2461 writer->Write<RawObject*>(ptr()->length_); \ 2470 writer->Write<RawObject*>(ptr()->length_); \
2462 TYPED_DATA_WRITE(type) \ 2471 TYPED_EXT_DATA_WRITE(type) \
2463 2472
2464 2473
2465 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, 2474 void RawExternalTypedData::WriteTo(SnapshotWriter* writer,
2466 intptr_t object_id, 2475 intptr_t object_id,
2467 Snapshot::Kind kind) { 2476 Snapshot::Kind kind) {
2468 ASSERT(writer != NULL); 2477 ASSERT(writer != NULL);
2469 intptr_t tags = writer->GetObjectTags(this); 2478 intptr_t tags = writer->GetObjectTags(this);
2470 intptr_t cid = ClassIdTag::decode(tags); 2479 intptr_t cid = ClassIdTag::decode(tags);
2471 intptr_t len = Smi::Value(ptr()->length_); 2480 intptr_t len = Smi::Value(ptr()->length_);
2472 2481
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 // We do not allow objects with native fields in an isolate message. 2788 // We do not allow objects with native fields in an isolate message.
2780 writer->SetWriteException(Exceptions::kArgument, 2789 writer->SetWriteException(Exceptions::kArgument,
2781 "Illegal argument in isolate message" 2790 "Illegal argument in isolate message"
2782 " : (object is a UserTag)"); 2791 " : (object is a UserTag)");
2783 } else { 2792 } else {
2784 UNREACHABLE(); 2793 UNREACHABLE();
2785 } 2794 }
2786 } 2795 }
2787 2796
2788 } // namespace dart 2797 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698