Re: [v8-users] Re: V8 snapshots

2017-09-08 Thread Yang Guo
V8's serializer simply does not support serializing handles. You can't have 
any open handle scopes when you serialize. You can store these handles 
somewhere on the context before serializing, and retrieve it after 
deserializing.

On Friday, September 8, 2017 at 12:29:33 AM UTC+2, Zac Hansen wrote:
>
> can you make a special code path just for making the snapshot that 
> releases the persistent/globals then makes the snapshots and then exits?   
> Then you start up the "normal" code pay with the new snapshots that can 
> create the persistent a/globals all it wants.  
>
> On Thu, Sep 7, 2017 at 1:33 PM Francisco Moraes  > wrote:
>
>> Thanks. I am finding that my main hurdle is that there are several 
>> v8::Persistent objects which block creation of the snapshot. Is there any 
>> suggested work around for those other than rewriting the code ?
>>
>>
>> On Thursday, September 7, 2017 at 11:16:24 AM UTC-4, Jakob Gruber wrote:
>>>
>>> You can use the `job` gdb macro (see gdbinit 
>>> )
>>>  
>>> to print heap objects. E.g. 'job 0x367b6c023fa9'.
>>>
>>>
>>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "v8-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.


Re: [v8-users] Re: V8 snapshots

2017-09-07 Thread Zac Hansen
can you make a special code path just for making the snapshot that releases
the persistent/globals then makes the snapshots and then exits?   Then you
start up the "normal" code pay with the new snapshots that can create the
persistent a/globals all it wants.

On Thu, Sep 7, 2017 at 1:33 PM Francisco Moraes 
wrote:

> Thanks. I am finding that my main hurdle is that there are several
> v8::Persistent objects which block creation of the snapshot. Is there any
> suggested work around for those other than rewriting the code ?
>
>
> On Thursday, September 7, 2017 at 11:16:24 AM UTC-4, Jakob Gruber wrote:
>>
>> You can use the `job` gdb macro (see gdbinit
>> )
>> to print heap objects. E.g. 'job 0x367b6c023fa9'.
>>
>>
>> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> v8-users+unsubscr...@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.


Re: [v8-users] Re: V8 snapshots

2017-09-07 Thread Francisco Moraes
Thanks. I am finding that my main hurdle is that there are several 
v8::Persistent objects which block creation of the snapshot. Is there any 
suggested work around for those other than rewriting the code ?


On Thursday, September 7, 2017 at 11:16:24 AM UTC-4, Jakob Gruber wrote:
>
> You can use the `job` gdb macro (see gdbinit 
> )
>  
> to print heap objects. E.g. 'job 0x367b6c023fa9'.
>
>
>

-- 
-- 
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] Re: V8 snapshots

2017-09-07 Thread 'Jakob Gruber' via v8-users
You can use the `job` gdb macro (see gdbinit
)
to print heap objects. E.g. 'job 0x367b6c023fa9'.

On Thu, Sep 7, 2017 at 5:04 PM, Francisco Moraes  wrote:

> If you know of a way to find more information on what the global handles
> may be, it may be helpful. Otherwise, I will have to scrub everything until
> I find something that works. For instance:
>
> (gdb) print isolate->global_handles()->Print()
> Global handles:
>   handle 0x7ffe3af84008 to 0x367b6c023fa9
>   handle 0x7ffe3af84028 to 0x7e1669936c1
>
> I would like to know what those 2 handles are that are causing the
> serialization to fail.
>
> On Wednesday, September 6, 2017 at 3:26:36 PM UTC-4, Zac Hansen wrote:
>>
>> If that doesn't do it, again try to come up with a self contained example
>> and post it.  Like I said before often v8 errors mean nothing more than
>> "you screwed up somewhere" so just the error message is rather
>> meaningless--at least to me.
>>
>> On Wed, Sep 6, 2017 at 12:00 PM Zac Hansen  wrote:
>>
>>> As far as I know they are only the ones you explicitly make to hold on
>>> to things outside of the scope of JavaScript.   Anything with the term
>>> "global" or "persistent" is a likely culprit.
>>>
>>> Again these are all guesses.   I would try taking a snapshot that works
>>> creating a global handle and trying again to see that it causes the same
>>> assertion before pursuing down this path to make sure I'm not just
>>> completely wrong.
>>>
>>> On Wed, Sep 6, 2017 at 11:56 AM Francisco Moraes 
>>> wrote:
>>>
 What's the best way to find what the Global Handles actually are? I
 found that I can print the handles but it still doesn't help me find what
 they actually are. Once I know what they are, I can find the culprit and
 eliminate it.


 On Wednesday, September 6, 2017 at 2:32:49 PM UTC-4, Zac Hansen wrote:

> Just a guess but how would he system know how to deal with objects
> held by global handles when making a snapshot?   You can't serialize the
> global handles in such a way that they would be useful in any way?
>
> I'm guessing this is just a sanity check to make sure you aren't doing
> something unintended.
>
> I could be completely wrong but I'd say just free up your globals and
> if that changes the behavior then you weren't ready to make a snapshot
> anyhow.
>
> On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes <
> francisc...@gmail.com> wrote:
>
>> After fixing the issue about the handle scope, I can successfully
>> create the snapshot for the test code, but when I tried something more
>> complicated, I ran into this now:
>>
>> Check failed: 0 == isolate->global_handles()->global_handles_count()
>> (0 vs. 4).
>>
>>
>> On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen
>> wrote:
>>>
>>> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_
>>> creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>>>
>>> Created a snapshot data blob. This must not be called from within a
>>> handle scope.
>>>
>>>
>>>
>>>
>>> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco
>>> Moraes wrote:

 Here's a simple recreate that I managed to create:

 #include 

 #include "v8.h"
 #include "libplatform/libplatform.h"

 int main(int argv, char **argc)
 {
 const char *v8flags = "";
 v8::Platform *platform = v8::platform::CreateDefaultPlatform();
 v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
 v8::V8::InitializePlatform(platform);
 v8::V8::Initialize();

 v8::SnapshotCreator creator;
 v8::Isolate *isolate = creator.GetIsolate();

 v8::HandleScope handle_scope(isolate);
 v8::Local context = v8::Context::New(isolate);
 const char* source = "function initialize(obj) { return true;
 }";
 v8::Context::Scope context_scope(context);
 v8::TryCatch try_catch(isolate);
 v8::Local source_string;
 v8::String::NewFromUtf8(isolate, source,
 v8::NewStringType::kNormal)
 .ToLocal(&source_string);
 v8::ScriptOrigin origin = 
 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate,
 "testscript"));
 v8::ScriptCompiler::Source sourcecode(source_string, origin);
 v8::Local script;
 bool success = v8::ScriptCompiler::Compile(context,
 &sourcecode).ToLocal(&script);

 script->Run(context);

 creator.SetDefaultContext(context);
 v8::StartupData blob = creator.CreateBlob(v8::Snapsho
 tCreator::FunctionCodeHandling::kClear);

>

Re: [v8-users] Re: V8 snapshots

2017-09-07 Thread Francisco Moraes
If you know of a way to find more information on what the global handles 
may be, it may be helpful. Otherwise, I will have to scrub everything until 
I find something that works. For instance:

(gdb) print isolate->global_handles()->Print()
Global handles:
  handle 0x7ffe3af84008 to 0x367b6c023fa9
  handle 0x7ffe3af84028 to 0x7e1669936c1

I would like to know what those 2 handles are that are causing the 
serialization to fail.

On Wednesday, September 6, 2017 at 3:26:36 PM UTC-4, Zac Hansen wrote:
>
> If that doesn't do it, again try to come up with a self contained example 
> and post it.  Like I said before often v8 errors mean nothing more than 
> "you screwed up somewhere" so just the error message is rather 
> meaningless--at least to me.  
>
> On Wed, Sep 6, 2017 at 12:00 PM Zac Hansen > 
> wrote:
>
>> As far as I know they are only the ones you explicitly make to hold on to 
>> things outside of the scope of JavaScript.   Anything with the term 
>> "global" or "persistent" is a likely culprit. 
>>
>> Again these are all guesses.   I would try taking a snapshot that works 
>> creating a global handle and trying again to see that it causes the same 
>> assertion before pursuing down this path to make sure I'm not just 
>> completely wrong.  
>>
>> On Wed, Sep 6, 2017 at 11:56 AM Francisco Moraes > > wrote:
>>
>>> What's the best way to find what the Global Handles actually are? I 
>>> found that I can print the handles but it still doesn't help me find what 
>>> they actually are. Once I know what they are, I can find the culprit and 
>>> eliminate it.
>>>
>>>
>>> On Wednesday, September 6, 2017 at 2:32:49 PM UTC-4, Zac Hansen wrote:
>>>
 Just a guess but how would he system know how to deal with objects held 
 by global handles when making a snapshot?   You can't serialize the global 
 handles in such a way that they would be useful in any way?

 I'm guessing this is just a sanity check to make sure you aren't doing 
 something unintended.  

 I could be completely wrong but I'd say just free up your globals and 
 if that changes the behavior then you weren't ready to make a snapshot 
 anyhow.  

 On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes  
 wrote:

> After fixing the issue about the handle scope, I can successfully 
> create the snapshot for the test code, but when I tried something more 
> complicated, I ran into this now:
>
> Check failed: 0 == isolate->global_handles()->global_handles_count() 
> (0 vs. 4).
>
>
> On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:
>>
>>
>> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>>
>> Created a snapshot data blob. This must not be called from within a 
>> handle scope.
>>
>>
>>
>>
>> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes 
>> wrote:
>>>
>>> Here's a simple recreate that I managed to create:
>>>
>>> #include 
>>>
>>> #include "v8.h"
>>> #include "libplatform/libplatform.h"
>>>
>>> int main(int argv, char **argc)
>>> {
>>> const char *v8flags = "";
>>> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
>>> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
>>> v8::V8::InitializePlatform(platform);
>>> v8::V8::Initialize();
>>>
>>> v8::SnapshotCreator creator;
>>> v8::Isolate *isolate = creator.GetIsolate();
>>> 
>>> v8::HandleScope handle_scope(isolate);
>>> v8::Local context = v8::Context::New(isolate);
>>> const char* source = "function initialize(obj) { return true; }";
>>> v8::Context::Scope context_scope(context);
>>> v8::TryCatch try_catch(isolate);
>>> v8::Local source_string;
>>> v8::String::NewFromUtf8(isolate, source, 
>>> v8::NewStringType::kNormal)
>>> .ToLocal(&source_string);
>>> v8::ScriptOrigin origin = 
>>> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
>>> v8::ScriptCompiler::Source sourcecode(source_string, origin);
>>> v8::Local script;
>>> bool success = v8::ScriptCompiler::Compile(context, 
>>> &sourcecode).ToLocal(&script);
>>>
>>> script->Run(context);
>>>   
>>> creator.SetDefaultContext(context);
>>> v8::StartupData blob = 
>>> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>>>
>>> return 1;
>>> }
>>>
>>> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it 
>>> works as it does all the above work for me, so something in trying to 
>>> use 
>>> the SnapshotCreator is causing me some issue as I will need to handle 
>>> custom embedder fields, etc...
>>>
>>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4,

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Zac Hansen
If that doesn't do it, again try to come up with a self contained example
and post it.  Like I said before often v8 errors mean nothing more than
"you screwed up somewhere" so just the error message is rather
meaningless--at least to me.

On Wed, Sep 6, 2017 at 12:00 PM Zac Hansen  wrote:

> As far as I know they are only the ones you explicitly make to hold on to
> things outside of the scope of JavaScript.   Anything with the term
> "global" or "persistent" is a likely culprit.
>
> Again these are all guesses.   I would try taking a snapshot that works
> creating a global handle and trying again to see that it causes the same
> assertion before pursuing down this path to make sure I'm not just
> completely wrong.
>
> On Wed, Sep 6, 2017 at 11:56 AM Francisco Moraes <
> francisco.mor...@gmail.com> wrote:
>
>> What's the best way to find what the Global Handles actually are? I found
>> that I can print the handles but it still doesn't help me find what they
>> actually are. Once I know what they are, I can find the culprit and
>> eliminate it.
>>
>>
>> On Wednesday, September 6, 2017 at 2:32:49 PM UTC-4, Zac Hansen wrote:
>>
>>> Just a guess but how would he system know how to deal with objects held
>>> by global handles when making a snapshot?   You can't serialize the global
>>> handles in such a way that they would be useful in any way?
>>>
>>> I'm guessing this is just a sanity check to make sure you aren't doing
>>> something unintended.
>>>
>>> I could be completely wrong but I'd say just free up your globals and if
>>> that changes the behavior then you weren't ready to make a snapshot anyhow.
>>>
>>>
>>> On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes 
>>> wrote:
>>>
 After fixing the issue about the handle scope, I can successfully
 create the snapshot for the test code, but when I tried something more
 complicated, I ran into this now:

 Check failed: 0 == isolate->global_handles()->global_handles_count() (0
 vs. 4).


 On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:
>
>
> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>
> Created a snapshot data blob. This must not be called from within a
> handle scope.
>
>
>
>
> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes
> wrote:
>>
>> Here's a simple recreate that I managed to create:
>>
>> #include 
>>
>> #include "v8.h"
>> #include "libplatform/libplatform.h"
>>
>> int main(int argv, char **argc)
>> {
>> const char *v8flags = "";
>> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
>> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
>> v8::V8::InitializePlatform(platform);
>> v8::V8::Initialize();
>>
>> v8::SnapshotCreator creator;
>> v8::Isolate *isolate = creator.GetIsolate();
>>
>> v8::HandleScope handle_scope(isolate);
>> v8::Local context = v8::Context::New(isolate);
>> const char* source = "function initialize(obj) { return true; }";
>> v8::Context::Scope context_scope(context);
>> v8::TryCatch try_catch(isolate);
>> v8::Local source_string;
>> v8::String::NewFromUtf8(isolate, source,
>> v8::NewStringType::kNormal)
>> .ToLocal(&source_string);
>> v8::ScriptOrigin origin =
>> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
>> v8::ScriptCompiler::Source sourcecode(source_string, origin);
>> v8::Local script;
>> bool success = v8::ScriptCompiler::Compile(context,
>> &sourcecode).ToLocal(&script);
>>
>> script->Run(context);
>>
>> creator.SetDefaultContext(context);
>> v8::StartupData blob =
>> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>>
>> return 1;
>> }
>>
>> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it
>> works as it does all the above work for me, so something in trying to use
>> the SnapshotCreator is causing me some issue as I will need to handle
>> custom embedder fields, etc...
>>
>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>>
>>> That kind of error usually means you either haven't created a
>>> context or aren't in a context or haven't created an appropriate handle.
>>> Or... Something else :-/. Maybe a lock?  V8 errors are very much a "you
>>> screwed up somewhere" notification and often nothing more
>>>
>>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes <
>>> francisc...@gmail.com> wrote:
>>>
 I will give it a try sometime this week. I tried to remove our
 initialization JS file but that caused a failure further down the
 serialization as well, so still investigating.

>>

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Zac Hansen
As far as I know they are only the ones you explicitly make to hold on to
things outside of the scope of JavaScript.   Anything with the term
"global" or "persistent" is a likely culprit.

Again these are all guesses.   I would try taking a snapshot that works
creating a global handle and trying again to see that it causes the same
assertion before pursuing down this path to make sure I'm not just
completely wrong.

On Wed, Sep 6, 2017 at 11:56 AM Francisco Moraes 
wrote:

> What's the best way to find what the Global Handles actually are? I found
> that I can print the handles but it still doesn't help me find what they
> actually are. Once I know what they are, I can find the culprit and
> eliminate it.
>
>
> On Wednesday, September 6, 2017 at 2:32:49 PM UTC-4, Zac Hansen wrote:
>
>> Just a guess but how would he system know how to deal with objects held
>> by global handles when making a snapshot?   You can't serialize the global
>> handles in such a way that they would be useful in any way?
>>
>> I'm guessing this is just a sanity check to make sure you aren't doing
>> something unintended.
>>
>> I could be completely wrong but I'd say just free up your globals and if
>> that changes the behavior then you weren't ready to make a snapshot anyhow.
>>
>>
>> On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes 
>> wrote:
>>
>>> After fixing the issue about the handle scope, I can successfully create
>>> the snapshot for the test code, but when I tried something more
>>> complicated, I ran into this now:
>>>
>>> Check failed: 0 == isolate->global_handles()->global_handles_count() (0
>>> vs. 4).
>>>
>>>
>>> On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:


 https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a

 Created a snapshot data blob. This must not be called from within a
 handle scope.




 On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes
 wrote:
>
> Here's a simple recreate that I managed to create:
>
> #include 
>
> #include "v8.h"
> #include "libplatform/libplatform.h"
>
> int main(int argv, char **argc)
> {
> const char *v8flags = "";
> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
> v8::V8::InitializePlatform(platform);
> v8::V8::Initialize();
>
> v8::SnapshotCreator creator;
> v8::Isolate *isolate = creator.GetIsolate();
>
> v8::HandleScope handle_scope(isolate);
> v8::Local context = v8::Context::New(isolate);
> const char* source = "function initialize(obj) { return true; }";
> v8::Context::Scope context_scope(context);
> v8::TryCatch try_catch(isolate);
> v8::Local source_string;
> v8::String::NewFromUtf8(isolate, source,
> v8::NewStringType::kNormal)
> .ToLocal(&source_string);
> v8::ScriptOrigin origin =
> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
> v8::ScriptCompiler::Source sourcecode(source_string, origin);
> v8::Local script;
> bool success = v8::ScriptCompiler::Compile(context,
> &sourcecode).ToLocal(&script);
>
> script->Run(context);
>
> creator.SetDefaultContext(context);
> v8::StartupData blob =
> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>
> return 1;
> }
>
> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it
> works as it does all the above work for me, so something in trying to use
> the SnapshotCreator is causing me some issue as I will need to handle
> custom embedder fields, etc...
>
> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>
>> That kind of error usually means you either haven't created a context
>> or aren't in a context or haven't created an appropriate handle.  Or...
>> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed
>> up somewhere" notification and often nothing more
>>
>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes <
>> francisc...@gmail.com> wrote:
>>
>>> I will give it a try sometime this week. I tried to remove our
>>> initialization JS file but that caused a failure further down the
>>> serialization as well, so still investigating.
>>>
>>>
>>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:

 Can you post a minimal complete example that reproduces your
 problem?

 On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes
 wrote:
