| 547 | } |
| 548 | |
| 549 | Isolate* Runtime::PrepareV8Runtime(const string& filesPath, |
| 550 | const string& nativeLibDir, |
| 551 | const string& packageName, bool isDebuggable, |
| 552 | const string& callingDir, |
| 553 | const string& profilerOutputDir, |
| 554 | const int maxLogcatObjectSize, |
| 555 | const bool forceLog) { |
| 556 | tns::instrumentation::Frame frame("Runtime.PrepareV8Runtime"); |
| 557 | |
| 558 | Isolate::CreateParams create_params; |
| 559 | |
| 560 | create_params.array_buffer_allocator = &g_allocator; |
| 561 | |
| 562 | /* |
| 563 | * Setup the V8Platform only once per process - once for the application |
| 564 | * lifetime Don't execute again if main thread has already been initialized |
| 565 | */ |
| 566 | if (!s_mainThreadInitialized) { |
| 567 | InitializeV8(); |
| 568 | } |
| 569 | |
| 570 | tns::instrumentation::Frame isolateFrame; |
| 571 | auto isolate = Isolate::New(create_params); |
| 572 | // Capture start and realtime origin |
| 573 | // MonotonicallyIncreasingTime returns seconds as double; store for |
| 574 | // performance.now() |
| 575 | m_startTime = platform->MonotonicallyIncreasingTime(); |
| 576 | m_realtimeOrigin = platform->CurrentClockTimeMillis(); |
| 577 | isolateFrame.log("Isolate.New"); |
| 578 | |
| 579 | s_isolate2RuntimesCache[isolate] = this; |
| 580 | v8::Locker locker(isolate); |
| 581 | Isolate::Scope isolate_scope(isolate); |
| 582 | HandleScope handleScope(isolate); |
| 583 | |
| 584 | m_objectManager->SetInstanceIsolate(isolate); |
| 585 | |
| 586 | // Sets a structure with v8 String constants on the isolate object at slot 1 |
| 587 | auto consts = new V8StringConstants::PerIsolateV8Constants(isolate); |
| 588 | isolate->SetData((uint32_t)Runtime::IsolateData::RUNTIME, this); |
| 589 | isolate->SetData((uint32_t)Runtime::IsolateData::CONSTANTS, consts); |
| 590 | |
| 591 | V8::SetFlagsFromString(Constants::V8_STARTUP_FLAGS.c_str(), |
| 592 | Constants::V8_STARTUP_FLAGS.size()); |
| 593 | isolate->SetCaptureStackTraceForUncaughtExceptions(true, 100, |
| 594 | StackTrace::kOverview); |
| 595 | |
| 596 | // Set up import.meta callback |
| 597 | isolate->SetHostInitializeImportMetaObjectCallback( |
| 598 | InitializeImportMetaObject); |
| 599 | |
| 600 | // Enable dynamic import() support |
| 601 | isolate->SetHostImportModuleDynamicallyCallback( |
| 602 | ImportModuleDynamicallyCallback); |
| 603 | |
| 604 | isolate->AddMessageListener(NativeScriptException::OnUncaughtError); |
| 605 | |
| 606 | __android_log_print(ANDROID_LOG_DEBUG, "TNS.Runtime", "V8 version %s", |
nothing calls this directly
no test coverage detected