|
17 | 17 | #include "JsDebugger.h" |
18 | 18 | #include "SimpleProfiler.h" |
19 | 19 | #include "SimpleAllocator.h" |
20 | | -#include "File.h" |
21 | 20 | #include "JType.h" |
22 | 21 | #include "Module.h" |
23 | 22 | #include "NativeScriptException.h" |
@@ -59,7 +58,6 @@ Runtime::Runtime(JNIEnv *env, jobject runtime, int id) |
59 | 58 | { |
60 | 59 | m_runtime = m_env.NewGlobalRef(runtime); |
61 | 60 | m_objectManager = new ObjectManager(m_runtime); |
62 | | - m_startupData = nullptr; |
63 | 61 | s_id2RuntimeCache.insert(make_pair(id, this)); |
64 | 62 | } |
65 | 63 |
|
@@ -340,10 +338,8 @@ void Runtime::PassUncaughtExceptionToJsNative(JNIEnv *env, jobject obj, jthrowab |
340 | 338 | } |
341 | 339 |
|
342 | 340 | void Runtime::ClearStartupData(JNIEnv *env, jobject obj) { |
343 | | - if (m_startupData) { |
344 | | - delete m_startupData->data; |
345 | | - delete m_startupData; |
346 | | - } |
| 341 | + delete m_heapSnapshotBlob; |
| 342 | + delete m_startupData; |
347 | 343 | } |
348 | 344 |
|
349 | 345 | static void InitializeV8() { |
@@ -380,11 +376,11 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, jstring packageName, |
380 | 376 |
|
381 | 377 | if (File::Exists(snapshotPath)) |
382 | 378 | { |
383 | | - int length; |
384 | | - m_startupData->data = reinterpret_cast<char*>(File::ReadBinary(snapshotPath, length)); |
385 | | - m_startupData->raw_size = length; |
| 379 | + m_heapSnapshotBlob = new MemoryMappedFile(MemoryMappedFile::Open(snapshotPath.c_str())); |
| 380 | + m_startupData->data = static_cast<const char*>(m_heapSnapshotBlob->memory); |
| 381 | + m_startupData->raw_size = m_heapSnapshotBlob->size; |
386 | 382 |
|
387 | | - DEBUG_WRITE_FORCE("Snapshot read %s (%dB).", snapshotPath.c_str(), length); |
| 383 | + DEBUG_WRITE_FORCE("Snapshot read %s (%dB).", snapshotPath.c_str(), m_heapSnapshotBlob->size); |
388 | 384 | } |
389 | 385 | else if(saveSnapshot) |
390 | 386 | { |
|
0 commit comments