fix the vtune support bug.
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 15 Jul 2014 08:13:42 +0000 (08:13 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 15 Jul 2014 08:13:42 +0000 (08:13 +0000)
During https://code.google.com/p/v8/source/detail?r=19925 checkin context bound scripts (Script)
and context unbound scripts (UnboundScript) are Distinguished.

And then Sven Panne helped to fix the vtune support compilation
error in https://code.google.com/p/v8/source/detail?r=20955.

The problem is that there is runtime error for vtune
support.
In our original implementation, we encapsulated and passed v8::internal::Script
to V8 API. It will leads to type check error for current V8::Script definition.

So I changed the Handle<Script> definition in JitCodeEvent
to Handle<UnboundScript>
 and add the corresponding change in log.cc.

If you do NOT prefer to change in include/v8.h. I think I can change the definition of
CodeEventLogger::LogRecordedBuffer(...) so that the we can pass the correct
type (JSFunction) as V8::Script to V8 API.

BUG=
R=danno@chromium.org, svenpanne@chromium.org

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

Patch from Chunyang Dai <chunyang.dai@intel.com>.

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

include/v8.h
src/log.cc
src/third_party/vtune/vtune-jit.cc

index ee3acab..01b2c1f 100644 (file)
@@ -4577,7 +4577,7 @@ struct JitCodeEvent {
   // Size of the instructions.
   size_t code_len;
   // Script info for CODE_ADDED event.
-  Handle<Script> script;
+  Handle<UnboundScript> script;
   // User-defined data for *_LINE_INFO_* event. It's used to hold the source
   // code line information which is returned from the
   // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
index 6c608d5..deb7e16 100644 (file)
@@ -508,11 +508,11 @@ void JitLogger::LogRecordedBuffer(Code* code,
   event.type = JitCodeEvent::CODE_ADDED;
   event.code_start = code->instruction_start();
   event.code_len = code->instruction_size();
-  Handle<Script> script_handle;
+  Handle<SharedFunctionInfo> shared_function_handle;
   if (shared && shared->script()->IsScript()) {
-    script_handle = Handle<Script>(Script::cast(shared->script()));
+    shared_function_handle = Handle<SharedFunctionInfo>(shared);
   }
-  event.script = ToApiHandle<v8::Script>(script_handle);
+  event.script = ToApiHandle<v8::UnboundScript>(shared_function_handle);
   event.name.str = name;
   event.name.len = length;
   code_event_handler_(&event);
index 023dd18..d62dcfb 100644 (file)
@@ -192,13 +192,12 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
         jmethod.method_size = static_cast<unsigned int>(event->code_len);
         jmethod.method_name = temp_method_name;
 
-        Handle<Script> script = event->script;
+        Handle<UnboundScript> script = event->script;
 
         if (*script != NULL) {
           // Get the source file name and set it to jmethod.source_file_name
-         if ((*script->GetUnboundScript()->GetScriptName())->IsString()) {
-            Handle<String> script_name =
-                script->GetUnboundScript()->GetScriptName()->ToString();
+          if ((*script->GetScriptName())->IsString()) {
+            Handle<String> script_name = script->GetScriptName()->ToString();
             temp_file_name = new char[script_name->Utf8Length() + 1];
             script_name->WriteUtf8(temp_file_name);
             jmethod.source_file_name = temp_file_name;
@@ -225,7 +224,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
               jmethod.line_number_table[index].Offset =
                   static_cast<unsigned int>(Iter->pc_);
               jmethod.line_number_table[index++].LineNumber =
-                  script->GetUnboundScript()->GetLineNumber(Iter->pos_)+1;
+                  script->GetLineNumber(Iter->pos_) + 1;
             }
             GetEntries()->erase(event->code_start);
           }