[v8-users] trying to understand v8's opt/deopt strategy, is this behavior normal?

2018-09-04 Thread Taylor Dondich
So I'm building a NES(Nintendo) emulator in Javascript and I'm doing 
optimizations to get the emulation to run faster.  Code is located 
at: https://github.com/tdondich/vue-2a03-emu

So, I have done a dump of v8 activity using --trace-opt and --trace-deopt

I'm seeing a lot of deopt over and over for certain critical functions.  V8 
will mark to opt, optimize, then do a soft deopt, over and over on the same 
functions.

So, my question is, what are good strategies to defend against this?  I'd 
rather it optimizes once and is good to go on these functions.

For example, I see:
[deoptimizing (DEOPT soft): begin 0x4356287660f9  (opt #112) @253, FP to SP delta: 152, caller sp: 
0x00202c9fd7d8]
;;; deoptimize at , 
Insufficient type feedback for generic named access

But documentation on insufficient type feedback for generic named access 
nowhere to be found.  How can I restructure my code to help avoid this?  Or 
the same for "Insufficent type feedback for generic named access".

So this goes on over and over, with the same depots happening on the same 
functions all the time (and my emu runs loops at over 3 million iterations 
a second).

Any insight?

Thanks!  First time going this level with V8. It's fun!

Taylor Dondich



-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Re: Calling method on Persistent

2018-09-04 Thread Mike Moening


Do you mean something like this?

 

Persistent obj;

obj.Reset(pIsolate, blah->NewInstance());

 

Handle objLocal = obj.Get(pIsolate);

 

objLocal->SetInternalField(0, External::New(pIsolate, ));

objLocal->SetInternalField(1, External::New(pIsolate, ));

 

obj.SetWeak(myPointer, MyClass::DestructorCallback);

 

Will making a Local object still affect the original Persistent object when 
I call SetInternalField()?

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Arraybuffer

2018-09-04 Thread Graham Reeves
> is std::numeric_limits 

::max 
();
 
referring to the max unsigned int value ? cause the source code won't find 
it 
Yes, that's the maximum value unsigned (an unsigned int) can be, but what 
do you mean by, the source won't find it?

On Monday, 3 September 2018 19:55:48 UTC+1, dan Med wrote:
>
> Can someone help me out?
>
> Il giorno sab 1 set 2018 alle ore 15:30 > 
> ha scritto:
>
>> array_buffer_builder.cc in src /
>> third_party /blink 
>> /renderer 
>> /
>> platform 
>> 
>> /wtf 
>> 
>> /typed_arrays 
>> 
>> /array_buffer_builder.cc 
>> 
>>  
>> the ArrayBufferBuilder 
>> 
>> ::Append 
>> 
>>  method 
>> will be called through a view on top of the arraybuffer? something like, 
>> there's a arraybuffer of 30bytes in length and we define a view on top of 
>> it (so a typedarray) wehn i call on the new typedarray object the .append 
>> method it will call ArrayBufferBuilder 
>> 
>> ::Append 
>> 
>>   
>> and then inside it's code it will execute ArrayBufferBuilder 
>> 
>> ::ExpandCapacity 
>> 
>>  if 
>> it needs to reallocate the array ?
>>
>> if so inside the expandCapacity definition bytes_used 
>> 
>>  referes 
>> to the elements inside the actual arraybuffer so if i have a arraybuffer 
>> which is 8 bytes in length [ ][ ][ ][ ][ ][ ][ ][ ] and i fill in only 3 
>> bytes so 
>> [1][2][3][ ][ ][ ][ ][ ] the bytes_used 
>> 
>>  when 
>> retrieved will be set to 3 bytes ??
>>
>> ArrayBufferBuilder 
>> ::ArrayBufferBuilder
>>  
>> ()
>> : bytes_used_ 
>> (0),
>>  variable_capacity_ 
>> 

Re: [v8-users] Help

2018-09-04 Thread Graham Reeves
memcpy is this
memcpy( writable_destination, const_source, length_in_bytes )

if you're unsure what it's doing, expand the arguments so the code is more 
readable (shame on whoever wrote this :)
memcpy(static_cast(buffer_->Data()) + bytes_used_, 
data,bytes_to_save);
...
auto* Destination = static_cast(buffer_->Data()); // start of buffer
Destination += bytes_used_; // offset from the start, same as Destination = 
[bytes_used_];
memcpy(Destination, data, bytes_to_save );

So to answer your question;

> with this memcpy is it copying from data which is a const char pointer n 
bytes_to_save into the array buffer_
No, it's copying the number of bytes *bytes_to_save* FROM *data* (from the 
start)

>  into a specific offset from the array 
yes, into a specific offset from the start of the array *Buffer->Data*

This isn't a v8 specific question, so you may get a better response for 
general C/++ questions on http://www.stackoverflow.com :)


On Monday, 3 September 2018 19:55:35 UTC+1, dan Med wrote:
>
> Can someone help me out ?
>
> Il giorno dom 2 set 2018 alle ore 11:26 > 
> ha scritto:
>
>>  memcpy(static_cast(buffer_->Data()) + bytes_used_, 
>> data,bytes_to_save);
>>
>> with this memcpy is it copying from data which is a const char pointer n 
>> bytes_to_save into the array buffer_ or into a specific offset from the 
>> array ?
>>
>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> 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 v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.