@@ -28,7 +28,6 @@ extern DFE dfe;
2828// Keep in sync with loader.dart.
2929static const intptr_t _Dart_kInitLoader = 4 ;
3030static const intptr_t _Dart_kImportExtension = 9 ;
31- static const intptr_t _Dart_kResolveAsFilePath = 10 ;
3231
3332Loader::Loader (IsolateData* isolate_data)
3433 : port_(ILLEGAL_PORT),
@@ -259,46 +258,6 @@ static bool PathContainsSeparator(const char* path) {
259258 (strstr (path, File::PathSeparator ()) != NULL ));
260259}
261260
262- void Loader::AddDependencyLocked (Loader* loader, const char * resolved_uri) {
263- MallocGrowableArray<char *>* dependencies =
264- loader->isolate_group_data ()->dependencies ();
265- if (dependencies == NULL ) {
266- return ;
267- }
268- dependencies->Add (strdup (resolved_uri));
269- }
270-
271- void Loader::ResolveDependenciesAsFilePaths () {
272- IsolateGroupData* isolate_group_data =
273- reinterpret_cast <IsolateGroupData*>(Dart_CurrentIsolateGroupData ());
274- ASSERT (isolate_group_data != NULL );
275- MallocGrowableArray<char *>* dependencies = isolate_group_data->dependencies ();
276- if (dependencies == NULL ) {
277- return ;
278- }
279-
280- for (intptr_t i = 0 ; i < dependencies->length (); i++) {
281- char * resolved_uri = (*dependencies)[i];
282-
283- uint8_t * file_path = NULL ;
284- intptr_t file_path_length = -1 ;
285- Dart_Handle uri = Dart_NewStringFromCString (resolved_uri);
286- ASSERT (!Dart_IsError (uri));
287- Dart_Handle result =
288- Loader::ResolveAsFilePath (uri, &file_path, &file_path_length);
289- if (Dart_IsError (result)) {
290- Syslog::Print (" Error resolving dependency: %s\n " , Dart_GetError (result));
291- return ;
292- }
293-
294- // Convert buffer buffer to NUL-terminated string.
295- (*dependencies)[i] = Utils::StrNDup (
296- reinterpret_cast <const char *>(file_path), file_path_length);
297- free (file_path);
298- free (resolved_uri);
299- }
300- }
301-
302261class ScopedDecompress : public ValueObject {
303262 public:
304263 ScopedDecompress (const uint8_t ** payload, intptr_t * payload_length)
@@ -343,17 +302,14 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
343302 Dart_NewStringFromCString (reinterpret_cast <char *>(result->library_uri ));
344303 }
345304
346- AddDependencyLocked (loader, result->resolved_uri );
347-
348305 // A negative result tag indicates a loading error occurred in the service
349306 // isolate. The payload is a C string of the error message.
350307 if (result->tag < 0 ) {
351308 Dart_Handle library = Dart_LookupLibrary (uri);
352309 Dart_Handle error =
353310 Dart_NewStringFromUTF8 (result->payload , result->payload_length );
354311 // If a library with the given uri exists, give it a chance to handle
355- // the error. If the load requests stems from a deferred library load,
356- // an IO error is not fatal.
312+ // the error.
357313 if (LibraryHandleError (library, error)) {
358314 return true ;
359315 }
@@ -421,23 +377,6 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
421377 return false ;
422378}
423379
424- bool Loader::ProcessPayloadResultLocked (Loader* loader,
425- Loader::IOResult* result) {
426- // A negative result tag indicates a loading error occurred in the service
427- // isolate. The payload is a C string of the error message.
428- if (result->tag < 0 ) {
429- Dart_Handle error =
430- Dart_NewStringFromUTF8 (result->payload , result->payload_length );
431- loader->error_ = Dart_NewUnhandledExceptionError (error);
432- return false ;
433- }
434- loader->payload_length_ = result->payload_length ;
435- loader->payload_ =
436- reinterpret_cast <uint8_t *>(::malloc (loader->payload_length_ ));
437- memmove (loader->payload_ , result->payload , loader->payload_length_ );
438- return true ;
439- }
440-
441380bool Loader::ProcessQueueLocked (ProcessResult process_result) {
442381 bool hit_error = false ;
443382 for (intptr_t i = 0 ; i < results_length (); i++) {
@@ -510,53 +449,6 @@ Dart_Handle Loader::ReloadNativeExtensions() {
510449 return Dart_True ();
511450}
512451
513- Dart_Handle Loader::SendAndProcessReply (intptr_t tag,
514- Dart_Handle url,
515- uint8_t ** payload,
516- intptr_t * payload_length) {
517- auto isolate_data = reinterpret_cast <IsolateData*>(Dart_CurrentIsolateData ());
518- ASSERT (isolate_data != NULL );
519- ASSERT (!isolate_data->HasLoader ());
520- Loader* loader = NULL ;
521-
522- // Setup the loader. The constructor does a bunch of leg work.
523- loader = new Loader (isolate_data);
524- loader->Init (isolate_data->isolate_group_data ()->package_root ,
525- isolate_data->packages_file (),
526- DartUtils::original_working_directory, NULL );
527- ASSERT (loader != NULL );
528- ASSERT (isolate_data->HasLoader ());
529-
530- // Now send a load request to the service isolate.
531- loader->SendRequest (tag, url, Dart_Null ());
532-
533- // Wait for a reply to the load request.
534- loader->BlockUntilComplete (ProcessPayloadResultLocked);
535-
536- // Copy fields from the loader before deleting it.
537- // The payload array itself which was malloced above is freed by
538- // the caller of LoadUrlContents.
539- Dart_Handle error = loader->error ();
540- *payload = loader->payload_ ;
541- *payload_length = loader->payload_length_ ;
542-
543- // Destroy the loader. The destructor does a bunch of leg work.
544- delete loader;
545-
546- // An error occurred during loading.
547- if (!Dart_IsNull (error)) {
548- return error;
549- }
550- return Dart_Null ();
551- }
552-
553- Dart_Handle Loader::ResolveAsFilePath (Dart_Handle url,
554- uint8_t ** payload,
555- intptr_t * payload_length) {
556- return SendAndProcessReply (_Dart_kResolveAsFilePath, url, payload,
557- payload_length);
558- }
559-
560452IsolateGroupData* Loader::isolate_group_data () {
561453 return isolate_data_->isolate_group_data ();
562454}
@@ -662,13 +554,6 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
662554 // Grab this isolate's loader.
663555 Loader* loader = NULL ;
664556
665- // The outer invocation of the tag handler for this isolate. We make the outer
666- // invocation block and allow any nested invocations to operate in parallel.
667- const bool blocking_call = !isolate_data->HasLoader ();
668-
669- // If we are the outer invocation of the tag handler and the tag is an import
670- // this means that we are starting a deferred library load.
671- const bool is_deferred_import = blocking_call && (tag == Dart_kImportTag);
672557 if (!isolate_data->HasLoader ()) {
673558 // The isolate doesn't have a loader -- this is the outer invocation which
674559 // will block.
@@ -717,42 +602,25 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
717602 }
718603 }
719604
720- if (blocking_call) {
721- // The outer invocation of the tag handler will block here until all nested
722- // invocations complete.
723- loader->BlockUntilComplete (ProcessResultLocked);
724-
725- // Remember the error (if any).
726- Dart_Handle error = loader->error ();
727- // Destroy the loader. The destructor does a bunch of leg work.
728- delete loader;
729-
730- // An error occurred during loading.
731- if (!Dart_IsNull (error)) {
732- if (false && is_deferred_import) {
733- // This blocks handles transitive load errors caused by a deferred
734- // import. Non-transitive load errors are handled above (see callers of
735- // |LibraryHandleError|). To handle the transitive case, we give the
736- // originating deferred library an opportunity to handle it.
737- Dart_Handle deferred_library = Dart_LookupLibrary (url);
738- if (!LibraryHandleError (deferred_library, error)) {
739- // Library did not handle it, return to caller as an unhandled
740- // exception.
741- return Dart_NewUnhandledExceptionError (error);
742- }
743- } else {
744- // We got an error during loading but we aren't loading a deferred
745- // library, return the error to the caller.
746- return error;
747- }
748- }
605+ // The outer invocation of the tag handler will block here until all nested
606+ // invocations complete.
607+ loader->BlockUntilComplete (ProcessResultLocked);
749608
750- // Finalize loading. This will complete any futures for completed deferred
751- // loads.
752- error = Dart_FinalizeLoading (true );
753- if (Dart_IsError (error)) {
754- return error;
755- }
609+ // Remember the error (if any).
610+ Dart_Handle error = loader->error ();
611+ // Destroy the loader. The destructor does a bunch of leg work.
612+ delete loader;
613+
614+ // An error occurred during loading.
615+ if (!Dart_IsNull (error)) {
616+ // We got an error during loading, return the error to the caller.
617+ return error;
618+ }
619+
620+ // Finalize loading.
621+ error = Dart_FinalizeLoading (true );
622+ if (Dart_IsError (error)) {
623+ return error;
756624 }
757625 return Dart_Null ();
758626}
0 commit comments