>
> Hello,
>
> I am trying to create a snapshot that includes most of code but I
> ran into the following assertion:
>
>

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Francisco Moraes
What's the best way to find what the Global Handles actually are? I found 
that I can print the handles but it still doesn't help me find what they 
actually are. Once I know what they are, I can find the culprit and 
eliminate it.

On Wednesday, September 6, 2017 at 2:32:49 PM UTC-4, Zac Hansen wrote:
>
> Just a guess but how would he system know how to deal with objects held by 
> global handles when making a snapshot?   You can't serialize the global 
> handles in such a way that they would be useful in any way?
>
> I'm guessing this is just a sanity check to make sure you aren't doing 
> something unintended.  
>
> I could be completely wrong but I'd say just free up your globals and if 
> that changes the behavior then you weren't ready to make a snapshot anyhow. 
>  
>
> On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes  > wrote:
>
>> After fixing the issue about the handle scope, I can successfully create 
>> the snapshot for the test code, but when I tried something more 
>> complicated, I ran into this now:
>>
>> Check failed: 0 == isolate->global_handles()->global_handles_count() (0 
>> vs. 4).
>>
>>
>> On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:
>>>
>>>
>>> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>>>
>>> Created a snapshot data blob. This must not be called from within a 
>>> handle scope.
>>>
>>>
>>>
>>>
>>> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes 
>>> wrote:

 Here's a simple recreate that I managed to create:

 #include 

 #include "v8.h"
 #include "libplatform/libplatform.h"

 int main(int argv, char **argc)
 {
 const char *v8flags = "";
 v8::Platform *platform = v8::platform::CreateDefaultPlatform();
 v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
 v8::V8::InitializePlatform(platform);
 v8::V8::Initialize();

 v8::SnapshotCreator creator;
 v8::Isolate *isolate = creator.GetIsolate();
 
 v8::HandleScope handle_scope(isolate);
 v8::Local context = v8::Context::New(isolate);
 const char* source = "function initialize(obj) { return true; }";
 v8::Context::Scope context_scope(context);
 v8::TryCatch try_catch(isolate);
 v8::Local source_string;
 v8::String::NewFromUtf8(isolate, source, v8::NewStringType::kNormal)
 .ToLocal(&source_string);
 v8::ScriptOrigin origin = 
 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
 v8::ScriptCompiler::Source sourcecode(source_string, origin);
 v8::Local script;
 bool success = v8::ScriptCompiler::Compile(context, 
 &sourcecode).ToLocal(&script);

 script->Run(context);
   
 creator.SetDefaultContext(context);
 v8::StartupData blob = 
 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);

 return 1;
 }

 The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it 
 works as it does all the above work for me, so something in trying to use 
 the SnapshotCreator is causing me some issue as I will need to handle 
 custom embedder fields, etc...

 On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>
> That kind of error usually means you either haven't created a context 
> or aren't in a context or haven't created an appropriate handle.  Or... 
> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
> up somewhere" notification and often nothing more 
>
> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  
> wrote:
>
>> I will give it a try sometime this week. I tried to remove our 
>> initialization JS file but that caused a failure further down the 
>> serialization as well, so still investigating.
>>
>>
>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>>>
>>> Can you post a minimal complete example that reproduces your problem?
>>>
>>> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes 
>>> wrote:

 Hello,

 I am trying to create a snapshot that includes most of code but I 
 ran into the following assertion:

   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());

 Any clarifications about what would generate it that our JS code is 
 doing and is not legal? I found that creating Unsafe Arrays is also 
 not 
 permitted but that is relatively easy to work around.

 Francisco

>>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to a topic in 
>> the Google Groups "v

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Zac Hansen
Just a guess but how would he system know how to deal with objects held by
global handles when making a snapshot?   You can't serialize the global
handles in such a way that they would be useful in any way?

I'm guessing this is just a sanity check to make sure you aren't doing
something unintended.

I could be completely wrong but I'd say just free up your globals and if
that changes the behavior then you weren't ready to make a snapshot anyhow.


On Wed, Sep 6, 2017 at 11:27 AM Francisco Moraes 
wrote:

> After fixing the issue about the handle scope, I can successfully create
> the snapshot for the test code, but when I tried something more
> complicated, I ran into this now:
>
> Check failed: 0 == isolate->global_handles()->global_handles_count() (0
> vs. 4).
>
>
> On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:
>>
>>
>> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>>
>> Created a snapshot data blob. This must not be called from within a
>> handle scope.
>>
>>
>>
>>
>> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes
>> wrote:
>>>
>>> Here's a simple recreate that I managed to create:
>>>
>>> #include 
>>>
>>> #include "v8.h"
>>> #include "libplatform/libplatform.h"
>>>
>>> int main(int argv, char **argc)
>>> {
>>> const char *v8flags = "";
>>> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
>>> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
>>> v8::V8::InitializePlatform(platform);
>>> v8::V8::Initialize();
>>>
>>> v8::SnapshotCreator creator;
>>> v8::Isolate *isolate = creator.GetIsolate();
>>>
>>> v8::HandleScope handle_scope(isolate);
>>> v8::Local context = v8::Context::New(isolate);
>>> const char* source = "function initialize(obj) { return true; }";
>>> v8::Context::Scope context_scope(context);
>>> v8::TryCatch try_catch(isolate);
>>> v8::Local source_string;
>>> v8::String::NewFromUtf8(isolate, source, v8::NewStringType::kNormal)
>>> .ToLocal(&source_string);
>>> v8::ScriptOrigin origin =
>>> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
>>> v8::ScriptCompiler::Source sourcecode(source_string, origin);
>>> v8::Local script;
>>> bool success = v8::ScriptCompiler::Compile(context,
>>> &sourcecode).ToLocal(&script);
>>>
>>> script->Run(context);
>>>
>>> creator.SetDefaultContext(context);
>>> v8::StartupData blob =
>>> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>>>
>>> return 1;
>>> }
>>>
>>> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it
>>> works as it does all the above work for me, so something in trying to use
>>> the SnapshotCreator is causing me some issue as I will need to handle
>>> custom embedder fields, etc...
>>>
>>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:

 That kind of error usually means you either haven't created a context
 or aren't in a context or haven't created an appropriate handle.  Or...
 Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed
 up somewhere" notification and often nothing more

 On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes 
 wrote:

