Commit 319e5226 authored by danno@chromium.org's avatar danno@chromium.org

fix the vtune support bug.

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