hi,
i have multi thread program with thread per isolate and context which each
runs the same script.
Since they all compile same script - I'd like to use the compiler to create
cache and distribute it between them.
Currently i get a crash when I get to the step of actually running the
script:
Can I share code cache (example below) between isolates? and script
compilations?
code example:
v8::TryCatch try_catch(thread_component_->thread_isolate);
v8::ScriptOrigin script_origin(v8::String::NewFromUtf8(
thread_isolate,
fileName));
const v8::Local<v8::String> raw_script(v8::String::NewFromUtf8(
thread_isolate, file_code));
v8::MaybeLocal<v8::UnboundScript> unbound_script;
v8::ScriptCompiler::Source* script_cache = script_cache_manager->
GetScriptCache(fileName);
if (script_cache == nullptr) {
script_cache = new v8::ScriptCompiler::Sourceraw_script,
script_origin);
unbound_script = v8::ScriptCompiler::CompileUnboundScript(isolate,
script_cache, v8::ScriptCompiler::kProduceCodeCache);
script_cache = script_cache_manager->AddScriptCache(fileName,
script_cache);
} else {
unbound_script = v8::ScriptCompiler::CompileUnboundScript(isolate,
script_cache, v8::ScriptCompiler::kConsumeCodeCache);
}
v8::Local<v8::Script> script = unbound_script.ToLocalChecked()->
BindToCurrentContext();
if (script.IsEmpty() || try_catch.HasCaught()) {
thread_component_->thread_isolate->ThrowException(try_catch.
Exception());
return;
}
v8::MaybeLocal<v8::Value> result(script->Run(
isolate_context));
if (result.IsEmpty() || try_catch.HasCaught()) {
thread_component_->thread_isolate->ThrowException(try_catch.
Exception());
return;
}
are there any suggestions for other optimazations i can do accross isolates?
--
--
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.