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

Side by Side Diff: src/serialize.cc

Issue 757983002: Reset code age on the cloned code when serializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/objects.cc ('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 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 #undef RAW_CASE 1867 #undef RAW_CASE
1868 { /* NOLINT */ 1868 { /* NOLINT */
1869 // We always end up here if we are outputting the code of a code object. 1869 // We always end up here if we are outputting the code of a code object.
1870 sink_->Put(kRawData, "RawData"); 1870 sink_->Put(kRawData, "RawData");
1871 sink_->PutInt(bytes_to_output, "length"); 1871 sink_->PutInt(bytes_to_output, "length");
1872 } 1872 }
1873 1873
1874 // To make snapshots reproducible, we need to wipe out all pointers in code. 1874 // To make snapshots reproducible, we need to wipe out all pointers in code.
1875 if (code_object_) { 1875 if (code_object_) {
1876 Code* code = CloneCodeObject(object_); 1876 Code* code = CloneCodeObject(object_);
1877 // Code age headers are not serializable.
1878 code->MakeYoung(serializer_->isolate());
1877 WipeOutRelocations(code); 1879 WipeOutRelocations(code);
1878 // We need to wipe out the header fields *after* wiping out the 1880 // We need to wipe out the header fields *after* wiping out the
1879 // relocations, because some of these fields are needed for the latter. 1881 // relocations, because some of these fields are needed for the latter.
1880 code->WipeOutHeader(); 1882 code->WipeOutHeader();
1881 object_start = code->address(); 1883 object_start = code->address();
1882 } 1884 }
1883 1885
1884 const char* description = code_object_ ? "Code" : "Byte"; 1886 const char* description = code_object_ ? "Code" : "Byte";
1885 sink_->PutRaw(object_start + base, bytes_to_output, description); 1887 sink_->PutRaw(object_start + base, bytes_to_output, description);
1886 if (code_object_) delete[] object_start; 1888 if (code_object_) delete[] object_start;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 SerializeIC(code_object, how_to_code, where_to_point); 2044 SerializeIC(code_object, how_to_code, where_to_point);
2043 return; 2045 return;
2044 case Code::FUNCTION: 2046 case Code::FUNCTION:
2045 DCHECK(code_object->has_reloc_info_for_serialization()); 2047 DCHECK(code_object->has_reloc_info_for_serialization());
2046 // Only serialize the code for the toplevel function unless specified 2048 // Only serialize the code for the toplevel function unless specified
2047 // by flag. Replace code of inner functions by the lazy compile builtin. 2049 // by flag. Replace code of inner functions by the lazy compile builtin.
2048 // This is safe, as checked in Compiler::BuildFunctionInfo. 2050 // This is safe, as checked in Compiler::BuildFunctionInfo.
2049 if (code_object != main_code_ && !FLAG_serialize_inner) { 2051 if (code_object != main_code_ && !FLAG_serialize_inner) {
2050 SerializeBuiltin(Builtins::kCompileLazy, how_to_code, where_to_point); 2052 SerializeBuiltin(Builtins::kCompileLazy, how_to_code, where_to_point);
2051 } else { 2053 } else {
2052 code_object->MakeYoung();
2053 SerializeGeneric(code_object, how_to_code, where_to_point); 2054 SerializeGeneric(code_object, how_to_code, where_to_point);
2054 } 2055 }
2055 return; 2056 return;
2056 } 2057 }
2057 UNREACHABLE(); 2058 UNREACHABLE();
2058 } 2059 }
2059 2060
2060 // Past this point we should not see any (context-specific) maps anymore. 2061 // Past this point we should not see any (context-specific) maps anymore.
2061 CHECK(!obj->IsMap()); 2062 CHECK(!obj->IsMap());
2062 // There should be no references to the global object embedded. 2063 // There should be no references to the global object embedded.
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 bool SerializedCodeData::IsSane(String* source) { 2321 bool SerializedCodeData::IsSane(String* source) {
2321 return GetHeaderValue(kCheckSumOffset) == CheckSum(source) && 2322 return GetHeaderValue(kCheckSumOffset) == CheckSum(source) &&
2322 PayloadLength() >= SharedFunctionInfo::kSize; 2323 PayloadLength() >= SharedFunctionInfo::kSize;
2323 } 2324 }
2324 2325
2325 2326
2326 int SerializedCodeData::CheckSum(String* string) { 2327 int SerializedCodeData::CheckSum(String* string) {
2327 return Version::Hash() ^ string->length(); 2328 return Version::Hash() ^ string->length();
2328 } 2329 }
2329 } } // namespace v8::internal 2330 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698