I am very thankful for the info Louis and Ben provided me with,
appreciated, it helped a lot!
I managed to create a protected environment for runnig the scripts with
react loaded in the global space. The idea is that i create a persistent
context and first compile and run everything that I want protected and
globally accessible. Then on each local script render I copy the properties
of the persistent context to a local context and run the scripts in that
local context, that way I don;t need to recompile and re-run the global
scripts each time. The performance is more than 10x times better now.
About the data which needs to be passed from the db to the scripts i chose
to pass a string describing the data in JSON like format and to JSON.parse
it in the script and then use that new object. This is the last phase i
need to implement.
Any comments and ideas are wellcome!
On Monday, November 3, 2014 7:55:20 PM UTC+2, Dimitar Dimitrov wrote:
>
> Hello,
>
> I am trying to implement a simple web server where web pages will be
> rendered with V8 and React.js.
>
> I need to load React.js once and make it available in the global space,
> and then upon request i need to read different javascript files and render
> them with React with passed parameters from the C code...
>
> Can somebody help?
>
> When I try to run the following code it is working only for about 500
> iterations and then it is exiting with "Segmentation fault" error..
> This means that i can run only 500 queries on the server or even less. If
> i reinitialize isolate on every iteration it is working but rendering
> becomes very slow.
>
> Is there a way to run infinite iterations with the test.js script without
> getting "Segmentation fault"?
>
> v8::V8::Initialize();
> m_isolate = v8::Isolate::New();
> v8::Isolate::Scope isolate_scope(m_isolate);
>
> v8::HandleScope scope(m_isolate);
>
> v8::Handle<v8::Context> context = v8::Context::New(m_isolate);
> v8::Context::Scope context_scope(context);
>
> v8::Handle<v8::String> reactSrc = ReadFile(m_isolate, "react.js");
> v8::Local<v8::Script> script = v8::Script::Compile(reactSrc);
> v8::Handle<v8::Value> result = script->Run();
>
> v8::Handle<v8::String> testSrc = ReadFile(m_isolate, "test.js");
>
> //the number of available iterations before it crash somehow depends
> on the size of test.js script
> for(int i=0; i<1000; i++){
> v8::Local<v8::Script> script = v8::Script::Compile(testSrc);
> v8::Handle<v8::Value> result = script->Run();
> v8::String::Utf8Value utf8(result);
> //printf("%s\n",*utf8);
> }
>
> v8::V8::Dispose();
>
> Thank you!
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.