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

Side by Side Diff: src/serialize.cc

Issue 8467010: Refactor embedded pointer visitors for the serializer (Closed)
Patch Set: Rebased on r9943, updated based on code review comments Created 9 years, 1 month 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 | « src/serialize.h ('k') | src/x64/assembler-x64-inl.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 } else { 1464 } else {
1465 serializer_->SerializeObject(current_contents, kPlain, kStartOfObject); 1465 serializer_->SerializeObject(current_contents, kPlain, kStartOfObject);
1466 bytes_processed_so_far_ += kPointerSize; 1466 bytes_processed_so_far_ += kPointerSize;
1467 current++; 1467 current++;
1468 } 1468 }
1469 } 1469 }
1470 } 1470 }
1471 } 1471 }
1472 1472
1473 1473
1474 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) {
1475 Object** current = rinfo->target_object_address();
1476
1477 OutputRawData(rinfo->target_address_address());
1478 HowToCode representation = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1479 serializer_->SerializeObject(*current, representation, kStartOfObject);
1480 bytes_processed_so_far_ += rinfo->target_address_size();
1481 }
1482
1483
1474 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start, 1484 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start,
1475 Address* end) { 1485 Address* end) {
1476 Address references_start = reinterpret_cast<Address>(start); 1486 Address references_start = reinterpret_cast<Address>(start);
1477 OutputRawData(references_start); 1487 OutputRawData(references_start);
1478 1488
1479 for (Address* current = start; current < end; current++) { 1489 for (Address* current = start; current < end; current++) {
1480 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); 1490 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef");
1481 int reference_id = serializer_->EncodeExternalReference(*current); 1491 int reference_id = serializer_->EncodeExternalReference(*current);
1482 sink_->PutInt(reference_id, "reference id"); 1492 sink_->PutInt(reference_id, "reference id");
1483 } 1493 }
1484 bytes_processed_so_far_ += static_cast<int>((end - start) * kPointerSize); 1494 bytes_processed_so_far_ += static_cast<int>((end - start) * kPointerSize);
1485 } 1495 }
1486 1496
1487 1497
1498 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) {
1499 Address references_start = rinfo->target_address_address();
1500 OutputRawData(references_start);
1501
1502 Address* current = rinfo->target_reference_address();
1503 int representation = rinfo->IsCodedSpecially() ?
1504 kFromCode + kStartOfObject : kPlain + kStartOfObject;
1505 sink_->Put(kExternalReference + representation, "ExternalRef");
1506 int reference_id = serializer_->EncodeExternalReference(*current);
1507 sink_->PutInt(reference_id, "reference id");
1508 bytes_processed_so_far_ += rinfo->target_address_size();
1509 }
1510
1511
1488 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { 1512 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) {
1489 Address target_start = rinfo->target_address_address(); 1513 Address target_start = rinfo->target_address_address();
1490 OutputRawData(target_start); 1514 OutputRawData(target_start);
1491 Address target = rinfo->target_address(); 1515 Address target = rinfo->target_address();
1492 uint32_t encoding = serializer_->EncodeExternalReference(target); 1516 uint32_t encoding = serializer_->EncodeExternalReference(target);
1493 CHECK(target == NULL ? encoding == 0 : encoding != 0); 1517 CHECK(target == NULL ? encoding == 0 : encoding != 0);
1494 int representation; 1518 int representation;
1495 // Can't use a ternary operator because of gcc. 1519 // Can't use a ternary operator because of gcc.
1496 if (rinfo->IsCodedSpecially()) { 1520 if (rinfo->IsCodedSpecially()) {
1497 representation = kStartOfObject + kFromCode; 1521 representation = kStartOfObject + kFromCode;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1666 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1643 } 1667 }
1644 } 1668 }
1645 int allocation_address = fullness_[space]; 1669 int allocation_address = fullness_[space];
1646 fullness_[space] = allocation_address + size; 1670 fullness_[space] = allocation_address + size;
1647 return allocation_address; 1671 return allocation_address;
1648 } 1672 }
1649 1673
1650 1674
1651 } } // namespace v8::internal 1675 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698