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/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.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 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 if (FLAG_profile_deserialization) timer.Start(); | 2415 if (FLAG_profile_deserialization) timer.Start(); |
2416 if (FLAG_trace_serializer) { | 2416 if (FLAG_trace_serializer) { |
2417 PrintF("[Serializing from"); | 2417 PrintF("[Serializing from"); |
2418 Object* script = info->script(); | 2418 Object* script = info->script(); |
2419 if (script->IsScript()) Script::cast(script)->name()->ShortPrint(); | 2419 if (script->IsScript()) Script::cast(script)->name()->ShortPrint(); |
2420 PrintF("]\n"); | 2420 PrintF("]\n"); |
2421 } | 2421 } |
2422 | 2422 |
2423 // Serialize code object. | 2423 // Serialize code object. |
2424 SnapshotByteSink sink(info->code()->CodeSize() * 2); | 2424 SnapshotByteSink sink(info->code()->CodeSize() * 2); |
2425 CodeSerializer cs(isolate, &sink, *source, info->code()); | 2425 CodeSerializer cs(isolate, &sink, *source); |
2426 DisallowHeapAllocation no_gc; | 2426 DisallowHeapAllocation no_gc; |
2427 Object** location = Handle<Object>::cast(info).location(); | 2427 Object** location = Handle<Object>::cast(info).location(); |
2428 cs.VisitPointer(location); | 2428 cs.VisitPointer(location); |
2429 cs.SerializeDeferredObjects(); | 2429 cs.SerializeDeferredObjects(); |
2430 cs.Pad(); | 2430 cs.Pad(); |
2431 | 2431 |
2432 SerializedCodeData data(sink.data(), cs); | 2432 SerializedCodeData data(sink.data(), cs); |
2433 ScriptData* script_data = data.GetScriptData(); | 2433 ScriptData* script_data = data.GetScriptData(); |
2434 | 2434 |
2435 if (FLAG_profile_deserialization) { | 2435 if (FLAG_profile_deserialization) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 case Code::STUB: | 2469 case Code::STUB: |
2470 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point); | 2470 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point); |
2471 return; | 2471 return; |
2472 #define IC_KIND_CASE(KIND) case Code::KIND: | 2472 #define IC_KIND_CASE(KIND) case Code::KIND: |
2473 IC_KIND_LIST(IC_KIND_CASE) | 2473 IC_KIND_LIST(IC_KIND_CASE) |
2474 #undef IC_KIND_CASE | 2474 #undef IC_KIND_CASE |
2475 SerializeIC(code_object, how_to_code, where_to_point); | 2475 SerializeIC(code_object, how_to_code, where_to_point); |
2476 return; | 2476 return; |
2477 case Code::FUNCTION: | 2477 case Code::FUNCTION: |
2478 DCHECK(code_object->has_reloc_info_for_serialization()); | 2478 DCHECK(code_object->has_reloc_info_for_serialization()); |
2479 // Only serialize the code for the toplevel function unless specified | 2479 SerializeGeneric(code_object, how_to_code, where_to_point); |
2480 // by flag. Replace code of inner functions by the lazy compile builtin. | |
2481 // This is safe, as checked in Compiler::GetSharedFunctionInfo. | |
2482 if (code_object != main_code_ && !FLAG_serialize_inner) { | |
2483 SerializeBuiltin(Builtins::kCompileLazy, how_to_code, where_to_point); | |
2484 } else { | |
2485 SerializeGeneric(code_object, how_to_code, where_to_point); | |
2486 } | |
2487 return; | 2480 return; |
2488 case Code::WASM_FUNCTION: | 2481 case Code::WASM_FUNCTION: |
2489 UNREACHABLE(); | 2482 UNREACHABLE(); |
2490 } | 2483 } |
2491 UNREACHABLE(); | 2484 UNREACHABLE(); |
2492 } | 2485 } |
2493 | 2486 |
2494 // Past this point we should not see any (context-specific) maps anymore. | 2487 // Past this point we should not see any (context-specific) maps anymore. |
2495 CHECK(!obj->IsMap()); | 2488 CHECK(!obj->IsMap()); |
2496 // There should be no references to the global object embedded. | 2489 // There should be no references to the global object embedded. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2878 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2886 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2879 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2887 if (r == CHECK_SUCCESS) return scd; | 2880 if (r == CHECK_SUCCESS) return scd; |
2888 cached_data->Reject(); | 2881 cached_data->Reject(); |
2889 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2882 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2890 delete scd; | 2883 delete scd; |
2891 return NULL; | 2884 return NULL; |
2892 } | 2885 } |
2893 } // namespace internal | 2886 } // namespace internal |
2894 } // namespace v8 | 2887 } // namespace v8 |
OLD | NEW |