| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |