Commit d44ef863 authored by Oleg Korshul's avatar Oleg Korshul

.

parent 2f42dc2c
......@@ -5,11 +5,13 @@ SET PATH=%SCRIPTPATH%depot_tools;%PATH%
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
SET GYP_MSVS_VERSION=2015
cd v8
call gn gen out.gn/win_64 --args="is_debug=false target_cpu=\"x64\" v8_target_cpu=\"x64\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
cd ../
call powershell -File .\fix-static_crt.ps1
cd v8
call ninja -C out.gn/win_64
\ No newline at end of file
call gn gen out.gn/win_64/release --args="is_debug=false target_cpu=\"x64\" v8_target_cpu=\"x64\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
call ninja -C out.gn/win_64/release
call gn gen out.gn/win_64/debug --args="is_debug=true target_cpu=\"x64\" v8_target_cpu=\"x64\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
call ninja -C out.gn/win_64/debug
rem v8_use_snapshot=true v8_use_external_startup_data=true
\ No newline at end of file
......@@ -6,7 +6,7 @@ INCLUDEPATH += \
$$CORE_V8_PATH_INCLUDE/include
core_windows {
#CORE_V8_PATH_LIBS = $$CORE_V8_PATH_INCLUDE/out.gn/$$CORE_BUILDS_PLATFORM_PREFIX_$$CORE_BUILDS_CONFIGURATION_PREFIX/obj
CORE_V8_PATH_LIBS = $$CORE_V8_PATH_INCLUDE/out.gn/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/obj
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_snapshot -lv8_libsampler
LIBS += -L$$CORE_V8_PATH_LIBS/third_party/icu -licui18n -licuuc
......
......@@ -1036,6 +1036,110 @@ public:
#define LOGGER_SPEED_LAP(__logger_param)
#endif
//////////////////////////////////////////////////////////////////////////////
#if 0
class CSnapshotScript
{
public:
bool m_bIsExist;
v8::StartupData m_oStartupData;
CSnapshotScript(const std::wstring& sDir = L"")
{
m_bIsExist = false;
m_oStartupData.data = NULL;
m_oStartupData.raw_size = 0;
std::wstring sFile = sDir + L"/heap_snapshot.bin";
if (NSFile::CFileBinary::Exists(sFile))
{
m_bIsExist = true;
NSFile::CFileBinary oFile;
oFile.OpenFile(sFile);
m_oStartupData.raw_size = (int)oFile.GetFileSize();
m_oStartupData.data = new char[m_oStartupData.raw_size];
DWORD dwRead = 0;
oFile.ReadFile((BYTE*)m_oStartupData.data, (DWORD)m_oStartupData.raw_size, dwRead);
oFile.CloseFile();
}
}
bool Generate(const std::string& sScript)
{
m_oStartupData = {NULL, 0};
{
v8::SnapshotCreator snapshot_creator;
// Obtain an isolate provided by SnapshotCreator.
v8::Isolate* isolate = snapshot_creator.GetIsolate();
{
v8::HandleScope scope(isolate);
// Create a new context and optionally run some script.
v8::Local<v8::Context> context = v8::Context::New(isolate);
//v8::Context::Scope context_scope(context);
if (!RunExtraCode(isolate, context, sScript.c_str(), "<embedded>"))
return false;
// Add the possibly customized context to the SnapshotCreator.
snapshot_creator.SetDefaultContext(context);
}
// Use the SnapshotCreator to create the snapshot blob.
m_oStartupData = snapshot_creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
}
return true;
}
void Save(const std::wstring& sDir)
{
if (m_oStartupData.data == NULL)
return;
std::wstring sFile = sDir + L"/heap_snapshot.bin";
NSFile::CFileBinary oFile;
oFile.CreateFile(sFile);
oFile.WriteFile((BYTE*)m_oStartupData.data, (DWORD)m_oStartupData.raw_size);
oFile.CloseFile();
}
bool RunExtraCode(v8::Isolate* isolate, v8::Local<v8::Context> context, const char* utf8_source, const char* name)
{
// Run custom script if provided.
v8::TryCatch try_catch(isolate);
v8::Local<v8::String> source_string;
if (!v8::String::NewFromUtf8(isolate, utf8_source, v8::NewStringType::kNormal).ToLocal(&source_string))
return false;
v8::Local<v8::String> resource_name = v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kNormal).ToLocalChecked();
v8::ScriptOrigin origin(resource_name);
v8::ScriptCompiler::Source source(source_string, origin);
v8::Local<v8::Script> script;
bool bRet = v8::ScriptCompiler::Compile(context, &source).ToLocal(&script);
if (try_catch.HasCaught())
{
std::string strCode = to_cstringA(try_catch.Message()->GetSourceLine());
std::string strException = to_cstringA(try_catch.Message()->Get());
return false;
}
script->Run();
if (try_catch.HasCaught())
{
std::string strCode = to_cstringA(try_catch.Message()->GetSourceLine());
std::string strException = to_cstringA(try_catch.Message()->Get());
return false;
}
return true;
}
};
#endif
//////////////////////////////////////////////////////////////////////////////
class CV8Initializer
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment