Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6883948

Browse files
committed
Revert runtime changes:
1 parent 6cc1a5d commit 6883948

10 files changed

+85
-338
lines changed

runtime/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ group("libdart") {
3737

3838
source_set("runtime") {
3939
sources = [
40-
"dart_deferred_load_handler.cc",
41-
"dart_deferred_load_handler.h",
4240
"dart_isolate.cc",
4341
"dart_isolate.h",
4442
"dart_isolate_group_data.cc",

runtime/dart_deferred_load_handler.cc

Lines changed: 0 additions & 38 deletions
This file was deleted.

runtime/dart_deferred_load_handler.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

runtime/dart_isolate.cc

Lines changed: 18 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
#include "flutter/runtime/dart_isolate.h"
6-
#include "flutter/runtime/dart_deferred_load_handler.h"
76

87
#include <cstdlib>
98
#include <tuple>
@@ -87,7 +86,6 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRunningRootIsolate(
8786
std::string advisory_script_uri,
8887
std::string advisory_script_entrypoint,
8988
Flags isolate_flags,
90-
Dart_DeferredLoadHandler& deferred_load_handler,
9189
const fml::closure& isolate_create_callback,
9290
const fml::closure& isolate_shutdown_callback,
9391
std::optional<std::string> dart_entrypoint,
@@ -118,7 +116,6 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRunningRootIsolate(
118116
advisory_script_uri, //
119117
advisory_script_entrypoint, //
120118
isolate_flags, //
121-
deferred_load_handler, //
122119
isolate_create_callback, //
123120
isolate_shutdown_callback //
124121
)
@@ -152,8 +149,8 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRunningRootIsolate(
152149
}
153150

154151
if (settings.root_isolate_create_callback) {
155-
// Isolate callbacks always occur in isolate scope and before user code
156-
// has had a chance to run.
152+
// Isolate callbacks always occur in isolate scope and before user code has
153+
// had a chance to run.
157154
tonic::DartState::Scope scope(isolate.get());
158155
settings.root_isolate_create_callback(*isolate.get());
159156
}
@@ -189,7 +186,6 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRootIsolate(
189186
std::string advisory_script_uri,
190187
std::string advisory_script_entrypoint,
191188
Flags flags,
192-
Dart_DeferredLoadHandler& deferred_load_handler,
193189
const fml::closure& isolate_create_callback,
194190
const fml::closure& isolate_shutdown_callback) {
195191
TRACE_EVENT0("flutter", "DartIsolate::CreateRootIsolate");
@@ -226,7 +222,7 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRootIsolate(
226222
auto isolate_flags = flags.Get();
227223
Dart_Isolate vm_isolate = CreateDartIsolateGroup(
228224
std::move(isolate_group_data), std::move(isolate_data), &isolate_flags,
229-
deferred_load_handler, error.error());
225+
error.error());
230226

231227
if (error) {
232228
FML_LOG(ERROR) << "CreateDartIsolateGroup failed: " << error.str();
@@ -292,8 +288,7 @@ std::string DartIsolate::GetServiceId() {
292288
return service_id;
293289
}
294290

295-
bool DartIsolate::Initialize(Dart_Isolate dart_isolate,
296-
Dart_DeferredLoadHandler& deferred_load_handler) {
291+
bool DartIsolate::Initialize(Dart_Isolate dart_isolate) {
297292
TRACE_EVENT0("flutter", "DartIsolate::Initialize");
298293
if (phase_ != Phase::Uninitialized) {
299294
return false;
@@ -325,9 +320,6 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate,
325320
return false;
326321
}
327322

328-
// Dart_SetDeferredLoadHandler(&DartDeferredLoadHandler);
329-
Dart_SetDeferredLoadHandler(deferred_load_handler);
330-
331323
if (!UpdateThreadPoolNames()) {
332324
return false;
333325
}
@@ -340,33 +332,6 @@ fml::RefPtr<fml::TaskRunner> DartIsolate::GetMessageHandlingTaskRunner() const {
340332
return message_handling_task_runner_;
341333
}
342334

343-
bool DartIsolate::LoadLoadingUnit(intptr_t loading_unit_id,
344-
const uint8_t* snapshot_data,
345-
const uint8_t* snapshot_instructions) {
346-
tonic::DartState::Scope scope(this);
347-
Dart_Handle result = Dart_DeferredLoadComplete(loading_unit_id, snapshot_data,
348-
snapshot_instructions);
349-
if (Dart_IsApiError(result)) {
350-
FML_LOG(ERROR) << "LOADING FAILED " << loading_unit_id;
351-
result =
352-
Dart_DeferredLoadCompleteError(loading_unit_id, Dart_GetError(result),
353-
/*transient*/ true);
354-
return false;
355-
}
356-
return true;
357-
}
358-
359-
void DartIsolate::LoadLoadingUnitFailure(intptr_t loading_unit_id,
360-
const std::string error_message,
361-
bool transient) {
362-
tonic::DartState::Scope scope(this);
363-
Dart_Handle result = Dart_DeferredLoadCompleteError(
364-
loading_unit_id, error_message.c_str(), transient);
365-
if (Dart_IsApiError(result)) {
366-
FML_LOG(ERROR) << "Dart error: " << Dart_GetError(result);
367-
}
368-
}
369-
370335
void DartIsolate::SetMessageHandlingTaskRunner(
371336
fml::RefPtr<fml::TaskRunner> runner) {
372337
if (!IsRootIsolate() || !runner) {
@@ -684,8 +649,8 @@ bool DartIsolate::RunFromLibrary(std::optional<std::string> library_name,
684649
bool DartIsolate::Shutdown() {
685650
TRACE_EVENT0("flutter", "DartIsolate::Shutdown");
686651
// This call may be re-entrant since Dart_ShutdownIsolate can invoke the
687-
// cleanup callback which deletes the embedder side object of the dart
688-
// isolate (a.k.a. this).
652+
// cleanup callback which deletes the embedder side object of the dart isolate
653+
// (a.k.a. this).
689654
if (phase_ == Phase::Shutdown) {
690655
return false;
691656
}
@@ -751,9 +716,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
751716
DART_VM_SERVICE_ISOLATE_NAME, // script uri
752717
DART_VM_SERVICE_ISOLATE_NAME, // script entrypoint
753718
DartIsolate::Flags{flags}, // flags
754-
DartDeferredLoadHandler::empty_dart_deferred_load_handler,
755-
nullptr, // isolate create callback
756-
nullptr // isolate shutdown callback
719+
nullptr, // isolate create callback
720+
nullptr // isolate shutdown callback
757721
);
758722

759723
std::shared_ptr<DartIsolate> service_isolate = weak_service_isolate.lock();
@@ -816,9 +780,8 @@ Dart_Isolate DartIsolate::DartIsolateGroupCreateCallback(
816780
// The VM attempts to start the VM service for us on |Dart_Initialize|. In
817781
// such a case, the callback data will be null and the script URI will be
818782
// DART_VM_SERVICE_ISOLATE_NAME. In such cases, we just create the service
819-
// isolate like normal but dont hold a reference to it at all. We also
820-
// start this isolate since we will never again reference it from the
821-
// engine.
783+
// isolate like normal but dont hold a reference to it at all. We also start
784+
// this isolate since we will never again reference it from the engine.
822785
return DartCreateAndStartServiceIsolate(package_root, //
823786
package_config, //
824787
flags, //
@@ -863,8 +826,7 @@ Dart_Isolate DartIsolate::DartIsolateGroupCreateCallback(
863826
false))); // is_root_isolate
864827

865828
Dart_Isolate vm_isolate = CreateDartIsolateGroup(
866-
std::move(isolate_group_data), std::move(isolate_data), flags,
867-
DartDeferredLoadHandler::empty_dart_deferred_load_handler, error);
829+
std::move(isolate_group_data), std::move(isolate_data), flags, error);
868830

869831
if (*error) {
870832
FML_LOG(ERROR) << "CreateDartIsolateGroup failed: " << error;
@@ -909,9 +871,7 @@ bool DartIsolate::DartIsolateInitializeCallback(void** child_callback_data,
909871
false))); // is_root_isolate
910872

911873
// root isolate should have been created via CreateRootIsolate
912-
if (!InitializeIsolate(
913-
*embedder_isolate, isolate,
914-
DartDeferredLoadHandler::empty_dart_deferred_load_handler, error)) {
874+
if (!InitializeIsolate(*embedder_isolate, isolate, error)) {
915875
return false;
916876
}
917877

@@ -927,7 +887,6 @@ Dart_Isolate DartIsolate::CreateDartIsolateGroup(
927887
std::unique_ptr<std::shared_ptr<DartIsolateGroupData>> isolate_group_data,
928888
std::unique_ptr<std::shared_ptr<DartIsolate>> isolate_data,
929889
Dart_IsolateFlags* flags,
930-
Dart_DeferredLoadHandler& deferred_load_handler,
931890
char** error) {
932891
TRACE_EVENT0("flutter", "DartIsolate::CreateDartIsolateGroup");
933892

@@ -943,14 +902,12 @@ Dart_Isolate DartIsolate::CreateDartIsolateGroup(
943902
return nullptr;
944903
}
945904

946-
// Ownership of the isolate data objects has been transferred to the Dart
947-
// VM.
905+
// Ownership of the isolate data objects has been transferred to the Dart VM.
948906
std::shared_ptr<DartIsolate> embedder_isolate(*isolate_data);
949907
isolate_group_data.release();
950908
isolate_data.release();
951909

952-
if (!InitializeIsolate(std::move(embedder_isolate), isolate,
953-
deferred_load_handler, error)) {
910+
if (!InitializeIsolate(std::move(embedder_isolate), isolate, error)) {
954911
return nullptr;
955912
}
956913

@@ -960,10 +917,9 @@ Dart_Isolate DartIsolate::CreateDartIsolateGroup(
960917
bool DartIsolate::InitializeIsolate(
961918
std::shared_ptr<DartIsolate> embedder_isolate,
962919
Dart_Isolate isolate,
963-
Dart_DeferredLoadHandler& deferred_load_handler,
964920
char** error) {
965921
TRACE_EVENT0("flutter", "DartIsolate::InitializeIsolate");
966-
if (!embedder_isolate->Initialize(isolate, deferred_load_handler)) {
922+
if (!embedder_isolate->Initialize(isolate)) {
967923
*error = fml::strdup("Embedder could not initialize the Dart isolate.");
968924
FML_DLOG(ERROR) << *error;
969925
return false;
@@ -976,9 +932,9 @@ bool DartIsolate::InitializeIsolate(
976932
return false;
977933
}
978934

979-
// Root isolates will be setup by the engine and the service isolate (which
980-
// is also a root isolate) by the utility routines in the VM. However,
981-
// secondary isolates will be run by the VM if they are marked as runnable.
935+
// Root isolates will be setup by the engine and the service isolate (which is
936+
// also a root isolate) by the utility routines in the VM. However, secondary
937+
// isolates will be run by the VM if they are marked as runnable.
982938
if (!embedder_isolate->IsRootIsolate()) {
983939
auto child_isolate_preparer =
984940
embedder_isolate->GetIsolateGroupData().GetChildIsolatePreparer();

runtime/dart_isolate.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ class DartIsolate : public UIDartState {
225225
std::string advisory_script_uri,
226226
std::string advisory_script_entrypoint,
227227
Flags flags,
228-
Dart_DeferredLoadHandler& deferred_load_handler,
229228
const fml::closure& isolate_create_callback,
230229
const fml::closure& isolate_shutdown_callback,
231230
std::optional<std::string> dart_entrypoint,
@@ -385,14 +384,6 @@ class DartIsolate : public UIDartState {
385384
///
386385
fml::RefPtr<fml::TaskRunner> GetMessageHandlingTaskRunner() const;
387386

388-
bool LoadLoadingUnit(intptr_t loading_unit_id,
389-
const uint8_t* snapshot_data,
390-
const uint8_t* snapshot_instructions);
391-
392-
void LoadLoadingUnitFailure(intptr_t loading_unit_id,
393-
const std::string error_message,
394-
bool transient);
395-
396387
private:
397388
friend class IsolateConfiguration;
398389
class AutoFireClosure {
@@ -427,7 +418,6 @@ class DartIsolate : public UIDartState {
427418
std::string advisory_script_uri,
428419
std::string advisory_script_entrypoint,
429420
Flags flags,
430-
Dart_DeferredLoadHandler& deferred_load_handler,
431421
const fml::closure& isolate_create_callback,
432422
const fml::closure& isolate_shutdown_callback);
433423

@@ -442,9 +432,7 @@ class DartIsolate : public UIDartState {
442432
std::string advisory_script_entrypoint,
443433
bool is_root_isolate);
444434

445-
[[nodiscard]] bool Initialize(
446-
Dart_Isolate isolate,
447-
Dart_DeferredLoadHandler& deferred_load_handler);
435+
[[nodiscard]] bool Initialize(Dart_Isolate isolate);
448436

449437
void SetMessageHandlingTaskRunner(fml::RefPtr<fml::TaskRunner> runner);
450438

@@ -484,12 +472,10 @@ class DartIsolate : public UIDartState {
484472
std::unique_ptr<std::shared_ptr<DartIsolateGroupData>> isolate_group_data,
485473
std::unique_ptr<std::shared_ptr<DartIsolate>> isolate_data,
486474
Dart_IsolateFlags* flags,
487-
Dart_DeferredLoadHandler& deferred_load_handler,
488475
char** error);
489476

490477
static bool InitializeIsolate(std::shared_ptr<DartIsolate> embedder_isolate,
491478
Dart_Isolate isolate,
492-
Dart_DeferredLoadHandler& deferred_load_handler,
493479
char** error);
494480

495481
// |Dart_IsolateShutdownCallback|

0 commit comments

Comments
 (0)