> I will give it a try sometime this week. I tried to remove our
> initialization JS file but that caused a failure further down the
> serialization as well, so still investigating.
>
>
> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>>
>> Can you post a minimal complete example that reproduces your problem?
>>
>> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes
>> wrote:
>>>
>>> Hello,
>>>
>>> I am trying to create a snapshot that includes most of code but I
>>> ran into the following assertion:
>>>
>>>   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
>>>
>>> Any clarifications about what would generate it that our JS code is
>>> doing and is not legal? I found that creating Unsafe Arrays is also not
>>> permitted but that is relatively easy to work around.
>>>
>>> Francisco
>>>
>> --
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> v8-users+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

>>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:

 That kind of error usually means you either haven't created a context
 or aren't in 

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Francisco Moraes
After fixing the issue about the handle scope, I can successfully create 
the snapshot for the test code, but when I tried something more 
complicated, I ran into this now:

Check failed: 0 == isolate->global_handles()->global_handles_count() (0 vs. 
4).

On Wednesday, September 6, 2017 at 12:27:35 PM UTC-4, Zac Hansen wrote:
>
>
> https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a
>
> Created a snapshot data blob. This must not be called from within a handle 
> scope.
>
>
>
>
> On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes 
> wrote:
>>
>> Here's a simple recreate that I managed to create:
>>
>> #include 
>>
>> #include "v8.h"
>> #include "libplatform/libplatform.h"
>>
>> int main(int argv, char **argc)
>> {
>> const char *v8flags = "";
>> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
>> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
>> v8::V8::InitializePlatform(platform);
>> v8::V8::Initialize();
>>
>> v8::SnapshotCreator creator;
>> v8::Isolate *isolate = creator.GetIsolate();
>> 
>> v8::HandleScope handle_scope(isolate);
>> v8::Local context = v8::Context::New(isolate);
>> const char* source = "function initialize(obj) { return true; }";
>> v8::Context::Scope context_scope(context);
>> v8::TryCatch try_catch(isolate);
>> v8::Local source_string;
>> v8::String::NewFromUtf8(isolate, source, v8::NewStringType::kNormal)
>> .ToLocal(&source_string);
>> v8::ScriptOrigin origin = 
>> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
>> v8::ScriptCompiler::Source sourcecode(source_string, origin);
>> v8::Local script;
>> bool success = v8::ScriptCompiler::Compile(context, 
>> &sourcecode).ToLocal(&script);
>>
>> script->Run(context);
>>   
>> creator.SetDefaultContext(context);
>> v8::StartupData blob = 
>> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>>
>> return 1;
>> }
>>
>> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it 
>> works as it does all the above work for me, so something in trying to use 
>> the SnapshotCreator is causing me some issue as I will need to handle 
>> custom embedder fields, etc...
>>
>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>>
>>> That kind of error usually means you either haven't created a context or 
>>> aren't in a context or haven't created an appropriate handle.  Or... 
>>> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
>>> up somewhere" notification and often nothing more 
>>>
>>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  
>>> wrote:
>>>
 I will give it a try sometime this week. I tried to remove our 
 initialization JS file but that caused a failure further down the 
 serialization as well, so still investigating.


 On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>
> Can you post a minimal complete example that reproduces your problem?
>
> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes 
> wrote:
>>
>> Hello,
>>
>> I am trying to create a snapshot that includes most of code but I ran 
>> into the following assertion:
>>
>>   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
>>
>> Any clarifications about what would generate it that our JS code is 
>> doing and is not legal? I found that creating Unsafe Arrays is also not 
>> permitted but that is relatively easy to work around.
>>
>> Francisco
>>
> -- 
 -- 
 v8-users mailing list
 v8-u...@googlegroups.com
 http://groups.google.com/group/v8-users
 --- 
 You received this message because you are subscribed to a topic in the 
 Google Groups "v8-users" group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 v8-users+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>>
>>> That kind of error usually means you either haven't created a context or 
>>> aren't in a context or haven't created an appropriate handle.  Or... 
>>> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
>>> up somewhere" notification and often nothing more 
>>>
>>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  
>>> wrote:
>>>
 I will give it a try sometime this week. I tried to remove our 
 initialization JS file but that caused a failure further down the 
 serialization as well, so still investigating.


 On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>
> Can you post a minimal complete example that re

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Zac Hansen
https://v8.paulfryzel.com/docs/master/classv8_1_1_snapshot_creator.html#a86b2023acdb88a9bd6eae2695f2b0a8a

Created a snapshot data blob. This must not be called from within a handle 
scope.




On Wednesday, September 6, 2017 at 7:20:33 AM UTC-7, Francisco Moraes wrote:
>
> Here's a simple recreate that I managed to create:
>
> #include 
>
> #include "v8.h"
> #include "libplatform/libplatform.h"
>
> int main(int argv, char **argc)
> {
> const char *v8flags = "";
> v8::Platform *platform = v8::platform::CreateDefaultPlatform();
> v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
> v8::V8::InitializePlatform(platform);
> v8::V8::Initialize();
>
> v8::SnapshotCreator creator;
> v8::Isolate *isolate = creator.GetIsolate();
> 
> v8::HandleScope handle_scope(isolate);
> v8::Local context = v8::Context::New(isolate);
> const char* source = "function initialize(obj) { return true; }";
> v8::Context::Scope context_scope(context);
> v8::TryCatch try_catch(isolate);
> v8::Local source_string;
> v8::String::NewFromUtf8(isolate, source, v8::NewStringType::kNormal)
> .ToLocal(&source_string);
> v8::ScriptOrigin origin = 
> v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
> v8::ScriptCompiler::Source sourcecode(source_string, origin);
> v8::Local script;
> bool success = v8::ScriptCompiler::Compile(context, 
> &sourcecode).ToLocal(&script);
>
> script->Run(context);
>   
> creator.SetDefaultContext(context);
> v8::StartupData blob = 
> creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
>
> return 1;
> }
>
> The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it works 
> as it does all the above work for me, so something in trying to use the 
> SnapshotCreator is causing me some issue as I will need to handle custom 
> embedder fields, etc...
>
> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>
>> That kind of error usually means you either haven't created a context or 
>> aren't in a context or haven't created an appropriate handle.  Or... 
>> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
>> up somewhere" notification and often nothing more 
>>
>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  
>> wrote:
>>
>>> I will give it a try sometime this week. I tried to remove our 
>>> initialization JS file but that caused a failure further down the 
>>> serialization as well, so still investigating.
>>>
>>>
>>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:

 Can you post a minimal complete example that reproduces your problem?

 On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes 
 wrote:
