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

Side by Side Diff: src/serialize.cc

Issue 8467010: Refactor embedded pointer visitors for the serializer (Closed)
Patch Set: 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
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 if(!(*current)->IsSmi()) {
Michael Starzinger 2011/11/09 10:46:19 Does the address actually ever get to be a SMI her
1478 OutputRawData(reinterpret_cast<Address>(rinfo->target_address_address()));
Michael Starzinger 2011/11/09 10:46:19 No cast should be needed here.
1479 HowToCode representation;
1480 if(rinfo->IsCodedSpecially()) {
Michael Starzinger 2011/11/09 10:46:19 Using the ternary operator here might make things
1481 representation = kFromCode;
1482 } else {
1483 representation = kPlain;
1484 }
1485 serializer_->SerializeObject(*current, representation, kStartOfObject);
1486 bytes_processed_so_far_ += rinfo->target_address_size();
1487 }
1488 }
1489
1490
1474 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start, 1491 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start,
1475 Address* end) { 1492 Address* end) {
1476 Address references_start = reinterpret_cast<Address>(start); 1493 Address references_start = reinterpret_cast<Address>(start);
1477 OutputRawData(references_start); 1494 OutputRawData(references_start);
1478 1495
1479 for (Address* current = start; current < end; current++) { 1496 for (Address* current = start; current < end; current++) {
1480 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); 1497 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef");
1481 int reference_id = serializer_->EncodeExternalReference(*current); 1498 int reference_id = serializer_->EncodeExternalReference(*current);
1482 sink_->PutInt(reference_id, "reference id"); 1499 sink_->PutInt(reference_id, "reference id");
1483 } 1500 }
1484 bytes_processed_so_far_ += static_cast<int>((end - start) * kPointerSize); 1501 bytes_processed_so_far_ += static_cast<int>((end - start) * kPointerSize);
1485 } 1502 }
1486 1503
1487 1504
1505 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) {
1506 Address references_start =
1507 reinterpret_cast<Address>(rinfo->target_address_address());
Michael Starzinger 2011/11/09 10:46:19 No cast should be needed here.
1508 OutputRawData(references_start);
1509 Address* current =
1510 reinterpret_cast<Address*>(rinfo->target_reference_address());
Michael Starzinger 2011/11/09 10:46:19 No cast should be needed here.
1511 int representation;
1512 if(rinfo->IsCodedSpecially()) {
Michael Starzinger 2011/11/09 10:46:19 Using the ternary operator here might make things
1513 representation = kFromCode + kStartOfObject;
1514 } else {
1515 representation = kPlain + kStartOfObject;
1516 }
1517 sink_->Put(kExternalReference + representation, "ExternalRef");
1518 int reference_id = serializer_->EncodeExternalReference(*current);
1519 sink_->PutInt(reference_id, "reference id");
1520 bytes_processed_so_far_ += rinfo->target_address_size();
1521 }
1522
1523
1488 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { 1524 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) {
1489 Address target_start = rinfo->target_address_address(); 1525 Address target_start = rinfo->target_address_address();
1490 OutputRawData(target_start); 1526 OutputRawData(target_start);
1491 Address target = rinfo->target_address(); 1527 Address target = rinfo->target_address();
1492 uint32_t encoding = serializer_->EncodeExternalReference(target); 1528 uint32_t encoding = serializer_->EncodeExternalReference(target);
1493 CHECK(target == NULL ? encoding == 0 : encoding != 0); 1529 CHECK(target == NULL ? encoding == 0 : encoding != 0);
1494 int representation; 1530 int representation;
1495 // Can't use a ternary operator because of gcc. 1531 // Can't use a ternary operator because of gcc.
1496 if (rinfo->IsCodedSpecially()) { 1532 if (rinfo->IsCodedSpecially()) {
1497 representation = kStartOfObject + kFromCode; 1533 representation = kStartOfObject + kFromCode;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1678 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1643 } 1679 }
1644 } 1680 }
1645 int allocation_address = fullness_[space]; 1681 int allocation_address = fullness_[space];
1646 fullness_[space] = allocation_address + size; 1682 fullness_[space] = allocation_address + size;
1647 return allocation_address; 1683 return allocation_address;
1648 } 1684 }
1649 1685
1650 1686
1651 } } // namespace v8::internal 1687 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « 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