Re: [v8-users] Partially executing a Javascript file in v8 c++ program

2017-08-04 Thread Kavin Mani
This gave me a good head start. However, my program crashes at 
function->Call statement. 

Can you please tell me what values function_value, function_name and 
function are supposed to take.I have also populated argv with random values 
since I am not using them in my function. If that could also be a reason 
for the crash, please let me know.

This is my JS code :

Local source =
*String::NewFromUtf8(isolate, "'function test_function() {var match = 0; 
return match+10;}'",*
* NewStringType::kNormal).ToLocalChecked();*

*Thanks,*
*Kavin*

On Friday, August 4, 2017 at 3:29:23 PM UTC-7, Jeremy Bettis wrote:
>
> What I do to call a function is to use 
>
> v8::Local function_value;
> context->Global()->Get(context, function_name).ToLocal(_value);
> v8::Local function = 
> v8::Local::Cast(function_value);
> const int argc = arguments.size();
> std::vector argv(argc);
> // populate the argv somehow
> function->Call(context, context->Global(), argc, argv.data());
>
> On Fri, Aug 4, 2017 at 4:17 PM, Kavin Mani  > wrote:
>
>> Hi,
>>
>> I am new to V8 engine and starting to experiment things. I am wondering 
>> if it is possible to execute different functions from a Javascript file at 
>> different times.
>>
>> Consider the following scenario:
>>
>> I have a Javascript file with a global variable *foo *and two functions 
>> *func1() *and *func2().* Something like this:
>>
>> *Test.js:*
>>
>> var foo = 0;
>>
>> function func1() {
>>   foo = 100;
>> }
>>
>> function func2() {
>>   return foo + 10;
>> }
>>
>> In my *cpp* file, I want to first execute *func1() *from Test.js*, *print 
>> some random statements (need not be related to using *foo*) and then 
>> call *func2()*. Finally, I want to print the value of *foo *in my C++ 
>> program. Here is what I want to do - 
>>
>> *Test.cpp*
>>
>> Print some statements...
>>
>> Call func1()
>>
>> Print some more statements...
>>
>> Call func2()
>>
>> Print the value of foo
>>
>>
>> Almost all of the examples that I could find takes the Javascript program 
>> as a string and executes it completely. However, I want to execute them in 
>> parts at different times. Can someone please help me to find a way to do 
>> this?
>>
>> Thanks,
>> Kavin
>>
>> -- 
>> -- 
>> 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.
>>
>
>
>
> -- 
> Jeremy Bettis | Staff Software Engineer | jbe...@google.com 
>  | 303-257-2486
>

-- 
-- 
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] Partially executing a Javascript file in v8 c++ program

2017-08-04 Thread 'Jeremy Bettis' via v8-users
What I do to call a function is to use

v8::Local function_value;
context->Global()->Get(context, function_name).ToLocal(_value);
v8::Local function =
v8::Local::Cast(function_value);
const int argc = arguments.size();
std::vector argv(argc);
// populate the argv somehow
function->Call(context, context->Global(), argc, argv.data());

On Fri, Aug 4, 2017 at 4:17 PM, Kavin Mani  wrote:

> Hi,
>
> I am new to V8 engine and starting to experiment things. I am wondering if
> it is possible to execute different functions from a Javascript file at
> different times.
>
> Consider the following scenario:
>
> I have a Javascript file with a global variable *foo *and two functions
> *func1() *and *func2().* Something like this:
>
> *Test.js:*
>
> var foo = 0;
>
> function func1() {
>   foo = 100;
> }
>
> function func2() {
>   return foo + 10;
> }
>
> In my *cpp* file, I want to first execute *func1() *from Test.js*, *print
> some random statements (need not be related to using *foo*) and then call
> *func2()*. Finally, I want to print the value of *foo *in my C++ program.
> Here is what I want to do -
>
> *Test.cpp*
>
> Print some statements...
>
> Call func1()
>
> Print some more statements...
>
> Call func2()
>
> Print the value of foo
>
>
> Almost all of the examples that I could find takes the Javascript program
> as a string and executes it completely. However, I want to execute them in
> parts at different times. Can someone please help me to find a way to do
> this?
>
> Thanks,
> Kavin
>
> --
> --
> 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.
>



-- 
Jeremy Bettis | Staff Software Engineer | jbet...@google.com | 303-257-2486

-- 
-- 
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.


smime.p7s
Description: S/MIME Cryptographic Signature


[v8-users] Partially executing a Javascript file in v8 c++ program

2017-08-04 Thread Kavin Mani
Hi,

I am new to V8 engine and starting to experiment things. I am wondering if 
it is possible to execute different functions from a Javascript file at 
different times.

Consider the following scenario:

