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

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

Issue 1170723003: Only mark checksummed memory as initialized for MSAN. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.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 | « no previous file | 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 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 to_skip = 0; // This instruction includes skip. 2121 to_skip = 0; // This instruction includes skip.
2122 } else { 2122 } else {
2123 // We always end up here if we are outputting the code of a code object. 2123 // We always end up here if we are outputting the code of a code object.
2124 sink_->Put(kVariableRawData, "VariableRawData"); 2124 sink_->Put(kVariableRawData, "VariableRawData");
2125 sink_->PutInt(bytes_to_output, "length"); 2125 sink_->PutInt(bytes_to_output, "length");
2126 } 2126 }
2127 2127
2128 if (is_code_object_) object_start = PrepareCode(); 2128 if (is_code_object_) object_start = PrepareCode();
2129 2129
2130 const char* description = is_code_object_ ? "Code" : "Byte"; 2130 const char* description = is_code_object_ ? "Code" : "Byte";
2131 #ifdef MEMORY_SANITIZER
2132 // Object sizes are usually rounded up with uninitialized padding space.
2133 MSAN_MEMORY_IS_INITIALIZED(object_start + base, bytes_to_output);
2134 #endif // MEMORY_SANITIZER
2135 sink_->PutRaw(object_start + base, bytes_to_output, description); 2131 sink_->PutRaw(object_start + base, bytes_to_output, description);
2136 } 2132 }
2137 if (to_skip != 0 && return_skip == kIgnoringReturn) { 2133 if (to_skip != 0 && return_skip == kIgnoringReturn) {
2138 sink_->Put(kSkip, "Skip"); 2134 sink_->Put(kSkip, "Skip");
2139 sink_->PutInt(to_skip, "SkipDistance"); 2135 sink_->PutInt(to_skip, "SkipDistance");
2140 to_skip = 0; 2136 to_skip = 0;
2141 } 2137 }
2142 return to_skip; 2138 return to_skip;
2143 } 2139 }
2144 2140
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 const byte* payload = data_ + kHeaderSize + reservations_size; 2507 const byte* payload = data_ + kHeaderSize + reservations_size;
2512 int length = GetHeaderValue(kPayloadLengthOffset); 2508 int length = GetHeaderValue(kPayloadLengthOffset);
2513 DCHECK_EQ(data_ + size_, payload + length); 2509 DCHECK_EQ(data_ + size_, payload + length);
2514 return Vector<const byte>(payload, length); 2510 return Vector<const byte>(payload, length);
2515 } 2511 }
2516 2512
2517 2513
2518 class Checksum { 2514 class Checksum {
2519 public: 2515 public:
2520 explicit Checksum(Vector<const byte> payload) { 2516 explicit Checksum(Vector<const byte> payload) {
2517 #ifdef MEMORY_SANITIZER
2518 // Computing the checksum includes padding bytes for objects like strings.
2519 // Mark every object as initialized in the code serializer.
2520 MSAN_MEMORY_IS_INITIALIZED(payload.start(), payload.length());
2521 #endif // MEMORY_SANITIZER
2521 // Fletcher's checksum. Modified to reduce 64-bit sums to 32-bit. 2522 // Fletcher's checksum. Modified to reduce 64-bit sums to 32-bit.
2522 uintptr_t a = 1; 2523 uintptr_t a = 1;
2523 uintptr_t b = 0; 2524 uintptr_t b = 0;
2524 const uintptr_t* cur = reinterpret_cast<const uintptr_t*>(payload.start()); 2525 const uintptr_t* cur = reinterpret_cast<const uintptr_t*>(payload.start());
2525 DCHECK(IsAligned(payload.length(), kIntptrSize)); 2526 DCHECK(IsAligned(payload.length(), kIntptrSize));
2526 const uintptr_t* end = cur + payload.length() / kIntptrSize; 2527 const uintptr_t* end = cur + payload.length() / kIntptrSize;
2527 while (cur < end) { 2528 while (cur < end) {
2528 // Unsigned overflow expected and intended. 2529 // Unsigned overflow expected and intended.
2529 a += *cur++; 2530 a += *cur++;
2530 b += a; 2531 b += a;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2678 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2678 SanityCheckResult r = scd->SanityCheck(isolate, source); 2679 SanityCheckResult r = scd->SanityCheck(isolate, source);
2679 if (r == CHECK_SUCCESS) return scd; 2680 if (r == CHECK_SUCCESS) return scd;
2680 cached_data->Reject(); 2681 cached_data->Reject();
2681 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2682 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2682 delete scd; 2683 delete scd;
2683 return NULL; 2684 return NULL;
2684 } 2685 }
2685 } // namespace internal 2686 } // namespace internal
2686 } // namespace v8 2687 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698