Re: [v8-users] How to run a v8 shell standalone and inspect / debug with Chrome DevTools

2019-05-20 Thread Gautham B A
It tries to look for libraries in */usr/local/lib* and headers in 
*/usr/local/include* . So, just do a *$ make install* after building v8.

On Monday, 20 May 2019 19:25:08 UTC+5:30, Joe Lewis wrote:
>
> Thanks a lot Gautham, Ben! Looks like exactly what I need. 
>
> Being a complete C++/CMake newbie, I can't get the project to build to 
> correctly though. 
>
> Here's the error message I receive when I do cmake ..
>  
>
> CMake Error at FindV8.cmake:40 (MESSAGE):
>
>   Can't build v8inspector without V8
>
> Call Stack (most recent call first):
>
>   CMakeLists.txt:15 (INCLUDE)
>
>
>
> -- Configuring incomplete, errors occurred!
>
> See also "/Users/joe-2744/v8/v8inspector/build/CMakeFiles/CMakeOutput.log".
>
> I've cloned v8 source in a directory from which I build v8.
> I've cloned https://github.com/hsharsha/v8inspector in a separate 
> directory and I'm trying to execute cmake. 
>
> Is there a way to tell FindV8.cmake, where to look for v8 header files and 
> libs in my system?
>
>
> Thanks,
> Joe
>
>
> On Monday, 20 May 2019 10:11:24 UTC+5:30, Gautham B A wrote:
>>
>> Checkout this project - https://github.com/hsharsha/v8inspector . It 
>> does exactly what you're looking for. We're using the same at Couchbase and 
>> it's working absolutely fine.
>>
>> On Sunday, 19 May 2019 13:50:30 UTC+5:30, joe lewis wrote:
>>>
>>> A bit more reading and I understood how dumb the question is. I'd like 
>>> to validate if my current understanding is correct.
>>>
>>> V8 is more than the shell binary that comes with the build. V8 provides 
>>> extensive C++ APIs to compile Javascript source code from other programs 
>>> (usually termed as embedding V8). 
>>> So, to enable chrome devtools as debugging front-end I have to write a 
>>> program (C++ wrapper or such) that communicates through web-sockets, 
>>> debugging-protocol messages back and forth from the front-end to v8. Or did 
>>> I get it completely twisted?
>>>
>>> If it did make sense, is there a project that has already implemented 
>>> such standalone program that statically links to V8 and exposes a 
>>> remote-debugging session? If nothing like that exists I'd like to pursue 
>>> that direction and publish a simple project that spins up a V8 instance and 
>>> starts a chrome remote-debugging session.
>>>
>>> Full-stack developer here, with almost no experience working with system 
>>> software. Please let me know if I got it all completely wrong. 
>>>
>>> Thanks,
>>> Joe
>>>
>>>
>>> On Sun, 19 May 2019 at 12:19, Joe Lewis  wrote:
>>>
 I'm pretty sure that my understanding of the entire topic is fairly 
 limited and this is not going to be easy. Here's what I'm looking for:

 We're trying to re-use the product's javascript code across browser, 
 server & devices. We've settled on running v8 with Java bindings  (J2v8) 
 for the server and android devices.

 While developing I'd like to setup a chrome devtools environment and 
 test my JS code as if it's running on V8 directly. I understand I can spin 
 up a chrome instance with --remore-debugging-port option and connect a 
 devtools instance to that chrome for browser and for node --inspect 
 does something similar. Is there an equivalent for a v8 shell?

 Is there any way I can do something like

 bash-$ ./d8 --remote-debugging-port=9222

 and connect a chrome devtools instance to that shell?

 Can somebody point me in the right direction?

 -- 
 -- 
 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-u...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/v8-users/0bb21c0a-a1fa-4b70-8854-94f34061b4ba%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/9997dd68-fdbd-4a13-99e7-f108b2249972%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] How to run a v8 shell standalone and inspect / debug with Chrome DevTools

