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 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 return; | 2035 return; |
2036 case Code::STUB: | 2036 case Code::STUB: |
2037 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point); | 2037 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point); |
2038 return; | 2038 return; |
2039 #define IC_KIND_CASE(KIND) case Code::KIND: | 2039 #define IC_KIND_CASE(KIND) case Code::KIND: |
2040 IC_KIND_LIST(IC_KIND_CASE) | 2040 IC_KIND_LIST(IC_KIND_CASE) |
2041 #undef IC_KIND_CASE | 2041 #undef IC_KIND_CASE |
2042 SerializeIC(code_object, how_to_code, where_to_point); | 2042 SerializeIC(code_object, how_to_code, where_to_point); |
2043 return; | 2043 return; |
2044 case Code::FUNCTION: | 2044 case Code::FUNCTION: |
2045 // Only serialize the code for the toplevel function. Replace code | 2045 DCHECK(code_object->has_reloc_info_for_serialization()); |
2046 // of included function literals by the lazy compile builtin. | 2046 // Only serialize the code for the toplevel function unless specified |
| 2047 // by flag. Replace code of inner functions by the lazy compile builtin. |
2047 // This is safe, as checked in Compiler::BuildFunctionInfo. | 2048 // This is safe, as checked in Compiler::BuildFunctionInfo. |
2048 if (code_object != main_code_) { | 2049 if (code_object != main_code_ && !FLAG_serialize_inner) { |
2049 SerializeBuiltin(Builtins::kCompileLazy, how_to_code, where_to_point); | 2050 SerializeBuiltin(Builtins::kCompileLazy, how_to_code, where_to_point); |
2050 } else { | 2051 } else { |
2051 code_object->MakeYoung(); | 2052 code_object->MakeYoung(); |
2052 SerializeGeneric(code_object, how_to_code, where_to_point); | 2053 SerializeGeneric(code_object, how_to_code, where_to_point); |
2053 } | 2054 } |
2054 return; | 2055 return; |
2055 } | 2056 } |
2056 UNREACHABLE(); | 2057 UNREACHABLE(); |
2057 } | 2058 } |
2058 | 2059 |
2059 // Past this point we should not see any (context-specific) maps anymore. | 2060 // Past this point we should not see any (context-specific) maps anymore. |
2060 CHECK(!obj->IsMap()); | 2061 CHECK(!obj->IsMap()); |
2061 // There should be no references to the global object embedded. | 2062 // There should be no references to the global object embedded. |
2062 CHECK(!obj->IsJSGlobalProxy() && !obj->IsGlobalObject()); | 2063 CHECK(!obj->IsJSGlobalProxy() && !obj->IsGlobalObject()); |
2063 // There should be no hash table embedded. They would require rehashing. | 2064 // There should be no hash table embedded. They would require rehashing. |
2064 CHECK(!obj->IsHashTable()); | 2065 CHECK(!obj->IsHashTable()); |
| 2066 // We expect no instantiated function objects or contexts. |
| 2067 CHECK(!obj->IsJSFunction() && !obj->IsContext()); |
2065 | 2068 |
2066 SerializeGeneric(obj, how_to_code, where_to_point); | 2069 SerializeGeneric(obj, how_to_code, where_to_point); |
2067 } | 2070 } |
2068 | 2071 |
2069 | 2072 |
2070 void CodeSerializer::SerializeGeneric(HeapObject* heap_object, | 2073 void CodeSerializer::SerializeGeneric(HeapObject* heap_object, |
2071 HowToCode how_to_code, | 2074 HowToCode how_to_code, |
2072 WhereToPoint where_to_point) { | 2075 WhereToPoint where_to_point) { |
2073 if (FLAG_trace_code_serializer) { | 2076 if (FLAG_trace_code_serializer) { |
2074 PrintF(" Encoding heap object: "); | 2077 PrintF(" Encoding heap object: "); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 bool SerializedCodeData::IsSane(String* source) { | 2320 bool SerializedCodeData::IsSane(String* source) { |
2318 return GetHeaderValue(kCheckSumOffset) == CheckSum(source) && | 2321 return GetHeaderValue(kCheckSumOffset) == CheckSum(source) && |
2319 PayloadLength() >= SharedFunctionInfo::kSize; | 2322 PayloadLength() >= SharedFunctionInfo::kSize; |
2320 } | 2323 } |
2321 | 2324 |
2322 | 2325 |
2323 int SerializedCodeData::CheckSum(String* string) { | 2326 int SerializedCodeData::CheckSum(String* string) { |
2324 return Version::Hash() ^ string->length(); | 2327 return Version::Hash() ^ string->length(); |
2325 } | 2328 } |
2326 } } // namespace v8::internal | 2329 } } // namespace v8::internal |
OLD | NEW |