[vm/kernel/bytecode] Constant evaluate Symbol literals in bytecode

Now, instead of generating Symbol constant pool entries, bytecode generator
uses kernel-to-kernel constant evaluator to evaluate symbol literals.

Change-Id: I8dae4e388b6c1e8158ce39da792bb2e1cea2687a
Reviewed-on: https://dart-review.googlesource.com/69900
Reviewed-by: RĂ©gis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
diff --git a/pkg/vm/lib/bytecode/constant_pool.dart b/pkg/vm/lib/bytecode/constant_pool.dart
index 7aa3fc3..662f140 100644
--- a/pkg/vm/lib/bytecode/constant_pool.dart
+++ b/pkg/vm/lib/bytecode/constant_pool.dart
@@ -126,44 +126,39 @@
   List<Pair<CanonicalNameReference, ConstantIndex>> fieldValues;
 }
 
-type ConstantSymbol extends ConstantPoolEntry {
-  Byte tag = 18;
-  StringReference value;
-}
-
 type ConstantTypeArgumentsForInstanceAllocation extends ConstantPoolEntry {
-  Byte tag = 19;
+  Byte tag = 18;
   CanonicalNameReference instantiatingClass;
   List<DartType> types;
 }
 
 type ConstantClosureFunction extends ConstantPoolEntry {
-  Byte tag = 20;
+  Byte tag = 19;
   StringReference name;
   FunctionNode function; // Doesn't have a body.
 }
 
 type ConstantEndClosureFunctionScope extends ConstantPoolEntry {
-  Byte tag = 21;
+  Byte tag = 20;
 }
 
 type ConstantNativeEntry extends ConstantPoolEntry {
-  Byte tag = 22;
+  Byte tag = 21;
   StringReference nativeName;
 }
 
 type ConstantSubtypeTestCache extends ConstantPoolEntry {
-  Byte tag = 23;
+  Byte tag = 22;
 }
 
 type ConstantPartialTearOffInstantiation extends ConstantPoolEntry {
-  Byte tag = 24;
+  Byte tag = 23;
   ConstantIndex tearOffConstant;
   ConstantIndex typeArguments;
 }
 
 type ConstantEmptyTypeArguments extends ConstantPoolEntry {
-  Byte tag = 25;
+  Byte tag = 24;
 }
 
 */
@@ -187,7 +182,6 @@
   kTypeArguments,
   kList,
   kInstance,
-  kSymbol,
   kTypeArgumentsForInstanceAllocation,
   kClosureFunction,
   kEndClosureFunctionScope,
@@ -252,8 +246,6 @@
         return new ConstantList.readFromBinary(source);
       case ConstantTag.kInstance:
         return new ConstantInstance.readFromBinary(source);
-      case ConstantTag.kSymbol:
-        return new ConstantSymbol.readFromBinary(source);
       case ConstantTag.kTypeArgumentsForInstanceAllocation:
         return new ConstantTypeArgumentsForInstanceAllocation.readFromBinary(
             source);
@@ -878,34 +870,6 @@
       mapEquals(this._fieldValues, other._fieldValues);
 }
 
-class ConstantSymbol extends ConstantPoolEntry {
-  final String value;
-
-  ConstantSymbol(this.value);
-  ConstantSymbol.fromLiteral(SymbolLiteral literal) : this(literal.value);
-
-  @override
-  ConstantTag get tag => ConstantTag.kSymbol;
-
-  @override
-  void writeValueToBinary(BinarySink sink) {
-    sink.writeStringReference(value);
-  }
-
-  ConstantSymbol.readFromBinary(BinarySource source)
-      : value = source.readStringReference();
-
-  @override
-  String toString() => 'Symbol \'$value\'';
-
-  @override
-  int get hashCode => value.hashCode;
-
-  @override
-  bool operator ==(other) =>
-      other is ConstantSymbol && this.value == other.value;
-}
-
 class ConstantTypeArgumentsForInstanceAllocation extends ConstantPoolEntry {
   final Reference _instantiatingClassRef;
   final List<DartType> typeArgs;
diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart
index d103a85..9d39980 100644
--- a/pkg/vm/lib/bytecode/gen_bytecode.dart
+++ b/pkg/vm/lib/bytecode/gen_bytecode.dart
@@ -1697,8 +1697,7 @@
 
   @override
   visitSymbolLiteral(SymbolLiteral node) {
-    final cpIndex = cp.add(new ConstantSymbol.fromLiteral(node));
-    asm.emitPushConstant(cpIndex);
+    _genPushConstExpr(node);
   }
 
   @override
diff --git a/pkg/vm/testcases/bytecode/literals.dart.expect b/pkg/vm/testcases/bytecode/literals.dart.expect
index b997fdf..1e7fbae 100644
--- a/pkg/vm/testcases/bytecode/literals.dart.expect
+++ b/pkg/vm/testcases/bytecode/literals.dart.expect
@@ -658,18 +658,19 @@
 Bytecode {
   Entry                0
   CheckStack
-  PushConstant         CP#0
   PushConstant         CP#2
-  IndirectStaticCall   1, CP#1
+  PushConstant         CP#4
+  IndirectStaticCall   1, CP#3
   Drop1
-  PushConstant         CP#3
+  PushConstant         CP#0
   ReturnTOS
 }
 ConstantPool {
-  [0] = Symbol 'test_symbol'
-  [1] = ArgDesc num-args 1, num-type-args 0, names []
-  [2] = StaticICData target 'dart.core::print', arg-desc CP#1
-  [3] = Null
+  [0] = Null
+  [1] = String 'test_symbol'
+  [2] = Instance dart._internal::Symbol type-args CP#0 {_name: CP#1}
+  [3] = ArgDesc num-args 1, num-type-args 0, names []
+  [4] = StaticICData target 'dart.core::print', arg-desc CP#3
 }
 ]static method test_symbol() → void {
   core::print(#test_symbol);
diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc
index 3c46f83..fe7750d 100644
--- a/runtime/vm/compiler/frontend/bytecode_reader.cc
+++ b/runtime/vm/compiler/frontend/bytecode_reader.cc
@@ -117,7 +117,6 @@
     kTypeArguments,
     kList,
     kInstance,
-    kSymbol,
     kTypeArgumentsForInstanceAllocation,
     kClosureFunction,
     kEndClosureFunctionScope,
@@ -341,10 +340,6 @@
         }
         obj = H.Canonicalize(Instance::Cast(obj));
       } break;
-      case ConstantPoolTag::kSymbol:
-        obj = H.DartSymbolPlain(helper_->ReadStringReference()).raw();
-        ASSERT(String::Cast(obj).IsSymbol());
-        break;
       case ConstantPoolTag::kTypeArgumentsForInstanceAllocation: {
         cls = H.LookupClassByKernelClass(helper_->ReadCanonicalNameReference());
         obj =