2019-05-20 Thread Joe Lewis
Thanks a lot Gautham, Ben! Looks like exactly what I need. 

Being a complete C++/CMake newbie, I can't get the project to build to 
correctly though. 

Here's the error message I receive when I do cmake ..
 

CMake Error at FindV8.cmake:40 (MESSAGE):

  Can't build v8inspector without V8

Call Stack (most recent call first):

  CMakeLists.txt:15 (INCLUDE)



-- Configuring incomplete, errors occurred!

See also "/Users/joe-2744/v8/v8inspector/build/CMakeFiles/CMakeOutput.log".

I've cloned v8 source in a directory from which I build v8.
I've cloned https://github.com/hsharsha/v8inspector in a separate directory 
and I'm trying to execute cmake. 

Is there a way to tell FindV8.cmake, where to look for v8 header files and 
libs in my system?


Thanks,
Joe


On Monday, 20 May 2019 10:11:24 UTC+5:30, Gautham B A wrote:
>
> Checkout this project - https://github.com/hsharsha/v8inspector . It does 
> exactly what you're looking for. We're using the same at Couchbase and it's 
> working absolutely fine.
>
> On Sunday, 19 May 2019 13:50:30 UTC+5:30, joe lewis wrote:
>>
>> A bit more reading and I understood how dumb the question is. I'd like to 
>> validate if my current understanding is correct.
>>
>> V8 is more than the shell binary that comes with the build. V8 provides 
>> extensive C++ APIs to compile Javascript source code from other programs 
>> (usually termed as embedding V8). 
>> So, to enable chrome devtools as debugging front-end I have to write a 
>> program (C++ wrapper or such) that communicates through web-sockets, 
>> debugging-protocol messages back and forth from the front-end to v8. Or did 
>> I get it completely twisted?
>>
>> If it did make sense, is there a project that has already implemented 
>> such standalone program that statically links to V8 and exposes a 
>> remote-debugging session? If nothing like that exists I'd like to pursue 
>> that direction and publish a simple project that spins up a V8 instance and 
>> starts a chrome remote-debugging session.
>>
>> Full-stack developer here, with almost no experience working with system 
>> software. Please let me know if I got it all completely wrong. 
>>
>> Thanks,
>> Joe
>>
>>
>> On Sun, 19 May 2019 at 12:19, Joe Lewis  wrote:
>>
>>> I'm pretty sure that my understanding of the entire topic is fairly 
>>> limited and this is not going to be easy. Here's what I'm looking for:
>>>
>>> We're trying to re-use the product's javascript code across browser, 
>>> server & devices. We've settled on running v8 with Java bindings  (J2v8) 
>>> for the server and android devices.
>>>
>>> While developing I'd like to setup a chrome devtools environment and 
>>> test my JS code as if it's running on V8 directly. I understand I can spin 
>>> up a chrome instance with --remore-debugging-port option and connect a 
>>> devtools instance to that chrome for browser and for node --inspect 
>>> does something similar. Is there an equivalent for a v8 shell?
>>>
>>> Is there any way I can do something like
>>>
>>> bash-$ ./d8 --remote-debugging-port=9222
>>>
>>> and connect a chrome devtools instance to that shell?
>>>
>>> Can somebody point me in the right direction?
>>>
>>> -- 
>>> -- 
>>> 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-u...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/v8-users/0bb21c0a-a1fa-4b70-8854-94f34061b4ba%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/aca59629-ddf5-4b7a-97eb-4f0e74d136ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] gc and threading

2019-05-20 Thread 'Peter Marshall' via v8-users
If you block the main thread at a safe time (e.g. not during GC) then you 
can probably access heap objects from your other threads without handles as 
long as you do your own synchronization between the background threads.
Not sure how concurrent marking threads from the GC will feel about that 
though.

