@@ -36,8 +36,9 @@ const uint16_t HERMES_SAMPLING_FREQUENCY_HZ = 10000;
3636class HermesRuntimeSamplingProfileDelegate {
3737 public:
3838 explicit HermesRuntimeSamplingProfileDelegate (
39- std::shared_ptr<HermesRuntime> hermesRuntime)
40- : hermesRuntime_(std::move(hermesRuntime)) {}
39+ std::shared_ptr<jsi::Runtime> runtime,
40+ hermes::HermesRuntime& hermesRuntime)
41+ : runtime_(std::move(runtime)), hermesRuntime_(hermesRuntime) {}
4142
4243 void startSampling () {
4344 auto * hermesAPI = jsi::castInterface<IHermesRootAPI>(makeHermesRootAPI ());
@@ -52,11 +53,12 @@ class HermesRuntimeSamplingProfileDelegate {
5253 tracing::RuntimeSamplingProfile collectSamplingProfile () {
5354 return tracing::HermesRuntimeSamplingProfileSerializer::
5455 serializeToTracingSamplingProfile (
55- hermesRuntime_-> dumpSampledTraceToProfile ());
56+ hermesRuntime_. dumpSampledTraceToProfile ());
5657 }
5758
5859 private:
59- std::shared_ptr<HermesRuntime> hermesRuntime_;
60+ std::shared_ptr<jsi::Runtime> runtime_;
61+ HermesRuntime& hermesRuntime_;
6062};
6163
6264} // namespace
@@ -93,13 +95,16 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
9395 public:
9496 explicit Impl (
9597 HermesRuntimeTargetDelegate& delegate,
96- std::shared_ptr<HermesRuntime> hermesRuntime)
98+ std::shared_ptr<jsi::Runtime> runtime,
99+ HermesRuntime& hermesRuntime)
97100 : delegate_(delegate),
98- runtime_(hermesRuntime),
99- cdpDebugAPI_(CDPDebugAPI::create(*runtime_)),
101+ runtime_(runtime),
102+ hermesRuntime_(hermesRuntime),
103+ cdpDebugAPI_(CDPDebugAPI::create(hermesRuntime_)),
100104 samplingProfileDelegate_(
101105 std::make_unique<HermesRuntimeSamplingProfileDelegate>(
102- std::move (hermesRuntime))) {}
106+ std::move (runtime),
107+ hermesRuntime_)) {}
103108
104109 CDPDebugAPI& getCDPDebugAPI () {
105110 return *cdpDebugAPI_;
@@ -119,7 +124,7 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
119124 sessionState,
120125 std::move (previouslyExportedState),
121126 executionContextDescription,
122- *runtime_ ,
127+ hermesRuntime_ ,
123128 delegate_,
124129 std::move (runtimeExecutor)));
125130 }
@@ -209,7 +214,7 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
209214 // properly representing the stack trace in other use cases, where native
210215 // frames aren't stripped on serialisation.
211216 return std::make_unique<HermesStackTraceWrapper>(
212- runtime_-> getDebugger ().captureStackTrace ());
217+ hermesRuntime_. getDebugger ().captureStackTrace ());
213218 }
214219
215220 void enableSamplingProfiler () override {
@@ -267,7 +272,8 @@ class HermesRuntimeTargetDelegate::Impl final : public RuntimeTargetDelegate {
267272
268273 private:
269274 HermesRuntimeTargetDelegate& delegate_;
270- std::shared_ptr<HermesRuntime> runtime_;
275+ std::shared_ptr<jsi::Runtime> runtime_;
276+ HermesRuntime& hermesRuntime_;
271277 const std::unique_ptr<CDPDebugAPI> cdpDebugAPI_;
272278 std::unique_ptr<HermesRuntimeSamplingProfileDelegate>
273279 samplingProfileDelegate_;
@@ -284,11 +290,13 @@ class HermesRuntimeTargetDelegate::Impl final
284290 public:
285291 explicit Impl (
286292 HermesRuntimeTargetDelegate&,
287- std::shared_ptr<HermesRuntime> hermesRuntime)
288- : FallbackRuntimeTargetDelegate{hermesRuntime->description ()},
293+ std::shared_ptr<jsi::Runtime> runtime,
294+ HermesRuntime& hermesRuntime)
295+ : FallbackRuntimeTargetDelegate{hermesRuntime.description ()},
289296 samplingProfileDelegate_ (
290297 std::make_unique<HermesRuntimeSamplingProfileDelegate>(
291- std::move (hermesRuntime))) {}
298+ std::move (runtime),
299+ hermesRuntime)) {}
292300
293301 void enableSamplingProfiler () override {
294302 samplingProfileDelegate_->startSampling ();
@@ -310,8 +318,9 @@ class HermesRuntimeTargetDelegate::Impl final
310318#endif // HERMES_ENABLE_DEBUGGER
311319
312320HermesRuntimeTargetDelegate::HermesRuntimeTargetDelegate (
313- std::shared_ptr<HermesRuntime> hermesRuntime)
314- : impl_(std::make_unique<Impl>(*this , std::move(hermesRuntime))) {}
321+ std::shared_ptr<jsi::Runtime> runtime,
322+ HermesRuntime& hermesRuntime)
323+ : impl_(std::make_unique<Impl>(*this , std::move(runtime), hermesRuntime)) {}
315324
316325HermesRuntimeTargetDelegate::~HermesRuntimeTargetDelegate () = default ;
317326
0 commit comments