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

Side by Side Diff: src/serialize.cc

Issue 8352045: Fix missing write barrier in deserialization. Issue 1783. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 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
« src/heap.h ('K') | « src/heap.h ('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 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ReadObject(space_number, dest_space, current); \ 776 ReadObject(space_number, dest_space, current); \
777 emit_write_barrier = (space_number == NEW_SPACE && \ 777 emit_write_barrier = (space_number == NEW_SPACE && \
778 source_space != NEW_SPACE && \ 778 source_space != NEW_SPACE && \
779 source_space != CELL_SPACE); \ 779 source_space != CELL_SPACE); \
780 } else { \ 780 } else { \
781 Object* new_object = NULL; /* May not be a real Object pointer. */ \ 781 Object* new_object = NULL; /* May not be a real Object pointer. */ \
782 if (where == kNewObject) { \ 782 if (where == kNewObject) { \
783 ASSIGN_DEST_SPACE(space_number) \ 783 ASSIGN_DEST_SPACE(space_number) \
784 ReadObject(space_number, dest_space, &new_object); \ 784 ReadObject(space_number, dest_space, &new_object); \
785 } else if (where == kRootArray) { \ 785 } else if (where == kRootArray) { \
786 if (source_space != CELL_SPACE && \
787 source_space != CODE_SPACE && \
788 source_space != OLD_DATA_SPACE) { \
789 emit_write_barrier = true; \
790 } \
786 int root_id = source_->GetInt(); \ 791 int root_id = source_->GetInt(); \
787 new_object = isolate->heap()->roots_array_start()[root_id]; \ 792 new_object = isolate->heap()->roots_array_start()[root_id]; \
788 } else if (where == kPartialSnapshotCache) { \ 793 } else if (where == kPartialSnapshotCache) { \
794 if (source_space != CELL_SPACE && \
795 source_space != CODE_SPACE && \
796 source_space != OLD_DATA_SPACE) { \
797 emit_write_barrier = true; \
798 } \
789 int cache_index = source_->GetInt(); \ 799 int cache_index = source_->GetInt(); \
790 new_object = isolate->serialize_partial_snapshot_cache() \ 800 new_object = isolate->serialize_partial_snapshot_cache() \
791 [cache_index]; \ 801 [cache_index]; \
792 } else if (where == kExternalReference) { \ 802 } else if (where == kExternalReference) { \
793 int reference_id = source_->GetInt(); \ 803 int reference_id = source_->GetInt(); \
794 Address address = external_reference_decoder_-> \ 804 Address address = external_reference_decoder_-> \
795 Decode(reference_id); \ 805 Decode(reference_id); \
796 new_object = reinterpret_cast<Object*>(address); \ 806 new_object = reinterpret_cast<Object*>(address); \
797 } else if (where == kBackref) { \ 807 } else if (where == kBackref) { \
798 emit_write_barrier = (space_number == NEW_SPACE && \ 808 emit_write_barrier = (space_number == NEW_SPACE && \
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 int size = source_->GetInt(); 923 int size = source_->GetInt();
914 byte* raw_data_out = reinterpret_cast<byte*>(current); 924 byte* raw_data_out = reinterpret_cast<byte*>(current);
915 source_->CopyRaw(raw_data_out, size); 925 source_->CopyRaw(raw_data_out, size);
916 current = reinterpret_cast<Object**>(raw_data_out + size); 926 current = reinterpret_cast<Object**>(raw_data_out + size);
917 break; 927 break;
918 } 928 }
919 929
920 SIXTEEN_CASES(kRootArrayLowConstants) 930 SIXTEEN_CASES(kRootArrayLowConstants)
921 SIXTEEN_CASES(kRootArrayHighConstants) { 931 SIXTEEN_CASES(kRootArrayHighConstants) {
922 int root_id = RootArrayConstantFromByteCode(data); 932 int root_id = RootArrayConstantFromByteCode(data);
923 *current++ = isolate->heap()->roots_array_start()[root_id]; 933 Object* object = isolate->heap()->roots_array_start()[root_id];
934 ASSERT(!isolate->heap()->InNewSpace(object));
935 *current++ = object;
924 break; 936 break;
925 } 937 }
926 938
927 case kRepeat: { 939 case kRepeat: {
928 int repeats = source_->GetInt(); 940 int repeats = source_->GetInt();
929 Object* object = current[-1]; 941 Object* object = current[-1];
942 ASSERT(!isolate->heap()->InNewSpace(object));
930 for (int i = 0; i < repeats; i++) current[i] = object; 943 for (int i = 0; i < repeats; i++) current[i] = object;
931 current += repeats; 944 current += repeats;
932 break; 945 break;
933 } 946 }
934 947
948 STATIC_ASSERT(kRootArrayNumberOfConstantEncodings ==
949 Heap::kOldSpaceRoots);
935 STATIC_ASSERT(kMaxRepeats == 12); 950 STATIC_ASSERT(kMaxRepeats == 12);
936 FOUR_CASES(kConstantRepeat) 951 FOUR_CASES(kConstantRepeat)
937 FOUR_CASES(kConstantRepeat + 4) 952 FOUR_CASES(kConstantRepeat + 4)
938 FOUR_CASES(kConstantRepeat + 8) { 953 FOUR_CASES(kConstantRepeat + 8) {
939 int repeats = RepeatsForCode(data); 954 int repeats = RepeatsForCode(data);
940 Object* object = current[-1]; 955 Object* object = current[-1];
956 ASSERT(!isolate->heap()->InNewSpace(object));
941 for (int i = 0; i < repeats; i++) current[i] = object; 957 for (int i = 0; i < repeats; i++) current[i] = object;
942 current += repeats; 958 current += repeats;
943 break; 959 break;
944 } 960 }
945 961
946 // Deserialize a new object and write a pointer to it to the current 962 // Deserialize a new object and write a pointer to it to the current
947 // object. 963 // object.
948 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) 964 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject)
949 // Support for direct instruction pointers in functions 965 // Support for direct instruction pointers in functions
950 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction) 966 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction)
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 1434
1419 1435
1420 void Serializer::ObjectSerializer::VisitPointers(Object** start, 1436 void Serializer::ObjectSerializer::VisitPointers(Object** start,
1421 Object** end) { 1437 Object** end) {
1422 Object** current = start; 1438 Object** current = start;
1423 while (current < end) { 1439 while (current < end) {
1424 while (current < end && (*current)->IsSmi()) current++; 1440 while (current < end && (*current)->IsSmi()) current++;
1425 if (current < end) OutputRawData(reinterpret_cast<Address>(current)); 1441 if (current < end) OutputRawData(reinterpret_cast<Address>(current));
1426 1442
1427 while (current < end && !(*current)->IsSmi()) { 1443 while (current < end && !(*current)->IsSmi()) {
1444 HeapObject* current_contents = HeapObject::cast(*current);
1445 int root_index = serializer_->RootIndex(current_contents);
1446 // Repeats are not subject to the write barrier so there are only some
1447 // objects that can be used in a repeat encoding. These are the early
1448 // ones in the root array that are never in new space.
1428 if (current != start && 1449 if (current != start &&
1429 current[0] == current[-1] && 1450 root_index != kInvalidRootIndex &&
1430 !HEAP->InNewSpace(*current)) { 1451 root_index < kRootArrayNumberOfConstantEncodings &&
1452 current_contents == current[-1]) {
1453 ASSERT(!HEAP->InNewSpace(current_contents));
1431 int repeat_count = 1; 1454 int repeat_count = 1;
1432 while (current < end - 1 && current[repeat_count] == current[0]) { 1455 while (current < end - 1 && current[repeat_count] == current_contents) {
1433 repeat_count++; 1456 repeat_count++;
1434 } 1457 }
1435 current += repeat_count; 1458 current += repeat_count;
1436 bytes_processed_so_far_ += repeat_count * kPointerSize; 1459 bytes_processed_so_far_ += repeat_count * kPointerSize;
1437 if (repeat_count > kMaxRepeats) { 1460 if (repeat_count > kMaxRepeats) {
1438 sink_->Put(kRepeat, "SerializeRepeats"); 1461 sink_->Put(kRepeat, "SerializeRepeats");
1439 sink_->PutInt(repeat_count, "SerializeRepeats"); 1462 sink_->PutInt(repeat_count, "SerializeRepeats");
1440 } else { 1463 } else {
1441 sink_->Put(CodeForRepeats(repeat_count), "SerializeRepeats"); 1464 sink_->Put(CodeForRepeats(repeat_count), "SerializeRepeats");
1442 } 1465 }
1443 } else { 1466 } else {
1444 serializer_->SerializeObject(*current, kPlain, kStartOfObject); 1467 serializer_->SerializeObject(current_contents, kPlain, kStartOfObject);
1445 bytes_processed_so_far_ += kPointerSize; 1468 bytes_processed_so_far_ += kPointerSize;
1446 current++; 1469 current++;
1447 } 1470 }
1448 } 1471 }
1449 } 1472 }
1450 } 1473 }
1451 1474
1452 1475
1453 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start, 1476 void Serializer::ObjectSerializer::VisitExternalReferences(Address* start,
1454 Address* end) { 1477 Address* end) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1644 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1622 } 1645 }
1623 } 1646 }
1624 int allocation_address = fullness_[space]; 1647 int allocation_address = fullness_[space];
1625 fullness_[space] = allocation_address + size; 1648 fullness_[space] = allocation_address + size;
1626 return allocation_address; 1649 return allocation_address;
1627 } 1650 }
1628 1651
1629 1652
1630 } } // namespace v8::internal 1653 } } // namespace v8::internal
OLDNEW
« src/heap.h ('K') | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698