From 54b2f8da53ace9c087fc727db4c25bf2d48962de Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Tue, 22 Jul 2014 10:35:38 +0000 Subject: [PATCH] Add profiling to code serializer. R=jochen@chromium.org Review URL: https://codereview.chromium.org/408143004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22521 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler.cc | 19 +++++++++++++++---- src/serialize.cc | 8 +++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index 718c0dc..8d59dbc 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -960,15 +960,22 @@ Handle Compiler::CompileScript( MaybeHandle maybe_result; Handle result; if (extension == NULL) { - maybe_result = compilation_cache->LookupScript( - source, script_name, line_offset, column_offset, - is_shared_cross_origin, context); - if (maybe_result.is_null() && FLAG_serialize_toplevel && + if (FLAG_serialize_toplevel && compile_options == ScriptCompiler::kConsumeCodeCache) { return CodeSerializer::Deserialize(isolate, *cached_data, source); + } else { + maybe_result = compilation_cache->LookupScript( + source, script_name, line_offset, column_offset, + is_shared_cross_origin, context); } } + base::ElapsedTimer timer; + if (FLAG_profile_deserialization && FLAG_serialize_toplevel && + compile_options == ScriptCompiler::kProduceCodeCache) { + timer.Start(); + } + if (!maybe_result.ToHandle(&result)) { // No cache entry found. Compile the script. @@ -1002,6 +1009,10 @@ Handle Compiler::CompileScript( if (FLAG_serialize_toplevel && compile_options == ScriptCompiler::kProduceCodeCache) { *cached_data = CodeSerializer::Serialize(isolate, result, source); + if (FLAG_profile_deserialization) { + PrintF("[Compiling and serializing %d bytes took %0.3f ms]\n", + (*cached_data)->length(), timer.Elapsed().InMillisecondsF()); + } } } diff --git a/src/serialize.cc b/src/serialize.cc index c35464e..2031935 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -1991,11 +1991,12 @@ void CodeSerializer::SerializeSourceObject(HowToCode how_to_code, Handle CodeSerializer::Deserialize(Isolate* isolate, ScriptData* data, Handle source) { + base::ElapsedTimer timer; + if (FLAG_profile_deserialization) timer.Start(); SerializedCodeData scd(data, *source); SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); Deserializer deserializer(&payload); STATIC_ASSERT(NEW_SPACE == 0); - // TODO(yangguo) what happens if remaining new space is too small? for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { deserializer.set_reservation(i, scd.GetReservation(i)); } @@ -2009,6 +2010,11 @@ Handle CodeSerializer::Deserialize(Isolate* isolate, Object* root; deserializer.DeserializePartial(isolate, &root); deserializer.FlushICacheForNewCodeObjects(); + if (FLAG_profile_deserialization) { + double ms = timer.Elapsed().InMillisecondsF(); + int length = data->length(); + PrintF("[Deserializing from %d bytes took %0.3f ms]\n", length, ms); + } return Handle(SharedFunctionInfo::cast(root), isolate); } -- 2.7.4