I have a Javascript file with a global variable *foo *and two functions 
*func1() *and *func2().* Something like this:

*Test.js:*

var foo = 0;

function func1() {
  foo = 100;
}

function func2() {
  return foo + 10;
}

In my *cpp* file, I want to first execute *func1() *from Test.js*, *print 
some random statements (need not be related to using *foo*) and then call 
*func2()*. Finally, I want to print the value of *foo *in my C++ program. 
Here is what I want to do - 

*Test.cpp*

Print some statements...

Call func1()

Print some more statements...

Call func2()

Print the value of foo


Almost all of the examples that I could find takes the Javascript program 
as a string and executes it completely. However, I want to execute them in 
parts at different times. Can someone please help me to find a way to do 
this?

Thanks,
Kavin

-- 
-- 
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] v8 6.0.286.52 test-unboxed-doubles.cc is failing.

2017-08-04 Thread Jakob Kummerow
All tests are important. And all the test-unboxed-doubles tests pass with a
regular build (Release or Debug) of the unmodified sources at that revision.

I would suggest that you try to narrow down which difference between your
build and the official build causes these tests to fail. (Is it gcc vs.
clang? is it one of your patches? is it one of your build settings? All of
these seem unlikely, but there must be a difference *somewhere*.)

On Fri, Aug 4, 2017 at 9:32 AM,  wrote:

> I managed to build v8 on arch linux using gcc7, here you can find the full
> configuration for the package: https://aur.archlinux.org/packages/v8/
>
> I've used this patch for building on gcc7: https://github.com/
> nodejs/node/commit/d9a8f80c0dea64d7c95eac48f8f57d7a25ea7edf
>
> this is my rendition of the patch, had to change one hunk:
>
> compile-patch: https://aur.archlinux.org/cgit/aur.git/
> tree/gcc7.patch?h=v8=3bd1540d3de247333eeebc5de5e1534f710da314
>
> But i had to cut also a function and a test to make the package compile
> and test:
> test-patch: https://aur.archlinux.org/cgit/aur.git/tree/ctest.patch?
> h=v8=3bd1540d3de247333eeebc5de5e1534f710da314
>
> My question is: is this test important?
>
> The test is failing giving a stacktrace: failing on line 144 of
> text-unboxed-doubles.cc
>
> Do you need the stacktrace to confirm ?
>
>
>
> === cctest/test-unboxed-doubles/LayoutDescriptorBasicFast ===
> #
> # Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 144
> # Check failed: layout_desc->IsFastPointerLayout().
> #
>
>  C stack trace ===
>
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe) [0x7fc27d11729e]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libplatform.so(+0x5073) [0x7fc27d0f8073]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(V8_Fatal+0xe2) [0x7fc27d114822]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0xbc68da)
> [0xf5449f78da]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef53a)
> [0xf54462053a]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x79f870)
> [0xf5445d0870]
> /usr/lib/libc.so.6(__libc_start_main+0xea) [0x7fc27b6c44ca]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef19a)
> [0xf54462019a]
> Received signal 6
> Command: /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest
> --random-seed=-742090116 test-unboxed-doubles/LayoutDescriptorBasicFast
> --nohard-abort --nodead-code-elimination --nofold-constants
>
>
>
> [00:03|%   0|+  14|-   1]: debugger/debug/ignition/debug-
> step-prefix-byteco...
>
>
> [00:03|%   0|+  15|-   1]: debugger/debug/debug-stepout-scope-part6
>
> [00:03|%   0|+  16|-   1]: debugger/debug/debug-stepout-scope-part3
>
> [00:03|%   0|+  17|-   1]: debugger/debug/debug-scopes
>
> [00:03|%   0|+  17|-   2]: cctest/test-unboxed-doubles/
> LayoutDescriptorBasi...
>
>
> === cctest/test-unboxed-doubles/LayoutDescriptorBasicFast ===
> #
> # Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 144
> # Check failed: layout_desc->IsFastPointerLayout().
> #
>
>  C stack trace ===
>
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe) [0x7f999eaab29e]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libplatform.so(+0x5073) [0x7f999ea8c073]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(V8_Fatal+0xe2) [0x7f999eaa8822]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0xbc68da)
> [0xe3a8e358da]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef53a)
> [0xe3a8a5e53a]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x79f870)
> [0xe3a8a0e870]
> /usr/lib/libc.so.6(__libc_start_main+0xea) [0x7f999d0584ca]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef19a)
> [0xe3a8a5e19a]
> Received signal 6
> Command: /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest
> --random-seed=-742090116 --no-turbo 
> test-unboxed-doubles/LayoutDescriptorBasicFast
> --nohard-abort --nodead-code-elimination --nofold-constants
>
>
>
> [00:03|%   0|+  17|-   3]: cctest/test-unboxed-doubles/
> LayoutDescriptorHelp...
>
>
> === cctest/test-unboxed-doubles/LayoutDescriptorHelperAllDoubles ===
> #
> # Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 1253
> # Check failed: first_non_tagged_field_offset == end_of_region_offset.
> #
>
>  C stack trace ===
>
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe) [0x7f5fcd66629e]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libplatform.so(+0x5073) [0x7f5fcd647073]
> /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_
> libbase.so(V8_Fatal+0xe2) [0x7f5fcd663822]
>  

[v8-users] v8 6.0.286.52 test-unboxed-doubles.cc is failing.

2017-08-04 Thread pompilimrc
I managed to build v8 on arch linux using gcc7, here you can find the full 
configuration for the package: https://aur.archlinux.org/packages/v8/

I've used this patch for building on 
gcc7: 
https://github.com/nodejs/node/commit/d9a8f80c0dea64d7c95eac48f8f57d7a25ea7edf

this is my rendition of the patch, had to change one hunk:

compile-patch: 
https://aur.archlinux.org/cgit/aur.git/tree/gcc7.patch?h=v8=3bd1540d3de247333eeebc5de5e1534f710da314

But i had to cut also a function and a test to make the package compile and 
test:
test-patch: 
https://aur.archlinux.org/cgit/aur.git/tree/ctest.patch?h=v8=3bd1540d3de247333eeebc5de5e1534f710da314

My question is: is this test important?

The test is failing giving a stacktrace: failing on line 144 of 
text-unboxed-doubles.cc

Do you need the stacktrace to confirm ?


  
=== cctest/test-unboxed-doubles/LayoutDescriptorBasicFast ===
#
# Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 144
# Check failed: layout_desc->IsFastPointerLayout().
#

 C stack trace ===


/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe)
 
[0x7fc27d11729e]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libplatform.so(+0x5073) 
[0x7fc27d0f8073]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(V8_Fatal+0xe2)
 
[0x7fc27d114822]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0xbc68da) 
[0xf5449f78da]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef53a) 
[0xf54462053a]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x79f870) 
[0xf5445d0870]
/usr/lib/libc.so.6(__libc_start_main+0xea) [0x7fc27b6c44ca]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef19a) 
[0xf54462019a]
Received signal 6
Command: /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest 
--random-seed=-742090116 test-unboxed-doubles/LayoutDescriptorBasicFast 
--nohard-abort --nodead-code-elimination --nofold-constants


  
[00:03|%   0|+  14|-   1]: 
debugger/debug/ignition/debug-step-prefix-byteco... 

  
[00:03|%   0|+  15|-   1]: debugger/debug/debug-stepout-scope-part6 
   
[00:03|%   0|+  16|-   1]: debugger/debug/debug-stepout-scope-part3 
   
[00:03|%   0|+  17|-   1]: debugger/debug/debug-scopes 
  
[00:03|%   0|+  17|-   2]: 
cctest/test-unboxed-doubles/LayoutDescriptorBasi... 

  
=== cctest/test-unboxed-doubles/LayoutDescriptorBasicFast ===
#
# Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 144
# Check failed: layout_desc->IsFastPointerLayout().
#

 C stack trace ===


/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe)
 
[0x7f999eaab29e]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libplatform.so(+0x5073) 
[0x7f999ea8c073]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(V8_Fatal+0xe2)
 
[0x7f999eaa8822]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0xbc68da) 
[0xe3a8e358da]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef53a) 
[0xe3a8a5e53a]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x79f870) 
[0xe3a8a0e870]
/usr/lib/libc.so.6(__libc_start_main+0xea) [0x7f999d0584ca]
/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest(+0x7ef19a) 
[0xe3a8a5e19a]
Received signal 6
Command: /home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/cctest 
--random-seed=-742090116 --no-turbo 
test-unboxed-doubles/LayoutDescriptorBasicFast --nohard-abort 
--nodead-code-elimination --nofold-constants


  
[00:03|%   0|+  17|-   3]: 
cctest/test-unboxed-doubles/LayoutDescriptorHelp... 

  
=== cctest/test-unboxed-doubles/LayoutDescriptorHelperAllDoubles ===
#
# Fatal error in ../../test/cctest/test-unboxed-doubles.cc, line 1253
# Check failed: first_non_tagged_field_offset == end_of_region_offset.
#

 C stack trace ===


/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0xe)
 
[0x7f5fcd66629e]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libplatform.so(+0x5073) 
[0x7f5fcd647073]

/home/marcs/DevLab/aur/v8/src/v8/out.gn/Release/./libv8_libbase.so(V8_Fatal+0xe2)
 
[0x7f5fcd663822]