>
> Hello,
>
> I am trying to create a snapshot that includes most of code but I ran 
> into the following assertion:
>
>   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
>
> Any clarifications about what would generate it that our JS code is 
> doing and is not legal? I found that creating Unsafe Arrays is also not 
> permitted but that is relatively easy to work around.
>
> Francisco
>
 -- 
>>> -- 
>>> v8-users mailing list
>>> v8-u...@googlegroups.com
>>> http://groups.google.com/group/v8-users
>>> --- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "v8-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> v8-users+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
> On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>>
>> That kind of error usually means you either haven't created a context or 
>> aren't in a context or haven't created an appropriate handle.  Or... 
>> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
>> up somewhere" notification and often nothing more 
>>
>> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  
>> wrote:
>>
>>> I will give it a try sometime this week. I tried to remove our 
>>> initialization JS file but that caused a failure further down the 
>>> serialization as well, so still investigating.
>>>
>>>
>>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:

 Can you post a minimal complete example that reproduces your problem?

 On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes 
 wrote:
>
> Hello,
>
> I am trying to create a snapshot that includes most of code but I ran 
> into the following assertion:
>
>   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
>
> Any clarifications about what would generate it that our JS code is 
> doing and is not legal? I found that creating 

Re: [v8-users] Re: V8 snapshots

2017-09-06 Thread Francisco Moraes
Here's a simple recreate that I managed to create:

#include 

#include "v8.h"
#include "libplatform/libplatform.h"

int main(int argv, char **argc)
{
const char *v8flags = "";
v8::Platform *platform = v8::platform::CreateDefaultPlatform();
v8::V8::SetFlagsFromString (v8flags, strlen (v8flags));
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();

v8::SnapshotCreator creator;
v8::Isolate *isolate = creator.GetIsolate();

v8::HandleScope handle_scope(isolate);
v8::Local context = v8::Context::New(isolate);
const char* source = "function initialize(obj) { return true; }";
v8::Context::Scope context_scope(context);
v8::TryCatch try_catch(isolate);
v8::Local source_string;
v8::String::NewFromUtf8(isolate, source, v8::NewStringType::kNormal)
.ToLocal(&source_string);
v8::ScriptOrigin origin = 
v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "testscript"));
v8::ScriptCompiler::Source sourcecode(source_string, origin);
v8::Local script;
bool success = v8::ScriptCompiler::Compile(context, 
&sourcecode).ToLocal(&script);

script->Run(context);
  
creator.SetDefaultContext(context);
v8::StartupData blob = 
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);

return 1;
}

The interesting thing is if I call v8::V8::CreateSnapshotDataBlob it works 
as it does all the above work for me, so something in trying to use the 
SnapshotCreator is causing me some issue as I will need to handle custom 
embedder fields, etc...

On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>
> That kind of error usually means you either haven't created a context or 
> aren't in a context or haven't created an appropriate handle.  Or... 
> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
> up somewhere" notification and often nothing more 
>
> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  > wrote:
>
>> I will give it a try sometime this week. I tried to remove our 
>> initialization JS file but that caused a failure further down the 
>> serialization as well, so still investigating.
>>
>>
>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>>>
>>> Can you post a minimal complete example that reproduces your problem?
>>>
>>> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes wrote:

 Hello,

 I am trying to create a snapshot that includes most of code but I ran 
 into the following assertion:

   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());

 Any clarifications about what would generate it that our JS code is 
 doing and is not legal? I found that creating Unsafe Arrays is also not 
 permitted but that is relatively easy to work around.

 Francisco

>>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "v8-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
On Tuesday, September 5, 2017 at 2:50:36 PM UTC-4, Zac Hansen wrote:
>
> That kind of error usually means you either haven't created a context or 
> aren't in a context or haven't created an appropriate handle.  Or... 
> Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed 
> up somewhere" notification and often nothing more 
>
> On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes  > wrote:
>
>> I will give it a try sometime this week. I tried to remove our 
>> initialization JS file but that caused a failure further down the 
>> serialization as well, so still investigating.
>>
>>
>> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>>>
>>> Can you post a minimal complete example that reproduces your problem?
>>>
>>> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes wrote:

 Hello,

 I am trying to create a snapshot that includes most of code but I ran 
 into the following assertion:

   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());

 Any clarifications about what would generate it that our JS code is 
 doing and is not legal? I found that creating Unsafe Arrays is also not 
 permitted but that is relatively easy to work around.

 Francisco

>>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "v8-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe

Re: [v8-users] Re: V8 snapshots

2017-09-05 Thread Zac Hansen
That kind of error usually means you either haven't created a context or
aren't in a context or haven't created an appropriate handle.  Or...
Something else :-/. Maybe a lock?  V8 errors are very much a "you screwed
up somewhere" notification and often nothing more

On Tue, Sep 5, 2017 at 9:42 AM Francisco Moraes 
wrote:

