Is there anyway to use something like CreateDataProperty to override the 
accessor so that the actual function is associated with the property, 
albeit lazily created?

I tried to use CreateDataProperty in place of ForceSet, since ForceSet is 
deprecated, but that didn't do it, and my property becomes undefined.

On Friday, October 30, 2015 at 2:12:12 AM UTC-7, Jakob Kummerow wrote:
>
> Well, the profile tells you which function was executed. It doesn't know 
> or care what name you used to refer to this function -- it can't, as it's a 
> sampling profiler. Pure-JS example:
>
> function f() { /* long-running stuff */ }
> var g = f;
> g();  // Shows up as "f" in the profile.
>
> In your example, the function is a C++ object, so it doesn't even have a 
> name, so V8 tries to infer a name that it hopes is meaningful to a human 
> reader. The point is that for a single function, it can only infer a single 
> name.
>
> I think this is working as intended.
>
> On Thu, Oct 29, 2015 at 11:57 PM, Jane Chen <[email protected] 
> <javascript:>> wrote:
>
>> A test case to demonstrate the issue can be found at:
>>
>> https://code.google.com/p/v8/issues/detail?id=4527
>>
>>
>> On Thursday, October 29, 2015 at 3:46:21 PM UTC-7, Jane Chen wrote:
>>>
>>> Testing profiling against v8 4.6.88.
>>>
>>> I have functions that are exposed through accessor callbacks.  If a 
>>> native function is set for multiple accessor properties, the last property 
>>> shows up as the function name in the CpuProfileNode, regardless what name 
>>> you set to the function returned by the accessor function.  For example:
>>>
>>> global->SetAccessor(
>>>     v8::String::NewFromUtf8(isolate, "print", v8::NewStringType::kNormal)
>>>           .ToLocalChecked(),
>>>     getFunction);
>>> global->SetAccessor(
>>>     v8::String::NewFromUtf8(isolate, "read", v8::NewStringType::kNormal)
>>>           .ToLocalChecked(),
>>>     getFunction);
>>>
>>> Now "get read" is the function name in CpuProfileNode although print is 
>>> called.
>>>
>>> Test script: 
>>>  
>>> function isPrime(num) { 
>>>   for (var count = 2; count < num; count++) 
>>>     if (num % count == 0) return false; 
>>>   return true; 
>>> }; 
>>>  
>>> var total = 0; 
>>> for (var i = 2; i < 100000; i++) { 
>>>   if (isPrime(i)) { 
>>>     print(i); 
>>>     total++ 
>>>   } 
>>> }; 
>>> total; 
>>>  
>>> TotalHitCount:2233
>>>
>>> FunctionName:(root)
>>> LineNumber:0
>>> ColumnNumber:0
>>> HitCount:0
>>>     FunctionName:(program)
>>>     LineNumber:0
>>>     ColumnNumber:0
>>>     HitCount:7
>>>     FunctionName:
>>>     LineNumber:0
>>>     ColumnNumber:0
>>>     HitCount:13
>>>         FunctionName:isPrime
>>>         LineNumber:1
>>>         ColumnNumber:17
>>>         HitCount:8
>>>     FunctionName:
>>>     LineNumber:1
>>>     ColumnNumber:1
>>>     HitCount:2196
>>>         FunctionName:get read
>>>         LineNumber:0
>>>         ColumnNumber:0
>>>         HitCount:2
>>>     FunctionName:(garbage collector)
>>>     LineNumber:0
>>>     ColumnNumber:0
>>>     HitCount:7
>>>
>>>
>>> Given that an accessor callback takes a property name, it should allow 
>>> one native function to handle multiple properties.  Is this a bug, or am I 
>>> doing something wrong?  
>>>
>> -- 
>> -- 
>> v8-users mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" 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.

Reply via email to