Log code event for deserialized code.
authoryangguo@chromium.org <yangguo@chromium.org>
Fri, 24 Oct 2014 08:37:03 +0000 (08:37 +0000)
committeryangguo@chromium.org <yangguo@chromium.org>
Fri, 24 Oct 2014 08:37:03 +0000 (08:37 +0000)
R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/663453005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24861 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/serialize.cc
src/serialize.h
test/cctest/test-serialize.cc

index b862c76..ba4bf41 100644 (file)
@@ -2245,6 +2245,18 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
   }
   Handle<SharedFunctionInfo> result(SharedFunctionInfo::cast(root), isolate);
   result->set_deserialized(true);
+
+  if (isolate->logger()->is_logging_code_events() ||
+      isolate->cpu_profiler()->is_profiling()) {
+    String* name = isolate->heap()->empty_string();
+    if (result->script()->IsScript()) {
+      Script* script = Script::cast(result->script());
+      if (script->name()->IsString()) name = String::cast(script->name());
+    }
+    isolate->logger()->CodeCreateEvent(Logger::SCRIPT_TAG, result->code(),
+                                       *result, NULL, name);
+  }
+
   return result;
 }
 
index d15fb54..3766801 100644 (file)
@@ -700,9 +700,7 @@ class CodeSerializer : public Serializer {
       : Serializer(isolate, sink),
         source_(source),
         main_code_(main_code),
-        num_internalized_strings_(0) {
-    InitializeCodeAddressMap();
-  }
+        num_internalized_strings_(0) {}
 
   virtual void SerializeObject(HeapObject* o, HowToCode how_to_code,
                                WhereToPoint where_to_point, int skip);
index 83903e2..ac716a4 100644 (file)
@@ -1156,6 +1156,17 @@ TEST(SerializeToplevelExternalScriptName) {
 }
 
 
+static bool toplevel_test_code_event_found = false;
+
+
+static void SerializerCodeEventListener(const v8::JitCodeEvent* event) {
+  if (event->type == v8::JitCodeEvent::CODE_ADDED &&
+      memcmp(event->name.str, "Script:~test", 12) == 0) {
+    toplevel_test_code_event_found = true;
+  }
+}
+
+
 TEST(SerializeToplevelIsolates) {
   FLAG_serialize_toplevel = true;
 
@@ -1188,6 +1199,9 @@ TEST(SerializeToplevelIsolates) {
   isolate1->Dispose();
 
   v8::Isolate* isolate2 = v8::Isolate::New();
+  isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault,
+                                   SerializerCodeEventListener);
+  toplevel_test_code_event_found = false;
   {
     v8::Isolate::Scope iscope(isolate2);
     v8::HandleScope scope(isolate2);
@@ -1206,6 +1220,7 @@ TEST(SerializeToplevelIsolates) {
     v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
     CHECK(result->ToString()->Equals(v8_str("abcdef")));
   }
+  DCHECK(toplevel_test_code_event_found);
   isolate2->Dispose();
 }