Reviewers: jochen,
https://codereview.chromium.org/408143004/diff/1/src/compiler.cc
File src/compiler.cc (right):
https://codereview.chromium.org/408143004/diff/1/src/compiler.cc#newcode966
src/compiler.cc:966: } else {
Without this change, --cache=code for d8 has no effect, since the
compilation cache kicks in before we consume the code cache. We may
change this later when we turn on --serialize-toplevel by default,
though.
Description:
Add profiling to code serializer.
Please review this at https://codereview.chromium.org/408143004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+22, -5 lines):
M src/compiler.cc
M src/serialize.cc
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
718c0dc8fb00b5ef17ab95546612e5406305e897..8d59dbca2dc90c185eb9eede87562f6bdf69387e
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -960,15 +960,22 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
MaybeHandle<SharedFunctionInfo> maybe_result;
Handle<SharedFunctionInfo> 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<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());
+ }
}
}
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
c35464e2f8e37954f753e7129ac61e82349fd1e2..20319357ab57cde4d60ca3f9d6c77ae64d67561d
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.