Hi Ilya,
The following code should illustrate how to use the function mirror to get
the source line. To run it you can add it to the end of the GetMirror test
in test/cctest/test-debug.cc and run tools/test.py cctest/test-debug/
GetMirror.
v8::ScriptOrigin origin =
v8::ScriptOrigin(v8::String::New("test"));
v8::Script::Compile(script, &origin)->Run();
v8::Local<v8::Function> f =
v8::Local<v8::Function>::Cast(env
->Global()->Get(v8::String::New("f")));
v8::Local<v8::Function> g =
v8::Local<v8::Function>::Cast(env
->Global()->Get(v8::String::New("g")));
v8::Handle<v8::Value> mirror_f = v8::Debug::GetMirror(f);
v8::Handle<v8::Value> mirror_g = v8::Debug::GetMirror(g);
v8::Handle<v8::Function> function_info = v8::Handle<v8::Function>::Cast(
v8::Script::New(
v8::String::New(
"function functionInfo(mirror) {"
" return mirror.sourceLocation().line;"
"}"
""
"functionInfo;"))->Run());
result = function_info->Call(env->Global(), 1, &mirror_f);
CHECK_EQ(0, result->Int32Value());
result = function_info->Call(env->Global(), 1, &mirror_g);
CHECK_EQ(3, result->Int32Value());
I suggest you return a JavaScript object which contains all the information
needed that is something like
function functionInfo(mirror) {
return { script: script().name(), line: mirror.sourceLocation().line }
}
Look in src/mirror-delay.js to see what information is available for object
mirrors.
/Søren
On Wed, Feb 3, 2010 at 12:12, Søren Gjesse <[email protected]> wrote:
> I think looking at performance is the right thing to do. Please try to use
> the GetMirror API in the code in V8Proxy.cpp, before adding devtools
> specific functions to the V8 debugger API. Remember that you can compile the
> JavaScript function taking the FunctionMirror object once. If using the
> mirror has a performance overhead then maybe providing more direct access to
> the script/line for a function on the FunctionMirror could solve the
> problem.
>
> If more features are needed in the debugger API I think the API should be
> more general, like providing a full mirror like API.
>
> Regards,
> Søren
>
>
> On Tue, Feb 2, 2010 at 18:26, Ilya Tikhonovsky <[email protected]>wrote:
>
>> Hi,
>>
>> Please see preliminary patch for third step.
>>
>> https://bugs.webkit.org/show_bug.cgi?id=33995
>>
>> as far as that portion of code will be called a number of times I think it
>> would be nice to have a performance metrics for these possible
>> implementations.
>> Yury: Where I can implement this perf test?
>> Søren: in context of timeline implementation it does not necessary to have
>> the position it the row because we only select the corresponding source
>> line,
>> but probably it will be useful for some other use cases.
>> The only situation when the position is really useful is an obfuscated
>> code.
>>
>>
>> <https://bugs.webkit.org/show_bug.cgi?id=33995>
>> Regards,
>> Tim.
>>
>>
>>
>> On Tue, Feb 2, 2010 at 6:55 AM, <[email protected]> wrote:
>>
>>> On 2010/02/02 00:41:55, loislo wrote:
>>>
>>>> A patch for v8 for extending Timeline panel's functionality.
>>>>
>>> Could you upload the patch where this new method is going to be used so
>>> that
>>> it's easier to evaluate whether the new API method is necessary?
>>>
>>>
>>>
>>> http://codereview.chromium.org/565007
>>>
>>
>>
>
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev