[VM] Evaluate symbols in kernel2kernel constant evaluator in AOT (even in non-const contexts)
Closes https://github.com/dart-lang/sdk/issues/33185
Change-Id: Ifa6a3e34e6f1a517f0adce1593e4ff747fe5c2cb
Reviewed-on: https://dart-review.googlesource.com/60246
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
diff --git a/pkg/kernel/lib/transformations/constants.dart b/pkg/kernel/lib/transformations/constants.dart
index b8a3aa8..cf18494 100644
--- a/pkg/kernel/lib/transformations/constants.dart
+++ b/pkg/kernel/lib/transformations/constants.dart
@@ -287,6 +287,10 @@
// Handle use-sites of constants (and "inline" constant expressions):
+ visitSymbolLiteral(SymbolLiteral node) {
+ return new ConstantExpression(constantEvaluator.evaluate(node));
+ }
+
visitStaticGet(StaticGet node) {
final Member target = node.target;
if (target is Field && target.isConst) {
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index be23f78..68ac2f7 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -4348,6 +4348,13 @@
const TypeArguments& type_arguments,
const Function& constructor,
const Object& argument) {
+ // We use a kernel2kernel constant evaluator in Dart 2.0 AOT compilation, so
+ // we should never end up evaluating constants using the VM's constant
+ // evaluator.
+ if (I->strong() && FLAG_precompiled_mode) {
+ UNREACHABLE();
+ }
+
// Factories have one extra argument: the type arguments.
// Constructors have 1 extra arguments: receiver.
const int kTypeArgsLen = 0;
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index c157f1a..82afa1e 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -25,16 +25,6 @@
RawObject* DartEntry::InvokeFunction(const Function& function,
const Array& arguments) {
ASSERT(Thread::Current()->IsMutatorThread());
-
- // We use a kernel2kernel constant evaluator in Dart 2.0 AOT compilation
- // and never start the VM service isolate. So we should never end up invoking
- // any dart code in the Dart 2.0 AOT compiler.
-#if !defined(DART_PRECOMPILED_RUNTIME)
- if (Isolate::Current()->strong() && FLAG_precompiled_mode) {
- UNREACHABLE();
- }
-#endif // !defined(DART_PRECOMPILED_RUNTIME)
-
const int kTypeArgsLen = 0; // No support to pass type args to generic func.
const Array& arguments_descriptor =
Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, arguments.Length()));
@@ -120,6 +110,15 @@
const Array& arguments,
const Array& arguments_descriptor,
uword current_sp) {
+ // We use a kernel2kernel constant evaluator in Dart 2.0 AOT compilation
+ // and never start the VM service isolate. So we should never end up invoking
+ // any dart code in the Dart 2.0 AOT compiler.
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ if (Isolate::Current()->strong() && FLAG_precompiled_mode) {
+ UNREACHABLE();
+ }
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
// Get the entrypoint corresponding to the function specified, this
// will result in a compilation of the function if it is not already
// compiled.