> I will give it a try sometime this week. I tried to remove our
> initialization JS file but that caused a failure further down the
> serialization as well, so still investigating.
>
>
> On Saturday, September 2, 2017 at 1:07:28 AM UTC-4, Zac Hansen wrote:
>>
>> Can you post a minimal complete example that reproduces your problem?
>>
>> On Friday, September 1, 2017 at 8:57:51 AM UTC-7, Francisco Moraes wrote:
>>>
>>> Hello,
>>>
>>> I am trying to create a snapshot that includes most of code but I ran
>>> into the following assertion:
>>>
>>>   CHECK(isolate->handle_scope_implementer()->blocks()->is_empty());
>>>
>>> Any clarifications about what would generate it that our JS code is
>>> doing and is not legal? I found that creating Unsafe Arrays is also not
>>> permitted but that is relatively easy to work around.
>>>
>>> Francisco
>>>
>> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/kxtnaSSQL9c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> v8-users+unsubscr...@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.


Re: [v8-users] Re: V8 Snapshots Questions and Clarifications

2014-11-11 Thread Louis Santillan
Thanks for the clarifications, Jakob.

On Tue, Nov 11, 2014 at 1:40 AM, Jakob Kummerow  wrote:
> mksnapshot isn't intended for creating arbitrary snapshots, that's why it's
> not exposed or documented. You are of course free to play around with it,
> but you're pretty much on your own.
>
> For the record, Chrome does not create a Chrome-specific V8 snapshot
> (AFAIK).
>
> Also, bear in mind that putting stuff into the snapshot is a tradeoff:
> extracting things from the snapshot is (usually) faster than
> parsing/compiling them from source, but on the other hand extracting a
> bigger snapshot is obviously slower than extracting a smaller snapshot. So
> V8 tries very carefully to only put the most important bits into the
> snapshot, rather than anything that might potentially be used at some point.
>
> On Tue, Nov 11, 2014 at 7:29 AM, Louis Santillan  wrote:
>>
>> So if I'm reading the qt doc [0] and src/mksnapshot.cc [1] correctly,
>> mksnapshot expects to be run like something like
>>
>> ./mksnapshot [optional v8 engine args] mystartup.js mysnapshot.cc
>>
>> where mystartup.js is a JS file that runs without error.  I would
>> expect mystartup.js to be a significant enough part of your app that
>> you can measure its compilation during startup.  It should also be
>> composed of the "common" part of your app; the part of your app that
>> must run as a prerequisite for all execution paths.  For v8, that
>> means it uses mksnapshot to build the JS built-in objects into the
>> runtime startup of itself (a sort bootstrapping technique).  It's a
>> process that takes less than 5 ms on an Intel(R) Xeon(R) CPU E3-1240
>> V2 @ 3.40GHz.  I would imagine it's a lot more beneficial in
>> Chrome/Chromium where DOM and a bunch of UI, network, crypto, etc.,
>> takes multiple MBs to load.
>>
>> Where this gets interesting is when your mystartup.js depends on
>> Native objects or Native code not built-in to v8 or JS built-ins.
>> mksnapshot does not seem to take this into account.  However, it
>> appears, that if you modify src/mksnapshot.cc somewhere after here [2]
>> but before [3], then your mystartup.js *CAN* depend (and compile
>> against) Native code just as is done in samples/shell.cc [4] to load
>> the print/read/load/quit/version Native code.  You'll have to rebuild
>> v8 and you'll have to get your source tree co-mingled with v8's
>> tree/build process, but such is life.
>>
>> [0] http://qt-project.org/wiki/V8Snapshot
>> [1] https://github.com/v8/v8/blob/master/src/mksnapshot.cc
>> [2]
>> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L370
>> [3]
>> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L395
>> [4]
>> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/samples/shell.cc#L96
>>
>> On Mon, Nov 10, 2014 at 7:06 PM, Flying Jester 
>> wrote:
>> > Snapshots are enabled all the time unless you expressly disable them
>> > with
>> > gyp.
>> >
>> >
>> > On Monday, November 10, 2014 4:59:37 PM UTC-9, Chris E wrote:
>> >>
>> >> Hello all,
>> >>
>> >> I am trying to use v8 snapshots to improve the start-up time of a v8
>> >> application (like what chrome/chromium does), but I am unable to find
>> >> sufficient documentation to understand and use this feature.
>> >>
>> >> I have looked at the following references, but it is still not clear to
>> >> me
>> >> exactly how to make the best use of snapshots for performance.
>> >> https://developers.google.com/v8/embed
>> >> http://qt-project.org/wiki/V8Snapshot
>> >>
>> >> The QT link seemed the most useful so can anyone verify the correctness
>> >> of
>> >> this reference?
>> >>
>> >> So basically we have to compile and run our JS application with an
>> >> emulator and somehow generate the  snapshot.cc using mksnapshot?
>> >> If our JS application is large and has many features, how do we know
>> >> how
>> >> much of it should run before creating the snapshot?
>> >> How is this snapshot affected by libraries (both C++ and JS) that get
>> >> loaded dynamically?
>> >>
>> >> Also it sounds like we have to be careful that the snapshot is not
>> >> 'stale'
>> >> or outdated with respect to the code that we run to create the snapshot
>> >> right?
>> >>
>> >> Thank you so much for the help and clarifications.
>> >
>> > --
>> > --
>> > 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 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 

Re: [v8-users] Re: V8 Snapshots Questions and Clarifications

2014-11-11 Thread Jakob Kummerow
mksnapshot isn't intended for creating arbitrary snapshots, that's why it's
not exposed or documented. You are of course free to play around with it,
but you're pretty much on your own.

For the record, Chrome does not create a Chrome-specific V8 snapshot
(AFAIK).

Also, bear in mind that putting stuff into the snapshot is a tradeoff:
extracting things from the snapshot is (usually) faster than
parsing/compiling them from source, but on the other hand extracting a
bigger snapshot is obviously slower than extracting a smaller snapshot. So
V8 tries very carefully to only put the most important bits into the
snapshot, rather than anything that might potentially be used at some point.

On Tue, Nov 11, 2014 at 7:29 AM, Louis Santillan  wrote:

