Commit 54b2f8da authored by yangguo@chromium.org's avatar yangguo@chromium.org

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
parent a973e3a1
...@@ -960,15 +960,22 @@ Handle<SharedFunctionInfo> Compiler::CompileScript( ...@@ -960,15 +960,22 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
MaybeHandle<SharedFunctionInfo> maybe_result; MaybeHandle<SharedFunctionInfo> maybe_result;
Handle<SharedFunctionInfo> result; Handle<SharedFunctionInfo> result;
if (extension == NULL) { if (extension == NULL) {
maybe_result = compilation_cache->LookupScript( if (FLAG_serialize_toplevel &&
source, script_name, line_offset, column_offset,
is_shared_cross_origin, context);
if (maybe_result.is_null() && FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kConsumeCodeCache) { compile_options == ScriptCompiler::kConsumeCodeCache) {
return CodeSerializer::Deserialize(isolate, *cached_data, source); 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)) { if (!maybe_result.ToHandle(&result)) {
// No cache entry found. Compile the script. // No cache entry found. Compile the script.
...@@ -1002,6 +1009,10 @@ Handle<SharedFunctionInfo> Compiler::CompileScript( ...@@ -1002,6 +1009,10 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
if (FLAG_serialize_toplevel && if (FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kProduceCodeCache) { compile_options == ScriptCompiler::kProduceCodeCache) {
*cached_data = CodeSerializer::Serialize(isolate, result, source); *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());
}
} }
} }
......
...@@ -1991,11 +1991,12 @@ void CodeSerializer::SerializeSourceObject(HowToCode how_to_code, ...@@ -1991,11 +1991,12 @@ void CodeSerializer::SerializeSourceObject(HowToCode how_to_code,
Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate, Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate,
ScriptData* data, ScriptData* data,
Handle<String> source) { Handle<String> source) {
base::ElapsedTimer timer;
if (FLAG_profile_deserialization) timer.Start();
SerializedCodeData scd(data, *source); SerializedCodeData scd(data, *source);
SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); SnapshotByteSource payload(scd.Payload(), scd.PayloadLength());
Deserializer deserializer(&payload); Deserializer deserializer(&payload);
STATIC_ASSERT(NEW_SPACE == 0); 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++) { for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) {
deserializer.set_reservation(i, scd.GetReservation(i)); deserializer.set_reservation(i, scd.GetReservation(i));
} }
...@@ -2009,6 +2010,11 @@ Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate, ...@@ -2009,6 +2010,11 @@ Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate,
Object* root; Object* root;
deserializer.DeserializePartial(isolate, &root); deserializer.DeserializePartial(isolate, &root);
deserializer.FlushICacheForNewCodeObjects(); 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); return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root), isolate);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment