Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: runtime/vm/kernel_binary_flowgraph.cc

Issue 2941983002: [kernel] Fix loss of supertype arguments. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/kernel_binary_flowgraph.h" 5 #include "vm/kernel_binary_flowgraph.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/longjump.h" 8 #include "vm/longjump.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 } 1677 }
1678 1678
1679 UNREACHABLE(); 1679 UNREACHABLE();
1680 } 1680 }
1681 1681
1682 const TypeArguments& StreamingDartTypeTranslator::BuildTypeArguments( 1682 const TypeArguments& StreamingDartTypeTranslator::BuildTypeArguments(
1683 intptr_t length) { 1683 intptr_t length) {
1684 bool only_dynamic = true; 1684 bool only_dynamic = true;
1685 intptr_t offset = builder_->ReaderOffset(); 1685 intptr_t offset = builder_->ReaderOffset();
1686 for (intptr_t i = 0; i < length; ++i) { 1686 for (intptr_t i = 0; i < length; ++i) {
1687 if (builder_->ReadTag() != kDynamicType) { // read ith type's tag. 1687 if (builder_->ReadTag() != kDynamicType) { // read ith type's tag.
Kevin Millikin (Google) 2017/06/21 06:43:42 Format comments as if they were sentences. Capita
1688 only_dynamic = false; 1688 only_dynamic = false;
1689 builder_->SetOffset(offset); 1689 builder_->SetOffset(offset);
1690 break; 1690 break;
1691 } 1691 }
1692 } 1692 }
1693 TypeArguments& type_arguments = TypeArguments::ZoneHandle(Z); 1693 TypeArguments& type_arguments = TypeArguments::ZoneHandle(Z);
1694 if (!only_dynamic) { 1694 if (!only_dynamic) {
1695 type_arguments = TypeArguments::New(length); 1695 type_arguments = TypeArguments::New(length);
1696 for (intptr_t i = 0; i < length; ++i) { 1696 for (intptr_t i = 0; i < length; ++i) {
1697 BuildTypeInternal(); // read ith type. 1697 BuildTypeInternal(); // read ith type.
1698 if (!result_.IsDynamicType()) {
1699 only_dynamic = false;
1700 }
1701 if (result_.IsMalformed()) { 1698 if (result_.IsMalformed()) {
1702 type_arguments = TypeArguments::null(); 1699 type_arguments = TypeArguments::null();
1703 // skip rest of arguments. 1700 // skip rest of arguments.
Kevin Millikin (Google) 2017/06/21 06:43:42 'skip rest of' ==> 'Skip the rest of the'.
1704 for (++i; i < length; ++i) { 1701 for (++i; i < length; ++i) {
1705 builder_->SkipDartType(); 1702 builder_->SkipDartType();
1706 } 1703 }
1707 return type_arguments; 1704 return type_arguments;
1708 } 1705 }
1709 type_arguments.SetTypeAt(i, result_); 1706 type_arguments.SetTypeAt(i, result_);
1710 } 1707 }
1711 1708
1712 if (finalize_) { 1709 if (finalize_) {
1713 type_arguments = type_arguments.Canonicalize(); 1710 type_arguments = type_arguments.Canonicalize();
1714 } 1711 }
1715 } 1712 }
1716 return type_arguments; 1713 return type_arguments;
1717 } 1714 }
1718 1715
1719 const TypeArguments& 1716 const TypeArguments&
1720 StreamingDartTypeTranslator::BuildInstantiatedTypeArguments( 1717 StreamingDartTypeTranslator::BuildInstantiatedTypeArguments(
1721 const dart::Class& receiver_class, 1718 const dart::Class& receiver_class,
1722 intptr_t length) { 1719 intptr_t length) {
1723 const TypeArguments& type_arguments = BuildTypeArguments(length); 1720 const TypeArguments& type_arguments = BuildTypeArguments(length);
1724 if (type_arguments.IsNull()) return type_arguments; 1721
1722 // If type_arguments is null all arguments are dynamic.
1723 // If, however, this class doesn't specify all the type arguments directly we
1724 // still need to finalize the type below in order to get any non-dynamic types
1725 // from any super. See http://www.dartbug.com/29537.
1726 if (type_arguments.IsNull() && receiver_class.NumTypeArguments() == length) {
1727 return type_arguments;
1728 }
1725 1729
1726 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to 1730 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to
1727 // finalize the argument types. 1731 // finalize the argument types.
1728 // (This can for example make the [type_arguments] vector larger) 1732 // (This can for example make the [type_arguments] vector larger)
1729 Type& type = Type::Handle( 1733 Type& type = Type::Handle(
1730 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); 1734 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource));
1731 if (finalize_) { 1735 if (finalize_) {
1732 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type); 1736 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type);
1733 } 1737 }
1734 1738
(...skipping 3578 matching lines...) Expand 10 before | Expand all | Expand 10 after
5313 instructions += ThrowTypeError(); 5317 instructions += ThrowTypeError();
5314 5318
5315 // Bail out early. 5319 // Bail out early.
5316 return instructions; 5320 return instructions;
5317 } 5321 }
5318 5322
5319 SetOffset(offset); 5323 SetOffset(offset);
5320 } 5324 }
5321 5325
5322 if (klass.NumTypeArguments() > 0) { 5326 if (klass.NumTypeArguments() > 0) {
5323 const TypeArguments& type_arguments = PeekArgumentsInstantiatedType(klass);
5324 if (!klass.IsGeneric()) { 5327 if (!klass.IsGeneric()) {
5325 Type& type = Type::ZoneHandle(Z, T.ReceiverType(klass).raw()); 5328 Type& type = Type::ZoneHandle(Z, T.ReceiverType(klass).raw());
5326 5329
5327 // TODO(27590): Can we move this code into [ReceiverType]? 5330 // TODO(27590): Can we move this code into [ReceiverType]?
5328 type ^= ClassFinalizer::FinalizeType(*active_class()->klass, type, 5331 type ^= ClassFinalizer::FinalizeType(*active_class()->klass, type,
5329 ClassFinalizer::kFinalize); 5332 ClassFinalizer::kFinalize);
5330 ASSERT(!type.IsMalformedOrMalbounded()); 5333 ASSERT(!type.IsMalformedOrMalbounded());
5331 5334
5332 TypeArguments& canonicalized_type_arguments = 5335 TypeArguments& canonicalized_type_arguments =
5333 TypeArguments::ZoneHandle(Z, type.arguments()); 5336 TypeArguments::ZoneHandle(Z, type.arguments());
5334 canonicalized_type_arguments = 5337 canonicalized_type_arguments =
5335 canonicalized_type_arguments.Canonicalize(); 5338 canonicalized_type_arguments.Canonicalize();
5336 instructions += Constant(canonicalized_type_arguments); 5339 instructions += Constant(canonicalized_type_arguments);
5337 } else { 5340 } else {
5341 const TypeArguments& type_arguments =
5342 PeekArgumentsInstantiatedType(klass);
5338 instructions += TranslateInstantiatedTypeArguments(type_arguments); 5343 instructions += TranslateInstantiatedTypeArguments(type_arguments);
5339 } 5344 }
5340 5345
5341 instructions += PushArgument(); 5346 instructions += PushArgument();
5342 instructions += AllocateObject(klass, 1); 5347 instructions += AllocateObject(klass, 1);
5343 } else { 5348 } else {
5344 instructions += AllocateObject(klass, 0); 5349 instructions += AllocateObject(klass, 0);
5345 } 5350 }
5346 LocalVariable* variable = MakeTemporary(); 5351 LocalVariable* variable = MakeTemporary();
5347 5352
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
7150 metadata_values.SetAt(i, value); 7155 metadata_values.SetAt(i, value);
7151 } 7156 }
7152 7157
7153 return metadata_values.raw(); 7158 return metadata_values.raw();
7154 } 7159 }
7155 7160
7156 } // namespace kernel 7161 } // namespace kernel
7157 } // namespace dart 7162 } // namespace dart
7158 7163
7159 #endif // !defined(DART_PRECOMPILED_RUNTIME) 7164 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698