Re-land "[vm/kernel/aot] Exclude vmservice_io from "product" AOT snapshots."
This reverts commit 17585c42fee27c135381d808810a0c9a02f1030a.
The original revision is in Patchset 1.
Fixed Tests:
python tools/test.py -m debug -c dartkp -r dart_precompiled --strong standalone_2/no_support_service_test
python tools/test.py -m product -c precompiler -r dart_precompiled lib_2/isolate/function_send1_test
Change-Id: I6af715ee3c080b515c8312357f3d8be6e494747a
Reviewed-on: https://dart-review.googlesource.com/59760
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
diff --git a/pkg/vm/bin/gen_kernel.dart b/pkg/vm/bin/gen_kernel.dart
index 151be0e..7d91811 100644
--- a/pkg/vm/bin/gen_kernel.dart
+++ b/pkg/vm/bin/gen_kernel.dart
@@ -15,7 +15,7 @@
show globalDebuggingNames, NameSystem;
import 'package:vm/bytecode/gen_bytecode.dart' show isKernelBytecodeEnabled;
import 'package:vm/kernel_front_end.dart'
- show compileToKernel, ErrorDetector, ErrorPrinter;
+ show compileToKernel, ErrorDetector, ErrorPrinter, parseCommandLineDefines;
final ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
..addOption('platform',
@@ -93,7 +93,7 @@
final bool enableConstantEvaluation = options['enable-constant-evaluation'];
final Map<String, String> environmentDefines = {};
- if (!_parseDefines(options['define'], environmentDefines)) {
+ if (!parseCommandLineDefines(options['define'], environmentDefines, _usage)) {
return _badUsageExitCode;
}
@@ -179,22 +179,3 @@
}
});
}
-
-bool _parseDefines(
- List<String> dFlags, Map<String, String> environmentDefines) {
- for (final String dflag in dFlags) {
- final equalsSignIndex = dflag.indexOf('=');
- if (equalsSignIndex < 0) {
- environmentDefines[dflag] = '';
- } else if (equalsSignIndex > 0) {
- final key = dflag.substring(0, equalsSignIndex);
- final value = dflag.substring(equalsSignIndex + 1);
- environmentDefines[key] = value;
- } else {
- print('The environment constant options must have a key (was: "$dflag")');
- print(_usage);
- return false;
- }
- }
- return true;
-}
diff --git a/pkg/vm/lib/frontend_server.dart b/pkg/vm/lib/frontend_server.dart
index 38b2e10..dba6fbf 100644
--- a/pkg/vm/lib/frontend_server.dart
+++ b/pkg/vm/lib/frontend_server.dart
@@ -29,7 +29,8 @@
import 'package:path/path.dart' as path;
import 'package:usage/uuid/uuid.dart';
import 'package:vm/incremental_compiler.dart' show IncrementalCompiler;
-import 'package:vm/kernel_front_end.dart' show compileToKernel;
+import 'package:vm/kernel_front_end.dart'
+ show compileToKernel, parseCommandLineDefines;
ArgParser argParser = new ArgParser(allowTrailingOptions: true)
..addFlag('train',
@@ -92,7 +93,10 @@
help: 'Normally the output dill is used to specify which dill to '
'initialize from, but it can be overwritten here.',
defaultsTo: null,
- hide: true);
+ hide: true)
+ ..addMultiOption('define',
+ abbr: 'D',
+ help: 'The values for the environment constants (e.g. -Dkey=value).');
String usage = '''
Usage: server [options] [input.dart]
@@ -292,6 +296,12 @@
}
}
+ final Map<String, String> environmentDefines = {};
+ if (!parseCommandLineDefines(
+ options['define'], environmentDefines, usage)) {
+ return false;
+ }
+
final TargetFlags targetFlags = new TargetFlags(
strongMode: options['strong'], syncAsync: options['sync-async']);
compilerOptions.target = getTarget(options['target'], targetFlags);
@@ -322,7 +332,8 @@
_mainSource, compilerOptions,
aot: options['aot'],
useGlobalTypeFlowAnalysis: options['tfa'],
- entryPoints: options['entry-points']));
+ entryPoints: options['entry-points'],
+ environmentDefines: environmentDefines));
}
if (component != null) {
if (transformer != null) {
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index 72a6607..928cac8 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -330,3 +330,22 @@
return node == null ? TreeNode.noOffset : node.fileOffset;
}
}
+
+bool parseCommandLineDefines(
+ List<String> dFlags, Map<String, String> environmentDefines, String usage) {
+ for (final String dflag in dFlags) {
+ final equalsSignIndex = dflag.indexOf('=');
+ if (equalsSignIndex < 0) {
+ environmentDefines[dflag] = '';
+ } else if (equalsSignIndex > 0) {
+ final key = dflag.substring(0, equalsSignIndex);
+ final value = dflag.substring(equalsSignIndex + 1);
+ environmentDefines[key] = value;
+ } else {
+ print('The environment constant options must have a key (was: "$dflag")');
+ print(usage);
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 811ed14..b7bfae3 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -52,7 +52,9 @@
// either a Uri or a List<int>.
Future<T> _makeLoaderRequest<T>(int tag, String uri) {
assert(_isolateId != null);
- assert(_loadPort != null);
+ if (_loadPort == null) {
+ throw new UnsupportedError("Service isolate is not available.");
+ }
Completer completer = new Completer<T>();
RawReceivePort port = new RawReceivePort();
port.handler = (msg) {
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 59b994e..58fc399 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -37,6 +37,8 @@
#include "bin/gzip.h"
#endif
+#include "vm/flags.h"
+
extern "C" {
extern const uint8_t kDartVmSnapshotData[];
extern const uint8_t kDartVmSnapshotInstructions[];
@@ -291,10 +293,12 @@
result = DartUtils::PrepareForScriptLoading(false, Options::trace_loading());
CHECK_RESULT(result);
- // Set up the load port provided by the service isolate so that we can
- // load scripts.
- result = DartUtils::SetupServiceLoadPort();
- CHECK_RESULT(result);
+ if (FLAG_support_service || !kDartPrecompiledRuntime) {
+ // Set up the load port provided by the service isolate so that we can
+ // load scripts.
+ result = DartUtils::SetupServiceLoadPort();
+ CHECK_RESULT(result);
+ }
// Setup package root if specified.
result = DartUtils::SetupPackageRoot(package_root, packages_config);
@@ -367,7 +371,9 @@
result = DartUtils::SetupIOLibrary(Options::namespc(), script_uri,
Options::exit_disabled());
CHECK_RESULT(result);
- Loader::InitForSnapshot(script_uri);
+ if (FLAG_support_service) {
+ Loader::InitForSnapshot(script_uri);
+ }
#if !defined(DART_PRECOMPILED_RUNTIME)
if (is_main_isolate) {
// Find the canonical uri of the app snapshot. We'll use this to decide if
diff --git a/runtime/bin/vmservice/vmservice_io.dart b/runtime/bin/vmservice/vmservice_io.dart
index 9dc5954..3747f4e 100644
--- a/runtime/bin/vmservice/vmservice_io.dart
+++ b/runtime/bin/vmservice/vmservice_io.dart
@@ -220,7 +220,7 @@
_signalSubscription = _signalWatch(ProcessSignal.SIGQUIT).listen(_onSignal);
}
-@pragma("vm.entry_point")
+@pragma("vm.entry_point", !const bool.fromEnvironment("dart.vm.product"))
main() {
// Set embedder hooks.
VMServiceEmbedderHooks.cleanup = cleanupCallback;
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index e419327..ff286b6 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -342,7 +342,6 @@
I->object_store()->set_future_class(null_class);
I->object_store()->set_pragma_class(null_class);
I->object_store()->set_completer_class(null_class);
- I->object_store()->set_stream_iterator_class(null_class);
I->object_store()->set_symbol_class(null_class);
I->object_store()->set_compiletime_error_class(null_class);
I->object_store()->set_simple_instance_of_function(null_function);
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 034de31..6318284 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -307,15 +307,11 @@
Service::SetGetServiceAssetsCallback(get_service_assets);
}
-#if defined(DART_PRECOMPILED_RUNTIME)
- const bool is_precompiled_runtime = true;
-#else
- const bool is_precompiled_runtime = false;
-#endif
-
const bool is_dart2_aot_precompiler =
- FLAG_strong && FLAG_precompiled_mode && !is_precompiled_runtime;
- if (!is_dart2_aot_precompiler) {
+ FLAG_strong && FLAG_precompiled_mode && !kDartPrecompiledRuntime;
+
+ if (!is_dart2_aot_precompiler &&
+ (FLAG_support_service || !kDartPrecompiledRuntime)) {
ServiceIsolate::Run();
}
diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h
index 432e3d3..7dd0cc2 100644
--- a/runtime/vm/flag_list.h
+++ b/runtime/vm/flag_list.h
@@ -26,6 +26,12 @@
#define USING_PRODUCT false
#endif
+#if defined(DART_PRECOMPILED_RUNTIME)
+constexpr bool kDartPrecompiledRuntime = true;
+#else
+constexpr bool kDartPrecompiledRuntime = false;
+#endif
+
// List of all flags in the VM.
// Flags can be one of three categories:
// * P roduct flags: Can be set in any of the deployment modes, including in
diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc
index e2d676d..b9eeeba 100644
--- a/runtime/vm/object_store.cc
+++ b/runtime/vm/object_store.cc
@@ -149,9 +149,6 @@
cls = async_lib.LookupClass(Symbols::Completer());
ASSERT(!cls.IsNull());
set_completer_class(cls);
- cls = async_lib.LookupClass(Symbols::StreamIterator());
- ASSERT(!cls.IsNull());
- set_stream_iterator_class(cls);
String& function_name = String::Handle(zone);
Function& function = Function::Handle(zone);
diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h
index 74f3dfb..01b5a52 100644
--- a/runtime/vm/object_store.h
+++ b/runtime/vm/object_store.h
@@ -58,7 +58,6 @@
RW(Class, pragma_class) \
RW(Class, future_class) \
RW(Class, completer_class) \
- RW(Class, stream_iterator_class) \
RW(Class, symbol_class) \
RW(Class, one_byte_string_class) \
RW(Class, two_byte_string_class) \
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 80b7358..08388da 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -9290,7 +9290,7 @@
// Build creation of implicit StreamIterator.
// var :for-in-iter = new StreamIterator(stream_expr).
const Class& stream_iterator_cls =
- Class::ZoneHandle(Z, I->object_store()->stream_iterator_class());
+ Class::ZoneHandle(Z, async_lib.LookupClass(Symbols::StreamIterator()));
ASSERT(!stream_iterator_cls.IsNull());
const Function& iterator_ctor = Function::ZoneHandle(
Z,
diff --git a/sdk/lib/core/annotations.dart b/sdk/lib/core/annotations.dart
index c0234f5..4c7c812 100644
--- a/sdk/lib/core/annotations.dart
+++ b/sdk/lib/core/annotations.dart
@@ -248,6 +248,7 @@
* function foo is annotated with a pragma 'other-pragma' specific to OtherTool.
*
*/
+@pragma('vm.entry_point')
class pragma {
/**
* The name of the hint.