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
This commit is contained in:
yangguo@chromium.org 2014-07-22 10:35:38 +00:00
parent a973e3a16e
commit 54b2f8da53
2 changed files with 22 additions and 5 deletions

View File

@ -960,15 +960,22 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
MaybeHandle<SharedFunctionInfo> maybe_result;
Handle<SharedFunctionInfo> result;
if (extension == NULL) {
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);
if (maybe_result.is_null() && FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kConsumeCodeCache) {
return CodeSerializer::Deserialize(isolate, *cached_data, source);
}
}
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<SharedFunctionInfo> 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());
}
}
}

View File

@ -1991,11 +1991,12 @@ void CodeSerializer::SerializeSourceObject(HowToCode how_to_code,
Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate,
ScriptData* data,
Handle<String> 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<SharedFunctionInfo> 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>(SharedFunctionInfo::cast(root), isolate);
}