On Friday, May 17, 2019 at 5:43:08 PM UTC+2, Ledion Bitincka wrote:
>
> >You could read from the heap on a concurrent thread but there is no 
> synchronization when writing to the heap from the main thread
>
> My current thinking is something like this - ie I'd be blocking in the 
> main thread until the serialization is done 
> in main thread:
>  handles[] = getHandlesToSerialize(); 
>  results[] = []
>  threads[] = spawnThreads(N, handles, results);
>
>  join(threads);
>
>
> One problem though is that I can't use the Handles directly in other 
> threads as they'd require access to the Isolate and thus would require 
> synchronization to enter/lock the Isolate. So the only option, as you 
> alluded to, is to copy off-heap then serialize, which I need to test to see 
> if it would result into any perf benefits due to the high setup cost for 
> going multi-threaded. Maybe I'll find a way to actually keep pointers to 
> underlying data rather than actually copy - will report here what I find. 
>
>
>
>
> On Thursday, May 16, 2019 at 6:18:06 AM UTC-7, Peter Marshall wrote:
>>
>> On Wednesday, May 15, 2019 at 9:09:18 PM UTC+2, Ledion Bitincka wrote:
>>>
>>> Thanks! 
>>>
>>> > While I understand that this is tempting, please be aware that only 
>>> one thread may be active in one Isolate at any given time.
>>> I was hoping that there could be multiple threads that had "read-only" 
>>> access to an Isolate's heap - I was looking through how ValueSerializer 
>>> works 
>>> and now I understand there's no such thing as "read-only" given the 
>>> getter/setter functions. However, wondering if this would be possible for 
>>> simple objects (key/value) and bail for more complex ones. Any other 
>>> suggestions for how that work can be parallelized, is it even possible? 
>>> (this is custom serialization, not JSON)
>>>

 You could read from the heap on a concurrent thread but there is no 
>> synchronization when writing to the heap from the main thread, so there's 
>> no guarantee that what you are reading is not being concurrently written 
>> e.g. when it is being allocated, when it is modified by user JS code or 
>> when the GC moves it.
>>
>> If the serialization work itself was particularly expensive (e.g. the 
>> format is very complicated or the data requires a lot of processing) then 
>> you could copy the relevant parts of the heap objects off-heap and then 
>> serialize from concurrent threads.
>>
>

-- 
-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/2e9675e8-1f1e-4c8d-9cac-f990342b01ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Callback when variable is no longer valid

2019-05-20 Thread Ben Noordhuis
On Mon, May 20, 2019 at 6:59 AM Gautham B A  wrote:
>
> Hi all,
>
> I'm trying to track when a variable becomes invalid.
> Consider the following code where the variable goes out of scope -
>
> function SomeFunction() {
> for(let i = 0; i < 10; ++i) {
> let instance = new MyClass(); // MyClass is implemented in C++
> }
> // instance goes out of scope and isn't accessible at this line
> }
>
> Or when a variable gets reassigned.
>
> function SomeFunction() {
> let instance = new MyClass(); // MyClass is implemented in C++
> instance = 10; // instance gets reassigned
> }
>
> Does v8 provide any callbacks that I can register on the object returned by 
> MyClass which gets called in the above two scenarios?
>
> The motivation behind my ask is that, When an instance of MyClass is created, 
> some system resources (such as database connections etc) are allocated and 
> bound to the instance. I wish to claim them back as soon as we can detect 
> that the variable's value is unusable, as described in the above two 
> scenarios.
>
> Thanks,
> --Gautham

If you wrap the object in a v8::Persistent and then call
persistent_handle.SetWeak(...), the garbage collector will invoke your
callback when the object is reclaimed.

That isn't exactly what you're asking for but it's the closest thing.
What you want doesn't exist and cannot exist because it would be
prohibitively expensive. Static escape analysis is easily defeated in
JS. You effectively would have to perform a full GC after every
statement.

-- 
-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAHQurc-71onVW4_sKRB3c3g%2BcL8phJeZ_8NShg3t%3DgPRcexzBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.