> So if I'm reading the qt doc [0] and src/mksnapshot.cc [1] correctly,
> mksnapshot expects to be run like something like
>
> ./mksnapshot [optional v8 engine args] mystartup.js mysnapshot.cc
>
> where mystartup.js is a JS file that runs without error.  I would
> expect mystartup.js to be a significant enough part of your app that
> you can measure its compilation during startup.  It should also be
> composed of the "common" part of your app; the part of your app that
> must run as a prerequisite for all execution paths.  For v8, that
> means it uses mksnapshot to build the JS built-in objects into the
> runtime startup of itself (a sort bootstrapping technique).  It's a
> process that takes less than 5 ms on an Intel(R) Xeon(R) CPU E3-1240
> V2 @ 3.40GHz.  I would imagine it's a lot more beneficial in
> Chrome/Chromium where DOM and a bunch of UI, network, crypto, etc.,
> takes multiple MBs to load.
>
> Where this gets interesting is when your mystartup.js depends on
> Native objects or Native code not built-in to v8 or JS built-ins.
> mksnapshot does not seem to take this into account.  However, it
> appears, that if you modify src/mksnapshot.cc somewhere after here [2]
> but before [3], then your mystartup.js *CAN* depend (and compile
> against) Native code just as is done in samples/shell.cc [4] to load
> the print/read/load/quit/version Native code.  You'll have to rebuild
> v8 and you'll have to get your source tree co-mingled with v8's
> tree/build process, but such is life.
>
> [0] http://qt-project.org/wiki/V8Snapshot
> [1] https://github.com/v8/v8/blob/master/src/mksnapshot.cc
> [2]
> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L370
> [3]
> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L395
> [4]
> https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/samples/shell.cc#L96
>
> On Mon, Nov 10, 2014 at 7:06 PM, Flying Jester 
> wrote:
> > Snapshots are enabled all the time unless you expressly disable them with
> > gyp.
> >
> >
> > On Monday, November 10, 2014 4:59:37 PM UTC-9, Chris E wrote:
> >>
> >> Hello all,
> >>
> >> I am trying to use v8 snapshots to improve the start-up time of a v8
> >> application (like what chrome/chromium does), but I am unable to find
> >> sufficient documentation to understand and use this feature.
> >>
> >> I have looked at the following references, but it is still not clear to
> me
> >> exactly how to make the best use of snapshots for performance.
> >> https://developers.google.com/v8/embed
> >> http://qt-project.org/wiki/V8Snapshot
> >>
> >> The QT link seemed the most useful so can anyone verify the correctness
> of
> >> this reference?
> >>
> >> So basically we have to compile and run our JS application with an
> >> emulator and somehow generate the  snapshot.cc using mksnapshot?
> >> If our JS application is large and has many features, how do we know how
> >> much of it should run before creating the snapshot?
> >> How is this snapshot affected by libraries (both C++ and JS) that get
> >> loaded dynamically?
> >>
> >> Also it sounds like we have to be careful that the snapshot is not
> 'stale'
> >> or outdated with respect to the code that we run to create the snapshot
> >> right?
> >>
> >> Thank you so much for the help and clarifications.
> >
> > --
> > --
> > 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 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 mailing list
v8-users@googlegroups.com
http://groups.google.com

Re: [v8-users] Re: V8 Snapshots Questions and Clarifications

2014-11-10 Thread Louis Santillan
So if I'm reading the qt doc [0] and src/mksnapshot.cc [1] correctly,
mksnapshot expects to be run like something like

./mksnapshot [optional v8 engine args] mystartup.js mysnapshot.cc

where mystartup.js is a JS file that runs without error.  I would
expect mystartup.js to be a significant enough part of your app that
you can measure its compilation during startup.  It should also be
composed of the "common" part of your app; the part of your app that
must run as a prerequisite for all execution paths.  For v8, that
means it uses mksnapshot to build the JS built-in objects into the
runtime startup of itself (a sort bootstrapping technique).  It's a
process that takes less than 5 ms on an Intel(R) Xeon(R) CPU E3-1240
V2 @ 3.40GHz.  I would imagine it's a lot more beneficial in
Chrome/Chromium where DOM and a bunch of UI, network, crypto, etc.,
takes multiple MBs to load.

Where this gets interesting is when your mystartup.js depends on
Native objects or Native code not built-in to v8 or JS built-ins.
mksnapshot does not seem to take this into account.  However, it
appears, that if you modify src/mksnapshot.cc somewhere after here [2]
but before [3], then your mystartup.js *CAN* depend (and compile
against) Native code just as is done in samples/shell.cc [4] to load
the print/read/load/quit/version Native code.  You'll have to rebuild
v8 and you'll have to get your source tree co-mingled with v8's
tree/build process, but such is life.

[0] http://qt-project.org/wiki/V8Snapshot
[1] https://github.com/v8/v8/blob/master/src/mksnapshot.cc
[2] 
https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L370
[3] 
https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/src/mksnapshot.cc#L395
[4] 
https://github.com/v8/v8/blob/134ebca3d871784966ea068d06210d9fe70ec4ab/samples/shell.cc#L96

On Mon, Nov 10, 2014 at 7:06 PM, Flying Jester  wrote:
> Snapshots are enabled all the time unless you expressly disable them with
> gyp.
>
>
> On Monday, November 10, 2014 4:59:37 PM UTC-9, Chris E wrote:
>>
>> Hello all,
>>
>> I am trying to use v8 snapshots to improve the start-up time of a v8
>> application (like what chrome/chromium does), but I am unable to find
>> sufficient documentation to understand and use this feature.
>>
>> I have looked at the following references, but it is still not clear to me
>> exactly how to make the best use of snapshots for performance.
>> https://developers.google.com/v8/embed
>> http://qt-project.org/wiki/V8Snapshot
>>
>> The QT link seemed the most useful so can anyone verify the correctness of
>> this reference?
>>
>> So basically we have to compile and run our JS application with an
>> emulator and somehow generate the  snapshot.cc using mksnapshot?
>> If our JS application is large and has many features, how do we know how
>> much of it should run before creating the snapshot?
>> How is this snapshot affected by libraries (both C++ and JS) that get
>> loaded dynamically?
>>
>> Also it sounds like we have to be careful that the snapshot is not 'stale'
>> or outdated with respect to the code that we run to create the snapshot
>> right?
>>
>> Thank you so much for the help and clarifications.
>
> --
> --
> 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 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.