Skip to content

Commit 5ff9a2e

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Cleanup the loader code to remove some unused pieces.
Change-Id: I026b2b0dfb964c2dd67a9022260e4aba9c019e9c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125444 Commit-Queue: Siva Annamalai <asiva@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
1 parent b8dbaaa commit 5ff9a2e

File tree

6 files changed

+2
-268
lines changed

6 files changed

+2
-268
lines changed

runtime/bin/vmservice/loader.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,6 @@ const _Dart_kCanonicalizeUrl = 0; // Canonicalize the URL.
957957

958958
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
959959
const _Dart_kInitLoader = 4; // Initialize the loader.
960-
const _Dart_kResourceLoad = 5; // Resource class support.
961-
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
962960
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
963961
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
964962

@@ -1009,19 +1007,6 @@ _processLoadRequest(request) {
10091007
assert(isolateEmbedderData[isolateId] == loaderState);
10101008
}
10111009
break;
1012-
case _Dart_kResourceLoad:
1013-
{
1014-
Uri uri = Uri.parse(request[4]);
1015-
_handleResourceRequest(
1016-
loaderState, sp, traceLoading, tag, uri, uri, null);
1017-
}
1018-
break;
1019-
case _Dart_kGetPackageRootUri:
1020-
loaderState._triggerPackageResolution(() {
1021-
// The package root is deprecated and now always returns null.
1022-
sp.send(null);
1023-
});
1024-
break;
10251010
case _Dart_kGetPackageConfigUri:
10261011
loaderState._triggerPackageResolution(() {
10271012
// Respond with the packages config (if any) after package resolution.

runtime/vm/unit_test.cc

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,6 @@ void SetupCoreLibrariesForUnitTest() {
157157
RELEASE_ASSERT(!Dart_IsError(result));
158158
}
159159

160-
static const char* kPackageScheme = "package:";
161-
162-
static bool IsPackageSchemeURL(const char* url_name) {
163-
static const intptr_t kPackageSchemeLen = strlen(kPackageScheme);
164-
return (strncmp(url_name, kPackageScheme, kPackageSchemeLen) == 0);
165-
}
166-
167160
struct TestLibEntry {
168161
const char* url;
169162
const char* source;
@@ -212,13 +205,6 @@ static const char* IsolateReloadTestLibUri() {
212205
return "test:isolate_reload_helper";
213206
}
214207

215-
static bool IsIsolateReloadTestLib(const char* url_name) {
216-
static const intptr_t kIsolateReloadTestLibUriLen =
217-
strlen(IsolateReloadTestLibUri());
218-
return (strncmp(url_name, IsolateReloadTestLibUri(),
219-
kIsolateReloadTestLibUriLen) == 0);
220-
}
221-
222208
static void ReloadTest(Dart_NativeArguments native_args) {
223209
Dart_Handle result = TestCase::TriggerReload(/* kernel_buffer= */ NULL,
224210
/* kernel_buffer_size= */ 0);
@@ -241,15 +227,6 @@ static Dart_Handle LoadIsolateReloadTestLib() {
241227
}
242228
#endif // !PRODUCT
243229

244-
static Dart_Handle ResolvePackageUri(const char* uri_chars) {
245-
const int kNumArgs = 1;
246-
Dart_Handle dart_args[kNumArgs];
247-
dart_args[0] = DartUtils::NewString(uri_chars);
248-
return Dart_Invoke(DartUtils::LookupBuiltinLib(),
249-
DartUtils::NewString("_filePathFromUri"), kNumArgs,
250-
dart_args);
251-
}
252-
253230
char* TestCase::CompileTestScriptWithDFE(const char* url,
254231
const char* source,
255232
const uint8_t** kernel_buffer,
@@ -273,54 +250,6 @@ char* TestCase::CompileTestScriptWithDFE(const char* url,
273250
multiroot_filepaths, multiroot_scheme);
274251
}
275252

276-
#if 0
277-
278-
char* TestCase::CompileTestScriptWithDFE(const char* url,
279-
int sourcefiles_count,
280-
Dart_SourceFile sourcefiles[],
281-
void** kernel_pgm,
282-
bool incrementally,
283-
bool allow_compile_errors) {
284-
Zone* zone = Thread::Current()->zone();
285-
Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel(
286-
url, platform_strong_dill, platform_strong_dill_size,
287-
sourcefiles_count, sourcefiles, incrementally, NULL);
288-
return ValidateCompilationResult(zone, compilation_result, kernel_pgm);
289-
}
290-
291-
char* TestCase::ValidateCompilationResult(
292-
Zone* zone,
293-
Dart_KernelCompilationResult compilation_result,
294-
void** kernel_pgm,
295-
bool allow_compile_errors) {
296-
if (!allow_compile_errors &&
297-
(compilation_result.status != Dart_KernelCompilationStatus_Ok)) {
298-
char* result =
299-
OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
300-
free(compilation_result.error);
301-
return result;
302-
}
303-
304-
const uint8_t* kernel_file = compilation_result.kernel;
305-
intptr_t kernel_length = compilation_result.kernel_size;
306-
if (kernel_file == NULL) {
307-
return OS::SCreate(zone, "front end generated a NULL kernel file");
308-
}
309-
*kernel_pgm =
310-
Dart_ReadKernelBinary(kernel_file, kernel_length, ReleaseFetchedBytes);
311-
if (*kernel_pgm == NULL) {
312-
return OS::SCreate(zone, "Failed to read generated kernel binary");
313-
}
314-
if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
315-
char* result =
316-
OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
317-
free(compilation_result.error);
318-
return result;
319-
}
320-
return NULL;
321-
}
322-
#endif
323-
324253
char* TestCase::CompileTestScriptWithDFE(const char* url,
325254
int sourcefiles_count,
326255
Dart_SourceFile sourcefiles[],
@@ -377,70 +306,6 @@ static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
377306
}
378307
return Dart_DefaultCanonicalizeUrl(library_url, url);
379308
}
380-
if (!Dart_IsLibrary(library)) {
381-
return Dart_NewApiError("not a library");
382-
}
383-
if (!Dart_IsString(url)) {
384-
return Dart_NewApiError("url is not a string");
385-
}
386-
const char* url_chars = NULL;
387-
Dart_Handle result = Dart_StringToCString(url, &url_chars);
388-
if (Dart_IsError(result)) {
389-
return Dart_NewApiError("accessing url characters failed");
390-
}
391-
Dart_Handle library_url = Dart_LibraryUrl(library);
392-
const char* library_url_string = NULL;
393-
result = Dart_StringToCString(library_url, &library_url_string);
394-
if (Dart_IsError(result)) {
395-
return result;
396-
}
397-
398-
bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars);
399-
bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string);
400-
bool is_standalone_library = DartUtils::IsDartCLILibURL(library_url_string);
401-
if (is_dart_scheme_url) {
402-
ASSERT(tag == Dart_kImportTag);
403-
// Handle imports of other built-in libraries present in the SDK.
404-
if (DartUtils::IsDartIOLibURL(url_chars)) {
405-
return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
406-
} else if (DartUtils::IsDartBuiltinLibURL(url_chars)) {
407-
return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
408-
} else if (DartUtils::IsDartCLILibURL(url_chars)) {
409-
return Builtin::LoadAndCheckLibrary(Builtin::kCLILibrary);
410-
} else {
411-
return DartUtils::NewError("Do not know how to load '%s'", url_chars);
412-
}
413-
}
414-
const char* lib_source = TestCase::GetTestLib(url_chars);
415-
if (lib_source != NULL) {
416-
UNREACHABLE();
417-
}
418-
#if !defined(PRODUCT)
419-
if (IsIsolateReloadTestLib(url_chars)) {
420-
UNREACHABLE();
421-
return Dart_Null();
422-
}
423-
#endif
424-
if (is_io_library) {
425-
UNREACHABLE();
426-
return Dart_Null();
427-
}
428-
if (is_standalone_library) {
429-
UNREACHABLE();
430-
return Dart_Null();
431-
}
432-
Dart_Handle resolved_url = url;
433-
const char* resolved_url_chars = url_chars;
434-
if (IsPackageSchemeURL(url_chars)) {
435-
resolved_url = ResolvePackageUri(url_chars);
436-
EXPECT_VALID(resolved_url);
437-
if (Dart_IsError(Dart_StringToCString(resolved_url, &resolved_url_chars))) {
438-
return Dart_NewApiError("unable to convert resolved uri to string");
439-
}
440-
}
441-
// Do sync loading since unit_test doesn't support async.
442-
Dart_Handle source = DartUtils::ReadStringFromFile(resolved_url_chars);
443-
EXPECT_VALID(source);
444309
UNREACHABLE();
445310
return Dart_Null();
446311
}

sdk/lib/_internal/vm/bin/builtin.dart

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ int _isolateId;
4747
// Requests made to the service isolate over the load port.
4848

4949
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
50-
const _Dart_kResourceLoad = 5; // Resource class support.
51-
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
5250
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
5351
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
5452

@@ -254,66 +252,14 @@ Uri _resolvePackageUri(Uri uri) {
254252
return _packageRoot.resolve(uri.path);
255253
}
256254

257-
// Returns either a file path or a URI starting with http[s]:, as a String.
258-
String _filePathFromUri(String userUri) {
259-
var uri = Uri.parse(userUri);
260-
if (_traceLoading) {
261-
_log('Getting file path from: $uri');
262-
}
263-
264-
var path;
265-
switch (uri.scheme) {
266-
case '':
267-
case 'file':
268-
return uri.toFilePath();
269-
case 'package':
270-
return _filePathFromUri(_resolvePackageUri(uri).toString());
271-
case 'data':
272-
case 'http':
273-
case 'https':
274-
return uri.toString();
275-
default:
276-
// Only handling file, http, and package URIs
277-
// in standalone binary.
278-
if (_traceLoading) {
279-
_log('Unknown scheme (${uri.scheme}) in $uri.');
280-
}
281-
throw 'Not a known scheme: $uri';
282-
}
283-
}
284-
285255
// Register callbacks and hooks with the rest of the core libraries.
286256
@pragma("vm:entry-point")
287257
_setupHooks() {
288258
_setupCompleted = true;
289-
VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
290-
291-
VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
292259
VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
293260
VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
294261
}
295262

296-
// Handling of Resource class by dispatching to the load port.
297-
Future<List<int>> _resourceReadAsBytes(Uri uri) async {
298-
List response =
299-
await _makeLoaderRequest<List<int>>(_Dart_kResourceLoad, uri.toString());
300-
if (response[4] is String) {
301-
// Throw the error.
302-
throw response[4];
303-
} else {
304-
return response[4];
305-
}
306-
}
307-
308-
// TODO(mfairhurst): remove this
309-
Future<Uri> _getPackageRootFuture() {
310-
if (_traceLoading) {
311-
_log("Request for package root from user code.");
312-
}
313-
// Return null, as the `packages/` directory is not supported in dart 2.
314-
return new Future.value(null);
315-
}
316-
317263
Future<Uri> _getPackageConfigFuture() {
318264
if (_traceLoading) {
319265
_log("Request for package config from user code.");

sdk/lib/_internal/vm/lib/isolate_patch.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,7 @@ class Isolate {
327327

328328
@patch
329329
static Future<Uri> get packageRoot {
330-
var hook = VMLibraryHooks.packageRootUriFuture;
331-
if (hook == null) {
332-
throw new UnsupportedError("Isolate.packageRoot");
333-
}
334-
return hook();
330+
return null;
335331
}
336332

337333
@patch

sdk_nnbd/lib/_internal/vm/bin/builtin.dart

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ int _isolateId;
4747
// Requests made to the service isolate over the load port.
4848

4949
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
50-
const _Dart_kResourceLoad = 5; // Resource class support.
51-
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
5250
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
5351
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
5452

@@ -254,66 +252,14 @@ Uri _resolvePackageUri(Uri uri) {
254252
return _packageRoot.resolve(uri.path);
255253
}
256254

257-
// Returns either a file path or a URI starting with http[s]:, as a String.
258-
String _filePathFromUri(String userUri) {
259-
var uri = Uri.parse(userUri);
260-
if (_traceLoading) {
261-
_log('Getting file path from: $uri');
262-
}
263-
264-
var path;
265-
switch (uri.scheme) {
266-
case '':
267-
case 'file':
268-
return uri.toFilePath();
269-
case 'package':
270-
return _filePathFromUri(_resolvePackageUri(uri).toString());
271-
case 'data':
272-
case 'http':
273-
case 'https':
274-
return uri.toString();
275-
default:
276-
// Only handling file, http, and package URIs
277-
// in standalone binary.
278-
if (_traceLoading) {
279-
_log('Unknown scheme (${uri.scheme}) in $uri.');
280-
}
281-
throw 'Not a known scheme: $uri';
282-
}
283-
}
284-
285255
// Register callbacks and hooks with the rest of the core libraries.
286256
@pragma("vm:entry-point")
287257
_setupHooks() {
288258
_setupCompleted = true;
289-
VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
290-
291-
VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
292259
VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
293260
VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
294261
}
295262

296-
// Handling of Resource class by dispatching to the load port.
297-
Future<List<int>> _resourceReadAsBytes(Uri uri) async {
298-
List response =
299-
await _makeLoaderRequest<List<int>>(_Dart_kResourceLoad, uri.toString());
300-
if (response[4] is String) {
301-
// Throw the error.
302-
throw response[4];
303-
} else {
304-
return response[4];
305-
}
306-
}
307-
308-
// TODO(mfairhurst): remove this
309-
Future<Uri> _getPackageRootFuture() {
310-
if (_traceLoading) {
311-
_log("Request for package root from user code.");
312-
}
313-
// Return null, as the `packages/` directory is not supported in dart 2.
314-
return new Future.value(null);
315-
}
316-
317263
Future<Uri> _getPackageConfigFuture() {
318264
if (_traceLoading) {
319265
_log("Request for package config from user code.");

sdk_nnbd/lib/_internal/vm/lib/isolate_patch.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,7 @@ class Isolate {
327327

328328
@patch
329329
static Future<Uri> get packageRoot {
330-
var hook = VMLibraryHooks.packageRootUriFuture;
331-
if (hook == null) {
332-
throw new UnsupportedError("Isolate.packageRoot");
333-
}
334-
return hook();
330+
return null;
335331
}
336332

337333
@patch

0 commit comments

Comments
 (0)