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

Side by Side Diff: src/snapshot/serialize.cc

Issue 1072923003: Serializer: canonicalize cleared weak cells. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/snapshot/serialize.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 const Heap::Reservation& reservation = reservations_[space]; 1085 const Heap::Reservation& reservation = reservations_[space];
1086 // Make sure the current chunk is indeed exhausted. 1086 // Make sure the current chunk is indeed exhausted.
1087 CHECK_EQ(reservation[chunk_index].end, high_water_[space]); 1087 CHECK_EQ(reservation[chunk_index].end, high_water_[space]);
1088 // Move to next reserved chunk. 1088 // Move to next reserved chunk.
1089 chunk_index = ++current_chunk_[space]; 1089 chunk_index = ++current_chunk_[space];
1090 CHECK_LT(chunk_index, reservation.length()); 1090 CHECK_LT(chunk_index, reservation.length());
1091 high_water_[space] = reservation[chunk_index].start; 1091 high_water_[space] = reservation[chunk_index].start;
1092 break; 1092 break;
1093 } 1093 }
1094 1094
1095 case kClearedWeakCell: {
1096 Object* cleared_weak_cell = isolate_->heap()->cleared_weak_cell();
1097 UnalignedCopy(current++, &cleared_weak_cell);
1098 break;
1099 }
1100
1095 case kSynchronize: 1101 case kSynchronize:
1096 // If we get here then that indicates that you have a mismatch between 1102 // If we get here then that indicates that you have a mismatch between
1097 // the number of GC roots when serializing and deserializing. 1103 // the number of GC roots when serializing and deserializing.
1098 CHECK(false); 1104 CHECK(false);
1099 break; 1105 break;
1100 1106
1101 case kNativesStringResource: { 1107 case kNativesStringResource: {
1102 DCHECK(!isolate_->heap()->deserialization_complete()); 1108 DCHECK(!isolate_->heap()->deserialization_complete());
1103 int index = source_.Get(); 1109 int index = source_.Get();
1104 Vector<const char> source_vector = Natives::GetScriptSource(index); 1110 Vector<const char> source_vector = Natives::GetScriptSource(index);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 } else { 1461 } else {
1456 return chunk_index < completed_chunks_[space].length() && 1462 return chunk_index < completed_chunks_[space].length() &&
1457 reference.chunk_offset() < completed_chunks_[space][chunk_index]; 1463 reference.chunk_offset() < completed_chunks_[space][chunk_index];
1458 } 1464 }
1459 } 1465 }
1460 #endif // DEBUG 1466 #endif // DEBUG
1461 1467
1462 1468
1463 bool Serializer::SerializeKnownObject(HeapObject* obj, HowToCode how_to_code, 1469 bool Serializer::SerializeKnownObject(HeapObject* obj, HowToCode how_to_code,
1464 WhereToPoint where_to_point, int skip) { 1470 WhereToPoint where_to_point, int skip) {
1471 if (obj->IsWeakCell() && WeakCell::cast(obj)->cleared()) {
1472 FlushSkip(skip);
1473 sink_->Put(kClearedWeakCell, "ClearedWeakCell");
1474 return true;
1475 }
1465 if (how_to_code == kPlain && where_to_point == kStartOfObject) { 1476 if (how_to_code == kPlain && where_to_point == kStartOfObject) {
1466 // Encode a reference to a hot object by its index in the working set. 1477 // Encode a reference to a hot object by its index in the working set.
1467 int index = hot_objects_.Find(obj); 1478 int index = hot_objects_.Find(obj);
1468 if (index != HotObjectsList::kNotFound) { 1479 if (index != HotObjectsList::kNotFound) {
1469 DCHECK(index >= 0 && index < kNumberOfHotObjects); 1480 DCHECK(index >= 0 && index < kNumberOfHotObjects);
1470 if (FLAG_trace_serializer) { 1481 if (FLAG_trace_serializer) {
1471 PrintF(" Encoding hot object %d:", index); 1482 PrintF(" Encoding hot object %d:", index);
1472 obj->ShortPrint(); 1483 obj->ShortPrint();
1473 PrintF("\n"); 1484 PrintF("\n");
1474 } 1485 }
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 DisallowHeapAllocation no_gc; 2602 DisallowHeapAllocation no_gc;
2592 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2603 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2593 SanityCheckResult r = scd->SanityCheck(isolate, source); 2604 SanityCheckResult r = scd->SanityCheck(isolate, source);
2594 if (r == CHECK_SUCCESS) return scd; 2605 if (r == CHECK_SUCCESS) return scd;
2595 cached_data->Reject(); 2606 cached_data->Reject();
2596 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2607 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2597 delete scd; 2608 delete scd;
2598 return NULL; 2609 return NULL;
2599 } 2610 }
2600 } } // namespace v8::internal 2611 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/snapshot/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698