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

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

Issue 1188973003: Port "Add snapshoting methods for code's metadata." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.h » ('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/object.h" 5 #include "vm/object.h"
6 #include "vm/object_store.h" 6 #include "vm/object_store.h"
7 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
8 #include "vm/stub_code.h" 8 #include "vm/stub_code.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 intptr_t object_id, 1278 intptr_t object_id,
1279 Snapshot::Kind kind) { 1279 Snapshot::Kind kind) {
1280 UNREACHABLE(); 1280 UNREACHABLE();
1281 } 1281 }
1282 1282
1283 1283
1284 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, 1284 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
1285 intptr_t object_id, 1285 intptr_t object_id,
1286 intptr_t tags, 1286 intptr_t tags,
1287 Snapshot::Kind kind) { 1287 Snapshot::Kind kind) {
1288 UNREACHABLE(); 1288 ASSERT(reader->allow_code());
1289 return PcDescriptors::null(); 1289
1290 const int32_t length = reader->Read<int32_t>();
1291 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone(),
1292 PcDescriptors::New(length));
1293 reader->AddBackRef(object_id, &result, kIsDeserialized);
1294
1295 // Set the object tags.
1296 result.set_tags(tags);
1297
1298 if (result.Length() > 0) {
1299 NoSafepointScope no_safepoint;
1300 intptr_t len = result.Length();
1301 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1302 reader->ReadBytes(data, len);
1303 }
1304
1305 return result.raw();
1290 } 1306 }
1291 1307
1292 1308
1293 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, 1309 void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
1294 intptr_t object_id, 1310 intptr_t object_id,
1295 Snapshot::Kind kind) { 1311 Snapshot::Kind kind) {
1296 UNREACHABLE(); 1312 ASSERT(writer->allow_code());
1313
1314 // Write out the serialization header value for this object.
1315 writer->WriteInlinedObjectHeader(object_id);
1316 writer->WriteIndexedObject(kPcDescriptorsCid);
1317 writer->WriteTags(writer->GetObjectTags(this));
1318 writer->Write<int32_t>(ptr()->length_);
1319 if (ptr()->length_ > 0) {
1320 intptr_t len = ptr()->length_;
1321 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1322 writer->WriteBytes(data, len);
1323 }
1297 } 1324 }
1298 1325
1299 1326
1300 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, 1327 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
1301 intptr_t object_id, 1328 intptr_t object_id,
1302 intptr_t tags, 1329 intptr_t tags,
1303 Snapshot::Kind kind) { 1330 Snapshot::Kind kind) {
1304 UNREACHABLE(); 1331 ASSERT(reader->allow_code());
1305 return Stackmap::null(); 1332
1333 const int32_t length = reader->Read<int32_t>();
1334 const int32_t register_bit_count = reader->Read<int32_t>();
1335 const uword pc_offset = reader->Read<uint32_t>();
1336
1337 Stackmap& result =
1338 Stackmap::ZoneHandle(reader->zone(),
1339 Stackmap::New(length, register_bit_count, pc_offset));
1340 reader->AddBackRef(object_id, &result, kIsDeserialized);
1341
1342 // Set the object tags.
1343 result.set_tags(tags);
1344
1345 if (result.Length() > 0) {
1346 NoSafepointScope no_safepoint;
1347 intptr_t len = (result.Length() + 7) / 8;
1348 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1349 reader->ReadBytes(data, len);
1350 }
1351
1352 return result.raw();
1306 } 1353 }
1307 1354
1308 1355
1309 void RawStackmap::WriteTo(SnapshotWriter* writer, 1356 void RawStackmap::WriteTo(SnapshotWriter* writer,
1310 intptr_t object_id, 1357 intptr_t object_id,
1311 Snapshot::Kind kind) { 1358 Snapshot::Kind kind) {
1312 UNREACHABLE(); 1359 ASSERT(writer->allow_code());
1360
1361 // Write out the serialization header value for this object.
1362 writer->WriteInlinedObjectHeader(object_id);
1363 writer->WriteIndexedObject(kStackmapCid);
1364 writer->WriteTags(writer->GetObjectTags(this));
1365 writer->Write<int32_t>(ptr()->length_);
1366 writer->Write<int32_t>(ptr()->register_bit_count_);
1367 writer->Write<uint32_t>(ptr()->pc_offset_);
1368 if (ptr()->length_ > 0) {
1369 intptr_t len = (ptr()->length_ + 7) / 8;
1370 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1371 writer->WriteBytes(data, len);
1372 }
1313 } 1373 }
1314 1374
1315 1375
1316 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, 1376 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader,
1317 intptr_t object_id, 1377 intptr_t object_id,
1318 intptr_t tags, 1378 intptr_t tags,
1319 Snapshot::Kind kind) { 1379 Snapshot::Kind kind) {
1320 UNREACHABLE(); 1380 ASSERT(reader->allow_code());
1321 return LocalVarDescriptors::null(); 1381
1382 const int32_t num_entries = reader->Read<int32_t>();
1383
1384 LocalVarDescriptors& result =
1385 LocalVarDescriptors::ZoneHandle(reader->zone(),
1386 LocalVarDescriptors::New(num_entries));
1387 reader->AddBackRef(object_id, &result, kIsDeserialized);
1388
1389 // Set the object tags.
1390 result.set_tags(tags);
1391
1392 for (intptr_t i = 0; i < num_entries; i++) {
1393 (*reader->StringHandle()) ^= reader->ReadObjectRef();
1394 result.StorePointer(result.raw()->nameAddrAt(i),
1395 reader->StringHandle()->raw());
1396 }
1397
1398 if (num_entries > 0) {
1399 NoSafepointScope no_safepoint;
1400 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo);
1401 uint8_t* data = result.UnsafeMutableNonPointer(
1402 reinterpret_cast<const uint8_t*>(result.raw()->data()));
1403 reader->ReadBytes(data, len);
1404 }
1405
1406 return result.raw();
1322 } 1407 }
1323 1408
1324 1409
1325 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, 1410 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer,
1326 intptr_t object_id, 1411 intptr_t object_id,
1327 Snapshot::Kind kind) { 1412 Snapshot::Kind kind) {
1328 UNREACHABLE(); 1413 ASSERT(writer->allow_code());
1414
1415 // Write out the serialization header value for this object.
1416 writer->WriteInlinedObjectHeader(object_id);
1417 writer->WriteIndexedObject(kLocalVarDescriptorsCid);
1418 writer->WriteTags(writer->GetObjectTags(this));
1419 writer->Write<int32_t>(ptr()->num_entries_);
1420 for (intptr_t i = 0; i < ptr()->num_entries_; i++) {
1421 writer->WriteObjectImpl(ptr()->names()[i]);
1422 }
1423 if (ptr()->num_entries_ > 0) {
1424 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo);
1425 uint8_t* data = reinterpret_cast<uint8_t*>(this->data());
1426 writer->WriteBytes(data, len);
1427 }
1329 } 1428 }
1330 1429
1331 1430
1332 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, 1431 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
1333 intptr_t object_id, 1432 intptr_t object_id,
1334 intptr_t tags, 1433 intptr_t tags,
1335 Snapshot::Kind kind) { 1434 Snapshot::Kind kind) {
1336 UNREACHABLE(); 1435 ASSERT(reader->allow_code());
1337 return ExceptionHandlers::null(); 1436
1437 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); // handled_types_data_
1438
1439 ExceptionHandlers& result =
1440 ExceptionHandlers::ZoneHandle(reader->zone(),
1441 ExceptionHandlers::New(*reader->ArrayHandle()));
1442 reader->AddBackRef(object_id, &result, kIsDeserialized);
1443
1444 // Set the object tags.
1445 result.set_tags(tags);
1446
1447 if (result.num_entries() > 0) {
1448 NoSafepointScope no_safepoint;
1449 const intptr_t len =
1450 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo);
1451 uint8_t* data = result.UnsafeMutableNonPointer(
1452 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data()));
1453 reader->ReadBytes(data, len);
1454 }
1455
1456 return result.raw();
1338 } 1457 }
1339 1458
1340 1459
1341 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, 1460 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer,
1342 intptr_t object_id, 1461 intptr_t object_id,
1343 Snapshot::Kind kind) { 1462 Snapshot::Kind kind) {
1344 UNREACHABLE(); 1463 ASSERT(writer->allow_code());
1464
1465 // Write out the serialization header value for this object.
1466 writer->WriteInlinedObjectHeader(object_id);
1467 writer->WriteIndexedObject(kExceptionHandlersCid);
1468 writer->WriteTags(writer->GetObjectTags(this));
1469 writer->WriteObjectImpl(ptr()->handled_types_data_);
1470
1471 if (ptr()->num_entries_ > 0) {
1472 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo);
1473 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1474 writer->WriteBytes(data, len);
1475 }
1345 } 1476 }
1346 1477
1347 1478
1348 RawContext* Context::ReadFrom(SnapshotReader* reader, 1479 RawContext* Context::ReadFrom(SnapshotReader* reader,
1349 intptr_t object_id, 1480 intptr_t object_id,
1350 intptr_t tags, 1481 intptr_t tags,
1351 Snapshot::Kind kind) { 1482 Snapshot::Kind kind) {
1352 ASSERT(reader != NULL); 1483 ASSERT(reader != NULL);
1353 1484
1354 // Allocate context object. 1485 // Allocate context object.
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 // We do not allow objects with native fields in an isolate message. 3083 // We do not allow objects with native fields in an isolate message.
2953 writer->SetWriteException(Exceptions::kArgument, 3084 writer->SetWriteException(Exceptions::kArgument,
2954 "Illegal argument in isolate message" 3085 "Illegal argument in isolate message"
2955 " : (object is a UserTag)"); 3086 " : (object is a UserTag)");
2956 } else { 3087 } else {
2957 UNREACHABLE(); 3088 UNREACHABLE();
2958 } 3089 }
2959 } 3090 }
2960 3091
2961 } // namespace dart 3092 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698